From 61d01e7cbfcb8ffce37546547a76abad0cc4c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 22 Jan 2021 16:59:13 +0800 Subject: [PATCH] aa --- business/jxstore/cms/permission.go | 16 +++------------- business/model/dao/place.go | 2 +- business/model/user.go | 10 ++++++---- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/business/jxstore/cms/permission.go b/business/jxstore/cms/permission.go index 29f10e803..8c85daa76 100644 --- a/business/jxstore/cms/permission.go +++ b/business/jxstore/cms/permission.go @@ -82,32 +82,22 @@ func UpdateMenu(ctx *jxcontext.Context, menuID int, payload map[string]interface return num, err } -type GetRoleResult struct { - Role *model.Role - CityInfo []*model.Place `json:"cityInfo"` - Stores []*model.Store `json:"storeInfo"` -} - -func GetRole(ctx *jxcontext.Context, name string) (getRoleResults []*GetRoleResult, err error) { +func GetRole(ctx *jxcontext.Context, name string) (roles []*model.Role, err error) { var ( db = dao.GetDB() ) roles, err := dao.GetRole(db, name, "") for _, v := range roles { - getRoleResult := &GetRoleResult{ - Role: v, - } if v.CityCodes != "" { if cityInfos, err := dao.GetPlaces(db, jxutils.StrListToIntList(strings.Split(v.CityCodes, ","))); err == nil { - getRoleResult.CityInfo = cityInfos + v.CityInfo = cityInfos } } if v.StoreIDs != "" { if stores, err := dao.GetStoreList(db, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")), nil, nil, nil, nil, ""); err == nil { - getRoleResult.Stores = stores + v.Stores = stores } } - getRoleResults = append(getRoleResults, getRoleResult) } return getRoleResults, err } diff --git a/business/model/dao/place.go b/business/model/dao/place.go index 0f0b468f6..9a51a9cfe 100644 --- a/business/model/dao/place.go +++ b/business/model/dao/place.go @@ -94,7 +94,7 @@ func GetPlaces(db *DaoDB, cityCodes []int) (places []*model.Place, err error) { ` sqlParams := []interface{}{} if len(cityCodes) > 0 { - sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")" + sql += " AND code IN (" + GenQuestionMarks(len(cityCodes)) + ")" sqlParams = append(sqlParams, cityCodes) } return places, err diff --git a/business/model/user.go b/business/model/user.go index 9c708b927..62b71b07a 100644 --- a/business/model/user.go +++ b/business/model/user.go @@ -228,10 +228,12 @@ func (v *UserMember) TableIndex() [][]string { type Role struct { ModelIDCULD - Name string `json:"name"` //角色名 - BrandID int `orm:"column(brand_id)" json:"brandID"` - CityCodes string `orm:"type(text)" json:"cityCodes"` - StoreIDs string `orm:"column(store_ids);type(text)" json:"storeIDs"` + Name string `json:"name"` //角色名 + BrandID int `orm:"column(brand_id)" json:"brandID"` + CityCodes string `orm:"type(text)" json:"cityCodes"` + StoreIDs string `orm:"column(store_ids);type(text)" json:"storeIDs"` + CityInfo []*Place `orm:"-" json:"cityInfo"` + Stores []*Store `orm:"-" json:"storeInfo"` } func (*Role) TableUnique() [][]string {