From 863edee71c1e904c25a4173913c2d897b534482e Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 10 Nov 2021 15:09:31 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/supplier.go | 41 +++++++++++++++++++++ app/api/user.go | 64 +++++++++++++++++++++++++++++++++ app/api/work.go | 30 +++++++++++++--- app/controller/menu/instance.go | 12 ++++++- app/controller/user/instance.go | 17 +++++++++ router/router.go | 2 ++ 6 files changed, 161 insertions(+), 5 deletions(-) diff --git a/app/api/supplier.go b/app/api/supplier.go index 552f1e8..999ee4b 100644 --- a/app/api/supplier.go +++ b/app/api/supplier.go @@ -24,6 +24,47 @@ type ( } ) +/** +* @api {post} /api/v1/supplier/select 供应商Select +* @apiVersion 1.0.0 +* @apiName SupplierSelect +* @apiGroup Supplier +* +* @apiHeader {string} x-token token +* +* @apiParam {Number} kind 类型(101:制造商,102:材料合作商,103;维修合作商) +* +* @apiSuccess (200) {Object} data 数据信息 +* @apiSuccess (200) {String} data.id ID +* @apiSuccess (200) {String} data.name 名称 +* @apiSuccess (200) {Number} code 成功响应状态码! +* @apiSuccess (200) {String} msg 成功提示 +* +* @apiSuccessExample {json} Success response: +* HTTPS 200 OK +* { +* "code": 200 +* "msg": "ok" +* "data": [ +* { +* "id": "EgmJ4Ga7LQ", +* "name": "测试的", +* } +* ] +* } + */ +func (*Supplier) Select(c *gin.Context) { + form := &struct { + Kind int `json:"kind" form:"kind" binding:"required"` + }{} + if err := bind(form)(c); err != nil { + APIFailure(err.(error))(c) + return + } + data, err := manage.NewSupplier()(getSession()(c).(*service.Session)).Select(form.Kind) + APIResponse(err, data)(c) +} + /** * @api {post} /api/v1/supplier/material 器材信息 * @apiVersion 1.0.0 diff --git a/app/api/user.go b/app/api/user.go index cb1522b..b8ca9e9 100644 --- a/app/api/user.go +++ b/app/api/user.go @@ -53,6 +53,70 @@ func (*User) Info(c *gin.Context) { APIResponse(nil, data)(c) } +/** +* @api {get} /api/v1/user/select 用户Select信息 +* @apiVersion 1.0.0 +* @apiName UserSelect +* @apiGroup User +* +* @apiHeader {string} x-token token +* +* @apiSuccess (200) {Object} data 数据信息 +* @apiSuccess (200) {String} data.id ID-即uuid +* @apiSuccess (200) {String} data.name 用户名 +* @apiSuccess (200) {Number} code 成功响应状态码! +* @apiSuccess (200) {String} msg 成功提示 +* +* @apiSuccessExample {json} Success response: +* HTTPS 200 OK +* { +* "code": 200 +* "msg": "ok" +* "data": [ +* { +* "id": "2098151543063711744", +* "name": "超级管理员", +* } +* ] +* } + */ +func (*User) Select(c *gin.Context) { + data, err := user.NewInstance()(getSession()(c).(*service.Session)).Select() + APIResponse(err, data)(c) +} + +/** +* @api {get} /api/v1/user/menu 用户菜单信息 +* @apiVersion 1.0.0 +* @apiName UserMenu +* @apiGroup User +* +* @apiHeader {string} x-token token +* +* @apiSuccess (200) {Object} data 数据信息-参考菜单信息 +* @apiSuccess (200) {Number} code 成功响应状态码! +* @apiSuccess (200) {String} msg 成功提示 +* +* @apiSuccessExample {json} Success response: +* HTTPS 200 OK +* { +* "code": 200 +* "msg": "ok" +* "data": [ +* { +* "id": "7X2JlBVknr", +* "name": "装备维修", +* "kind": 1, +* "link": "", +* "component": "", +* "icon": "", +* "parent_id": "0", +* "checked": true, +* "checked": [], +* } +* ] +* } + */ func (*User) Menu(c *gin.Context) { data, err := user.NewMenu()(getSession()(c).(*service.Session)).Menu() APIResponse(err, data)(c) diff --git a/app/api/work.go b/app/api/work.go index e031f79..7c5eeba 100644 --- a/app/api/work.go +++ b/app/api/work.go @@ -270,6 +270,28 @@ func (*Work) Examine(c *gin.Context) { APIResponse(err) } +/** +* @api {post} /api/v1/work/delete 工单流程信息删除 +* @apiVersion 1.0.0 +* @apiName WorkDelete +* @apiGroup Work +* +* @apiHeader {string} x-token token +* +* @apiParam {String} id Id +* +* @apiSuccess (200) {Object} data 数据信息 +* @apiSuccess (200) {Number} code 成功响应状态码! +* @apiSuccess (200) {String} msg 成功提示 +* +* @apiSuccessExample {json} Success response: +* HTTPS 200 OK +* { +* "code": 200 +* "msg": "ok" +* "data": null +* } + */ func (*Work) Delete(c *gin.Context) { form := new(IDStringForm) @@ -337,9 +359,9 @@ func (*Work) Schedule(c *gin.Context) { } /** -* @api {get} /api/v1/work/schedule/edit 工单流程信息修改 +* @api {post} /api/v1/work/schedule/edit 工单流程信息修改 * @apiVersion 1.0.0 -* @apiName WorkSchedulEdit +* @apiName WorkScheduleEdit * @apiGroup Work * * @apiHeader {string} x-token token @@ -378,9 +400,9 @@ func (*Work) ScheduleEdit(c *gin.Context) { } /** -* @api {get} /api/v1/work/schedule/delete 工单流程信息删除 +* @api {post} /api/v1/work/schedule/delete 工单流程信息删除 * @apiVersion 1.0.0 -* @apiName WorkSchedulDelete +* @apiName WorkScheduleDelete * @apiGroup Work * * @apiHeader {string} x-token token diff --git a/app/controller/menu/instance.go b/app/controller/menu/instance.go index bc81ce4..6ed9210 100644 --- a/app/controller/menu/instance.go +++ b/app/controller/menu/instance.go @@ -24,6 +24,7 @@ type ( InstanceIdentityInfo struct { ID string `json:"id"` *model2.SysMenuBasic + ParentID string `json:"parent_id"` Checked bool `json:"checked"` Children []*InstanceIdentityInfo `json:"children"` } @@ -67,9 +68,18 @@ func TreeIdentity(iModel model2.IModel, src []*model.SysMenuScene, parentID uint for _, v := range src { if v.ParentID == parentID { iModel.SetID(v.ID) + id := iModel.GetEncodeID() + + _parentID := "0" + + if v.ParentID > 0 { + iModel.SetID(v.ParentID) + _parentID = iModel.GetEncodeID() + } out = append(out, &InstanceIdentityInfo{ - ID: iModel.GetEncodeID(), + ID: id, SysMenuBasic: v.SysMenuBasic, + ParentID: _parentID, Checked: v.SceneID > 0, Children: TreeIdentity(iModel, src, v.ID), }) diff --git a/app/controller/user/instance.go b/app/controller/user/instance.go index 8630ab3..16e25a1 100644 --- a/app/controller/user/instance.go +++ b/app/controller/user/instance.go @@ -30,6 +30,11 @@ type ( Account, Name, Avatar, Mobile, Password, Remark string Gender int } + // InstanceBasicInfo 基本信息 + InstanceBasicInfo struct { + UUID string `json:"id"` // 别名更改为ID + Name string `json:"name"` + } ) // Info 基本信息 @@ -37,6 +42,18 @@ func (c *Instance) Info() *InstanceBasic { return &InstanceBasic{Name: c.Name, Avatar: c.Avatar} } +// Select 筛选信息 +func (c *Instance) Select() ([]*InstanceBasicInfo, error) { + mSysUser := model.NewSysUser() + + out := make([]*InstanceBasicInfo, 0) + + if err := model2.ScanFields(mSysUser.SysUser, &out, []string{"uuid", "name"}); err != nil { + return nil, err + } + return out, nil +} + // List 列表信息 func (c *Instance) List(name, mobile string, tenantID uint64, page, pageSize int) (*basic.PageDataResponse, error) { mSysUser := model.NewSysUser() diff --git a/router/router.go b/router/router.go index d306489..231b4ea 100644 --- a/router/router.go +++ b/router/router.go @@ -86,6 +86,7 @@ func (this *Router) registerAPI() { { _api := new(api.User) userV1.GET("/info", _api.Info) + userV1.GET("/select", _api.Select) userV1.GET("/menu", _api.Menu) userV1.POST("/list", _api.List) userV1.POST("/add", _api.Add) @@ -123,6 +124,7 @@ func (this *Router) registerAPI() { supplierV1 := v1.Group("/supplier") { _api := new(api.Supplier) + supplierV1.POST("/select", _api.Select) supplierV1.POST("/material", _api.Material) supplierV1.POST("/material/add", _api.MaterialAdd) supplierV1.POST("/material/edit", _api.MaterialEdit)