Пример #1
0
 def get(self):
     nlp_task_id = Common().get_nlp_task_id_by_route()
     result = DocTypeService().get_doc_type_info_by_nlp_task_by_user(
         nlp_task_id=nlp_task_id, current_user=self.get_current_user())
     return {
         "message": "请求成功",
         "result": result,
     }, 200
Пример #2
0
 def delete(self: Resource, doc_type_id: int, doc_relation_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     删除一个条款
     """
     DocTypeService().delete_relation(doc_relation_id)
     return {
                "message": "删除成功",
            }, 204
Пример #3
0
 def patch(self: Resource, doc_type_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     取消置顶一个文档类型,简单修改index=0
     """
     result = DocTypeService().set_favoriate_doc_type(doc_type_id, False)
     return {
                "message": "更新成功",
                "result": result,
            }, 201
Пример #4
0
 def post(self, args: typing.Dict, doc_type_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     创建一个关系
     """
     result = DocTypeService().create_relation(doc_type_id, args.get("doc_term_ids"), args.get("doc_relation_name"))
     return {
                "message": "创建成功",
                "result": result,
            }, 201
Пример #5
0
 def patch(self: Resource, args: typing.Dict, doc_type_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     修改一个文档类型,不包括修改它的条款
     """
     result = DocTypeService().update_relation_doc_type(args, doc_type_id)
     return {
                "message": "更新成功",
                "result": result,
            }, 201
Пример #6
0
 def get(self: Resource, doc_type_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     获取一个文档类型
     """
     result = DocTypeService().get_doc_type_items(doc_type_id)
     return {
                "message": "请求成功",
                "result": result,
            }, 200
Пример #7
0
 def post(self: Resource, args: typing.Dict) -> typing.Tuple[typing.Dict, int]:
     """
     创建一个文档类型包括它的条款
     """
     args.update({"nlp_task_id": NlpTaskEnum.relation.value})
     args.update({"group_id": self.get_current_user().user_groups[0]})
     result = DocTypeService.create_relation_doc_type(args)
     return {
                "message": "创建成功",
                "result": result,
            }, 201
Пример #8
0
 def post(self: Resource, args: typing.Dict) -> typing.Tuple[typing.Dict, int]:
     """
     创建一个文档类型包括它的条款
     """
     args.update({'nlp_task_id': Common().get_nlp_task_id_by_route()})
     args.update({"group_id": self.get_current_user().user_groups[0]})
     result = DocTypeService().create_doc_type(self.get_current_user(), args)
     return {
                "message": "创建成功",
                "result": result,
            }, 201
Пример #9
0
 def post(self: Resource, args: typing.Dict) -> typing.Tuple[typing.Dict, int]:
     """
     检查文档类型是否合法和重复,暂时只检查名称是否重复
     """
     item = DocTypeService().check_doc_type_name_exists(args['doc_type_name'])
     return {
                "message": "请求成功",
                "result": {
                    "existed": bool(item)
                },
            }, 200
Пример #10
0
 def get(self, args: typing.Dict, doc_type_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     获取所有条款,不分页
     """
     result, count = DocTypeService().get_relation_list(doc_type_id, args.get("offset"), args.get("limit"),
                                                        doc_relation_ids=args.get("doc_relation_ids"))
     return {
                "message": "请求成功",
                "result": result,
                "count": count,
            }, 200
Пример #11
0
 def patch(self: Resource,
           args: typing.Dict,
           doc_type_id: int,
           doc_relation_id: int) -> typing.Tuple[typing.Dict, int]:
     """
     修改一个条款
     """
     doc_term_ids = list(set(args.pop("doc_term_ids", [])))
     if len(doc_term_ids) != 2:
         abort(400, message="文档条款不正确,请确保填写了正确的文档条款")
     result = DocTypeService().update_relation(doc_type_id, args.get("doc_relation_name"), args.get("doc_term_ids", []))
     return {
                "message": "更新成功",
                "result": result,
            }, 201
Пример #12
0
 def get(self: Resource, args: typing.Dict) -> typing.Tuple[typing.Dict, int]:
     """
     获取所有文档条款
     :param args:
     :return:
     """
     nlp_task_id = Common().get_nlp_task_id_by_route()
     args.update({
         'nlp_task_id': nlp_task_id
     })
     result, count = DocTypeService().get_doc_type(self.get_current_user(), args)
     return {
                "message": "请求成功",
                "result": result,
                "count": count,
            }, 200