feat:完善项目
This commit is contained in:
@ -126,11 +126,30 @@ func (*Config) Breakdown(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Config) BreakdownAdd(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := config.NewBreakdown()(getSession()(c).(*service.Session)).Form(0, form.Title, form.Remark)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Config) BreakdownEdit(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := config.NewBreakdown()(getSession()(c).(*service.Session)).Form(form.Convert(), form.Title, form.Remark)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Config) BreakdownDelete(c *gin.Context) {
|
||||
|
@ -40,7 +40,7 @@ type (
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Array} data 具体信息
|
||||
* @apiSuccess (200) {Number} data.id 菜单ID
|
||||
* @apiSuccess (200) {String} data.id 菜单ID
|
||||
* @apiSuccess (200) {Number} data.parent_id 父级ID
|
||||
* @apiSuccess (200) {String} data.name 菜单名称
|
||||
* @apiSuccess (200) {Number} data.kind 类型(1:目录,2:菜单)
|
||||
@ -54,7 +54,7 @@ type (
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* "id": 1,
|
||||
* "id": "qeqwe",
|
||||
* "parent_id": 0,
|
||||
* "name": "系统管理",
|
||||
* "kind": 1,
|
||||
@ -62,7 +62,7 @@ type (
|
||||
* "component": ""
|
||||
* "children": [
|
||||
* {
|
||||
* "id": 2,
|
||||
* "id": "23123asqw",
|
||||
* "parent_id": 1,
|
||||
* "name": "用户管理",
|
||||
* "kind": 1,
|
||||
|
@ -105,6 +105,8 @@ func (a *Role) Delete(c *gin.Context) {
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {Number} role_id 角色ID
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Array} data 具体信息
|
||||
@ -144,13 +146,15 @@ func (a *Role) Delete(c *gin.Context) {
|
||||
*/
|
||||
func (a *Role) Menu(c *gin.Context) {
|
||||
form := &struct {
|
||||
RoleID uint64 `json:"role_id" form:"role_id" binding:"required"`
|
||||
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := role.NewMenu()(getSession()(c).(*service.Session)).List(form.RoleID)
|
||||
obj := new(IDStringForm)
|
||||
obj.ID = form.RoleID
|
||||
data, err := role.NewMenu()(getSession()(c).(*service.Session)).List(obj.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -178,21 +182,22 @@ func (a *Role) Menu(c *gin.Context) {
|
||||
*/
|
||||
func (a *Role) MenuBind(c *gin.Context) {
|
||||
form := &struct {
|
||||
RoleID uint64 `json:"role_id" form:"role_id" binding:"required"`
|
||||
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
||||
MenuIDs []string `json:"menu_ids" form:"menu_ids" binding:"required"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
menuIDs := make([]uint64, 0)
|
||||
|
||||
handle := new(IDStringForm)
|
||||
handle.ID = form.RoleID
|
||||
roleID := handle.Convert()
|
||||
menuIDs := make([]uint64, 0)
|
||||
|
||||
for _, v := range form.MenuIDs {
|
||||
handle.ID = v
|
||||
menuIDs = append(menuIDs, handle.Convert())
|
||||
}
|
||||
err := role.NewMenu()(getSession()(c).(*service.Session)).Bind(form.RoleID, menuIDs)
|
||||
err := role.NewMenu()(getSession()(c).(*service.Session)).Bind(roleID, menuIDs)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package api
|
||||
import (
|
||||
"ArmedPolice/app/handle"
|
||||
"ArmedPolice/app/service"
|
||||
"ArmedPolice/config"
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"net/http"
|
||||
@ -25,8 +27,18 @@ func (*Websocket) Ws(c *gin.Context) {
|
||||
APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
session := getSession()(c).(*service.Session)
|
||||
token := c.Query(config.APIRequestToken)
|
||||
|
||||
if token == "" {
|
||||
APIFailure(errors.New("Token异常"))(c)
|
||||
return
|
||||
}
|
||||
session := new(service.Session)
|
||||
|
||||
if session, err = service.NewAuthToken(token).Auth(); err != nil {
|
||||
APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
client := service.NewWebsocket(session.UIDToString(), conn)
|
||||
service.HubMessage.RegisterHandle(client)
|
||||
go client.Write()
|
||||
|
@ -12,6 +12,9 @@ import (
|
||||
|
||||
type Work struct{}
|
||||
|
||||
type workLaunchForm struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/work/list 工单信息
|
||||
* @apiVersion 1.0.0
|
||||
@ -76,7 +79,18 @@ func (*Work) ToDo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (*Work) Launch(c *gin.Context) {
|
||||
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
IsAssist int `json:"is_assist" form:"is_assist"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch()
|
||||
APIResponse(err)
|
||||
}
|
||||
|
||||
func (*Work) Examine(c *gin.Context) {
|
||||
|
Reference in New Issue
Block a user