feat:完善项目
This commit is contained in:
@ -27,6 +27,11 @@ type (
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
Unit int `json:"unit" form:"Unit" binding:"required"`
|
||||
}
|
||||
// manageNoticeForm 公告参数信息
|
||||
manageNoticeForm struct {
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
@ -444,20 +449,59 @@ func (*Manage) MaterialSupplierDelete(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Manage) Notice(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
PageForm
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewNotice()(getSession()(c).(*service.Session)).List(form.Page, form.PageSize)
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) NoticeDetail(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewNotice()(getSession()(c).(*service.Session)).Detail(form.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) NoticeAdd(c *gin.Context) {
|
||||
form := new(manageNoticeForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := manage.NewNotice()(getSession()(c).(*service.Session)).Form(0, form.Title, form.Content)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Manage) NoticeEdit(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
manageNoticeForm
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := manage.NewNotice()(getSession()(c).(*service.Session)).Form(form.Convert(), form.Title, form.Content)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Manage) NoticeDelete(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := manage.NewNotice()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package api
|
||||
import (
|
||||
"ArmedPolice/app/controller/menu"
|
||||
"ArmedPolice/app/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -25,6 +24,12 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (this *menuForm) parentInfo() uint64 {
|
||||
obj := new(IDStringForm)
|
||||
obj.ID = this.ParentID
|
||||
return obj.Convert()
|
||||
}
|
||||
|
||||
/**
|
||||
* @apiDefine Menu 菜单管理
|
||||
*/
|
||||
@ -115,10 +120,8 @@ func (a *Menu) Add(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := new(IDStringForm)
|
||||
obj.ID = form.ParentID
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
||||
ParentID: obj.Convert(), Name: form.Name, Kind: form.Kind, Link: form.Link, Component: form.Component,
|
||||
ParentID: form.parentInfo(), Name: form.Name, Kind: form.Kind, Link: form.Link, Component: form.Component,
|
||||
Icon: form.Icon, Auth: form.Auth, Sort: form.Sort, Status: form.Status, Remark: form.Remark,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
@ -163,10 +166,8 @@ func (a *Menu) Edit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := new(IDStringForm)
|
||||
obj.ID = form.ParentID
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
||||
ID: form.Convert(), ParentID: obj.Convert(), Name: form.Name, Kind: form.Kind, Link: form.Link, Component: form.Component,
|
||||
ID: form.Convert(), ParentID: form.parentInfo(), Name: form.Name, Kind: form.Kind, Link: form.Link, Component: form.Component,
|
||||
Icon: form.Icon, Auth: form.Auth, Sort: form.Sort, Status: form.Status, Remark: form.Remark,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
|
@ -26,6 +26,28 @@ type userForm struct {
|
||||
RoleIDs []string `json:"role_ids" form:"role_ids"`
|
||||
}
|
||||
|
||||
func (this *userForm) avatarInfo() string {
|
||||
obj := &ImageForm{Image: this.Avatar}
|
||||
return obj.FilterImageURL()
|
||||
}
|
||||
|
||||
func (this *userForm) tenantInfo() uint64 {
|
||||
obj := &IDStringForm{ID: this.TenantID}
|
||||
return obj.Convert()
|
||||
}
|
||||
|
||||
// roleInfo 角色信息
|
||||
func (this *userForm) roleInfo() []uint64 {
|
||||
obj := new(IDStringForm)
|
||||
roleIDs := make([]uint64, 0)
|
||||
|
||||
for _, v := range this.RoleIDs {
|
||||
obj.ID = v
|
||||
roleIDs = append(roleIDs, obj.Convert())
|
||||
}
|
||||
return roleIDs
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/info 用户信息
|
||||
* @apiVersion 1.0.0
|
||||
@ -152,7 +174,7 @@ func (*User) Detail(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/add 用户信息添加
|
||||
* @api {post} /api/v1/user/add 用户信息添加
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserAdd
|
||||
* @apiGroup User
|
||||
@ -191,18 +213,16 @@ func (*User) Add(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &ImageForm{Image: form.Avatar}
|
||||
IDObj := &IDStringForm{ID: form.TenantID}
|
||||
|
||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
||||
TenantID: IDObj.Convert(), Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(),
|
||||
TenantID: form.tenantInfo(), Account: form.Account, Name: form.Name, Avatar: form.avatarInfo(),
|
||||
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||
RoleIDs: form.roleInfo(),
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/edit 用户信息修改
|
||||
* @api {post} /api/v1/user/edit 用户信息修改
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserEdit
|
||||
* @apiGroup User
|
||||
@ -244,18 +264,16 @@ func (*User) Edit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &ImageForm{Image: form.Avatar}
|
||||
IDObj := &IDStringForm{ID: form.TenantID}
|
||||
|
||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
||||
ID: form.Convert(), TenantID: IDObj.Convert(), Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(),
|
||||
ID: form.Convert(), TenantID: form.tenantInfo(), Account: form.Account, Name: form.Name, Avatar: form.avatarInfo(),
|
||||
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||
RoleIDs: form.roleInfo(),
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/delete 用户信息删除
|
||||
* @api {post} /api/v1/user/delete 用户信息删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserDelete
|
||||
* @apiGroup User
|
||||
@ -288,7 +306,7 @@ func (*User) Delete(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/password/quick 用户密码快速设置
|
||||
* @api {post} /api/v1/user/password/quick 用户密码快速设置
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordQuick
|
||||
* @apiGroup User
|
||||
@ -324,7 +342,7 @@ func (*User) PasswordQuick(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/password/tradition 用户密码传统设置
|
||||
* @api {post} /api/v1/user/password/tradition 用户密码传统设置
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordTradition
|
||||
* @apiGroup User
|
||||
@ -365,7 +383,7 @@ func (*User) PasswordTradition(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/password/activate 用户账号激活
|
||||
* @api {post} /api/v1/user/activate 用户账号激活
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordActivate
|
||||
* @apiGroup User
|
||||
@ -398,7 +416,7 @@ func (*User) Activate(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/password/frozen 用户账号冻结
|
||||
* @api {post} /api/v1/user/frozen 用户账号冻结
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordFrozen
|
||||
* @apiGroup User
|
||||
@ -481,7 +499,7 @@ func (a *User) Role(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/role/bind 用户角色绑定
|
||||
* @api {post} /api/v1/user/role/bind 用户角色绑定
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserRoleBind
|
||||
* @apiGroup User
|
||||
|
Reference in New Issue
Block a user