添加用户模块功能;

修复首页接口跨域问题
duizhaopin
apan 2 years ago
parent 5362927ab9
commit f41fc83dcb

@ -62,8 +62,8 @@ def get_home_info():
@home_router.route("/home_drug_remaining", methods=["GET", "POST"]) @home_router.route("/home_drug_remaining", methods=["GET", "POST"])
def drug_remaining(): def drug_remaining():
client_id = request.values.get("client_id") client_id = request.values.get("client_id")
page = request.values.get("page", 1) page = int(request.values.get("page", 1))
page_size = request.values.get("page_size", 10) page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
data_list = BllMedicament().get_drug_surplus(client_id=client_id, page_param=page_param) data_list = BllMedicament().get_drug_surplus(client_id=client_id, page_param=page_param)
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": Utils.msyql_table_model(data_list)})) return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": Utils.msyql_table_model(data_list)}))
@ -83,8 +83,8 @@ def get_warning_list():
start_time = request.values.get("start_time") start_time = request.values.get("start_time")
end_time = request.values.get("end_time") end_time = request.values.get("end_time")
object_type = request.values.get("object_type") object_type = request.values.get("object_type")
page = request.values.get('page', 1) page = int(request.values.get('page', 1))
page_size = request.values.get('page_size', 15) page_size = int(request.values.get('page_size', 15))
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
warning_list = BllWarning().getWarningList( warning_list = BllWarning().getWarningList(
pageParam=page_param, pageParam=page_param,

@ -0,0 +1,27 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/08/01 17:04:40
'''
from operator import index
import sys
sys.path.append('.')
from flask import Blueprint, request, g
from db_logic.module_relation import BllModuleRelation
from Common.Utils import Utils
power_router = Blueprint('power', __name__)
@power_router.route("/user_power", methods=["GET", "POST"])
def get_user_power_list():
user_info = g.current_user
module_list = BllModuleRelation().get_user_module_list(user_id=user_info.user_id, role_id=user_info.role_id)
module_list = Utils.msyql_table_model(module_list)
if len(module_list) > 6:
for module in module_list:
if module["module_code"] == "DataReport":
if module_list.index(module) in [1,2,4]:
module_list.pop(module_list.index(module))
module_list.insert(5, module)
data = module_list

@ -13,15 +13,8 @@ from db_logic.user import BllUser
user_router = Blueprint('user', __name__) user_router = Blueprint('user', __name__)
# class LoginBase(BaseModel):
# user_name: str
# password: str
@user_router.route("/login", methods=["POST"]) @user_router.route("/login", methods=["POST"])
# @token_auth.login_required # @token_auth.login_required
# @doc_siwa.doc(body=LoginBase)
def user_login(): def user_login():
user_name = request.values.get("user_name") user_name = request.values.get("user_name")
password = request.values.get('password') password = request.values.get('password')
@ -33,6 +26,18 @@ def user_login():
else: else:
return jsonify(Utils.false_return(status=201, msg="登陆失败")) return jsonify(Utils.false_return(status=201, msg="登陆失败"))
# 修改密码,根据token获取用户信息接受老密码进行校验新密码写入
@user_router.route("/update_password", methods=["POST"])
def user_update_password():
old_password = request.values.get("old_password")
new_password = request.values.get("new_password")
# user_id = g.current_user.user_id
msg_bool, msg_token = BllUser().update_password(g.current_user, old_password=old_password, new_password=new_password)
if msg_bool:
return jsonify(Utils.true_return(data={"token": msg_token}))
else:
return jsonify(Utils.false_return(msg=msg_token))
@user_router.route("/get_user_power", methods=["GET"]) @user_router.route("/get_user_power", methods=["GET"])
@token_auth.login_required @token_auth.login_required

@ -83,14 +83,19 @@ class BllMedicamentRecord(Repository):
# filter_base += f"client_id='{client_id}'" # filter_base += f"client_id='{client_id}'"
sql_all = sql_all % filter_base sql_all = sql_all % filter_base
sql_data = self.execute(sql_all).fetchall() sql_data = self.execute(sql_all).fetchall()
data_list = Utils.msyql_table_model(sql_data) n_a, n_b = 0,0
n_a = 0 data_list = []
n_b = 0 default_list = [(1,0),(2,0),(3,0)]
sql_data = sql_data if sql_data else default_list
for i in sql_data: for i in sql_data:
if i[0] == 2: if i[0] == 2:
n_a = i[1] n_a = i[1]
if i[0] == 3: if i[0] == 3:
n_b = i[1] n_b = i[1]
data_list.append({
"record_type":i[0],
"type_number":i[1]
})
data_list.append( data_list.append(
{ {
"record_type":100, "record_type":100,

@ -0,0 +1,60 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/08/01 15:36:46
'''
import sys
sys.path.append('.')
from db_logic.db_base import Repository
from models.power_models import EntityModule
from Common.Utils import Utils
class BllModule(Repository):
def __init__(self, entityType=EntityModule):
return super().__init__(entityType)
"""
module_id = Column(String(50), primary_key=True, comment="模块ID")
module_type = Column(String(50), comment="模块类型")
module_code = Column(String(50), comment="")
module_name = Column(String(50), comment="模块名称")
icon = Column(String(50), comment="图片")
url_address = Column(String(50), comment="图片地址")
sort_index = Column(Integer, comment="排序下标")
module_weight = Column(Integer, comment="模块权重")
parent_id = Column(String(50), comment="父id")
is_enabled = Column(Integer, comment="是否启用")
description = Column(String(50), comment="备注")
create_date = Column(String(50), comment="创建时间")
create_user_id = Column(String(50), comment="创建用户id")
create_user_name = Column(String(50), comment="创建用户名")
is_add = Column(Integer, comment="")
"""
def inster_info_list(self):
obj_list = []
from demo import data_list
for i in data_list:
obj = EntityModule(
module_type=i.get("ModuleType"),
module_name=i.get("ModuleName"),
module_code=i.get("ModuleCode"),
sort_index=i.get("SortIndex"),
module_weight=i.get("SortIndex"),
parent_id=0,
is_enabled=1,
create_date=Utils.get_str_datetime(),
create_user_id='4cea74ee-0d8b-11ed-943e-f47b094925e1',
create_user_name="admin",
)
obj_list.append(obj)
self.insert_many(obj_list)
if __name__ == '__main__':
from Common.Utils import Utils
aaa = BllModule().inster_info_list()
# aaa_list = Utils.msyql_table_model(aaa)
print(aaa)

@ -0,0 +1,67 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/08/01 15:32:08
'''
import sys
sys.path.append(".")
from Common.Utils import Utils
from db_logic.db_base import Repository
from models.power_models import EntityModuleRelation
class BllModuleRelation(Repository):
def __init__(self, entityType=EntityModuleRelation):
return super().__init__(entityType)
def get_user_module_list(self, user_id, role_id):
sql_all = f"""
select c.module_id, c.module_code, c.sort_index, c.module_name from(
SELECT a.module_id, b.module_code, b.sort_index, b.module_name
from rms_module_relation as a
LEFT JOIN rms_module as b on a.module_id=b.module_id
WHERE object_id='{user_id}' AND object_type=2 AND b.module_type=1
UNION
SELECT a.module_id, b.module_code, b.sort_index, b.module_name
from rms_module_relation as a
LEFT JOIN rms_module as b on a.module_id=b.module_id
WHERE object_id='{role_id}' AND object_type=1 AND b.module_type=1
) c ORDER BY c.sort_index asc
"""
return self.execute(sql_all).fetchall()
def add_inster_user_moduele(self):
role_id = "a699ff99-117b-11ed-a086-f47b094925e5"
obj_list = []
all_module_list = self.execute("select * from rms_module")
all_module_list = Utils.msyql_table_model(all_module_list)
for i in all_module_list:
obj = EntityModuleRelation(
object_type=1,
object_id=role_id,
module_type=i['module_type'],
module_id=i['module_id'],
create_date=Utils.get_str_datetime(),
create_user_id='4cea74ee-0d8b-11ed-943e-f47b094925e1',
create_user_name=''
)
obj_list.append(obj)
self.insert_many(obj_list)
if __name__ == '__main__':
module_list = BllModuleRelation().get_user_module_list(
user_id='4cea74ee-0d8b-11ed-943e-f47b094925e1', role_id='a699ff99-117b-11ed-a086-f47b094925e5')
module_list = Utils.msyql_table_model(module_list)
if len(module_list) > 6:
for module in module_list:
if module["module_code"] == "DataReport":
if module_list.index(module) in [1,2,4]:
module_list.pop(module_list.index(module))
module_list.insert(5, module)
data = module_list

@ -0,0 +1,40 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/08/01 17:14:39
'''
from gc import isenabled
import sys
sys.path.append('.')
from db_logic.db_base import Repository
from models.user_models import EntityRole
# 角色类
class BllRole(Repository):
def __init__(self, entityType=EntityRole):
return super().__init__(entityType)
def add_inster_role_user(self):
obj_list = []
name_list = [
{"code": "admin", "name": "管理员", "index": 2},
{"code": "maintain_user", "name": "维护人员", "index": 3},
{"code": "simple_user", "name": "普通用户", "index": 1},
]
for i in range(3):
obj = EntityRole(
role_code=name_list[i].get("code"),
role_name=name_list[i].get("name"),
role_level=name_list[i].get("index"),
sort_index=name_list[i].get("index"),
is_enabled=1
)
obj_list.append(obj)
self.insert_many(obj_list)
if __name__ == '__main__':
BllRole().add_inster_role_user()

@ -29,6 +29,15 @@ class BllUser(Repository):
return self.get_jwt(user_info) return self.get_jwt(user_info)
return False return False
# 用户密码修改
def update_password(self, user_info, old_password, new_password):
if user_info.check_password(old_password):
user_info.set_password(new_password)
self.update(user_info)
return True, self.get_jwt(user_info)
else:
return False, "旧密码错误"
def get_jwt(self, obj, expires_in=36000): def get_jwt(self, obj, expires_in=36000):
'''用户登录后,发放有效的 JWT''' '''用户登录后,发放有效的 JWT'''
now = datetime.datetime.now() now = datetime.datetime.now()

@ -24,8 +24,8 @@ class BllWarning(Repository):
""" """
filter_base = "" filter_base = ""
if key_word: if key_word:
key_word = f"%{key_word}%" key_word = f"'%{key_word}%'"
filter_base += f" where object_name like {key_word} or warning_user_name like {key_word}" filter_base += f" where object_name like {key_word} or warning_user_name like {key_word} or warning_content like {key_word}"
if object_type: if object_type:
if filter_base: if filter_base:
filter_base += " and " filter_base += " and "

@ -194,3 +194,114 @@ def model_name_loer(db_model):
{"variety_id": "f84451a8-9950-11ec-96ca-e2052a1045e4", "remark1": "", "remark2": "", "remark3": "\u5371\u5316\u54c1", "remark4": "", "name": "\u56db\u6c2f\u5316\u78b3", "english_name": "", "purity": "\u7ea2\u5916\u6d4b\u6cb9\u4eea\u4e13\u7528", "cas_number": "56-23-5", "remark5": "", "speci": "500", "speci_unit": "ml", "export_count": "31", "remark6": "\u74f6", "production_date": "2022-03-01", "shelf_life": 10529, "price": "0", "is_supervise": 0, "remain": "1126", "manufacturer": "\u5b89\u8c31", "remark8": "", "remark9": "\u77ff\u7269\u6cb9", "remark10": ""}] {"variety_id": "f84451a8-9950-11ec-96ca-e2052a1045e4", "remark1": "", "remark2": "", "remark3": "\u5371\u5316\u54c1", "remark4": "", "name": "\u56db\u6c2f\u5316\u78b3", "english_name": "", "purity": "\u7ea2\u5916\u6d4b\u6cb9\u4eea\u4e13\u7528", "cas_number": "56-23-5", "remark5": "", "speci": "500", "speci_unit": "ml", "export_count": "31", "remark6": "\u74f6", "production_date": "2022-03-01", "shelf_life": 10529, "price": "0", "is_supervise": 0, "remain": "1126", "manufacturer": "\u5b89\u8c31", "remark8": "", "remark9": "\u77ff\u7269\u6cb9", "remark10": ""}]
""" """
# import datetime
# data_list = [
# {'ModuleId': '06508334-2507-49c4-be5c-8e8d9775bc56', 'ModuleType': '1', 'ModuleCode': 'MyDrug', 'ModuleName': '我的药剂', 'Icon': None, 'UrlAddress': None, 'SortIndex': 4, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '0b87a3a3-e09d-4f71-a6e4-b4df8b092683', 'ModuleType': '1', 'ModuleCode': 'About', 'ModuleName': '关于系统', 'Icon': None, 'UrlAddress': None, 'SortIndex': 13, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '0c9144a7-13b0-4a0e-8364-42a783488b36', 'ModuleType': '2', 'ModuleCode': 'DrugScanBarCode', 'ModuleName': '扫码查询', 'Icon': None, 'UrlAddress': None, 'SortIndex': 15, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '18dfe869-1811-4af5-bfcf-48e14319a862', 'ModuleType': '2', 'ModuleCode': 'UserIndex', 'ModuleName': '用户管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 52, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '198654be-cdc7-4581-9476-1607ebb067cf', 'ModuleType': '2', 'ModuleCode': 'CabinetIndex', 'ModuleName': '柜体管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 26, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '2deee6c6-8ee0-4f10-bbc2-76e355c47dde', 'ModuleType': '1', 'ModuleCode': 'WarningData', 'ModuleName': '预警管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 7, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '2e1cbd6d-d550-4f9c-bf3b-7baa206d5e16', 'ModuleType': '1', 'ModuleCode': 'WarningConfig', 'ModuleName': '系统设置', 'Icon': None, 'UrlAddress': None, 'SortIndex': 12, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1,
# 'Description': None, 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '3461016c-d8f5-11e8-95b1-7427eac89794', 'ModuleType': '1', 'ModuleCode': 'RemoteManage', 'ModuleName': '远程管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 10, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1,
# 'Description': None, 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '4d354993-6977-4a2e-b11c-7f1993875284', 'ModuleType': '2', 'ModuleCode': 'DrugUseView', 'ModuleName': '试剂领用', 'Icon': None, 'UrlAddress': None, 'SortIndex': 18, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '4d8a2e05-86e5-4a44-8167-fbbd76ae9dca', 'ModuleType': '2', 'ModuleCode': 'DrugReturnView', 'ModuleName': '试剂归还', 'Icon': None, 'UrlAddress': None, 'SortIndex': 20, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '5b216724-cfff-4032-9e82-4f2e4c7aa085', 'ModuleType': '1', 'ModuleCode': 'DrugView', 'ModuleName': '药剂查询', 'Icon': None, 'UrlAddress': None, 'SortIndex': 5, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': 'rererttrtryty', 'ModifyUserName': '系统维护员', 'IsAdd': None},
# {'ModuleId': '60013b06-d8f5-11e8-983e-7427eac89794', 'ModuleType': '1', 'ModuleCode': 'quitSystem', 'ModuleName': '退出系统', 'Icon': None, 'UrlAddress': None, 'SortIndex': 13, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '66b8da23-37b3-4b68-b05f-7c67385d8d1a', 'ModuleType': '2', 'ModuleCode': 'HumitureIndex', 'ModuleName': '温度记录', 'Icon': None, 'UrlAddress': None, 'SortIndex': 36, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '6fa6fa4b-f9ba-4624-85f8-30326e58596e', 'ModuleType': '2', 'ModuleCode': 'DrugWeigh', 'ModuleName': '试剂称重', 'Icon': None, 'UrlAddress': None, 'SortIndex': 22, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '6fdf7f81-e8f4-4b33-90cc-9682f0c181ba', 'ModuleType': '1', 'ModuleCode': 'UserManage', 'ModuleName': '用户管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 9, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '74eed32c-adc0-4bff-8dd0-1b6312a2110a', 'ModuleType': '1', 'ModuleCode': 'Camera', 'ModuleName': '视频监控', 'Icon': None, 'UrlAddress': None, 'SortIndex': 8, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '7c4503bb-4f30-42a3-8ebf-e97be4a5dae9', 'ModuleType': '1', 'ModuleCode': 'DrugWeigh', 'ModuleName': '药剂称重', 'Icon': None, 'UrlAddress': None, 'SortIndex': 0, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2019, 12, 8, 15, 52, 11), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2019, 12, 8, 15, 52, 16), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '84baf3f0-1933-41c8-8778-cc8db716cd25', 'ModuleType': '2', 'ModuleCode': 'DrugTypeIndex', 'ModuleName': '试剂类别', 'Icon': None, 'UrlAddress': None, 'SortIndex': 30, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '8596d10d-f24f-4ea1-816a-7fe66e0b57f4', 'ModuleType': '2', 'ModuleCode': 'UserRoleIndex', 'ModuleName': '角色管理', 'Icon': None, 'UrlAddress': None, 'SortIndex': 56, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '85b29cd3-c6ef-485c-8ddf-8517bdf35fe1', 'ModuleType': '2', 'ModuleCode': 'StockTakingIndex', 'ModuleName': '库存盘点', 'Icon': None, 'UrlAddress': None, 'SortIndex': 50, 'ModuleWeight': 5, 'ParentId': '0',
# 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': '8f4e0f8d-4334-44cc-8374-a8cb2c805e83', 'ModuleType': '2', 'ModuleCode': 'WarningIndex', 'ModuleName': '预警信息', 'Icon': None, 'UrlAddress': None, 'SortIndex': 32, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'a465f95a-8b67-4a01-b958-68ba0f1a635d', 'ModuleType': '2', 'ModuleCode': 'DrugTemplateIndex', 'ModuleName': '试剂入库', 'Icon': None, 'UrlAddress': None, 'SortIndex': 16, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'a5fccba3-2a73-439b-a619-19dec121a44b', 'ModuleType': '1', 'ModuleCode': 'DrugReturn', 'ModuleName': '药剂归还', 'Icon': None, 'UrlAddress': None, 'SortIndex': 2, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': 'rererttrtryty', 'ModifyUserName': '系统维护员', 'IsAdd': None},
# {'ModuleId': 'a98db670-b1d9-4655-83d1-6e285691d567', 'ModuleType': '2', 'ModuleCode': 'DataReportIndex', 'ModuleName': '报表统计', 'Icon': None, 'UrlAddress': None, 'SortIndex': 38, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'c826c343-945b-4ba0-91f2-c3effd3865d0', 'ModuleType': '2', 'ModuleCode': 'DrugIndex', 'ModuleName': '试剂数据', 'Icon': None, 'UrlAddress': None, 'SortIndex': 28, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'd314dcd7-c23c-4117-a1a2-9304ae8eb7ed', 'ModuleType': '1', 'ModuleCode': 'SysSetting', 'ModuleName': '运行日志', 'Icon': None, 'UrlAddress': None, 'SortIndex': 11, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'ec10a7d2-ece7-4122-9b54-a87fb4d56b65', 'ModuleType': '1', 'ModuleCode': 'DrugPutIn', 'ModuleName': '药剂入库', 'Icon': None, 'UrlAddress': None, 'SortIndex': 3, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 25), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 25), 'ModifyUserId': 'rererttrtryty', 'ModifyUserName': '系统维护员', 'IsAdd': None},
# {'ModuleId': 'ec1637ca-e813-437e-9651-5d75761a634d', 'ModuleType': '1', 'ModuleCode': 'DrugUse', 'ModuleName': '药剂领用', 'Icon': None, 'UrlAddress': None, 'SortIndex': 1, 'ModuleWeight': 10, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': 'rererttrtryty', 'ModifyUserName': '系统维护员', 'IsAdd': None},
# {'ModuleId': 'f132f6ad-fb46-4293-be2d-c69fe93bcfbe', 'ModuleType': '2', 'ModuleCode': 'LogIndex', 'ModuleName': '日志数据', 'Icon': None, 'UrlAddress': None, 'SortIndex': 58, 'ModuleWeight': 5,
# 'ParentId': '0', 'IsEnabled': 1, 'Description': None, 'CreateDate': None, 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': None, 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None},
# {'ModuleId': 'fb1130d3-a487-46e1-84cb-05c25a1cca8d', 'ModuleType': '1', 'ModuleCode': 'DataReport', 'ModuleName': '报表数据', 'Icon': None, 'UrlAddress': None, 'SortIndex': 6, 'ModuleWeight': 5, 'ParentId': '0', 'IsEnabled': 1, 'Description': None,
# 'CreateDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'CreateUserId': None, 'CreateUserName': None, 'ModifyDate': datetime.datetime(2017, 6, 16, 14, 26, 18), 'ModifyUserId': None, 'ModifyUserName': None, 'IsAdd': None}
# ]
"""
SELECT
c.ModuleId,
c.ModuleCode,
c.SortIndex,
c.ModuleName
FROM
(
SELECT
a.ModuleId,
b.ModuleCode,
b.SortIndex,
b.ModuleName
FROM
`RMS_ModuleRelation` AS a
LEFT JOIN RMS_Module AS b ON a.ModuleId = b.ModuleId
WHERE
ObjectId = : user_id
AND ObjectType = 2 UNION
SELECT
a.ModuleId,
b.ModuleCode,
b.SortIndex,
b.ModuleName
FROM
`RMS_ModuleRelation` AS a
LEFT JOIN RMS_Module AS b ON a.ModuleId = b.ModuleId
WHERE
ObjectId = : role_id
AND ObjectType = 1
) AS c
ORDER BY
c.SortIndex ASC
object_type=2 查询用户id
object_type=1 查询权限id
"""

@ -6,7 +6,7 @@
import sys import sys
sys.path.append(".") sys.path.append(".")
from sqlalchemy import Column, String, Integer from sqlalchemy import Column, String, Integer
from models.models_base import Base from models.models_base import Base, get_uuid
#终端模块实体类 #终端模块实体类
@ -18,8 +18,7 @@ class EntityModule(Base):
} }
) )
module_id = Column(String(50), primary_key=True, comment="模块ID", default=get_uuid)
module_id = Column(String(50), primary_key=True, comment="模块ID")
module_type = Column(String(50), comment="模块类型") module_type = Column(String(50), comment="模块类型")
module_code = Column(String(50), comment="") module_code = Column(String(50), comment="")
module_name = Column(String(50), comment="模块名称") module_name = Column(String(50), comment="模块名称")
@ -36,6 +35,7 @@ class EntityModule(Base):
is_add = Column(Integer, comment="") is_add = Column(Integer, comment="")
# #终端模块权限实体类 # #终端模块权限实体类
class EntityModuleRelation(Base): class EntityModuleRelation(Base):
__tablename__ = "rms_module_relation" __tablename__ = "rms_module_relation"
@ -45,7 +45,7 @@ class EntityModuleRelation(Base):
} }
) )
module_relation_id = Column(String(50), primary_key=True, comment="模块权限id") module_relation_id = Column(String(50), primary_key=True, comment="模块权限id", default=get_uuid)
customer_id = Column(String(50), comment="客户id") customer_id = Column(String(50), comment="客户id")
object_type = Column(String(50), comment="类型") object_type = Column(String(50), comment="类型")
object_id = Column(String(50), comment="类型id") object_id = Column(String(50), comment="类型id")

Loading…
Cancel
Save