You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.4 KiB
96 lines
2.4 KiB
package setting
|
|
|
|
import (
|
|
"base/app/common"
|
|
"base/app/lib/bean"
|
|
"base/app/logic/manage/setting"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Manage struct {
|
|
}
|
|
|
|
type argsManageLists struct {
|
|
setting.ManageListsSearch
|
|
bean.Page
|
|
}
|
|
|
|
// Lists @Title 用户列表
|
|
func (u *Manage) Lists(c *gin.Context) {
|
|
args := argsManageLists{}
|
|
if err := c.ShouldBind(&args); err != nil {
|
|
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
|
|
return
|
|
}
|
|
lists, total := setting.ManageLogic.Lists(args.ManageListsSearch, args.Page)
|
|
bean.Response.ResultSuc(c, "操作成功", bean.ResultLists{
|
|
List: lists,
|
|
Total: total,
|
|
})
|
|
}
|
|
|
|
// Add @Title 添加用户
|
|
func (u *Manage) Add(c *gin.Context) {
|
|
args := setting.ManageAdd{}
|
|
if err := c.ShouldBind(&args); err != nil {
|
|
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
|
|
return
|
|
}
|
|
if err := setting.ManageLogic.Add(args); err != nil {
|
|
bean.Response.ResultFail(c, 10002, err.Error())
|
|
return
|
|
}
|
|
bean.Response.ResultSuc(c, "操作成功", nil)
|
|
}
|
|
|
|
// Edit @Title 编辑用户
|
|
func (u *Manage) Edit(c *gin.Context) {
|
|
args := setting.ManageEdit{}
|
|
if err := c.ShouldBind(&args); err != nil {
|
|
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
|
|
return
|
|
}
|
|
if err := setting.ManageLogic.Edit(args); err != nil {
|
|
bean.Response.ResultFail(c, 10002, err.Error())
|
|
return
|
|
}
|
|
bean.Response.ResultSuc(c, "操作成功", nil)
|
|
}
|
|
|
|
type argsManageEnabled struct {
|
|
ManageId uint `binding:"required" label:"用户"`
|
|
}
|
|
|
|
// Enabled @Title 启用
|
|
func (u *Manage) Enabled(c *gin.Context) {
|
|
args := argsManageEnabled{}
|
|
if err := c.ShouldBind(&args); err != nil {
|
|
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
|
|
return
|
|
}
|
|
if err := setting.ManageLogic.Enabled(args.ManageId); err != nil {
|
|
bean.Response.ResultFail(c, 10002, err.Error())
|
|
return
|
|
}
|
|
bean.Response.ResultSuc(c, "操作成功", nil)
|
|
}
|
|
|
|
// Disabled @Title 停用
|
|
func (u *Manage) Disabled(c *gin.Context) {
|
|
args := argsManageEnabled{}
|
|
if err := c.ShouldBind(&args); err != nil {
|
|
bean.Response.ResultFail(c, 10001, common.GetVerErr(err))
|
|
return
|
|
}
|
|
if err := setting.ManageLogic.Disabled(args.ManageId); err != nil {
|
|
bean.Response.ResultFail(c, 10002, err.Error())
|
|
return
|
|
}
|
|
bean.Response.ResultSuc(c, "操作成功", nil)
|
|
}
|
|
|
|
// Select @Title 用户筛选
|
|
func (u *Manage) Select(c *gin.Context) {
|
|
bean.Response.ResultSuc(c, "操作成功", setting.ManageLogic.Select())
|
|
}
|