Explorar o código

feat:常用功能

wangshan %!s(int64=2) %!d(string=hai) anos
pai
achega
5a4f474c58
Modificáronse 2 ficheiros con 7 adicións e 9 borrados
  1. 3 1
      entity/workDesktop.go
  2. 4 8
      service/workDesktop.go

+ 3 - 1
entity/workDesktop.go

@@ -45,6 +45,7 @@ type JYMenu struct {
 	CapitalInfo    Additional //留资弹窗
 	Children       []*JYMenu  //菜单s
 	Authority      int        //权限逻辑备注 默认0:功能权限、资源权限、留资权限必须全部满足;1:功能权限或资源权限或留资权限满足其一就行;
+	Level          int        //1:一级菜单;2:二级菜单;3:三级菜单;4:四级菜单
 }
 
 type Additional struct {
@@ -367,11 +368,12 @@ func CommonlyUpdate(in *pb.WorkDesktopComprehensiveReq) (B bool, M string) {
 		//id 解密
 		ids = append(ids, encrypt.SE.DecodeString(mid))
 	}
+	logx.Info("------ids:", ids)
 	//更新此用户设置的常用功能
 	if B = BaseMysql.ExecTx("常用功能批量更新", func(tx *sql.Tx) bool {
 		//查询此用户常用功能是否已存在记录
 		var id = 0
-		existingData := BaseMysql.SelectBySqlByTx(tx, `SELECT id  FROM `+WorkCommonly+` WHERE base_userid = ? AND appid = ? AND field = ? AND platform = ?  ORDER BY id DESC `, in.NewUserId, in.AppId, in.ActionMode, in.Platform)
+		existingData := BaseMysql.SelectBySqlByTx(tx, `SELECT id  FROM `+WorkCommonly+` WHERE base_userid = ? AND appid = ? AND field = ?  ORDER BY id DESC `, in.NewUserId, in.AppId, in.ActionMode)
 		if existingData != nil && len(*existingData) > 0 {
 			id = MC.IntAll((*existingData)[0]["id"])
 		}

+ 4 - 8
service/workDesktop.go

@@ -65,7 +65,7 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 		if len(pIds) > 0 {
 			//常用功能存储是三级菜单id,需要四级菜单信息也查出来
 			//会出现 用户设置常用功能,此功能下线,用户设置依然保存的有此功能  查询不能加 AND status = 0
-			menuData := entity.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * from %s WHERE id IN (%s)  OR (parentid IN (%s)  AND status = 0)`, entity.WorkMenu, strings.Join(pIds, ","), strings.Join(pIds, ",")))
+			menuData := entity.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * from %s WHERE id IN (%s)  OR (parentid IN (%s)  AND status = 0)  ORDER BY FIELD(id , %s);`, entity.WorkMenu, strings.Join(pIds, ","), strings.Join(pIds, ","), strings.Join(pIds, ",")))
 			if menuData != nil && len(*menuData) > 0 {
 				var (
 					m = &entity.WorkDesktopMenu{
@@ -80,14 +80,9 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 					}
 					childMenus = map[int][]*entity.JYMenu{}
 				)
-				//是否存在父级
-				parentIsExists := map[int]bool{}
 				for _, mv := range *menuData {
-					//id
-					id := MC.IntAll(mv["id"])
 					//parentId
 					parentId := MC.IntAll(mv["parentid"])
-					parentIsExists[id] = true
 					menu := &entity.JYMenu{
 						Id:             MC.IntAll(mv["id"]),
 						Name:           MC.ObjToString(mv["name"]),
@@ -103,6 +98,7 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 						PermissionCode: MC.ObjToString(mv["permissioncode"]),
 						CapitalCode:    MC.ObjToString(mv["capitalcode"]),
 						Authority:      MC.IntAll(mv["authority"]),
+						Level:          MC.IntAll(mv["level"]),
 					}
 					var OpenType = map[string]string{}
 					if err := json.Unmarshal([]byte(MC.ObjToString(mv["opentype"])), &OpenType); err == nil {
@@ -124,7 +120,7 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 							menu.AdditionalInfo = additional
 						}
 					}
-					if parentIsExists[parentId] {
+					if menu.Level == 4 {
 						childMenus[parentId] = append(childMenus[parentId], menu)
 					} else {
 						m.MenuTree = append(m.MenuTree, menu)
@@ -149,7 +145,7 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 			r.ErrorCode = -1
 			r.ErrorMsg = "菜单模式-参数异常"
 		} else {
-			menuModes := entity.BaseMysql.SelectBySql(`SELECT id,value FROM `+entity.WorkCommonly+` WHERE appid=? AND base_userid =? AND field = ? AND platform = ? LIMIT 1`, in.AppId, in.NewUserId, in.ActionMode, in.Platform)
+			menuModes := entity.BaseMysql.SelectBySql(`SELECT id,value FROM `+entity.WorkCommonly+` WHERE appid=? AND base_userid =? AND field = ?  LIMIT 1`, in.AppId, in.NewUserId, in.ActionMode)
 			if menuModes != nil && len(*menuModes) > 0 {
 				menuMode := (*menuModes)[0]
 				if MC.ObjToString(menuMode["value"]) != in.MenuMode {