class InterfaceCase(db.Model):
    '''接口测试用例'''
    __tablename__ = 'apitest_interface_case'
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    interface_url = db.Column(db.String(255), comment='接口url')
    interface_headers = db.Column(db.String(255), comment='http请求消息头')
    interface_method = db.Column(db.String(255),
                                 server_default='GET',
                                 comment='接口请求方式')
    interface_params = db.Column(db.String(255), comment='请求参数')
    interface_response = db.Column(db.String(255), comment='请求响应')
    interface_response_assert = db.Column(db.String(255), comment='请求响应断言')
    create_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='用例创建时间')
    modify_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='用例修改时间')
    status = db.Column(db.Boolean(), default=False, comment='是否开启')
    interface_id = db.Column(db.Integer(),
                             db.ForeignKey('apitest_interface.id'),
                             comment='接口id')
    user_id = db.Column(db.INTEGER(),
                        db.ForeignKey('common_user.id'),
                        comment='测试执行者id')
    case_result = db.relationship('CaseResult',
                                  backref=db.backref('interface_case',
                                                     lazy='dynamic'))
Example #2
0
class Users(db.Model,UserMixin):
    __tablername__ = 'users'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(20), unique=True, nullable=False)
    password_hash = db.Column(db.String(128), nullable=False)
    tel = db.Column(db.String(11))
    #0 法院 1 不动产
    userid = db.Column(db.Boolean(), default=1, nullable=False)

    @property
    def password(self):
        raise ArithmeticError ('密码不可读')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)


    def is_authenticated(self):
        return True
    def is_active(self):
        return True
    def is_anonymous(self):
        return True
    def get_id(self):
        return unicode(self.id)
Example #3
0
class EoApi(db.Model):
    __tablename__ = 'eo_api'

    apiID = db.Column(db.Integer, primary_key=True, autoincrement=True)
    apiName = db.Column(db.String(100), nullable=False)  # 接口名称
    apiURI = db.Column(db.String(100), nullable=False)  # 接口URI
    apiProtocol = db.Column(db.Boolean, nullable=False)  # 接口协议
    apiFailureMock = db.Column(db.Text)  # 失败的示例
    apiSuccessMock = db.Column(db.Text)  # 成功的示例
    apiRequestType = db.Column(db.Boolean, nullable=False)  # 接口请求类型
    # apiSuccessMockType = db.Column(db.Boolean, nullable=False, default=0) # 成功Mock类型
    # apiFailureMockType = db.Column(db.Boolean, nullable=False, default=0) # 失败Mock类型
    apiStatus = db.Column(db.Boolean, nullable=False, default=0)  # api状态
    apiUpdateTime = db.Column(db.DateTime, nullable=False, default=datetime.now)  # 接口更新时间
    starred = db.Column(db.Boolean, nullable=False, default=0)  #
    removed = db.Column(db.Boolean, nullable=False, default=0)  # 移除
    removeTime = db.Column(db.DateTime, nullable=True, default=None)  # 移除时间
    # apiNoteType = db.Column(db.Boolean, nullable=False, default=0) # 详细说明类型
    # apiNoteRaw = db.Column(db.Text) # 详细说明
    apiRequestParamType = db.Column(db.Boolean(3), nullable=False, default=0)  # 请求参数类型
    apiRequestRaw = db.Column(db.Text)  # 请求参数
    updateUserId = db.Column(db.Integer, nullable=False, default=0)  # 更新用户
    apiSuccessStatusCode = db.Column(db.String(255), nullable=True, default=200)  # 成功状态码
    apiFailureStatusCode = db.Column(db.String(255), nullable=True, default=200)  # 失败状态码

    # 外键1 - 分组ID
    groupID = db.Column(db.Integer, db.ForeignKey("eo_api_group.groupID"))  # 分组ID
    # 关系1
    group = db.relationship("EoApiGroup", backref="apis")

    # 外键2 - 项目ID
    projectID = db.Column(db.Integer, db.ForeignKey("eo_project.projectID"))
    # 关系2
    project = db.relationship("EoProject", backref="apis")
class Module(db.Model):
    '''模块,有的接口是根据模块来划分的'''
    __tablename__ = 'apitest_module'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    module_name = db.Column(db.String(255), comment='模块名')
    module_description = db.Column(db.String(255), comment='模块描述')
    create_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='模块创建时间')
    modify_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='模块修改时间')
    status = db.Column(db.Boolean(), default=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey('common_user.id'),
                        comment='模块负责者id')
    project_id = db.Column(db.Integer(),
                           db.ForeignKey('apitest_project.id'),
                           comment='项目id')
    interface = db.relationship('Interface',
                                backref=db.backref('module', lazy='dynamic'))

    def __str__(self):
        return self.module_name
class Project(db.Model):
    '''项目'''
    __tablename__ = 'apitest_project'
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    project_name = db.Column(db.String(255), comment='项目名')
    project_description = db.Column(db.String(255), comment='项目描述')
    module_count = db.Column(db.Integer(), comment='模块数量')
    interface_count = db.Column(db.Integer(), comment='接口数量')
    create_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='项目创建时间')
    modify_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='项目修改时间')
    status = db.Column(db.Boolean(), default=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey('common_user.id'),
                        comment='项目负责人id')
    interface = db.relationship('Interface',
                                backref=db.backref('project', lazy='dynamic'))
    module = db.relationship('Module',
                             backref=db.backref('project', lazy='dynamic'))

    def __str__(self):
        return self.project_name
Example #6
0
class User(db.Model):
    """用户表"""
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(30), nullable=False)
    password = db.Column(db.String(100), nullable=False)
    phone = db.Column(db.String(11), unique=True, nullable=False)
    hobby = db.Column(db.String(30))
    icon = db.Column(db.String(300))
    is_delete = db.Column(db.Boolean())
    email = db.Column(db.String(200))
    rdatetime = db.Column(db.DateTime, default=datetime.now)

    def __str__(self):
        return self.username
Example #7
0
class EoApiRequestParam(db.Model):
    __tablename__ = 'eo_api_request_param'

    paramID = db.Column(db.Integer, primary_key=True, autoincrement=True)  # 参数ID
    paramName = db.Column(db.String(255), default=None)  # 说名
    paramKey = db.Column(db.String(255), nullable=False)  # 参数名
    paramValue = db.Column(db.Text, nullable=False)  # 参数示例
    paramType = db.Column(db.Boolean(3), default=0)  # 参数类型
    paramLimit = db.Column(db.String(255), default=None)  # 参数限制
    paramNotNull = db.Column(db.Boolean, nullable=False, default=0)  # 参数非空

    # 外键1 - apiID
    apiID = db.Column(db.Integer, db.ForeignKey("eo_api.apiID"))
    # 关系1
    api = db.relationship("EoApi", backref="request_params")
class Drug(db.Model):
    __tablename__ = 'drug'
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    num = db.Column(db.String(50), nullable=False)
    name = db.Column(db.String(50), nullable=False)
    desc = db.Column(db.String(500), nullable=False)
    isSale = db.Column(db.Boolean(), nullable=False, default=False)
    # isChoose = db.Column(db.Boolean(), nullable=False, default=False)
    stockDate = db.Column(db.DateTime(), default=datetime.now)
    stockPrice = db.Column(db.REAL(), nullable=True, default=0)
    saleDate = db.Column(db.DateTime(), nullable=True)
    salePice = db.Column(db.REAL(), nullable=True, default=0)
    # foreignkey药品关联药品类别表id
    drugTypeId = db.Column(db.Integer(), db.ForeignKey('drugType.id'))
    drugType = db.relationship('DrugType', backref='drug')
Example #9
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(15), nullable=False)
    password = db.Column(db.String(12), nullable=False)
    phone = db.Column(db.String(11))
    icon = db.Column(db.String(150))
    isdelete = db.Column(db.Boolean())
    email = db.Column(db.String(100))
    udatetime = db.Column(db.DateTime, default=datetime.datetime.now)

    friends = db.relationship('Friend',
                              backref='user',
                              foreign_keys=Friend.uid)

    def __str__(self):
        return self.username
class Interface(db.Model):
    '''接口'''
    __tablename__ = 'apitest_interface'
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    interface_name = db.Column(db.String(255), comment='接口名')
    interface_url = db.Column(db.String(255), comment='接口url')
    interface_headers = db.Column(db.String(255), comment='http请求消息头')
    interface_method = db.Column(db.String(255),
                                 server_default='GET',
                                 comment='接口请求方式')
    interface_params = db.Column(db.String(255), comment='请求参数示例')
    interface_response = db.Column(db.String(255), comment='请求响应示例')
    interface_description = db.Column(db.String(255), comment='接口描述')
    create_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='接口创建时间')
    modify_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now(),
                            comment='接口修改时间')
    status = db.Column(db.Boolean(), default=False)
    developer_id = db.Column(db.Integer(),
                             db.ForeignKey('common_user.id'),
                             comment='接口开发者id')
    tester_id = db.Column(db.Integer(),
                          db.ForeignKey('common_user.id'),
                          comment='接口负责者id')
    project_id = db.Column(db.Integer(),
                           db.ForeignKey('common_user.id'),
                           comment='项目id')
    module_id = db.Column(db.Integer(),
                          db.ForeignKey('apitest_module.id'),
                          comment='模块id')
    interface_case = db.relationship('InterfaceCase',
                                     backref=db.backref('interface',
                                                        lazy='dynamic'))

    def __str__(self):
        return self.interface_name
Example #11
0
class Case(db.Model):
    __tablename__ = 'test_case'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    case_code = db.Column(db.String(20), nullable=False, unique=True)
    own_project = db.Column(db.String(20), nullable=True)
    functional_module = db.Column(db.String(20), nullable=True)
    priority = db.Column(db.Integer, nullable=True)  #优先级
    batch_type = db.Column(db.String(20), nullable=True)
    order_type = db.Column(db.String(20), nullable=True)
    goods_type = db.Column(db.String(40), nullable=True)
    front_term = db.Column(db.String(100), nullable=True)  # 前置条件
    case_title = db.Column(db.String(20), nullable=True)
    case_description = db.Column(db.String(500), nullable=True)
    goods_name = db.Column(db.String(40), nullable=True)
    expect_result = db.Column(db.String(500), nullable=True)
    execute_result = db.Column(db.String(10), nullable=True, default='未执行')
    executive = db.Column(db.Integer,
                          db.ForeignKey("test_user.user_id"))  # 执行人
    creator = db.Column(db.Integer, db.ForeignKey("test_user.user_id"))  # 创建人
    remarks = db.Column(db.String(100), nullable=True)
    execute_log = db.Column(db.String(500), nullable=True)
    del_flag = db.Column(db.Boolean(), default=False)
Example #12
0
class User(db.Model, UserMixin):
    '''用户'''
    __tablename__ = 'common_user'
    id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    username = db.Column(db.String(64),
                         unique=True,
                         nullable=False,
                         comment='用户名')
    realname = db.Column(db.String(64), nullable=False, comment='真实姓名')
    phone = db.Column(db.String(11), default=None, comment='电话')
    gender = db.Column(db.String(1),
                       nullable=False,
                       comment='性别',
                       server_default='男')
    email = db.Column(db.String(255), unique=True, comment='电子邮箱')
    _password = db.Column(db.String(255), nullable=False, comment='密码')
    active = db.Column(db.Boolean(),
                       nullable=False,
                       comment='用户是否处于激活状态',
                       server_default='1')
    create_date = db.Column(db.TIMESTAMP,
                            nullable=False,
                            server_default=func.now())
    role = db.relationship('Role',
                           secondary=common_role_user,
                           backref=db.backref('user', lazy='dynamic'))

    def __init__(self,
                 username=None,
                 realname=None,
                 password=None,
                 gender=None,
                 phone=None,
                 email=None):
        self.username = username
        self.realname = realname
        self.password = password
        self.gender = gender
        self.phone = phone
        self.email = email

    @property
    def password(self):
        return self._password

    @password.setter
    def password(self, rawpwd):
        self._password = generate_password_hash(rawpwd)

    def check_password(self, rawpwd):
        return check_password_hash(self.password, rawpwd)

    def can(self, permissions):
        if self.roles is None:
            return False
        all_permissions = reduce(or_, map(lambda x: x.permissions, self.roles))
        return all_permissions & permissions == permissions

    def can_admin(self):
        return self.can(Permission.ADMINISTER)

    @property
    def is_authenticated(self):
        '''是否认证'''
        return True

    @property
    def is_active(self):
        '''用户是否处于激活状态'''
        if self.active and self.active is True:
            return True
        else:
            return False

    @property
    def is_anonymous(self):
        '''用户是否匿名用户'''
        return False

    def get_id(self):
        '''获取userId'''
        return self.id