ck 4 rokov pred
rodič
commit
da3d99c213
2 zmenil súbory, kde vykonal 15 pridanie a 6 odobranie
  1. 4 4
      data_manage/pitcher_panel.py
  2. 11 2
      model/UserAuthUtils.py

+ 4 - 4
data_manage/pitcher_panel.py

@@ -597,13 +597,13 @@ left join src_book_info c on a.dt=c.dt and a.book=c.book  and a.type=c.type and
 def get_channel_summary(user_id,channel,pitcher,page,page_size,order_by,order,state,location,start,end):
     db=MysqlUtils()
 
-    if user_id in super_auth():
+    if user_id in super_auth():  # 超级数据权限
         op = ''
     else:
-        if len(UserAuthUtils.get_auth_channel(user_id))==0:
-            return None,None,None
+        if len(UserAuthUtils.get_auth_user(user_id)) == 0: # 属于普通用户
+            op = f" and pitcher='{user_id}'"
         else:
-            op = f" and a.channel in {str(UserAuthUtils.get_auth_channel(user_id))}"
+            op = f" and pitcher in {tuple(UserAuthUtils.get_auth_user(user_id)+[user_id])}"
 
     op1=f" and a.channel='{channel}'" if channel else ''
     op2=f" and pitcher='{pitcher}'" if pitcher else ''

+ 11 - 2
model/UserAuthUtils.py

@@ -4,6 +4,7 @@ from model.DataBaseUtils import MysqlUtils
 
 
 def get_auth_user(user_id):
+    """获取用户拥有权限的的用户"""
     db = MysqlUtils()
     sql = f"""select b.nick_name from t_sys_user_group_relation a
             left join t_sys_user b USING(user_id)
@@ -12,7 +13,6 @@ def get_auth_user(user_id):
     return db.zx.getOneList(sql)
 
 
-
 def get_auth_channel(user_id):
     db = MysqlUtils()
     sql=f"""select nick_name from t_mp_account where 
@@ -47,5 +47,14 @@ def super_auth():
     return db.zx.getOneList(sql)
 
 
+def get_role(user_id):
+    """获取用户的角色"""
+    db = MysqlUtils()
+    sql = "select role_id from t_sys_user_role where user_id ="+str(user_id)
+    return db.zx.getOneList(sql)
+
+
 if __name__ == '__main__':
-    print(get_auth_channel(109))
+    # print(get_auth_channel(109))
+    # print(get_role(78))
+    print(f"ssed{tuple([1,3,4])}")