This commit is contained in:
苏尹岚
2021-03-19 10:45:27 +08:00
parent 8dba6fe19f
commit 2ba2ff5994
3 changed files with 49 additions and 39 deletions

View File

@@ -183,33 +183,33 @@ var (
"payeeBankCode": "开户行代码", "payeeBankCode": "开户行代码",
"payPercentage": "支付比例", "payPercentage": "支付比例",
} }
roleMoblieMap = map[string]string{ // roleMoblieMap = map[string]string{
"17380734342": "17380734342", //漆云的手机 用于判断updatestore的权限 // "17380734342": "17380734342", //漆云的手机 用于判断updatestore的权限
"18328080405": "18328080405", //肖娜娜的手机 // "18328080405": "18328080405", //肖娜娜的手机
"13350726500": "13350726500", //谭翔心 // "13350726500": "13350726500", //谭翔心
"15928865396": "15928865396", //何佳梦 // "15928865396": "15928865396", //何佳梦
"18048531223": "18048531223", //石老板 // "18048531223": "18048531223", //石老板
"18982250714": "18982250714", //赵敏夫 // "18982250714": "18982250714", //赵敏夫
"13708196093": "13708196093", //顾子航 // "13708196093": "13708196093", //顾子航
"15680070110": "15680070110", //李荣维 // "15680070110": "15680070110", //李荣维
"15208271238": "15208271238", // "15208271238": "15208271238",
} // }
marketManPhoneRoleMap = map[string]string{ marketManPhoneRoleMap = map[string]string{
"marketManPhone": "市场负责人电话", "marketManPhone": "市场负责人电话",
} }
marketManPhoneRoleMoblieMap = map[string]string{ // marketManPhoneRoleMoblieMap = map[string]string{
"13684045763": "13684045763", // "13684045763": "13684045763",
"18160030913": "18160030913", // "18160030913": "18160030913",
"18048531223": "18048531223", // "18048531223": "18048531223",
"18328080405": "18328080405", // "18328080405": "18328080405",
"17380734342": "17380734342", // "17380734342": "17380734342",
"15208271238": "15208271238", // "15208271238": "15208271238",
"18583684218": "18583684218", // "18583684218": "18583684218",
"18982250714": "18982250714", // "18982250714": "18982250714",
"13708196093": "13708196093", // "13708196093": "13708196093",
} // }
) )
func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]interface{}, orderTimeFrom, orderTimeTo time.Time) (sql string, sqlParams []interface{}, sqlFrom string, sqlFromParams []interface{}, err error) { func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]interface{}, orderTimeFrom, orderTimeTo time.Time) (sql string, sqlParams []interface{}, sqlFrom string, sqlFromParams []interface{}, err error) {
@@ -921,20 +921,26 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
} }
for k, _ := range valid { for k, _ := range valid {
if roleMap[k] != "" { if roleMap[k] != "" || marketManPhoneRoleMap[k] != "" {
if authInfo, err := ctx.GetV2AuthInfo(); err == nil { menus, _ := dao.GetMenu(db, "结算权限", 0, 1, ctx.GetUserID())
if roleMoblieMap[authInfo.Mobile] == "" { if len(menus) == 0 {
return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k])) return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改字段!", ctx.GetUserName()))
}
}
}
if marketManPhoneRoleMap[k] != "" {
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
if marketManPhoneRoleMoblieMap[authInfo.Mobile] == "" {
return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k]))
}
} }
} }
// if roleMap[k] != "" {
// if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
// if roleMoblieMap[authInfo.Mobile] == "" {
// return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k]))
// }
// }
// }
// if marketManPhoneRoleMap[k] != "" {
// if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
// if marketManPhoneRoleMoblieMap[authInfo.Mobile] == "" {
// return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k]))
// }
// }
// }
} }
// districtCode := 0 // districtCode := 0

View File

@@ -16,17 +16,17 @@ import (
func GetMenu(ctx *jxcontext.Context, userID string) (menus []*model.Menu, err error) { func GetMenu(ctx *jxcontext.Context, userID string) (menus []*model.Menu, err error) {
if userID == "" { if userID == "" {
return dao.GetMenu(dao.GetDB(), "", 0, userID) return dao.GetMenu(dao.GetDB(), "", 0, 0, userID)
} else { } else {
if user, err := dao.GetUserByID(dao.GetDB(), "user_id", userID); err == nil { if user, err := dao.GetUserByID(dao.GetDB(), "user_id", userID); err == nil {
if user.Type&model.UserTypeRole != 0 { if user.Type&model.UserTypeRole != 0 {
return dao.GetMenuWithUser(dao.GetDB(), "", 0, userID) return dao.GetMenuWithUser(dao.GetDB(), "", 0, userID)
} else { } else {
return dao.GetMenu(dao.GetDB(), "", 0, "") return dao.GetMenu(dao.GetDB(), "", 0, 0, "")
} }
} }
} }
return dao.GetMenu(dao.GetDB(), "", 0, userID) return dao.GetMenu(dao.GetDB(), "", 0, 0, userID)
} }
func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) { func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) {
@@ -39,7 +39,7 @@ func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) {
if menu.Name == "" || menu.Level == 0 { if menu.Name == "" || menu.Level == 0 {
return fmt.Errorf("添加失败menu 名称和等级必须有值!") return fmt.Errorf("添加失败menu 名称和等级必须有值!")
} }
menus, err := dao.GetMenu(db, menu.Name, menu.Level, "") menus, err := dao.GetMenu(db, menu.Name, menu.Level, 0, "")
if len(menus) > 0 { if len(menus) > 0 {
return fmt.Errorf("添加失败!已存在相同名称的 menu name : %v", menu.Name) return fmt.Errorf("添加失败!已存在相同名称的 menu name : %v", menu.Name)
} }

View File

@@ -5,7 +5,7 @@ import (
"git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model"
) )
func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.Menu, err error) { func GetMenu(db *DaoDB, name string, level, menuType int, userID string) (menus []*model.Menu, err error) {
sqlParams := []interface{}{} sqlParams := []interface{}{}
sql := ` sql := `
SELECT DISTINCT a.* SELECT DISTINCT a.*
@@ -29,6 +29,10 @@ func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.M
sql += " AND a.level = ?" sql += " AND a.level = ?"
sqlParams = append(sqlParams, level) sqlParams = append(sqlParams, level)
} }
if menuType != 0 {
sql += " AND a.type = ?"
sqlParams = append(sqlParams, menuType)
}
sql += " ORDER BY a.id" sql += " ORDER BY a.id"
err = GetRows(db, &menus, sql, sqlParams) err = GetRows(db, &menus, sql, sqlParams)
return menus, err return menus, err