aa
This commit is contained in:
@@ -82,8 +82,34 @@ func UpdateMenu(ctx *jxcontext.Context, menuID int, payload map[string]interface
|
||||
return num, err
|
||||
}
|
||||
|
||||
func GetRole(ctx *jxcontext.Context) (roles []*model.Role, err error) {
|
||||
return dao.GetRole(dao.GetDB(), "", "")
|
||||
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) {
|
||||
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
|
||||
}
|
||||
}
|
||||
if v.StoreIDs != "" {
|
||||
if stores, err := dao.GetStoreList(db, jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")), nil, nil, nil, nil, ""); err == nil {
|
||||
getRoleResult.Stores = stores
|
||||
}
|
||||
}
|
||||
getRoleResults = append(getRoleResults, getRoleResult)
|
||||
}
|
||||
return getRoleResults, err
|
||||
}
|
||||
|
||||
func AddRole(ctx *jxcontext.Context, name string) (err error) {
|
||||
|
||||
@@ -85,3 +85,17 @@ func GetPlaceByJdsCode(db *DaoDB, jdsCode int) (place *model.Place, err error) {
|
||||
err = db.Db.Read(place, "JdsCode")
|
||||
return place, err
|
||||
}
|
||||
|
||||
func GetPlaces(db *DaoDB, cityCodes []int) (places []*model.Place, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM place
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if len(cityCodes) > 0 {
|
||||
sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
||||
sqlParams = append(sqlParams, cityCodes)
|
||||
}
|
||||
return places, err
|
||||
}
|
||||
|
||||
@@ -79,12 +79,13 @@ func (c *PowerController) AddRole() {
|
||||
// @Title 查询角色
|
||||
// @Description 查询角色
|
||||
// @Param token header string true "认证token"
|
||||
// @Param name query string false "角色名"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetRole [get]
|
||||
func (c *PowerController) GetRole() {
|
||||
c.callGetRole(func(params *tPowerGetRoleParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetRole(params.Ctx)
|
||||
retVal, err = cms.GetRole(params.Ctx, params.Name)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user