feat(1.0):增加超管逻辑
This commit is contained in:
parent
86ab51f380
commit
a061e39dc7
@ -48,6 +48,15 @@ func (h *handler) CreateApp() core.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.SessionUserInfo().IsSuper != 1 {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.CreateAppError,
|
||||||
|
fmt.Sprintf("%s: %s", code.Text(code.CreateAppError), "禁止操作")),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
info, err := h.readDB.MiniProgram.WithContext(ctx.RequestContext()).
|
info, err := h.readDB.MiniProgram.WithContext(ctx.RequestContext()).
|
||||||
Where(h.readDB.MiniProgram.AppID.Eq(req.AppID)).
|
Where(h.readDB.MiniProgram.AppID.Eq(req.AppID)).
|
||||||
First()
|
First()
|
||||||
|
|||||||
@ -44,6 +44,15 @@ func (h *handler) DeleteApp() core.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.SessionUserInfo().IsSuper != 1 {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.CreateAppError,
|
||||||
|
fmt.Sprintf("%s: %s", code.Text(code.CreateAppError), "禁止操作")),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
idList := strings.Split(req.Ids, ",")
|
idList := strings.Split(req.Ids, ",")
|
||||||
if len(idList) == 0 || (len(idList) == 1 && idList[0] == "") {
|
if len(idList) == 0 || (len(idList) == 1 && idList[0] == "") {
|
||||||
ctx.AbortWithError(core.Error(
|
ctx.AbortWithError(core.Error(
|
||||||
|
|||||||
@ -83,6 +83,10 @@ func (h *handler) PageList() core.HandlerFunc {
|
|||||||
|
|
||||||
query := h.readDB.MiniProgram.WithContext(ctx.RequestContext())
|
query := h.readDB.MiniProgram.WithContext(ctx.RequestContext())
|
||||||
|
|
||||||
|
if ctx.SessionUserInfo().IsSuper != 1 {
|
||||||
|
query = query.Where(h.readDB.MiniProgram.AdminID.Eq(ctx.SessionUserInfo().Id))
|
||||||
|
}
|
||||||
|
|
||||||
if req.AppID != "" {
|
if req.AppID != "" {
|
||||||
query = query.Where(h.readDB.MiniProgram.AppID.Eq(req.AppID))
|
query = query.Where(h.readDB.MiniProgram.AppID.Eq(req.AppID))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,15 @@ func (h *handler) ModifyApp() core.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.SessionUserInfo().IsSuper != 1 {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.CreateAppError,
|
||||||
|
fmt.Sprintf("%s: %s", code.Text(code.CreateAppError), "禁止操作")),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if req.AppID == "" && req.Name == "" {
|
if req.AppID == "" && req.Name == "" {
|
||||||
ctx.AbortWithError(core.Error(
|
ctx.AbortWithError(core.Error(
|
||||||
http.StatusBadRequest,
|
http.StatusBadRequest,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ func newMiniProgram(db *gorm.DB, opts ...gen.DOOption) miniProgram {
|
|||||||
_miniProgram.ALL = field.NewAsterisk(tableName)
|
_miniProgram.ALL = field.NewAsterisk(tableName)
|
||||||
_miniProgram.ID = field.NewInt32(tableName, "id")
|
_miniProgram.ID = field.NewInt32(tableName, "id")
|
||||||
_miniProgram.AppID = field.NewString(tableName, "app_id")
|
_miniProgram.AppID = field.NewString(tableName, "app_id")
|
||||||
|
_miniProgram.AdminID = field.NewInt32(tableName, "admin_id")
|
||||||
_miniProgram.Name = field.NewString(tableName, "name")
|
_miniProgram.Name = field.NewString(tableName, "name")
|
||||||
_miniProgram.Description = field.NewString(tableName, "description")
|
_miniProgram.Description = field.NewString(tableName, "description")
|
||||||
_miniProgram.Avatar = field.NewString(tableName, "avatar")
|
_miniProgram.Avatar = field.NewString(tableName, "avatar")
|
||||||
@ -49,6 +50,7 @@ type miniProgram struct {
|
|||||||
ALL field.Asterisk
|
ALL field.Asterisk
|
||||||
ID field.Int32 // 主键ID
|
ID field.Int32 // 主键ID
|
||||||
AppID field.String // 小程序ID
|
AppID field.String // 小程序ID
|
||||||
|
AdminID field.Int32 // 管理员ID
|
||||||
Name field.String // 名称
|
Name field.String // 名称
|
||||||
Description field.String // 描述
|
Description field.String // 描述
|
||||||
Avatar field.String // 头像
|
Avatar field.String // 头像
|
||||||
@ -74,6 +76,7 @@ func (m *miniProgram) updateTableName(table string) *miniProgram {
|
|||||||
m.ALL = field.NewAsterisk(table)
|
m.ALL = field.NewAsterisk(table)
|
||||||
m.ID = field.NewInt32(table, "id")
|
m.ID = field.NewInt32(table, "id")
|
||||||
m.AppID = field.NewString(table, "app_id")
|
m.AppID = field.NewString(table, "app_id")
|
||||||
|
m.AdminID = field.NewInt32(table, "admin_id")
|
||||||
m.Name = field.NewString(table, "name")
|
m.Name = field.NewString(table, "name")
|
||||||
m.Description = field.NewString(table, "description")
|
m.Description = field.NewString(table, "description")
|
||||||
m.Avatar = field.NewString(table, "avatar")
|
m.Avatar = field.NewString(table, "avatar")
|
||||||
@ -97,9 +100,10 @@ func (m *miniProgram) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *miniProgram) fillFieldMap() {
|
func (m *miniProgram) fillFieldMap() {
|
||||||
m.fieldMap = make(map[string]field.Expr, 9)
|
m.fieldMap = make(map[string]field.Expr, 10)
|
||||||
m.fieldMap["id"] = m.ID
|
m.fieldMap["id"] = m.ID
|
||||||
m.fieldMap["app_id"] = m.AppID
|
m.fieldMap["app_id"] = m.AppID
|
||||||
|
m.fieldMap["admin_id"] = m.AdminID
|
||||||
m.fieldMap["name"] = m.Name
|
m.fieldMap["name"] = m.Name
|
||||||
m.fieldMap["description"] = m.Description
|
m.fieldMap["description"] = m.Description
|
||||||
m.fieldMap["avatar"] = m.Avatar
|
m.fieldMap["avatar"] = m.Avatar
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const TableNameMiniProgram = "mini_program"
|
|||||||
type MiniProgram struct {
|
type MiniProgram struct {
|
||||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键ID" json:"id"` // 主键ID
|
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键ID" json:"id"` // 主键ID
|
||||||
AppID string `gorm:"column:app_id;not null;comment:小程序ID" json:"app_id"` // 小程序ID
|
AppID string `gorm:"column:app_id;not null;comment:小程序ID" json:"app_id"` // 小程序ID
|
||||||
|
AdminID int32 `gorm:"column:admin_id;not null;comment:管理员ID" json:"admin_id"` // 管理员ID
|
||||||
Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称
|
Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称
|
||||||
Description string `gorm:"column:description;not null;comment:描述" json:"description"` // 描述
|
Description string `gorm:"column:description;not null;comment:描述" json:"description"` // 描述
|
||||||
Avatar string `gorm:"column:avatar;not null;comment:头像" json:"avatar"` // 头像
|
Avatar string `gorm:"column:avatar;not null;comment:头像" json:"avatar"` // 头像
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user