def operate_log(): # orm查询 # 使用分页获取data需要.items log = AdminLog.query.filter(AdminLog.url != '/passport/login').order_by( desc(AdminLog.create_time)).layui_paginate() count = log.total return table_api(data=model_to_dicts(schema=LogOutSchema, data=log.items), count=count)
def dict_type_data(): # 获取请求参数 type_name = xss_escape(request.args.get('typeName', type=str)) # 查询参数构造 mf = ModelFilter() if type_name: mf.vague(field_name="type_name", value=type_name) # orm查询 # 使用分页获取data需要.items dict_all = DictType.query.filter(mf.get_filter(DictType)).layui_paginate() count = dict_all.total data = curd.model_to_dicts(schema=DictTypeOutSchema, data=dict_all.items) return table_api(data=data, count=count)
def table(): # 获取请求参数 role_name = xss_escape(request.args.get('roleName', type=str)) role_code = xss_escape(request.args.get('roleCode', type=str)) # 查询参数构造 mf = ModelFilter() if role_name: mf.vague(field_name="name", value=role_name) if role_code: mf.vague(field_name="code", value=role_code) # orm查询 # 使用分页获取data需要.items role = Role.query.filter(mf.get_filter(Role)).layui_paginate() count = role.total # 返回api return table_api(data=model_to_dicts(schema=RoleOutSchema, data=role.items), count=count)
def data(): # 获取请求参数 real_name = xss_escape(request.args.get('realName', type=str)) username = xss_escape(request.args.get('username', type=str)) dept_id = request.args.get('deptId', type=int) # 查询参数构造 mf = ModelFilter() if real_name: mf.contains(field_name="realname", value=real_name) if username: mf.contains(field_name="username", value=username) if dept_id: mf.exact(field_name="dept_id", value=dept_id) # orm查询 # 使用分页获取data需要.items user = User.query.filter(mf.get_filter(model=User)).layui_paginate() count = user.total # 返回api return table_api(data=model_to_dicts(schema=UserOutSchema, data=user.items), count=count)
def tree(): dept = Dept.query.order_by(Dept.sort).all() power_data = curd.model_to_dicts(schema=DeptOutSchema, data=dept) res = {"status": {"code": 200, "message": "默认"}, "data": power_data} return jsonify(res)
def data(): dept = Dept.query.order_by(Dept.sort).all() power_data = curd.model_to_dicts(schema=DeptOutSchema, data=dept) res = {"data": power_data} return jsonify(res)
def get_photo(page, limit): photo = Photo.query.order_by(desc(Photo.create_time)).paginate(page=page, per_page=limit, error_out=False) count = Photo.query.count() data = model_to_dicts(schema=PhotoOutSchema, data=photo.items) return data, count
def dict_code_data(): type_code = xss_escape(request.args.get('typeCode', type=str)) dict_data = DictData.query.filter_by(type_code=type_code).layui_paginate() count = dict_data.total data = curd.model_to_dicts(schema=DictDataOutSchema, data=dict_data.items) return table_api(data=data, count=count)
def select_parent(): power = Power.query.all() res = curd.model_to_dicts(schema=PowerOutSchema2, data=power) res.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1}) res = {"status": {"code": 200, "message": "默认"}, "data": res} return jsonify(res)
def data(): power = Power.query.all() res = {"data": curd.model_to_dicts(schema=PowerOutSchema2, data=power)} return jsonify(res)