def group_roles():
        """
        用户组拥有角色列表
        :return:
        """
        params = request.values.get('params')
        conditions = json.loads(params)
        group_id = conditions['group_id']
        role_ids = PermissionsRelService.ids_in_groupids(
            model=TPermissionsRoleGroupRel(),
            gids=[group_id],
            select_column_name='rid')
        if not role_ids:
            data = {"rows": [], "total": 0}
            return make_response(
                json.dumps(ResponseCode.response(data=data),
                           ensure_ascii=False))
        conditions['group_id'] = None
        conditions['id'] = role_ids
        conditions['rule']['id'] = Constants.QUERY_CONDITION_RULE_IN
        model = TPermissionsRole()
        rows = CRUDHelper.execute_select(model, conditions)
        total = CRUDHelper.execute_select_count(model, conditions)

        data = {"rows": rows, "total": total}
        return make_response(
            json.dumps(ResponseCode.response(data=data), ensure_ascii=False))
Exemple #2
0
    def get_user_role():
        """
        获取当前用户可以关联的角色
        :return: 
        """
        params = request.values.get("params")
        params_data = json.loads(params)
        user_id = params_data['user_id']
        conditions = params_data['condition']

        data = {"total": 0, "rows": []}
        # 根据用户id获取所在的用户组
        group_ids = PermissionsRelService.ids_by_userid(
            TPermissionsUserGroupRel(), user_id, 'gid')
        if not group_ids or len(group_ids) < 1:
            return make_response(
                json.dumps(ResponseCode.response(data=data),
                           ensure_ascii=False))
        # 根据用户组获取角色id
        role_ids = PermissionsRelService.ids_in_groupids(
            TPermissionsRoleGroupRel(), group_ids, "rid")
        if not role_ids or len(role_ids) < 1:
            return make_response(
                json.dumps(ResponseCode.response(data=data),
                           ensure_ascii=False))
        # 条件查找
        conditions['id'] = role_ids
        conditions['rule']['id'] = Constants.QUERY_CONDITION_RULE_IN
        model = TPermissionsRole()
        rows = CRUDHelper.execute_select(model, conditions)
        total = CRUDHelper.execute_select_count(model, conditions)
        data['rows'] = rows
        data['total'] = total
        return make_response(
            json.dumps(ResponseCode.response(data=data), ensure_ascii=False))
Exemple #3
0
    def get_example():
        """
        example 查询
        :return: json
        """
        params = request.values.get('params')
        conditions = json.loads(params)
        example_model = TExample()

        rows = CRUDHelper.execute_select(example_model, conditions)
        total = CRUDHelper.execute_select_count(example_model, conditions)
        data = {"total": total, "rows": rows}
        return make_response(
            json.dumps(ResponseCode.response(data=data), ensure_ascii=False))
Exemple #4
0
 def get_user():
     """
     获取用户列表
     :return:
     """
     params = request.values.get('params')
     conditions = json.loads(params)
     model = TPermissionsUser()
     rows = CRUDHelper.execute_select(model, conditions)
     total = CRUDHelper.execute_select_count(model, conditions)
     DbHelper.get_db().session.close()
     data = {"total": total, "rows": rows}
     return make_response(
         json.dumps(ResponseCode.response(data=data), ensure_ascii=False))