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

@ -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)
}