feat:完善项目
This commit is contained in:
@ -27,6 +27,11 @@ type (
|
|||||||
Remark string `json:"remark" form:"remark"`
|
Remark string `json:"remark" form:"remark"`
|
||||||
Unit int `json:"unit" form:"Unit" binding:"required"`
|
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) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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 (
|
import (
|
||||||
"ArmedPolice/app/controller/menu"
|
"ArmedPolice/app/controller/menu"
|
||||||
"ArmedPolice/app/service"
|
"ArmedPolice/app/service"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"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 菜单管理
|
* @apiDefine Menu 菜单管理
|
||||||
*/
|
*/
|
||||||
@ -115,10 +120,8 @@ func (a *Menu) Add(c *gin.Context) {
|
|||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj := new(IDStringForm)
|
|
||||||
obj.ID = form.ParentID
|
|
||||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
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,
|
Icon: form.Icon, Auth: form.Auth, Sort: form.Sort, Status: form.Status, Remark: form.Remark,
|
||||||
})
|
})
|
||||||
APIResponse(err)(c)
|
APIResponse(err)(c)
|
||||||
@ -163,10 +166,8 @@ func (a *Menu) Edit(c *gin.Context) {
|
|||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj := new(IDStringForm)
|
|
||||||
obj.ID = form.ParentID
|
|
||||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
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,
|
Icon: form.Icon, Auth: form.Auth, Sort: form.Sort, Status: form.Status, Remark: form.Remark,
|
||||||
})
|
})
|
||||||
APIResponse(err)(c)
|
APIResponse(err)(c)
|
||||||
|
@ -26,6 +26,28 @@ type userForm struct {
|
|||||||
RoleIDs []string `json:"role_ids" form:"role_ids"`
|
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 用户信息
|
* @api {get} /api/v1/user/info 用户信息
|
||||||
* @apiVersion 1.0.0
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserAdd
|
* @apiName UserAdd
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
@ -191,18 +213,16 @@ func (*User) Add(c *gin.Context) {
|
|||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj := &ImageForm{Image: form.Avatar}
|
|
||||||
IDObj := &IDStringForm{ID: form.TenantID}
|
|
||||||
|
|
||||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
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,
|
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||||
|
RoleIDs: form.roleInfo(),
|
||||||
})
|
})
|
||||||
APIResponse(err)(c)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /api/v1/user/edit 用户信息修改
|
* @api {post} /api/v1/user/edit 用户信息修改
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserEdit
|
* @apiName UserEdit
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
@ -244,18 +264,16 @@ func (*User) Edit(c *gin.Context) {
|
|||||||
APIFailure(err.(error))(c)
|
APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj := &ImageForm{Image: form.Avatar}
|
|
||||||
IDObj := &IDStringForm{ID: form.TenantID}
|
|
||||||
|
|
||||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
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,
|
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||||
|
RoleIDs: form.roleInfo(),
|
||||||
})
|
})
|
||||||
APIResponse(err)(c)
|
APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /api/v1/user/delete 用户信息删除
|
* @api {post} /api/v1/user/delete 用户信息删除
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserDelete
|
* @apiName UserDelete
|
||||||
* @apiGroup User
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserPasswordQuick
|
* @apiName UserPasswordQuick
|
||||||
* @apiGroup User
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserPasswordTradition
|
* @apiName UserPasswordTradition
|
||||||
* @apiGroup User
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserPasswordActivate
|
* @apiName UserPasswordActivate
|
||||||
* @apiGroup User
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserPasswordFrozen
|
* @apiName UserPasswordFrozen
|
||||||
* @apiGroup User
|
* @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
|
* @apiVersion 1.0.0
|
||||||
* @apiName UserRoleBind
|
* @apiName UserRoleBind
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
|
@ -28,7 +28,7 @@ type Model struct {
|
|||||||
|
|
||||||
// ModelTenant
|
// ModelTenant
|
||||||
type ModelTenant struct {
|
type ModelTenant struct {
|
||||||
TenantID uint64 `gorm:"column:tenant_id;index:idx_sys_tenant_id;type:int(11);default:0;comment:租户ID" json:"-"`
|
TenantID uint64 `gorm:"column:tenant_id;index:idx_sys_tenant_id;type:int(11);default:0;comment:租户ID" json:"tenant_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModelDeleted
|
// ModelDeleted
|
||||||
|
@ -39,7 +39,7 @@ type SysUserStatus int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// SysUserStatusForNormal 正常
|
// SysUserStatusForNormal 正常
|
||||||
SysUserStatusForNormal SysUserStatus = 1
|
SysUserStatusForNormal SysUserStatus = iota + 1
|
||||||
// SysUserStatusForDisable 禁止登陆
|
// SysUserStatusForDisable 禁止登陆
|
||||||
SysUserStatusForDisable
|
SysUserStatusForDisable
|
||||||
)
|
)
|
||||||
|
@ -79,8 +79,10 @@ func (c *InstanceParams) roleHandle(tx *gorm.DB, uid uint64) error {
|
|||||||
})
|
})
|
||||||
mark[v] = v
|
mark[v] = v
|
||||||
}
|
}
|
||||||
if err = model2.Creates(mSysUserRole.SysUserRole, roles, tx); err != nil {
|
if len(roles) > 0 {
|
||||||
return err
|
if err = model2.Creates(mSysUserRole.SysUserRole, roles, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,10 @@ func (c *Role) Bind(id uint64, roleIDs []uint64) error {
|
|||||||
})
|
})
|
||||||
mark[v] = v
|
mark[v] = v
|
||||||
}
|
}
|
||||||
if err = model2.Creates(mSysUserRole.SysUserRole, roles, tx); err != nil {
|
if len(roles) > 0 {
|
||||||
return err
|
if err = model2.Creates(mSysUserRole.SysUserRole, roles, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -44,11 +44,12 @@ func (m *SysUser) GetByAccountOrMobile(param string) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Users 用户信息
|
||||||
func (m *SysUser) Users(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysUserInfo, error) {
|
func (m *SysUser) Users(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*SysUserInfo, error) {
|
||||||
mSysTenant := model.NewSysTenant()
|
mSysTenant := model.NewSysTenant()
|
||||||
|
|
||||||
db := orm.GetDB().Table(m.TableName()+" As u").Select("u.id", "u.uuid", "u.name", "u.avatar",
|
db := orm.GetDB().Table(m.TableName()+" As u").Select("u.id", "u.uuid", "account", "u.name", "u.avatar",
|
||||||
"u.mobile", "u.email", "u.status", "t.name AS tenant_name").
|
"u.mobile", "u.email", "u.status", "t.name AS tenant_name", "u.created_at").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON u.tenant_id = t.id", mSysTenant.TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON u.tenant_id = t.id", mSysTenant.TableName())).
|
||||||
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
Where("u.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func (this *Router) registerAPI() {
|
|||||||
userV1.POST("/password/tradition", _api.PasswordTradition)
|
userV1.POST("/password/tradition", _api.PasswordTradition)
|
||||||
userV1.POST("/activate", _api.Activate)
|
userV1.POST("/activate", _api.Activate)
|
||||||
userV1.POST("/frozen", _api.Frozen)
|
userV1.POST("/frozen", _api.Frozen)
|
||||||
userV1.POST("/role", _api.Role)
|
userV1.GET("/role", _api.Role)
|
||||||
userV1.POST("/role/bind", _api.RoleBind)
|
userV1.POST("/role/bind", _api.RoleBind)
|
||||||
}
|
}
|
||||||
// Menu 菜单管理
|
// Menu 菜单管理
|
||||||
|
Reference in New Issue
Block a user