feat:完善项目
This commit is contained in:
@ -19,11 +19,10 @@ type (
|
||||
}
|
||||
// manageMaterialForm 装备参数信息
|
||||
manageMaterialForm struct {
|
||||
ManufacturerID uint64 `json:"manufacturer_id" form:"manufacturer_id"`
|
||||
ManufacturerID string `json:"manufacturer_id" form:"manufacturer_id"`
|
||||
Code string `json:"code" form:"code" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
ImageForm
|
||||
Position string `json:"position" form:"position"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
Unit int `json:"unit" form:"Unit" binding:"required"`
|
||||
}
|
||||
@ -34,6 +33,11 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (this *manageMaterialForm) ManufacturerInfo() uint64 {
|
||||
obj := &IDStringForm{ID: this.ManufacturerID}
|
||||
return obj.Convert()
|
||||
}
|
||||
|
||||
/**
|
||||
* @apiDefine Manage 数据管理
|
||||
*/
|
||||
@ -85,7 +89,7 @@ type (
|
||||
*/
|
||||
func (*Manage) Equipment(c *gin.Context) {
|
||||
form := &struct {
|
||||
ParentID uint64 `json:"parent_id" form:"parent_id"`
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
Title string `json:"title" form:"title"`
|
||||
PageForm
|
||||
}{}
|
||||
@ -93,7 +97,8 @@ func (*Manage) Equipment(c *gin.Context) {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).List(form.ParentID, form.Title, form.Page, form.PageSize)
|
||||
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).
|
||||
List((&IDStringForm{ID: form.ParentID}).Convert(), form.Title, form.Page, form.PageSize)
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -194,6 +199,31 @@ func (*Manage) EquipmentDetail(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/equipment/add 装备信息添加
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageEquipmentAdd
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} code 器材编码
|
||||
* @apiParam {String} title 器材名称
|
||||
* @apiParam {String} image 器材图片
|
||||
* @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 (*Manage) EquipmentAdd(c *gin.Context) {
|
||||
form := new(manageEquipmentForm)
|
||||
|
||||
@ -208,6 +238,32 @@ func (*Manage) EquipmentAdd(c *gin.Context) {
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/equipment/edit 装备信息修改
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageEquipmentEdit
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
* @apiParam {String} code 器材编码
|
||||
* @apiParam {String} title 器材名称
|
||||
* @apiParam {String} image 器材图片
|
||||
* @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 (*Manage) EquipmentEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
@ -224,6 +280,28 @@ func (*Manage) EquipmentEdit(c *gin.Context) {
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/equipment/delete 装备信息删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageEquipmentDelete
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @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 (*Manage) EquipmentDelete(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
@ -235,20 +313,74 @@ func (*Manage) EquipmentDelete(c *gin.Context) {
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material 器材信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterial
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} [manufacturer_id="''"] 制造商ID
|
||||
* @apiParam {String} [supplier_id="''"] 供应商ID
|
||||
* @apiParam {String} [code="''"] 编码
|
||||
* @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.manufacturer_name 制造商名称
|
||||
* @apiSuccess (200) {String} data.data.supplier_name 供应商名称
|
||||
* @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 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": {
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "code": "S110",
|
||||
* "title": "装甲车-11",
|
||||
* "manufacturer_name": "制造商名称",
|
||||
* "supplier_name": "供应商名称",
|
||||
* "image": "http://192.168.31.195:8030/",
|
||||
* "created_at": "2021-11-09T13:39:19+08:00",
|
||||
* "children": []
|
||||
* }
|
||||
* ],
|
||||
* "count": 1
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
func (*Manage) Material(c *gin.Context) {
|
||||
form := &struct {
|
||||
ManufacturerID uint64 `json:"manufacturer_id" form:"manufacturer_id"`
|
||||
SupplierID uint64 `json:"supplier_id" form:"supplier_id"`
|
||||
ManufacturerID string `json:"manufacturer_id" form:"manufacturer_id"`
|
||||
SupplierID string `json:"supplier_id" form:"supplier_id"`
|
||||
Code string `json:"code" form:"code"`
|
||||
Title string `json:"title" form:"title"`
|
||||
PageForm
|
||||
}{}
|
||||
manufacturerID := (&IDStringForm{ID: form.ManufacturerID}).Convert()
|
||||
supplierID := (&IDStringForm{ID: form.SupplierID}).Convert()
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := manage.NewMaterial()(getSession()(c).(*service.Session)).
|
||||
List(form.ManufacturerID, form.SupplierID, form.Code, form.Title, form.Page, form.PageSize)
|
||||
List(manufacturerID, supplierID, form.Code, form.Title, form.Page, form.PageSize)
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -290,6 +422,33 @@ func (*Manage) MaterialSelect(c *gin.Context) {
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/add 器材信息添加
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialAdd
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} manufacturer_id 制造商ID
|
||||
* @apiParam {String} code 器材编码
|
||||
* @apiParam {String} title 器材名称
|
||||
* @apiParam {String} image 器材图片
|
||||
* @apiParam {Number} unit 单位
|
||||
* @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 (*Manage) MaterialAdd(c *gin.Context) {
|
||||
form := new(manageMaterialForm)
|
||||
|
||||
@ -298,12 +457,40 @@ func (*Manage) MaterialAdd(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Form(&manage.MaterialParams{
|
||||
ManufacturerID: form.ManufacturerID, Code: form.Code, Title: form.Title, Image: form.FilterImageURL(),
|
||||
Position: form.Position, Remark: form.Remark, Unit: form.Unit,
|
||||
ManufacturerID: form.ManufacturerInfo(), Code: form.Code, Title: form.Title, Image: form.FilterImageURL(),
|
||||
Remark: form.Remark, Unit: form.Unit,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/edit 器材信息修改
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialEdit
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
* @apiParam {String} manufacturer_id 制造商ID
|
||||
* @apiParam {String} code 器材编码
|
||||
* @apiParam {String} title 器材名称
|
||||
* @apiParam {String} image 器材图片
|
||||
* @apiParam {Number} unit 单位
|
||||
* @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 (*Manage) MaterialEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
@ -314,12 +501,34 @@ func (*Manage) MaterialEdit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Form(&manage.MaterialParams{
|
||||
ID: form.Convert(), ManufacturerID: form.ManufacturerID, Code: form.Code, Title: form.Title,
|
||||
Image: form.FilterImageURL(), Position: form.Position, Remark: form.Remark, Unit: form.Unit,
|
||||
ID: form.Convert(), ManufacturerID: form.ManufacturerInfo(), Code: form.Code, Title: form.Title,
|
||||
Image: form.FilterImageURL(), Remark: form.Remark, Unit: form.Unit,
|
||||
})
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/delete 器材信息删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialDelete
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @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 (*Manage) MaterialDelete(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
|
@ -15,7 +15,7 @@ type IDStringForm struct {
|
||||
}
|
||||
|
||||
func (this *IDStringForm) Convert() uint64 {
|
||||
if this.ID == "" {
|
||||
if this.ID == "" || this.ID == "0" {
|
||||
return 0
|
||||
}
|
||||
return uint64(utils.HASHIDDecode(this.ID))
|
||||
|
@ -28,7 +28,7 @@ type (
|
||||
// MaterialParams 基本参数
|
||||
MaterialParams struct {
|
||||
ID, ManufacturerID uint64
|
||||
Code, Title, Image, Position, Remark string
|
||||
Code, Title, Image, Remark string
|
||||
Unit int
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user