feat:完善项目
This commit is contained in:
@ -14,13 +14,16 @@ import (
|
||||
type User struct{}
|
||||
|
||||
type userForm struct {
|
||||
Account string `json:"account" form:"account" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Avatar string `json:"avatar" form:"avatar"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Password string `json:"password" form:"password"`
|
||||
Gender int `json:"gender" form:"gender"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
TenantID string `json:"tenant_id" form:"tenant_id"`
|
||||
Account string `json:"account" form:"account" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Avatar string `json:"avatar" form:"avatar"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Password string `json:"password" form:"password"`
|
||||
Gender int `json:"gender" form:"gender" binding:"required"`
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
RoleIDs []string `json:"role_ids" form:"role_ids"`
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,6 +141,16 @@ func (*User) List(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*User) Detail(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := user.NewInstance()(getSession()(c).(*service.Session)).Detail(form.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/add 用户信息添加
|
||||
* @apiVersion 1.0.0
|
||||
@ -146,13 +159,16 @@ func (*User) List(c *gin.Context) {
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} tenant_id 租户单位信息
|
||||
* @apiParam {String} account 登陆账号
|
||||
* @apiParam {String} name 姓名
|
||||
* @apiParam {String} [avatar="''"] 头像
|
||||
* @apiParam {String} mobile 手机号
|
||||
* @apiParam {String} password 密码
|
||||
* @apiParam {Number} gender 性别,1:男,2:女
|
||||
* @apiParam {Number} status 状态,1:启用,2:禁用
|
||||
* @apiParam {String} [remark="''"] 备注信息
|
||||
* @apiParam {String[]} [role_ids="[]"] 角色信息
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.name 用户名
|
||||
@ -176,10 +192,11 @@ func (*User) Add(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
obj := &ImageForm{Image: form.Avatar}
|
||||
IDObj := &IDStringForm{ID: form.TenantID}
|
||||
|
||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
||||
Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(), Mobile: form.Mobile,
|
||||
Password: form.Password, Remark: form.Remark, Gender: form.Gender,
|
||||
TenantID: IDObj.Convert(), Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(),
|
||||
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
@ -193,12 +210,15 @@ func (*User) Add(c *gin.Context) {
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
* @apiParam {String} tenant_id 租户单位信息
|
||||
* @apiParam {String} account 登陆账号
|
||||
* @apiParam {String} name 姓名
|
||||
* @apiParam {String} [avatar="''"] 头像
|
||||
* @apiParam {String} mobile 手机号
|
||||
* @apiParam {Number} gender 性别,1:男,2:女
|
||||
* @apiParam {Number} status 状态,1:启用,2:禁用
|
||||
* @apiParam {String} [remark="''"] 备注信息
|
||||
* @apiParam {String[]} [role_ids="[]"] 角色信息
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.name 用户名
|
||||
@ -225,10 +245,11 @@ func (*User) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
obj := &ImageForm{Image: form.Avatar}
|
||||
IDObj := &IDStringForm{ID: form.TenantID}
|
||||
|
||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Form(&user.InstanceParams{
|
||||
ID: form.Convert(), Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(),
|
||||
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender,
|
||||
ID: form.Convert(), TenantID: IDObj.Convert(), Account: form.Account, Name: form.Name, Avatar: obj.FilterImageURL(),
|
||||
Mobile: form.Mobile, Password: form.Password, Remark: form.Remark, Gender: form.Gender, Status: form.Status,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user