717 lines
19 KiB
Go
717 lines
19 KiB
Go
package api
|
|
|
|
import (
|
|
"ArmedPolice/app/controller/manage"
|
|
"ArmedPolice/app/service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Manage struct{}
|
|
|
|
type (
|
|
// manageEquipmentForm 装备参数信息
|
|
manageEquipmentForm struct {
|
|
Code string `json:"code" form:"code" binding:"required"`
|
|
Title string `json:"title" form:"title" binding:"required"`
|
|
ImageForm
|
|
Config string `json:"config" form:"config"`
|
|
Remark string `json:"remark" form:"remark"`
|
|
}
|
|
// manageMaterialForm 装备参数信息
|
|
manageMaterialForm struct {
|
|
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
|
|
Remark string `json:"remark" form:"remark"`
|
|
Unit int `json:"unit" form:"Unit" binding:"required"`
|
|
}
|
|
// manageNoticeForm 公告参数信息
|
|
manageNoticeForm struct {
|
|
Title string `json:"title" form:"title" binding:"required"`
|
|
Content string `json:"content" form:"content" binding:"required"`
|
|
}
|
|
)
|
|
|
|
func (this *manageMaterialForm) ManufacturerInfo() uint64 {
|
|
obj := &IDStringForm{ID: this.ManufacturerID}
|
|
return obj.Convert()
|
|
}
|
|
|
|
/**
|
|
* @apiDefine Manage 数据管理
|
|
*/
|
|
|
|
/**
|
|
* @api {post} /api/v1/manage/equipment 装备信息
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageEquipment
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @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 成功提示
|
|
*
|
|
* @apiSuccessExample {json} Success response:
|
|
* HTTPS 200 OK
|
|
* {
|
|
* "code": 200
|
|
* "msg": "ok"
|
|
* "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 string `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((&IDStringForm{ID: form.ParentID}).Convert(), form.Title, form.Page, form.PageSize)
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {get} /api/v1/manage/equipment/select 装备Select信息
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageEquipmentSelect
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @apiSuccess (200) {Object} data 数据信息
|
|
* @apiSuccess (200) {String} data.id ID
|
|
* @apiSuccess (200) {String} data.code 装备编码
|
|
* @apiSuccess (200) {String} data.title 装备名称
|
|
* @apiSuccess (200) {Number} code 成功响应状态码!
|
|
* @apiSuccess (200) {String} msg 成功提示
|
|
*
|
|
* @apiSuccessExample {json} Success response:
|
|
* HTTPS 200 OK
|
|
* {
|
|
* "code": 200
|
|
* "msg": "ok"
|
|
* "data": [
|
|
* {
|
|
* "id": "EgmJ4Ga7LQ",
|
|
* "code": "S110",
|
|
* "title": "装甲车-11",
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
func (*Manage) EquipmentSelect(c *gin.Context) {
|
|
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).Select()
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {post} /api/v1/manage/equipment/detail 装备详细信息
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageEquipmentDetail
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @apiParam {String} id ID
|
|
*
|
|
* @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.materials 器材信息
|
|
* @apiSuccess (200) {String} data.materials.id 器材ID
|
|
* @apiSuccess (200) {String} data.materials.code 器材编码
|
|
* @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
|
|
* {
|
|
* "code": 200
|
|
* "msg": "ok"
|
|
* "data": [
|
|
* {
|
|
* "id": "EgmJ4Ga7LQ",
|
|
* "code": "S110",
|
|
* "title": "装甲车-11",
|
|
* "image": "http://192.168.31.195:8030/",
|
|
* "config": "",
|
|
* "remark": "",
|
|
* "created_at": "2021-11-09T13:39:19+08:00",
|
|
* "materials": [
|
|
* {
|
|
* "id": "EgmJ4Ga7LQ",
|
|
* "code": "S110",
|
|
* "title": "装甲车-11",
|
|
* "unit": 1,
|
|
* "manufacturer_name": "测试的"
|
|
* }
|
|
* ]
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
func (*Manage) EquipmentDetail(c *gin.Context) {
|
|
form := new(IDStringForm)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewEquipment()(getSession()(c).(*service.Session)).Detail(form.Convert())
|
|
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)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewEquipment()(getSession()(c).(*service.Session)).Form(&manage.EquipmentParams{
|
|
Code: form.Code, Title: form.Title, Image: form.FilterImageURL(), Config: form.Config,
|
|
Remark: form.Remark,
|
|
})
|
|
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
|
|
manageEquipmentForm
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewEquipment()(getSession()(c).(*service.Session)).Form(&manage.EquipmentParams{
|
|
ID: form.Convert(), Code: form.Code, Title: form.Title, Image: form.FilterImageURL(), Config: form.Config,
|
|
Remark: form.Remark,
|
|
})
|
|
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)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewEquipment()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
|
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 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(manufacturerID, supplierID, form.Code, form.Title, form.Page, form.PageSize)
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {get} /api/v1/manage/material/select 器材Select信息
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageMaterialSelect
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @apiSuccess (200) {Object} data 数据信息
|
|
* @apiSuccess (200) {String} data.id ID
|
|
* @apiSuccess (200) {String} data.code 装备编码
|
|
* @apiSuccess (200) {String} data.title 装备名称
|
|
* @apiSuccess (200) {Float} data.price 单价
|
|
* @apiSuccess (200) {String} data.manufacturer_name 制造商
|
|
* @apiSuccess (200) {Number} code 成功响应状态码!
|
|
* @apiSuccess (200) {String} msg 成功提示
|
|
*
|
|
* @apiSuccessExample {json} Success response:
|
|
* HTTPS 200 OK
|
|
* {
|
|
* "code": 200
|
|
* "msg": "ok"
|
|
* "data": [
|
|
* {
|
|
* "id": "EgmJ4Ga7LQ",
|
|
* "code": "S110",
|
|
* "title": "装甲车-11",
|
|
* "price": 8.88,
|
|
* "manufacturer_name": "供应商",
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
func (*Manage) MaterialSelect(c *gin.Context) {
|
|
data, err := manage.NewMaterial()(getSession()(c).(*service.Session)).Select()
|
|
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)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Form(&manage.MaterialParams{
|
|
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
|
|
manageMaterialForm
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Form(&manage.MaterialParams{
|
|
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)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
|
APIResponse(err)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {post} /api/v1/manage/material/supplier/select 器材供应商信息
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageMaterialSupplierSelect
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @apiParam {String} material_id 器材ID
|
|
*
|
|
* @apiSuccess (200) {Object} data 数据信息
|
|
* @apiSuccess (200) {String} data.id ID
|
|
* @apiSuccess (200) {String} data.supplier_name 供应商名称
|
|
* @apiSuccess (200) {Number} code 成功响应状态码!
|
|
* @apiSuccess (200) {String} msg 成功提示
|
|
*
|
|
* @apiSuccessExample {json} Success response:
|
|
* HTTPS 200 OK
|
|
* {
|
|
* "code": 200
|
|
* "msg": "ok"
|
|
* "data": [
|
|
* {
|
|
* "id": "EgmJ4Ga7LQ",
|
|
* "supplier_name": "供应商名称",
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
func (*Manage) MaterialSupplierSelect(c *gin.Context) {
|
|
form := &struct {
|
|
MaterialID string `json:"material_id" form:"material_id" binding:"required"`
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
obj := &IDStringForm{ID: form.MaterialID}
|
|
data, err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Select(obj.Convert())
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {post} /api/v1/manage/material/supplier/bind 器材供应商绑定
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageMaterialSupplierBind
|
|
* @apiGroup Manage
|
|
*
|
|
* @apiHeader {string} x-token token
|
|
*
|
|
* @apiParam {String} material_id 器材ID
|
|
* @apiParam {String} supplier_id 供应商ID
|
|
* @apiParam {Float} stock 库存数
|
|
*
|
|
* @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) MaterialSupplierBind(c *gin.Context) {
|
|
form := &struct {
|
|
MaterialID string `json:"material_id" form:"material_id" binding:"required"`
|
|
SupplierID string `json:"supplier_id" form:"supplier_id" binding:"required"`
|
|
Stock float64 `json:"stock" form:"stock"`
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
obj := &IDStringForm{ID: form.MaterialID}
|
|
materialID := obj.Convert()
|
|
obj.ID = form.SupplierID
|
|
supplierID := obj.Convert()
|
|
err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Form(materialID, supplierID, form.Stock)
|
|
APIResponse(err)(c)
|
|
}
|
|
|
|
/**
|
|
* @api {post} /api/v1/manage/material/supplier/delete 器材供应商删除
|
|
* @apiVersion 1.0.0
|
|
* @apiName ManageMaterialSupplierDelete
|
|
* @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) MaterialSupplierDelete(c *gin.Context) {
|
|
form := new(IDStringForm)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
|
APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) Notice(c *gin.Context) {
|
|
form := &struct {
|
|
PageForm
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewNotice()(getSession()(c).(*service.Session)).List(form.Page, form.PageSize)
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) NoticeDetail(c *gin.Context) {
|
|
form := new(IDStringForm)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := manage.NewNotice()(getSession()(c).(*service.Session)).Detail(form.Convert())
|
|
APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Manage) NoticeAdd(c *gin.Context) {
|
|
form := new(manageNoticeForm)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewNotice()(getSession()(c).(*service.Session)).Form(0, form.Title, form.Content)
|
|
APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) NoticeEdit(c *gin.Context) {
|
|
form := &struct {
|
|
IDStringForm
|
|
manageNoticeForm
|
|
}{}
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewNotice()(getSession()(c).(*service.Session)).Form(form.Convert(), form.Title, form.Content)
|
|
APIResponse(err)(c)
|
|
}
|
|
|
|
func (*Manage) NoticeDelete(c *gin.Context) {
|
|
form := new(IDStringForm)
|
|
|
|
if err := bind(form)(c); err != nil {
|
|
APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := manage.NewNotice()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
|
APIResponse(err)(c)
|
|
}
|