def get(self, org_id, role_id, **kwargs): """角色员工列表 --- tags: - 权限、功能 parameters: - name: role_id in: path type: string required: true - name: org_id in: path type: string required: true responses: 200: description: examples: response: {"data": "data", "message": "ok"} """ page = kwargs.get('page', DEFAULT_PAGE) size = kwargs.get('size', DEFAULT_PAGE_SIZE) staff_obj = OrgStaff.query.join(OrgStaffRole, OrgRoleConfig).filter( OrgRoleConfig.org_id == org_id, OrgRoleConfig.id == role_id) staff_schema = OrgStaffSchema( many=True, only=('id', 'job_title', 'user', 'is_able', 'parent_superior', 'org_staff_role', 'org_department_staff')) page_result = paginate(staff_obj, page, size) res = staff_schema.dump(page_result.items).data return json_response(data=res, page=page_result)
def get(self, org_id, **kwargs): """获取组织集群列表 --- tags: - 集群 parameters: - name: org_id in: querystring type: string(uuid) required: true - name: page in: querystring type: int required: false - name: page_size in: querystring type: int required: false responses: 200: examples: response: {"data": [{"id":"xx", "host":"https://xxx", "port":6443, "token":"xxx"}], "message": "ok"} """ page = kwargs.get("page", DEFAULT_PAGE) page_size = kwargs.get("page_size", DEFAULT_PAGE_SIZE) user = get_current_user() cluster_query = db.session.query(Cluster).join(Organization, OrgStaff).filter( OrgStaff.org_id == org_id, OrgStaff.user_id == user.id) cluster_paginate = paginate(cluster_query, page, page_size) cluster_schema = ClusterSchema(many=True, exclude=("token",)) data = cluster_schema.dump(cluster_paginate.items).data return json_response(data, cluster_paginate)
def get(self, org_id, org_department_id, **kwargs): """获取组织部门雇员列表 --- tags: - 组织部门雇员 parameters: - name: org_id in: url type: string required: true description: 组织id - name: org_department_id in: url type: string required: true description: 组织部门id, 如果为-1表示查询组织所有雇员 responses: 200: description: examples: response: {"data": [], "message": "ok"} """ page = kwargs.get('page', DEFAULT_PAGE) size = kwargs.get('size', DEFAULT_PAGE_SIZE) current_user = get_current_user() org_staff_query = OrgStaff.query.filter_by(user_id=current_user.id, org_id=org_id, is_able=1) if org_department_id != "-1": # 自己属于该组织才能查看组织的成员 org_staff_list = db.session.query(OrgStaff).join( OrgDepartmentStaff).filter( org_staff_query.exists(), OrgStaff.org_id == org_id, OrgDepartmentStaff.org_department_id == org_department_id) else: org_staff_list = OrgStaff.query.filter(org_staff_query.exists(), OrgStaff.org_id == org_id) org_staff_schema = OrgStaffSchema( many=True, only=('id', 'job_title', 'user', 'is_able', 'parent_superior', 'org_staff_role', 'org_department_staff')) page_result = paginate(org_staff_list, page, size) data = org_staff_schema.dump(page_result.items).data return json_response(data=data, message="ok", page=page_result)
def get(self, **kwargs): """获取消息 --- tags: - 用户 parameters: - name: has_detail in: querystring type: int required: false description: 是否需要详细,如果为0返回未读的消息数量 0|1 - name: org_id in: querystring type: string required: false description: 组织id,如果存在,表示获取该组织下的用户消息,否则表示全部 - name: page in: querystring type: int required: false description: 当前页 - name: page_size in: querystring type: int required: false description: 一页的消息数量 responses: 200: examples: response: { "data":{ "message_list": [ { "id": "c77e641fbe9d472398feb89666087eee", "is_read": 1, "title": "xxx", "content": "xxx", "send_time": 1577328935, "read_time": read_time, "message_type": "消息类型(1. system系统 2. plus插件 3. org组织 4. invitee邀请" } ] },"message": "ok"} """ user = get_current_user() org_id = kwargs.get("org_id") has_detail = kwargs.get("has_detail") page = kwargs.get("page", 1) page_size = kwargs.get("page_size", 10) base_query = db.session.query(Message)\ .filter(Message.user_id == User.id, User.id == user.id) if org_id: base_query = base_query.filter(Message.organization_id == org_id) unread_count = base_query.filter(Message.is_read == 0).count() if not has_detail: return json_response(data={"unread_count": unread_count}, message="ok") if org_id: base_query = base_query.fitler(Message.organization_id == org_id) message_query = base_query.order_by(Message.is_read.asc(), Message.send_time.desc()) message_paginate = paginate(message_query, page, page_size) try: pass except Exception as e: _ = e return json_response(message="消息数据获取失败", status=500) else: message_schema = MessageSchema(many=True, only=("id", "is_read", "title", "content", "send_time", "read_time", 'message_type')) data ={ "message_list": message_schema.dump(message_paginate.items).data, "unread_count": unread_count } return json_response(data=data, message="ok", page=message_paginate)