app.py 5.52 KB
Newer Older
wanli's avatar
wanli committed
1 2 3 4 5 6 7 8 9
# -*- coding: utf-8 -*-

from application.app import db, ma
from .base import PrimaryModel 
from marshmallow import Schema, fields, INCLUDE, EXCLUDE

class AppModel(PrimaryModel):
    __tablename__ = 'evm_app'

wanliofficial's avatar
wanliofficial committed
10
<<<<<<< HEAD
wanli's avatar
wanli committed
11 12 13 14 15 16 17 18 19 20 21
    app_name = db.Column(db.String(70), index = True)
    app_icon = db.Column(db.String(200))
    app_version = db.Column(db.String(20))
    category = db.Column(db.Integer)
    category_2th = db.Column(db.Integer)
    developer = db.Column(db.Integer)
    download_url = db.Column(db.String(20))
    app_file_size = db.Column(db.Integer)
    app_screen_size = db.Column(db.Integer)
    app_arch = db.Column(db.String(20))
    app_review = db.Column(db.String(100))
wanliofficial's avatar
wanliofficial committed
22
=======
wanli's avatar
wanli committed
23 24 25 26 27 28 29 30 31 32 33
    app_name = db.Column(db.String(70), index = True, nullable = False)
    app_icon = db.Column(db.String(200), nullable = False)
    app_version = db.Column(db.String(20), nullable = False)
    category = db.Column(db.Integer, nullable = False)
    category_2th = db.Column(db.Integer, nullable = False)
    developer = db.Column(db.Integer, nullable = False)
    download_url = db.Column(db.String(20), nullable = False)
    app_file_size = db.Column(db.Integer, nullable = False)
    app_screen_size = db.Column(db.Integer, nullable = False)
    app_arch = db.Column(db.String(20), nullable = False)
    app_review = db.Column(db.String(100), nullable = False)
wanliofficial's avatar
wanliofficial committed
34
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

    # __table_args__ = (
    #     db.Index('idx_xxx', 'xxx', mysql_using='btree'),
    # )

    def __init__(self, app_name, app_icon, app_version, category, category_2th, developer, download_url, app_file_size, app_screen_size, app_arch, app_review):
        self.app_name = app_name
        self.app_icon = app_icon
        self.app_version = app_version
        self.category = category
        self.category_2th = category_2th
        self.developer = developer
        self.download_url = download_url
        self.app_file_size = app_file_size
        self.app_screen_size = app_screen_size
        self.app_arch = app_arch
        self.app_review = app_review

    def __repr__(self):
        return '<AppModel %r>' % (self.app_name)

    def to_json(self):
        return {
            'app_name': self.app_name,
            'app_icon': self.app_icon,
            'app_version': self.app_version,
            'category': self.category,
            'category_2th': self.category_2th,
            'developer': self.developer,
            'download_url': self.download_url,
            'app_file_size': self.app_file_size,
            'app_screen_size': self.app_screen_size,
            'app_arch': self.app_arch,
            'app_review': self.app_review,
        }


class PostAppSchema(ma.SQLAlchemySchema):
    class Meta:
        # unknown = INCLUDE # 未知字段默认包含
wanliofficial's avatar
wanliofficial committed
75
<<<<<<< HEAD
wanli's avatar
wanli committed
76
        # unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
77
=======
wanli's avatar
wanli committed
78
        unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
79
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
80 81 82 83 84 85 86 87 88 89 90 91 92
        model = AppModel

    app_name = ma.auto_field()
    app_icon = ma.auto_field()
    app_version = ma.auto_field()
    category = ma.auto_field()
    category_2th = ma.auto_field()
    developer = ma.auto_field()
    app_screen_size = ma.auto_field()
    app_arch = ma.auto_field()
    app_review = ma.auto_field()

postAppSchema = PostAppSchema()
wanliofficial's avatar
wanliofficial committed
93
<<<<<<< HEAD
wanli's avatar
wanli committed
94
postAppsSchema = PostAppSchema(many=True)
wanliofficial's avatar
wanliofficial committed
95 96
=======
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
97 98 99 100

class DeleteAppSchema(ma.SQLAlchemySchema):
    class Meta:
        # unknown = INCLUDE # 未知字段默认包含
wanliofficial's avatar
wanliofficial committed
101
<<<<<<< HEAD
wanli's avatar
wanli committed
102
        # unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
103
=======
wanli's avatar
wanli committed
104
        unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
105
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
106 107 108 109 110 111 112 113
        model = AppModel


deleteAppSchema = DeleteAppSchema()

class GetListAppSchema(ma.SQLAlchemySchema):
    class Meta:
        # unknown = INCLUDE # 未知字段默认包含
wanliofficial's avatar
wanliofficial committed
114
<<<<<<< HEAD
wanli's avatar
wanli committed
115
        # unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
116
=======
wanli's avatar
wanli committed
117
        unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
118
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
119 120 121 122 123 124 125 126 127 128 129
        model = AppModel

    page = fields.Integer(required=False)
    pageSize = fields.Integer(required=False)
    app_name = ma.auto_field()
    app_version = ma.auto_field()
    category = ma.auto_field()
    category_2th = ma.auto_field()
    app_arch = ma.auto_field()

getListAppSchema = GetListAppSchema()
wanliofficial's avatar
wanliofficial committed
130 131
<<<<<<< HEAD
=======
132
getListAppsSchema = GetListAppSchema(many=True)
wanliofficial's avatar
wanliofficial committed
133
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
134 135 136 137

class GetAppSchema(ma.SQLAlchemySchema):
    class Meta:
        # unknown = INCLUDE # 未知字段默认包含
wanliofficial's avatar
wanliofficial committed
138
<<<<<<< HEAD
wanli's avatar
wanli committed
139
        # unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
140
=======
wanli's avatar
wanli committed
141
        unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
142
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
143 144 145 146 147 148 149 150 151 152 153 154 155
        model = AppModel

    app_name = ma.auto_field()
    app_version = ma.auto_field()
    category = ma.auto_field()
    category_2th = ma.auto_field()
    app_arch = ma.auto_field()

getAppSchema = GetAppSchema()

class PutAppSchema(ma.SQLAlchemySchema):
    class Meta:
        # unknown = INCLUDE # 未知字段默认包含
wanliofficial's avatar
wanliofficial committed
156
<<<<<<< HEAD
wanli's avatar
wanli committed
157
        # unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
158
=======
wanli's avatar
wanli committed
159
        unknown = EXCLUDE # 未知字段默认排除
wanliofficial's avatar
wanliofficial committed
160
>>>>>>> 735d39eb4d0c3134b62bf4fe1b7a2ca0ea8da1ca
wanli's avatar
wanli committed
161 162 163 164 165 166 167 168 169 170 171 172
        model = AppModel

    app_name = ma.auto_field()
    app_icon = ma.auto_field()
    app_version = ma.auto_field()
    app_screen_size = ma.auto_field()
    app_arch = ma.auto_field()
    app_review = ma.auto_field()
    category = ma.auto_field()
    category_2th = ma.auto_field()

putAppSchema = PutAppSchema()