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)
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package menu
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller"
|
||||
"SciencesServer/app/api/admin/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Instance 菜单管理
|
||||
type Instance struct{ *controller.Platform }
|
||||
type Instance struct{ *session.Admin }
|
||||
|
||||
type InstanceHandle func(session *service.Session) *Instance
|
||||
type InstanceHandle func(session *session.Admin) *Instance
|
||||
|
||||
type (
|
||||
// InstanceParams 菜单参数
|
||||
@ -107,7 +106,7 @@ func (c *Instance) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *service.Session) *Instance {
|
||||
return &Instance{Platform: &controller.Platform{Session: session}}
|
||||
return func(session *session.Admin) *Instance {
|
||||
return &Instance{Admin: session}
|
||||
}
|
||||
}
|
||||
|
@ -5,15 +5,16 @@ import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Instance struct{ *controller.Platform }
|
||||
type Instance struct{ *session.Admin }
|
||||
|
||||
type InstanceHandle func(session *service.Session) *Instance
|
||||
type InstanceHandle func(session *session.Admin) *Instance
|
||||
|
||||
type (
|
||||
// InstanceInfo 基本信息
|
||||
@ -27,6 +28,7 @@ type (
|
||||
// InstanceUserInfo 用户信息
|
||||
InstanceUserInfo struct {
|
||||
UID string `json:"uid"`
|
||||
Avatar string `json:"avatar"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Mobile string `json:"mobile"`
|
||||
@ -51,7 +53,8 @@ func (c *Instance) Info() (*InstanceUserInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &InstanceUserInfo{
|
||||
UID: mSysUser.UUIDString(), Name: mSysUser.Name, Email: mSysUser.Email, Mobile: mSysUser.Mobile,
|
||||
UID: mSysUser.UUIDString(), Avatar: mSysUser.Avatar, Name: mSysUser.Name,
|
||||
Email: mSysUser.Email, Mobile: mSysUser.Mobile,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -82,7 +85,7 @@ func (c *Instance) Index(name, mobile string, status, page, pageSize int) (*cont
|
||||
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mSysUser.SysUser, out, []string{"id", "uid", "account", "name", "mobile", "gender",
|
||||
if err := model2.PagesFields(mSysUser.SysUser, &out, []string{"id", "uuid", "account", "avatar", "name", "mobile", "gender",
|
||||
"is_admin", "created_at"}, page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -92,6 +95,7 @@ func (c *Instance) Index(name, mobile string, status, page, pageSize int) (*cont
|
||||
list = append(list, &InstanceInfo{ID: v.GetEncodeID(),
|
||||
InstanceUserInfo: InstanceUserInfo{
|
||||
UID: v.UUIDString(),
|
||||
Avatar: v.Avatar,
|
||||
Name: v.Name,
|
||||
Email: v.Email,
|
||||
Mobile: v.Mobile,
|
||||
@ -234,7 +238,7 @@ func (c *Instance) Delete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *service.Session) *Instance {
|
||||
return &Instance{Platform: &controller.Platform{Session: session}}
|
||||
return func(session *session.Admin) *Instance {
|
||||
return &Instance{Admin: session}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/controller"
|
||||
menu2 "SciencesServer/app/api/admin/controller/menu"
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
type Menu struct{ *controller.Platform }
|
||||
type Menu struct{ *session.Admin }
|
||||
|
||||
type MenuHandle func(session *service.Session) *Menu
|
||||
type MenuHandle func(session *session.Admin) *Menu
|
||||
|
||||
// List 菜单列表
|
||||
func (c *Menu) List() (interface{}, error) {
|
||||
@ -34,7 +33,7 @@ func (c *Menu) List() (interface{}, error) {
|
||||
}
|
||||
|
||||
func NewMenu() MenuHandle {
|
||||
return func(session *service.Session) *Menu {
|
||||
return &Menu{Platform: &controller.Platform{Session: session}}
|
||||
return func(session *session.Admin) *Menu {
|
||||
return &Menu{Admin: session}
|
||||
}
|
||||
}
|
||||
|
@ -83,28 +83,70 @@ func (c *Index) distribution(src []*model.DataAreaDistributionInfo) map[string]*
|
||||
out[v.Province] = &InstanceDistributionDetailInfo{
|
||||
Code: v.Province,
|
||||
Name: config2.MemoryForAreaInfo[config.DefaultChinaAreaCode][v.Province],
|
||||
Industry: nil,
|
||||
Industry: make(map[string]int, 0),
|
||||
Count: 1,
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
}
|
||||
goto NEXT
|
||||
goto NEXT1
|
||||
}
|
||||
out[v.Province].Count++
|
||||
NEXT:
|
||||
NEXT1:
|
||||
if v.City != "" {
|
||||
if _, has = out[v.Province].Children[v.City]; !has {
|
||||
out[v.Province].Children[v.City] = &InstanceDistributionDetailInfo{
|
||||
Code: v.City,
|
||||
Count: 1,
|
||||
Name: config2.MemoryForAreaInfo[v.Province][v.City],
|
||||
Industry: make(map[string]int, 0),
|
||||
Children: make(map[string]*InstanceDistributionDetailInfo, 0),
|
||||
}
|
||||
goto NEXT2
|
||||
}
|
||||
out[v.Province].Children[v.City].Count++
|
||||
} else {
|
||||
out[v.Province].Industry = industrys
|
||||
}
|
||||
NEXT2:
|
||||
if v.District != "" {
|
||||
if _, has = out[v.Province].Children[v.City].Children[v.District]; !has {
|
||||
out[v.Province].Children[v.City].Children[v.District] = &InstanceDistributionDetailInfo{
|
||||
Code: v.District,
|
||||
Count: 1,
|
||||
Name: config2.MemoryForAreaInfo[v.City][v.District],
|
||||
Industry: industrys,
|
||||
}
|
||||
continue
|
||||
}
|
||||
out[v.Province].Children[v.City].Count++
|
||||
out[v.Province].Children[v.City].Children[v.District].Count++
|
||||
} else {
|
||||
out[v.Province].Children[v.City].Industry = industrys
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (c *Index) filterIndustry(src *InstanceDistributionDetailInfo, out map[string]int) {
|
||||
if len(src.Children) > 0 {
|
||||
for _, v := range src.Children {
|
||||
for key, val := range v.Industry {
|
||||
if _, has := out[key]; !has {
|
||||
out[key] = val
|
||||
continue
|
||||
}
|
||||
out[key] += val
|
||||
}
|
||||
c.filterIndustry(v, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Index) filter(src map[string]*InstanceDistributionDetailInfo) {
|
||||
for _, v := range src {
|
||||
c.filterIndustry(v, v.Industry)
|
||||
c.filter(v.Children)
|
||||
}
|
||||
}
|
||||
|
||||
// static 数量统计
|
||||
func (c *Index) static() (*InstanceStaticInfo, error) {
|
||||
out := new(InstanceStaticInfo)
|
||||
@ -159,7 +201,10 @@ func (c *Index) DistributionExpert(province, city string) (map[string]*InstanceD
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
// DistributionLaboratory 实验室分布
|
||||
@ -170,7 +215,10 @@ func (c *Index) DistributionLaboratory(province, city string) (map[string]*Insta
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
// DistributionDemand 需求信息
|
||||
@ -181,7 +229,10 @@ func (c *Index) DistributionDemand(province, city string) (map[string]*InstanceD
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
// DistributionPatent 专利信息
|
||||
@ -192,18 +243,24 @@ func (c *Index) DistributionPatent(province, city string) (map[string]*InstanceD
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
// DistributionAchievement 技术成果信息
|
||||
func (c *Index) DistributionAchievement(province, city string) (map[string]*InstanceDistributionDetailInfo, error) {
|
||||
mSysPatent := model.NewSysPatent()
|
||||
out, err := mSysPatent.Distribution()
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
out, err := mTechnologyAchievement.Distribution()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.distribution(out), nil
|
||||
_out := c.distribution(out)
|
||||
c.filter(_out)
|
||||
|
||||
return _out, nil
|
||||
}
|
||||
|
||||
// Instance 首页信息
|
||||
|
@ -4,5 +4,6 @@ package model
|
||||
type DataAreaDistributionInfo struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
District string `json:"district"`
|
||||
Industry string `json:"industry"`
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ func (m *ManageLaboratory) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()).
|
||||
Select("province", "city", "GROUP_CONCAT(industry SEPARATOR '&') AS industry").
|
||||
Group("province").Group("city").
|
||||
Order("province "+model.OrderModeToAsc).Order("city "+model.OrderModeToAsc).
|
||||
Select("province", "city", "district", "GROUP_CONCAT(industry SEPARATOR '&') AS industry").
|
||||
Group("province").Group("city").Group("district").
|
||||
Order("province "+model.OrderModeToAsc).Order("city "+model.OrderModeToAsc).Order("district "+model.OrderModeToAsc).
|
||||
Where("examine_status = ?", model.ExamineStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
|
@ -71,7 +71,7 @@ func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(p_c.industry_detail SEPARATOR '&') AS industry").
|
||||
Select("e.province", "e.city", "e.district", "GROUP_CONCAT(p_c.industry_detail SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS p_c ON p.ipc_code = p_c.ipc AND p_c.is_deleted = %d",
|
||||
model.NewSysPatentClassify().TableName(), model.DeleteStatusForNot)).
|
||||
Joins(fmt.Sprintf("RIGHT JOIN %s AS u_p ON p.id = u_p.patent_id AND u_p.is_deleted = %d",
|
||||
@ -80,8 +80,9 @@ func (m *SysPatent) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Where("p.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province " + model.OrderModeToAsc).Order("e.city " + model.OrderModeToAsc).Scan(&out).Error
|
||||
Group("e.province").Group("e.city").Group("e.district").
|
||||
Order("e.province " + model.OrderModeToAsc).Order("e.city " + model.OrderModeToAsc).Order("e.district " + model.OrderModeToAsc).
|
||||
Scan(&out).Error
|
||||
return out, err
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,11 @@ func (m *TechnologyAchievement) Distribution() ([]*DataAreaDistributionInfo, err
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(a.industry SEPARATOR '&') AS industry").
|
||||
Select("e.province", "e.city", "e.district", "GROUP_CONCAT(a.industry SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON a.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).
|
||||
Group("e.province").Group("e.city").Group("e.district").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).Order("e.district "+model.OrderModeToAsc).
|
||||
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
||||
Where("a.shelf_status = ?", model.ShelfStatusForUp).
|
||||
Scan(&out).Error
|
||||
|
@ -15,11 +15,11 @@ func (m *TechnologyDemand) Distribution() ([]*DataAreaDistributionInfo, error) {
|
||||
out := make([]*DataAreaDistributionInfo, 0)
|
||||
|
||||
err := orm.GetDB().Table(m.TableName()+" AS d").
|
||||
Select("e.province", "e.city", "GROUP_CONCAT(d.industry SEPARATOR '&') AS industry").
|
||||
Select("e.province", "e.city", "e.district", "GROUP_CONCAT(d.industry SEPARATOR '&') AS industry").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_e ON d.uid = u_e.uid", model.NewUserExpert().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS e ON u_e.expert_id = e.id", model.NewManageExpert().TableName())).
|
||||
Group("e.province").Group("e.city").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).
|
||||
Group("e.province").Group("e.city").Group("e.district").
|
||||
Order("e.province "+model.OrderModeToAsc).Order("e.city "+model.OrderModeToAsc).Order("e.district "+model.OrderModeToAsc).
|
||||
Where("d.status = ?", model.TechnologyDemandStatusForAgree).
|
||||
Scan(&out).Error
|
||||
|
||||
|
@ -51,6 +51,6 @@ type PositionForm struct {
|
||||
}
|
||||
|
||||
type PageForm struct {
|
||||
Page int `json:"current" form:"current" binding:"required"`
|
||||
Page int `json:"page_num" form:"page_num" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
v1 := g.Group("/v1")
|
||||
|
||||
// 登录验证
|
||||
g.Use(NeedLogin(config.RedisKeyForAccountAdmin, session.NewAdmin(), AddSkipperURL([]string{
|
||||
v1.Use(NeedLogin(config.RedisKeyForAccountAdmin, session.NewAdmin(), AddSkipperURL([]string{
|
||||
apiPrefix + "/v1/captcha",
|
||||
apiPrefix + "/v1/account/login",
|
||||
apiPrefix + "/v1/account/logout",
|
||||
@ -240,14 +240,14 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
||||
apiPrefix := "/enterprise"
|
||||
g := app.Group(apiPrefix)
|
||||
|
||||
g.Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{
|
||||
v1 := g.Group("/v1")
|
||||
|
||||
v1.Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{
|
||||
apiPrefix + "/v1/account/login",
|
||||
apiPrefix + "/v1/account/register",
|
||||
apiPrefix + "/v1/account/authorize",
|
||||
}...)))
|
||||
|
||||
v1 := g.Group("/v1")
|
||||
|
||||
// Upload 上传管理
|
||||
v1.POST("/upload", new(api.Upload).Upload)
|
||||
// Config 配置管理
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@ -31,6 +32,7 @@ func NeedLogin(key string, session logic.ISession, skipperURL ...SkipperURL) gin
|
||||
return
|
||||
}
|
||||
token := c.GetHeader(config.APIRequestToken)
|
||||
fmt.Println(token)
|
||||
|
||||
if token == "" {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "Token异常"})
|
||||
@ -44,6 +46,7 @@ func NeedLogin(key string, session logic.ISession, skipperURL ...SkipperURL) gin
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
fmt.Println(utils.AnyToJSON(session))
|
||||
c.Set(config.TokenForSession, session)
|
||||
c.Next()
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package web
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@ -57,10 +56,9 @@ func WithFunction(function func(string) (bool, func(r *http.Request))) Option {
|
||||
}
|
||||
|
||||
func (this *Web) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
|
||||
fmt.Println(remoteUrl)
|
||||
//remoteUrl, _ := url.Parse("http://192.168.0.147:9000")
|
||||
fmt.Println(r.Host)
|
||||
fmt.Println(r.RequestURI)
|
||||
//fmt.Println(r.RequestURI)
|
||||
|
||||
if this.function != nil {
|
||||
pass, callback := this.function(r.Host)
|
||||
|
Reference in New Issue
Block a user