diff --git a/main_service.py b/main_service.py index 6038fa2..807b50b 100644 --- a/main_service.py +++ b/main_service.py @@ -217,6 +217,22 @@ def run_sql_2(id: str, sql: str): return jsonify({"type": "sql_error", "error": str(e)}) +@app.flask_app.route("/yj_sqlbot/api/v0/verify", methods=["GET"]) +def verify_user(): + try: + id = request.args.get("user_id") + users = config('ALLOWED_USERS', cast=list, default=[]) + for user in users: + if user == id: + return jsonify({"type": "success", "verify": True}) + else: + return jsonify({"type": "success", "verify": False}) + except Exception as e: + logger.error(f"verify user failed:{e}") + return jsonify({"type": "error", "error": str(e)}) + + + if __name__ == '__main__': app.run(host='0.0.0.0', port=8084, debug=False) diff --git a/util/load_ddl_doc.py b/util/load_ddl_doc.py index 6cd21fd..03a5c1f 100644 --- a/util/load_ddl_doc.py +++ b/util/load_ddl_doc.py @@ -2,7 +2,9 @@ from service.cus_vanna_srevice import CustomVanna from util import train_ddl from util import q_and_a_dict table_ddls = [ - train_ddl.person_ddl_sql,train_ddl.rule_ddl,train_ddl.user_status_ddl + train_ddl.person_database_ddl,train_ddl.person_attendance_rule_ddl, + train_ddl.user_status_ddl,train_ddl.user_attendance_ddl,train_ddl.person_ac_position, + train_ddl.person_ac_area,train_ddl.org_orgs_ddl ] list_documentions = [ train_ddl.train_document, diff --git a/util/train_ddl.py b/util/train_ddl.py index c413f21..1d885c7 100644 --- a/util/train_ddl.py +++ b/util/train_ddl.py @@ -1,4 +1,4 @@ -person_ddl_sql = """ +person_database_ddl = """ { "db_name":"YJOA_APPSERVICE_DB", @@ -470,16 +470,7 @@ person_ddl_sql = """ """ -train_document=''' - 语法为达梦数据库语法; - 查询地址,籍贯,公司,单位时,尽量使用like查询; - 查询人员信息时,由于数据表字段过多。只需要展示人员关键信息字段,id,工号,姓名,单位以及用户问题中需要查询的字段; - 表字段信息以及字段枚举信息在values下,注意相关字段枚举值的转换; - 查询单位信息时,内部单位和外部单位都需要查询,用OR条件查询; - - ''' - -rule_ddl=''' +person_attendance_rule_ddl=''' { "db_name":"YJOA_APPSERVICE_DB", "table_name": "t_yj_person_attendance_rules", @@ -804,7 +795,75 @@ user_attendance_ddl = ''' } ''' +person_rules_ddl = ''' +{ + "db_name": "YJOA_APPSERVICE_DB", + "table_name": "t_yj_person_rules", + "table_comment": "人员考勤规则关联表,关联人员与考勤规则", + "columns": [ + { + "name": "id", + "type": "VARCHAR(50)", + "comment": "主键ID", + "role": "dimension", + "tags": ["主键", "ID标识"] + }, + { + "name": "person_id", + "type": "VARCHAR(50)", + "comment": "人员ID", + "role": "dimension", + "tags": ["人员标识", "外键"] + }, + { + "name": "person_name", + "type": "VARCHAR(50)", + "comment": "人员姓名", + "role": "dimension", + "tags": ["人员信息", "姓名"] + }, + { + "name": "rules_id", + "type": "VARCHAR(50)", + "comment": "考勤规则ID", + "role": "dimension", + "tags": ["规则标识", "外键"] + }, + { + "name": "dr", + "type": "CHAR(2)", + "comment": "删除标志", + "value": { + "0": "正常", + "1": "删除" + }, + "role": "dimension", + "tags": ["状态标识", "软删除", "枚举"] + } + ], + "relationships": [ + { + "from": "person_id", + "to_table": "t_yj_person_database", + "to_field": "id", + "type": "foreign_key", + "comment": "关联人员基本信息表" + }, + { + "from": "rules_id", + "to_table": "t_yj_person_attendance_rules", + "to_field": "id", + "type": "foreign_key", + "comment": "关联考勤规则表" + } + ], + "tags": ["人员考勤", "规则关联", "关系映射", "考勤管理"] +} +''' + person_ac_position = ''' + ], + { "db_name":"YJOA_APPSERVICE_DB", "table_name": "t_yj_person_ac_position", @@ -833,8 +892,13 @@ person_ac_position = ''' "type": "foreign_key", "comment": "关联门禁区域关系表" }, - ], - + { + "from": "position", + "to_table": "t_yj_person_ac_area", + "to_field": "area", + "type": "foreign_key", + "comment": "关联门禁区域关系表" + }, "tags": ["门禁控制点","门禁位置"] } ''' @@ -921,4 +985,14 @@ org_orgs_ddl = ''' "tags": ["部门id","部门信息","部门名称"] } -''' \ No newline at end of file +''' + +train_document = ''' + 语法为达梦数据库语法; + 查询地址,籍贯,公司,单位时,尽量使用like查询; + 查询人员信息时,由于数据表字段过多。只需要展示人员关键信息字段,id,工号,姓名,单位以及用户问题中需要查询的字段; + 表字段信息以及字段枚举信息在values下,注意相关字段枚举值的转换; + 查询单位信息时,内部单位和外部单位都需要查询,用OR条件查询; + + + ''' \ No newline at end of file