feat:完善项目信息
This commit is contained in:
@ -2,7 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller/menu"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -29,85 +30,11 @@ type (
|
||||
* @apiDefine Menu 菜单管理
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {get} /api/menu/list 菜单列表
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName MenuList
|
||||
* @apiGroup Menu
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Array} data 具体信息
|
||||
* @apiSuccess (200) {Number} data.id 菜单ID
|
||||
* @apiSuccess (200) {Number} data.parent_id 父级ID
|
||||
* @apiSuccess (200) {String} data.name 菜单名称
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:目录,2:菜单)
|
||||
* @apiSuccess (200) {String} data.link 访问地址
|
||||
* @apiSuccess (200) {String} data.component 组件
|
||||
* @apiSuccess (200) {Array} data.children="[]" 子集
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* "id": 1,
|
||||
* "parent_id": 0,
|
||||
* "name": "系统管理",
|
||||
* "kind": 1,
|
||||
* "link": "1"
|
||||
* "component": ""
|
||||
* "children": [
|
||||
* {
|
||||
* "id": 2,
|
||||
* "parent_id": 1,
|
||||
* "name": "用户管理",
|
||||
* "kind": 1,
|
||||
* "link": "1"
|
||||
* "component": ""
|
||||
* "children": [],
|
||||
* }
|
||||
* ]
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (a *Menu) List(c *gin.Context) {
|
||||
data, err := menu.NewInstance()(getSession()(c).(*service.Session)).List()
|
||||
APIResponse(err, data)(c)
|
||||
data, err := menu.NewInstance()(api.GetSession()(c).(*session.Admin)).List()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/menu/add 菜单添加
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName MenuAdd
|
||||
* @apiGroup Menu
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} parent_id 父级ID
|
||||
* @apiParam {String} name 菜单名
|
||||
* @apiParam {Number} kind 菜单类型(1:目录,2:菜单)
|
||||
* @apiParam {String} link 访问地址
|
||||
* @apiParam {String} component 页面组件
|
||||
* @apiParam {String} icon 页面icon
|
||||
* @apiParam {Number} auth 菜单权限(0:普通权限,1:超管权限)
|
||||
* @apiParam {Number} sort 排序,从大到小
|
||||
* @apiParam {Number} status 忘了干嘛,没用
|
||||
* @apiParam {String} remark 备注信息
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* }
|
||||
*/
|
||||
func (a *Menu) Add(c *gin.Context) {
|
||||
form := new(menuForm)
|
||||
|
||||
@ -115,43 +42,13 @@ func (a *Menu) Add(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
||||
err := menu.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&menu.InstanceParams{
|
||||
ParentID: form.ParentID, 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)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/menu/edit 菜单修改
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName MenuEdit
|
||||
* @apiGroup Menu
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
* @apiParam {Number} parent_id 父级ID
|
||||
* @apiParam {String} name 菜单名
|
||||
* @apiParam {Number} kind 菜单类型(1:目录,2:菜单)
|
||||
* @apiParam {String} link 访问地址
|
||||
* @apiParam {String} component 页面组件
|
||||
* @apiParam {String} icon 页面icon
|
||||
* @apiParam {Number} auth 菜单权限(0:普通权限,1:超管权限)
|
||||
* @apiParam {Number} sort 排序,从大到小
|
||||
* @apiParam {Number} status 禁用状态(1:启用,2:禁用)
|
||||
* @apiParam {String} remark 备注信息
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* }
|
||||
*/
|
||||
func (a *Menu) Edit(c *gin.Context) {
|
||||
form := &struct {
|
||||
idForm
|
||||
@ -161,35 +58,13 @@ func (a *Menu) Edit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Form(&menu.InstanceParams{
|
||||
err := menu.NewInstance()(api.GetSession()(c).(*session.Admin)).Form(&menu.InstanceParams{
|
||||
ID: form.ID, ParentID: form.ParentID, 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)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/menu/status 菜单状态
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName MenuStatus
|
||||
* @apiGroup Menu
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
* @apiParam {Number} status 状态(1:启动,2:禁用)
|
||||
*
|
||||
* @apiSuccess (200) {Number} code=200 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg="ok" 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *Menu) Status(c *gin.Context) {
|
||||
form := &struct {
|
||||
idForm
|
||||
@ -199,31 +74,10 @@ func (a *Menu) Status(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Status(form.ID, form.Status)
|
||||
err := menu.NewInstance()(api.GetSession()(c).(*session.Admin)).Status(form.ID, form.Status)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/menu/delete 删除菜单
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName MenuDelete
|
||||
* @apiGroup Menu
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Number} code=200 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg="ok" 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *Menu) Delete(c *gin.Context) {
|
||||
form := new(idForm)
|
||||
|
||||
@ -231,6 +85,6 @@ func (a *Menu) Delete(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := menu.NewInstance()(getSession()(c).(*service.Session)).Delete(form.ID)
|
||||
err := menu.NewInstance()(api.GetSession()(c).(*session.Admin)).Delete(form.ID)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
user2 "SciencesServer/app/api/admin/controller/user"
|
||||
"SciencesServer/app/api/admin/controller/user"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -25,7 +26,7 @@ type userForm struct {
|
||||
*/
|
||||
|
||||
func (a *User) Info(c *gin.Context) {
|
||||
data, err := user2.NewInstance()(getSession()(c).(*service.Session)).Info()
|
||||
data, err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Info()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -34,63 +35,18 @@ func (a *User) List(c *gin.Context) {
|
||||
Name string `json:"name" form:"name"`
|
||||
Mobile string `json:"mobile" form:"mobile"`
|
||||
Status int `json:"status" form:"status"`
|
||||
pageForm
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := user2.NewInstance()(getSession()(c).(*service.Session)).Index(form.Name, form.Mobile, form.Status, form.Page, form.PageSize)
|
||||
APIResponse(err, data)(c)
|
||||
data, err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Index(form.Name, form.Mobile, form.Status, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/user/menu 菜单信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserMenu
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Array} data 具体信息
|
||||
* @apiSuccess (200) {Number} data.id 菜单ID
|
||||
* @apiSuccess (200) {Number} data.parent_id 父级ID
|
||||
* @apiSuccess (200) {String} data.name 菜单名称
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:目录,2:菜单)
|
||||
* @apiSuccess (200) {String} data.link 访问地址
|
||||
* @apiSuccess (200) {String} data.component 组件
|
||||
* @apiSuccess (200) {Array} data.children="[]" 子集
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* "id": 1,
|
||||
* "parent_id": 0,
|
||||
* "name": "系统管理",
|
||||
* "kind": 1,
|
||||
* "link": "1"
|
||||
* "component": ""
|
||||
* "children": [
|
||||
* {
|
||||
* "id": 2,
|
||||
* "parent_id": 1,
|
||||
* "name": "用户管理",
|
||||
* "kind": 1,
|
||||
* "link": "1"
|
||||
* "component": ""
|
||||
* "children": [],
|
||||
* }
|
||||
* ]
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (a *User) Menu(c *gin.Context) {
|
||||
data, err := user2.NewMenu()(getSession()(c).(*service.Session)).List()
|
||||
data, err := user.NewMenu()(api.GetSession()(c).(*session.Admin)).List()
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -99,15 +55,15 @@ func (a *User) Add(c *gin.Context) {
|
||||
userForm
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewInstance()(getSession()(c).(*service.Session)).Add(&user2.InstanceForm{
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Add(&user.InstanceForm{
|
||||
Account: form.Account, Name: form.Name, Mobile: form.Mobile, Password: form.Password,
|
||||
Remark: form.Remark, Gender: form.Gender, Departments: form.Departments, Roles: form.Roles,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *User) Edit(c *gin.Context) {
|
||||
@ -119,36 +75,13 @@ func (a *User) Edit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewInstance()(getSession()(c).(*service.Session)).Edit(&user2.InstanceForm{
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Edit(&user.InstanceForm{
|
||||
ID: form.ID, Account: form.Account, Name: form.Name, Mobile: form.Mobile,
|
||||
Remark: form.Remark, Gender: form.Gender, Departments: form.Departments, Roles: form.Roles,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/user/password/quick 快速设置新密码
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordQuick
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
* @apiParam {String} password 登录密码
|
||||
* @apiParam {String} repeat_pwd 重复密码
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *User) Password(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
@ -159,34 +92,10 @@ func (a *User) Password(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewInstance()(getSession()(c).(*service.Session)).Password(form.Convert(), form.Password, form.RepeatPwd)
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Password(form.Convert(), form.Password, form.RepeatPwd)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/user/password/edit 修改新密码
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordEdit
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
* @apiParam {String} original_pwd 原始密码
|
||||
* @apiParam {String} password 登录密码
|
||||
* @apiParam {String} repeat_pwd 重复密码
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *User) PasswordEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
OldPwd string `json:"original_pwd" form:"original_pwd" binding:"required"`
|
||||
@ -197,31 +106,10 @@ func (a *User) PasswordEdit(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewPerson()(getSession()(c).(*service.Session)).EditPassword(form.OldPwd, form.Password, form.RepeatPwd)
|
||||
err := user.NewPerson()(getSession()(c).(*service.Session)).EditPassword(form.OldPwd, form.Password, form.RepeatPwd)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/user/delete 用户删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserDelete
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *User) Delete(c *gin.Context) {
|
||||
form := new(idForm)
|
||||
|
||||
@ -229,7 +117,7 @@ func (a *User) Delete(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewInstance()(getSession()(c).(*service.Session)).Delete(form.ID)
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Delete(form.ID)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
@ -241,7 +129,7 @@ func (a *User) Role(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := user2.NewRole()(getSession()(c).(*service.Session)).List(form.Convert())
|
||||
data, err := user.NewRole()(getSession()(c).(*service.Session)).List(form.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -254,6 +142,6 @@ func (a *User) RoleBind(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := user2.NewRole()(getSession()(c).(*service.Session)).Bind(form.Convert(), form.RoleIDs)
|
||||
err := user.NewRole()(getSession()(c).(*service.Session)).Bind(form.Convert(), form.RoleIDs)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user