| | |
| | | seq = Column(Integer) |
| | | roleKey = Column(String(100)) |
| | | dataScope = Column(Integer) |
| | | status = Column(String(10), default="0") |
| | | status = Column(String(10), default="1") |
| | | creator = Column(Integer) |
| | | role_type = Column(Integer, default=1) |
| | | |
| | | # 包含资源 |
| | | resources = relationship('ResourceModel', |
| | |
| | | 'dataScope': self.dataScope |
| | | } |
| | | |
| | | if len(self.resources) > 0: |
| | | json['resources'] = [resource.to_json() for resource in self.resources] |
| | | # if len(self.resources) > 0: |
| | | json['resources'] = [resource.to_json() for resource in self.resources] |
| | | |
| | | if hasattr(self, 'flag'): |
| | | json['flag'] = self.flag |
| | | json['dept'] = [dept.to_base_json() for dept in self.organizations] |
| | | |
| | | return json |
| | | |
| | | |
| | | def to_dict(self): |
| | | json = { |
| | | 'roleId': self.id, |
| | | 'createTime': self.created_at.strftime('%Y-%m-%d %H:%M:%S'), |
| | | 'updateTime': self.updated_at.strftime('%Y-%m-%d %H:%M:%S'), |
| | | 'roleName': self.name, |
| | | 'remark': self.description, |
| | | 'iconCls': self.iconCls, |
| | | 'roleSort': self.seq, |
| | | 'status': self.status, |
| | | 'roleKey': self.roleKey, |
| | | 'dataScope': self.dataScope |
| | | } |
| | | return json |
| | | |
| | | class RoleData(BaseModel): |
| | | remark: Optional[str] = "" |
| | | roleName: str |
| | | roleKey: Optional[str] = "" |
| | | dataScope: Optional[str] = "" |
| | | dataScope: Optional[int] = 0 |
| | | |
| | | |
| | | class RoleStatus(BaseModel): |
| | | role_id: str |
| | | roleId: str |
| | | status: constr(min_length=1, max_length=1, pattern='^(0|1)$') |
| | | |
| | | |
| | | class RoleEdit(BaseModel): |
| | | role_id: str |
| | | roleId: str |
| | | remark: Optional[str] = "" |
| | | roleName: Optional[str] = "" |
| | | resources: Optional[list] = [] |
| | | roleKey: Optional[str] = "" |
| | | dataScope: Optional[int] = 0 |
| | | editType: int |
| | | depts: Optional[list] = [] |