aa
This commit is contained in:
@@ -2,8 +2,11 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -105,10 +108,18 @@ func AddRole(ctx *jxcontext.Context, name string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateRole(ctx *jxcontext.Context, roleID int, name string, isDelete bool) (num int64, err error) {
|
||||
func UpdateRole(ctx *jxcontext.Context, roleID int, name string, isDelete bool, brandID int, cityCodes, storeIDs []int) (num int64, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
db = dao.GetDB()
|
||||
cityCodesStr []string
|
||||
storeIDsStr []string
|
||||
)
|
||||
for _, v := range cityCodes {
|
||||
cityCodesStr = append(cityCodesStr, utils.Int2Str(v))
|
||||
}
|
||||
for _, v := range storeIDs {
|
||||
storeIDsStr = append(storeIDsStr, utils.Int2Str(v))
|
||||
}
|
||||
if roleID == 1 {
|
||||
return 0, fmt.Errorf("管理员不允许修改!")
|
||||
}
|
||||
@@ -129,7 +140,10 @@ func UpdateRole(ctx *jxcontext.Context, roleID int, name string, isDelete bool)
|
||||
role.Name = name
|
||||
role.UpdatedAt = time.Now()
|
||||
role.LastOperator = ctx.GetUserName()
|
||||
num, err = dao.UpdateEntity(db, role, "Name", "UpdatedAt", "LastOperator")
|
||||
role.BrandID = brandID
|
||||
role.CityCodes = strings.Join(cityCodesStr, ",")
|
||||
role.StoreIDs = strings.Join(storeIDsStr, ",")
|
||||
num, err = dao.UpdateEntity(db, role, "Name", "UpdatedAt", "LastOperator", "BrandID", "CityCodes", "StoreIDs")
|
||||
} else {
|
||||
role.DeletedAt = time.Now()
|
||||
num, err = dao.UpdateEntity(db, role, "DeletedAt")
|
||||
|
||||
@@ -226,7 +226,10 @@ func (v *UserMember) TableIndex() [][]string {
|
||||
type Role struct {
|
||||
ModelIDCULD
|
||||
|
||||
Name string `json:"name"` //角色名
|
||||
Name string `json:"name"` //角色名
|
||||
BrandID int `orm:"column(brand_id)" json:"brandID"`
|
||||
CityCodes string `json:"cityCodes"`
|
||||
StoreIDs string `orm:"column(store_ids)" json:"storeIDs"`
|
||||
}
|
||||
|
||||
func (*Role) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user