feat ✨ 接口管理模块添加列排序

This commit is contained in:
wenjianzhang committed 2021-05-24 16:30:21 +08:00
1 parent 7880151ef2
commit cc74686108
3 files changed
+11 -13

No files matched your search

-2
View File
@@ -19,8 +19,6 @@ func registerSysApiRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlew
{ {
r.GET("", api.GetSysApiList) r.GET("", api.GetSysApiList)
r.GET("/:id", api.GetSysApi) r.GET("/:id", api.GetSysApi)
//r.POST("", api.InsertSysApi)
r.PUT("/:id", api.UpdateSysApi) r.PUT("/:id", api.UpdateSysApi)
//r.DELETE("", api.DeleteSysApi)
} }
} }
+4 -3
View File
@@ -12,7 +12,6 @@ import (
type SysApiSearch struct { type SysApiSearch struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Name string `form:"name" search:"type:exact;column:name;table:sys_api" comment:"名称"`
Title string `form:"title" search:"type:exact;column:title;table:sys_api" comment:"标题"` Title string `form:"title" search:"type:exact;column:title;table:sys_api" comment:"标题"`
Path string `form:"path" search:"type:exact;column:path;table:sys_api" comment:"地址"` Path string `form:"path" search:"type:exact;column:path;table:sys_api" comment:"地址"`
Action string `form:"action" search:"type:exact;column:action;table:sys_api" comment:"类型"` Action string `form:"action" search:"type:exact;column:action;table:sys_api" comment:"类型"`
@@ -21,7 +20,9 @@ type SysApiSearch struct {
} }
type SysApiOrder struct { type SysApiOrder struct {
HandleOrder string `search:"type:order;column:handle;table:sys_api" form:"handle_order"` TitleOrder string `search:"type:order;column:title;table:sys_api" form:"title_order"`
PathOrder string `search:"type:order;column:path;table:sys_api" form:"path_order"`
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_api" form:"createdAt_order"`
} }
func (m *SysApiSearch) GetNeedSearch() interface{} { func (m *SysApiSearch) GetNeedSearch() interface{} {
@@ -105,4 +106,4 @@ func (s *SysApiById) Generate() dto.Control {
func (s *SysApiById) GenerateM() (common.ActiveRecord, error) { func (s *SysApiById) GenerateM() (common.ActiveRecord, error) {
return &models.SysApi{}, nil return &models.SysApi{}, nil
} }
+7 -8
View File
@@ -77,18 +77,17 @@ func (e *SysApi) CheckStorageSysApi(c *[]runtime.Router) error {
// UpdateSysApi 修改SysApi对象 // UpdateSysApi 修改SysApi对象
func (e *SysApi) UpdateSysApi(c *dto.SysApiControl, p *actions.DataPermission) error { func (e *SysApi) UpdateSysApi(c *dto.SysApiControl, p *actions.DataPermission) error {
var model = models.SysApi{} var model = models.SysApi{}
e.Orm.Scopes( db := e.Orm.Debug().First(&model, c.GetId())
actions.Permission(model.TableName(), p), if db.RowsAffected == 0 {
).First(&model, c.GetId()) return errors.New("无权更新该数据")
}
c.Generate(&model) c.Generate(&model)
db := e.Orm.Save(&model) db = e.Orm.Save(&model)
if err := db.Error; err != nil { if err := db.Error; err != nil {
e.Log.Errorf("Service UpdateSysApi error:%s", err) e.Log.Errorf("Service UpdateSysApi error:%s", err)
return err return err
} }
if db.RowsAffected == 0 {
return errors.New("无权更新该数据")
}
return nil return nil
} }
@@ -108,4 +107,4 @@ func (e *SysApi) RemoveSysApi(d *dto.SysApiById, p *actions.DataPermission) erro
return errors.New("无权删除该数据") return errors.New("无权删除该数据")
} }
return nil return nil
} }