feat:完善项目

This commit is contained in:
henry
2021-11-09 14:42:16 +08:00
parent d544b7f80c
commit be0ef1a1d0
5 changed files with 512 additions and 33 deletions

View File

@ -43,44 +43,52 @@ type (
*
* @apiParam {String} [parent_id="''"] 父集ID
* @apiParam {String} [title="''"] 名称
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Object} data.data 具体信息
* @apiSuccess (200) {String} data.data.id ID
* @apiSuccess (200) {String} data.data.code 装备编码
* @apiSuccess (200) {String} data.data.title 装备名称
* @apiSuccess (200) {String} data.data.image 装备图片
* @apiSuccess (200) {String} data.data.created_at 创建时间
* @apiSuccess (200) {Object} data.data.childrens 子集
* @apiSuccess (200) {Number} data.count 总数
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {String} data.code 装备编码
* @apiSuccess (200) {String} data.title 装备名称
* @apiSuccess (200) {String} data.image 装备图片
* @apiSuccess (200) {String} data.created_at 创建时间
* @apiSuccess (200) {Object} data.childrens 子集
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "EgmJ4Ga7LQ",
* "code": "S110",
* "title": "装甲车-11",
* "image": "http://192.168.31.195:8030/",
* "created_at": "2021-11-09T13:39:19+08:00",
* "children": []
* }
* ]
* "data": {
* "data": [
* {
* "id": "EgmJ4Ga7LQ",
* "code": "S110",
* "title": "装甲车-11",
* "image": "http://192.168.31.195:8030/",
* "created_at": "2021-11-09T13:39:19+08:00",
* "children": []
* }
* ],
* "count": 1
* }
* }
*/
func (*Manage) Equipment(c *gin.Context) {
form := &struct {
ParentID uint64 `json:"parent_id" form:"parent_id"`
Title string `json:"title" form:"title"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).List(form.ParentID, form.Title)
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).List(form.ParentID, form.Title, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
@ -94,8 +102,6 @@ func (*Manage) Equipment(c *gin.Context) {
*
* @apiParam {String} [id="''"] 区域标识
*
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {String} data.code 装备编码
@ -108,6 +114,8 @@ func (*Manage) Equipment(c *gin.Context) {
* @apiSuccess (200) {String} data.materials.title 器材名称
* @apiSuccess (200) {Number} data.materials.unit 器材单位
* @apiSuccess (200) {String} data.materials.manufacturer_name 器材制造商
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK

View File

@ -7,18 +7,74 @@ import (
"github.com/gin-gonic/gin"
)
/**
* @apiDefine Supplier 供应商管理
*/
type Supplier struct{}
type (
// supplierForm 参数信息
supplierForm struct {
Name string `json:"name" form:"name" binding:"required"`
Mobile string `json:"mobile" form:"mobile" binding:"required"`
Address string `json:"address" form:"address"`
Remark string `json:"remark" form:"remark"`
Name string `json:"name" form:"name" binding:"required"`
Contacts string `json:"contacts" form:"contacts" binding:"required"`
Mobile string `json:"mobile" form:"mobile" binding:"required"`
Address string `json:"address" form:"address"`
Remark string `json:"remark" form:"remark"`
}
)
/**
* @api {post} /api/v1/supplier/material 器材信息
* @apiVersion 1.0.0
* @apiName SupplierMaterial
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} [name="''"] 名称
* @apiParam {String} [mobile="''"] 联系方式
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Object} data.data 具体信息
* @apiSuccess (200) {String} data.data.id ID
* @apiSuccess (200) {String} data.data.kind 类型101制造商102材料合作商103维修合作商
* @apiSuccess (200) {String} data.data.name 名称
* @apiSuccess (200) {String} data.data.mobile 联系方式
* @apiSuccess (200) {String} data.data.contacts 联系人
* @apiSuccess (200) {String} data.data.address 联系地址
* @apiSuccess (200) {String} data.data.remark 备注信息
* @apiSuccess (200) {Time} data.data.created_at 创建时间
* @apiSuccess (200) {Time} data.data.updated_at 更新时间
* @apiSuccess (200) {Number} data.count 总数
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": {
* "data": [
* {
* "id": "EgmJ4Ga7LQ",
* "kind": 102,
* "name": "测试的",
* "mobile": "",
* "contacts": "",
* "address": "",
* "remark": "",
* "created_at": "2021-11-09T13:39:19+08:00",
* "updated_at": "2021-11-09T13:52:39+08:00"
* }
* ],
* "count": 1
* }
* }
*/
func (*Supplier) Material(c *gin.Context) {
form := &struct {
Name string `json:"name" form:"name"`
@ -31,9 +87,35 @@ func (*Supplier) Material(c *gin.Context) {
}
data, err := manage.NewSupplier()(getSession()(c).(*service.Session)).
List(form.Name, form.Mobile, model.ManageSupplierKindForMaterial, form.Page, form.PageSize)
APIResponse(err, data)
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/supplier/material/add 器材信息添加
* @apiVersion 1.0.0
* @apiName SupplierMaterialAdd
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) MaterialAdd(c *gin.Context) {
form := new(supplierForm)
@ -48,6 +130,33 @@ func (*Supplier) MaterialAdd(c *gin.Context) {
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/material/edit 器材信息修改
* @apiVersion 1.0.0
* @apiName SupplierMaterialEdit
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id ID
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) MaterialEdit(c *gin.Context) {
form := &struct {
IDStringForm
@ -64,6 +173,28 @@ func (*Supplier) MaterialEdit(c *gin.Context) {
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/material/delete 器材信息删除
* @apiVersion 1.0.0
* @apiName SupplierMaterialDelete
* @apiGroup Supplier
*
* @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 (*Supplier) MaterialDelete(c *gin.Context) {
form := new(IDStringForm)
@ -75,6 +206,57 @@ func (*Supplier) MaterialDelete(c *gin.Context) {
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/repair 修理厂信息
* @apiVersion 1.0.0
* @apiName SupplierRepair
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} [name="''"] 名称
* @apiParam {String} [mobile="''"] 联系方式
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Object} data.data 具体信息
* @apiSuccess (200) {String} data.data.id ID
* @apiSuccess (200) {String} data.data.kind 类型101制造商102材料合作商103维修合作商
* @apiSuccess (200) {String} data.data.name 名称
* @apiSuccess (200) {String} data.data.mobile 联系方式
* @apiSuccess (200) {String} data.data.contacts 联系人
* @apiSuccess (200) {String} data.data.address 联系地址
* @apiSuccess (200) {String} data.data.remark 备注信息
* @apiSuccess (200) {Time} data.data.created_at 创建时间
* @apiSuccess (200) {Time} data.data.updated_at 更新时间
* @apiSuccess (200) {Number} data.count 总数
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": {
* "data": [
* {
* "id": "EgmJ4Ga7LQ",
* "kind": 102,
* "name": "测试的",
* "mobile": "",
* "contacts": "",
* "address": "",
* "remark": "",
* "created_at": "2021-11-09T13:39:19+08:00",
* "updated_at": "2021-11-09T13:52:39+08:00"
* }
* ],
* "count": 1
* }
* }
*/
func (*Supplier) Repair(c *gin.Context) {
form := &struct {
Name string `json:"name" form:"name"`
@ -90,6 +272,32 @@ func (*Supplier) Repair(c *gin.Context) {
APIResponse(err, data)
}
/**
* @api {post} /api/v1/supplier/repair/add 修理厂信息添加
* @apiVersion 1.0.0
* @apiName SupplierRepairAdd
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) RepairAdd(c *gin.Context) {
form := new(supplierForm)
@ -104,6 +312,33 @@ func (*Supplier) RepairAdd(c *gin.Context) {
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/repair/edit 修理厂信息修改
* @apiVersion 1.0.0
* @apiName SupplierRepairEdit
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id ID
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) RepairEdit(c *gin.Context) {
form := &struct {
IDStringForm
@ -120,6 +355,33 @@ func (*Supplier) RepairEdit(c *gin.Context) {
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/repair/delete 修理厂信息删除
* @apiVersion 1.0.0
* @apiName SupplierRepairDelete
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id ID
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) RepairDelete(c *gin.Context) {
form := new(IDStringForm)
@ -130,3 +392,185 @@ func (*Supplier) RepairDelete(c *gin.Context) {
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/manufacturer 制造商信息
* @apiVersion 1.0.0
* @apiName SupplierManufacturer
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} [name="''"] 名称
* @apiParam {String} [mobile="''"] 联系方式
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Object} data.data 具体信息
* @apiSuccess (200) {String} data.data.id ID
* @apiSuccess (200) {String} data.data.kind 类型101制造商102材料合作商103维修合作商
* @apiSuccess (200) {String} data.data.name 名称
* @apiSuccess (200) {String} data.data.mobile 联系方式
* @apiSuccess (200) {String} data.data.contacts 联系人
* @apiSuccess (200) {String} data.data.address 联系地址
* @apiSuccess (200) {String} data.data.remark 备注信息
* @apiSuccess (200) {Time} data.data.created_at 创建时间
* @apiSuccess (200) {Time} data.data.updated_at 更新时间
* @apiSuccess (200) {Number} data.count 总数
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": {
* "data": [
* {
* "id": "EgmJ4Ga7LQ",
* "kind": 102,
* "name": "测试的",
* "mobile": "",
* "contacts": "",
* "address": "",
* "remark": "",
* "created_at": "2021-11-09T13:39:19+08:00",
* "updated_at": "2021-11-09T13:52:39+08:00"
* }
* ],
* "count": 1
* }
* }
*/
func (*Supplier) Manufacturer(c *gin.Context) {
form := &struct {
Name string `json:"name" form:"name"`
Mobile string `json:"mobile" form:"mobile"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := manage.NewSupplier()(getSession()(c).(*service.Session)).
List(form.Name, form.Mobile, model.ManageSupplierKindForManufacturer, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/supplier/manufacturer/add 制造商信息添加
* @apiVersion 1.0.0
* @apiName SupplierManufacturerAdd
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) ManufacturerAdd(c *gin.Context) {
form := new(supplierForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Form(&manage.SupplierParams{
Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
Kind: model.ManageSupplierKindForManufacturer,
})
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/manufacturer/edit 制造商信息修改
* @apiVersion 1.0.0
* @apiName SupplierManufacturerEdit
* @apiGroup Supplier
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id ID
* @apiParam {String} name 名称
* @apiParam {String} contacts 联系人
* @apiParam {String} mobile 联系方式
* @apiParam {String} [address="''"] 联系地址
* @apiParam {String} [remark="''"] 联系备注
*
* @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 (*Supplier) ManufacturerEdit(c *gin.Context) {
form := &struct {
IDStringForm
supplierForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Form(&manage.SupplierParams{
ID: form.Convert(), Name: form.Name, Mobile: form.Mobile, Address: form.Address, Remark: form.Remark,
Kind: model.ManageSupplierKindForManufacturer,
})
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/supplier/manufacturer/delete 制造商信息删除
* @apiVersion 1.0.0
* @apiName SupplierManufacturerDelete
* @apiGroup Supplier
*
* @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 (*Supplier) ManufacturerDelete(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := manage.NewSupplier()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}

View File

@ -77,14 +77,14 @@ func (c *Equipment) tree(iModel model2.IModel, src []*model2.ManageEquipment, pa
}
// List 列表信息
func (c *Equipment) List(parentID uint64, title string) ([]*EquipmentInfo, error) {
func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*basic.PageDataResponse, error) {
mManageEquipment := model.NewManageEquipment()
out := make([]*model2.ManageEquipment, 0)
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("parentID", parentID),
Where: model2.NewWhere("parent_id", parentID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
},
}
@ -93,11 +93,20 @@ func (c *Equipment) List(parentID uint64, title string) ([]*EquipmentInfo, error
Where: model2.NewWhereLike("title", title),
})
}
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
where...); err != nil {
//if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
// where...); err != nil {
// return nil, err
//}
var count int64
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
page, pageSize, &count, where...); err != nil {
return nil, err
}
return c.tree(mManageEquipment.ManageEquipment, out, 0), nil
return &basic.PageDataResponse{
Data: c.tree(mManageEquipment.ManageEquipment, out, 0),
Count: count,
}, nil
}
// Detail 详细信息

View File

@ -26,9 +26,9 @@ type (
}
// SupplierParams 参数信息
SupplierParams struct {
ID uint64
Name, Mobile, Address, Remark string
Kind model2.ManageSupplierKind
ID uint64
Name, Contacts, Mobile, Address, Remark string
Kind model2.ManageSupplierKind
}
)
@ -129,6 +129,7 @@ func (c *Supplier) Form(params *SupplierParams) error {
}
mManageSupplier.Name = params.Name
mManageSupplier.Mobile = params.Mobile
mManageSupplier.Contacts = params.Contacts
mManageSupplier.Address = params.Address
mManageSupplier.Remark = params.Remark

View File

@ -110,6 +110,23 @@ func (this *Router) registerAPI() {
roleV1.POST("/menus", _api.Menu)
roleV1.POST("/menu/bind", _api.MenuBind)
}
// Supplier 供应商管理
supplierV1 := v1.Group("/supplier")
{
_api := new(api.Supplier)
supplierV1.POST("/material", _api.Material)
supplierV1.POST("/material/add", _api.MaterialAdd)
supplierV1.POST("/material/edit", _api.MaterialEdit)
supplierV1.POST("/material/delete", _api.MaterialDelete)
supplierV1.POST("/repair", _api.Repair)
supplierV1.POST("/repair/add", _api.RepairAdd)
supplierV1.POST("/repair/edit", _api.RepairEdit)
supplierV1.POST("/repair/delete", _api.RepairDelete)
supplierV1.POST("/manufacturer", _api.Manufacturer)
supplierV1.POST("/manufacturer/add", _api.MaterialAdd)
supplierV1.POST("/manufacturer/edit", _api.MaterialEdit)
supplierV1.POST("/manufacturer/delete", _api.MaterialDelete)
}
// Manage 数据管理
manageV1 := v1.Group("/manage")
{