Esempio n. 1
0
 def add_role(cls, name: str, description: str, label: str, creator: str)->tuple:
     """
     add role
     新增角色
     :param name:
     :param description:
     :param label:
     :param creator:
     :return:
     """
     role_obj = LoonRole(name=name, description=description, label=label, creator=creator)
     role_obj.save()
     return True, dict(role_id=role_obj.id)
Esempio n. 2
0
    def post(self, request, *args, **kwargs):
        """
        新增权限

        入参:
        name
        description

        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        name = request_data_dict.get('name', '')
        description = request_data_dict.get('description', '')

        LoonRole().create_role(name, description)

        return api_response(0, '')