Files
ArmedPolice/app/api/work.go
2021-11-19 11:53:20 +08:00

745 lines
24 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package api
import (
"ArmedPolice/app/controller/work"
"ArmedPolice/app/service"
"github.com/gin-gonic/gin"
)
/**
* @apiDefine Work 工单管理
*/
type Work struct{}
type (
// workLaunchForm 工单发起基本信息
workLaunchForm struct {
Kind int `json:"kind" form:"kind" binding:"required"` // 类型
Title string `json:"title" form:"title"`
EquipmentID string `json:"equipment_id" form:"equipment_id" binding:"required"` // 装备ID
Breakdowns []string `json:"breakdowns" form:"breakdowns"` // 故障类型
PlateNumber string `json:"plate_number" form:"plate_number"` // 车牌号
Priority int `json:"priority" form:"priority" binding:"required"` // 优先级
IsAssist int `json:"is_assist" form:"is_assist"` // 是否需要上级审批
Remark string `json:"remark" form:"remark"` // 备注信息
}
// workLaunchSupplierForm 供应商信息
workLaunchSupplierForm struct {
SupplierID string `json:"supplier_id" form:"supplier_id"`
}
// workLaunchMaterialForm 工单发起配件信息
workLaunchMaterialForm struct {
ID string `json:"id" form:"id"`
SupplierID string `json:"supplier_id" form:"supplier_id"`
Number float64 `json:"number" form:"number"`
}
// workLaunchPurchaseForm 工单发起配件信息
workLaunchPurchaseForm struct {
workLaunchMaterialForm
Price float64 `json:"price" form:"price"`
}
// workLaunchDistributionForm 工单发起地址信息
workLaunchDistributionForm struct {
Name string `json:"name" form:"name"` // 联系人
Mobile string `json:"mobile" form:"mobile"` // 联系方式
Address string `json:"address" form:"address"` // 联系地址
}
// scheduleForm 流程信息
scheduleForm struct {
Title string `json:"title" form:"title" binding:"required"`
Stage int `json:"stage" form:"stage"`
Step int `json:"step" form:"step"`
Target int `json:"target" form:"target" binding:"required"`
TargetValue []string `json:"target_value" form:"target_value" binding:"required"`
IsCountersign int `json:"is_countersign" form:"is_countersign"`
}
)
func (this *workLaunchForm) EquipmentInfo() uint64 {
return (&IDStringForm{ID: this.EquipmentID}).Convert()
}
func (this *workLaunchForm) BreakdownInfo() []uint64 {
out := make([]uint64, 0)
obj := new(IDStringForm)
for _, v := range this.Breakdowns {
obj.ID = v
out = append(out, obj.Convert())
}
return out
}
func (this *workLaunchSupplierForm) SupplierInfo() uint64 {
return (&IDStringForm{ID: this.SupplierID}).Convert()
}
func (this *workLaunchMaterialForm) IDInfo() uint64 {
return (&IDStringForm{ID: this.ID}).Convert()
}
func (this *workLaunchMaterialForm) SupplierInfo() uint64 {
return (&IDStringForm{ID: this.SupplierID}).Convert()
}
/**
* @api {post} /api/v1/work/list 工单信息
* @apiVersion 1.0.0
* @apiName WorkList
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} [equipment_code="''"] 装备编码
* @apiParam {String} [equipment_title="''"] 装备名称
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
* @apiSuccess (200) {String} data.schedule_title 流程名称
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
* @apiSuccess (200) {String} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
* "kind": 2,
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
* "schedule_title": "分管领导审批",
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
func (*Work) Instance(c *gin.Context) {
form := &struct {
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
Kind int `json:"kind" form:"kind"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).List(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/work/person 个人申请信息
* @apiVersion 1.0.0
* @apiName WorkPerson
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} [material_id=0] 装备ID
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
* @apiSuccess (200) {String} data.schedule_title 流程名称
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
* "kind": 2,
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
* "schedule_title": "分管领导审批",
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
func (*Work) Person(c *gin.Context) {
form := &struct {
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
Kind int `json:"kind" form:"kind"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Person(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/work/workbench 个人待办事项
* @apiVersion 1.0.0
* @apiName WorkWorkbench
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} [material_id=0] 装备ID
* @apiParam {String} [kind=0] 工单类型
* @apiParam {Number} current 当前页
* @apiParam {Number} page_size 页展示数
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
* @apiSuccess (200) {String} data.schedule_title 流程名称
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "id": "m9Qa2ZaOvE",
* "kind": 2,
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
* "schedule_title": "分管领导审批",
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* }
* ]
* }
*/
func (*Work) Workbench(c *gin.Context) {
form := &struct {
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
Kind int `json:"kind" form:"kind"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Workbench(form.EquipmentCode, form.EquipmentTitle, form.Kind, form.Page, form.PageSize)
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/work/detail 工单详情信息
* @apiVersion 1.0.0
* @apiName WorkDetail
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {String} id 工单ID
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {String} data.id ID
* @apiSuccess (200) {Number} data.kind 类型1外修2内修
* @apiSuccess (200) {String} data.title 标题名称
* @apiSuccess (200) {String} data.material_code 装备编码
* @apiSuccess (200) {String} data.material_title 装备名称
* @apiSuccess (200) {String} data.breakdown_title 故障信息
* @apiSuccess (200) {String} data.schedule_title 流程名称
* @apiSuccess (200) {Number} data.priority 紧急状态1普通2紧急3非常紧急
* @apiSuccess (200) {Number} data.status 状态0进行中1已完成
* @apiSuccess (200) {Time} data.created_at 创建时间
* @apiSuccess (200) {Object} data.distribution 配送信息
* @apiSuccess (200) {String} data.distribution.name 联系人
* @apiSuccess (200) {String} data.distribution.mobile 联系方式
* @apiSuccess (200) {String} data.distribution.address 联系地址
* @apiSuccess (200) {Object} data.materials 配件信息
* @apiSuccess (200) {Float} data.materials.material_number 所需数量
* @apiSuccess (200) {String} data.materials.material_code 配件编码
* @apiSuccess (200) {String} data.materials.material_title 配件名称
* @apiSuccess (200) {Float} data.materials.material_price 配件价格
* @apiSuccess (200) {String} data.materials.supplier_name 供应商名称
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": {
* "id": "m9Qa2ZaOvE",
* "kind": 2,
* "title": "刹车盘",
* "material_code": "装备编码",
* "material_title": "装备名称",
* "breakdown_title": "发动机,刹车盘",
* "schedule_title": "分管领导审批",
* "priority": 1,
* "status": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* "distribution": [
* "name": "",
* "mobile": "",
* "address": "",
* ],
* "materials": [
* {
* "material_number": 0,
* "material_code": "2222",
* "material_title": "qewqe",
* "material_price": 0,
* "supplier_name": "测试的"
* }
* ]
* }
* }
*/
func (*Work) Detail(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewInstance()(getSession()(c).(*service.Session)).Detail(form.Convert())
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/work/launch 工单发起
* @apiVersion 1.0.0
* @apiName WorkLaunch
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {Object} within 内修参数信息
* @apiParam {Object[]} within.material 配件信息
* @apiParam {String} within.material.id 配件ID
* @apiParam {String} within.material.supplier_id 供应商ID
* @apiParam {Float} within.material.number 配件数量
* @apiParam {Object[]} within.purchase 采购信息
* @apiParam {String} within.purchase.id 配件ID
* @apiParam {String} within.purchase.supplier_id 供应商ID
* @apiParam {Float} within.purchase.number 采购数量
* @apiParam {Float} within.purchase.Price 采购价格
* @apiParam {Object} outside 外修参数信息
* @apiParam {String} outside.supplier_id 配件ID
* @apiParam {Number} kind 工单类型
* @apiParam {String} [title="''"] 工单名称
* @apiParam {Number} equipment_id 装备名称
* @apiParam {String[]} breakdowns 故障类型
* @apiParam {String} plate_number 车牌号
* @apiParam {Number} priority 紧急状态1普通2紧急3非常紧急
* @apiParam {Number} [is_assist=0] 是否需要上级协助1
* @apiParam {String} [remark="''"] 备注信息
* @apiParam {Object} distribution 配送信息
* @apiParam {String} distribution.name 联系人
* @apiParam {String} distribution.mobile 联系方式
* @apiParam {String} distribution.address 联系地址
*
* @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) Launch(c *gin.Context) {
form := &struct {
workLaunchForm
Outside struct {
workLaunchSupplierForm
} `json:"outside" form:"outside"`
Within struct {
Material []*workLaunchMaterialForm `json:"material" form:"material"`
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
} `json:"within" form:"within"`
Distribution workLaunchDistributionForm `json:"distribution" form:"distribution"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
for _, v := range form.Within.Material {
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number,
})
}
purchase := make([]*work.InstanceLaunchParamsForPurchase, 0)
for _, v := range form.Within.Purchase {
purchase = append(purchase, &work.InstanceLaunchParamsForPurchase{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number, Price: v.Price,
})
}
err := work.NewInstance()(getSession()(c).(*service.Session)).Launch(&work.InstanceLaunchParams{
Kind: form.Kind, Title: form.Title, EquipmentID: form.EquipmentInfo(), Breakdowns: form.BreakdownInfo(),
PlateNumber: form.PlateNumber, Priority: form.Priority, IsAssist: form.IsAssist, Remark: form.Remark,
Supplier: &work.InstanceLaunchParamsForSupplier{SupplierID: form.Outside.SupplierInfo()},
Material: materials, Purchase: purchase,
Distribution: &work.InstanceLaunchParamsForDistribution{
Name: form.Distribution.Name, Mobile: form.Distribution.Mobile, Address: form.Distribution.Address,
},
})
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/work/examine 工单审核
* @apiVersion 1.0.0
* @apiName WorkExamine
* @apiGroup Work
*
* @apiHeader {string} x-token token
* @apiHeader {string} Content-Type=application/json 传输方式
*
* @apiParam {Object} within 内修参数信息
* @apiParam {Object[]} within.material 配件信息
* @apiParam {String} within.material.id 配件ID
* @apiParam {String} within.material.supplier_id 供应商ID
* @apiParam {Float} within.material.number 配件数量
* @apiParam {Object[]} within.purchase 采购信息
* @apiParam {String} within.purchase.id 配件ID
* @apiParam {String} within.purchase.supplier_id 供应商ID
* @apiParam {Float} within.purchase.number 采购数量
* @apiParam {Float} within.purchase.Price 采购价格
* @apiParam {String} id 工单ID
* @apiParam {String} status 审核状态
* @apiParam {String} remark 备注信息
* @apiParam {Number} [is_assist=0] 是否需要上级协助0不需要1需要
*
* @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) Examine(c *gin.Context) {
form := &struct {
IDStringForm
Status int `json:"status" form:"status" binding:"required"`
Remark string `json:"remark" form:"remark"`
IsAssist int `json:"is_assist" form:"is_assist"`
Within struct {
Material []*workLaunchMaterialForm `json:"material" form:"material"`
Purchase []*workLaunchPurchaseForm `json:"purchase" form:"purchase"`
} `json:"within" form:"within"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
materials := make([]*work.InstanceLaunchParamsForMaterial, 0)
for _, v := range form.Within.Material {
materials = append(materials, &work.InstanceLaunchParamsForMaterial{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number,
})
}
purchase := make([]*work.InstanceLaunchParamsForPurchase, 0)
for _, v := range form.Within.Purchase {
purchase = append(purchase, &work.InstanceLaunchParamsForPurchase{
ID: v.IDInfo(), SupplierID: v.SupplierInfo(), Number: v.Number, Price: v.Price,
})
}
err := work.NewInstance()(getSession()(c).(*service.Session)).Examine(form.Convert(), form.Status, form.Remark,
form.IsAssist, &work.InstanceExamineParams{Material: materials, Purchase: purchase})
APIResponse(err)(c)
}
/**
* @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)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewInstance()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}
/**
* @api {get} /api/v1/work/schedule 工单流程信息
* @apiVersion 1.0.0
* @apiName WorkSchedule
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiSuccess (200) {Object} data 数据信息
* @apiSuccess (200) {Number} data.kind 流程类型1维修工单
* @apiSuccess (200) {String} data.title 流程名称
* @apiSuccess (200) {Object} data.schedules 流程信息
* @apiSuccess (200) {String} data.schedules.id 流程详细ID
* @apiSuccess (200) {String} data.schedules.title 流程详细名称
* @apiSuccess (200) {Number} data.schedules.stage 阶段
* @apiSuccess (200) {Number} data.schedules.step 步骤
* @apiSuccess (200) {Number} data.schedules.target 触发对象1个人2角色
* @apiSuccess (200) {String} data.schedules.target_value 触发对象信息
* @apiSuccess (200) {String} data.schedules.target_value_title 触发对象具体信息
* @apiSuccess (200) {Number} data.schedules.is_countersign 是否会签01暂不需要此字段
* @apiSuccess (200) {Time} data.schedules.created_at 创建时间
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": [
* {
* "kind": "m9Qa2ZaOvE",
* "title": "刹车盘",
* "schedules": [
* {
* "id": "A9GVg5JZdr",
* "title": "发起工单",
* "stage": 1,
* "step": 2,
* "target": 2,
* "target_value": "9",
* "target_value_title": "区域修理队",
* "is_countersign": 0,
* "created_at": "2021-11-05T14:24:07+08:00",
* ]
* }
* }
* ]
* }
*/
func (*Work) Schedule(c *gin.Context) {
data, err := work.NewSchedule()(getSession()(c).(*service.Session)).List()
APIResponse(err, data)(c)
}
/**
* @api {post} /api/v1/work/schedule/edit 工单流程信息修改
* @apiVersion 1.0.0
* @apiName WorkScheduleEdit
* @apiGroup Work
*
* @apiHeader {string} x-token token
*
* @apiParam {String} id Id
* @apiParam {String} title 名称
* @apiParam {Number} target 触发对象
* @apiParam {Array.String} target_value 触发对象具体信息
*
* @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) ScheduleEdit(c *gin.Context) {
form := &struct {
IDStringForm
scheduleForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewSchedule()(getSession()(c).(*service.Session)).Form(&work.ScheduleParams{
ID: form.Convert(), Title: form.Title, Stage: form.Stage, Step: form.Step,
Target: form.Target, IsCountersign: form.IsCountersign, TargetValue: form.TargetValue,
})
APIResponse(err)(c)
}
/**
* @api {post} /api/v1/work/schedule/delete 工单流程信息删除
* @apiVersion 1.0.0
* @apiName WorkScheduleDelete
* @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) ScheduleDelete(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewSchedule()(getSession()(c).(*service.Session)).Delete(form.Convert())
APIResponse(err)(c)
}
func (*Work) Repair(c *gin.Context) {
form := &struct {
OrderNo string `json:"order_no" form:"order_no"`
EquipmentCode string `json:"equipment_code" form:"equipment_code"`
EquipmentTitle string `json:"equipment_title" form:"equipment_title"`
PageForm
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewRepair()(getSession()(c).(*service.Session)).List(form.OrderNo, form.EquipmentCode, form.EquipmentTitle,
form.Page, form.PageSize)
APIResponse(err, data)(c)
}
func (*Work) RepairDetail(c *gin.Context) {
form := new(IDStringForm)
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := work.NewRepair()(getSession()(c).(*service.Session)).Detail(form.Convert())
APIResponse(err, data)(c)
}
func (*Work) RepairBegin(c *gin.Context) {
form := &struct {
IDStringForm
Remark string `json:"remark" form:"remark"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Begin(form.Convert(), form.Remark)
APIResponse(err)(c)
}
func (*Work) RepairFinish(c *gin.Context) {
form := &struct {
IDStringForm
ImageForm
Remark string `json:"remark" form:"remark"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Finish(form.Convert(), form.Image, form.Remark)
APIResponse(err)(c)
}
func (*Work) RepairEvaluate(c *gin.Context) {
form := &struct {
IDStringForm
Score float64 `json:"score" form:"score" binding:"required"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
err := work.NewRepair()(getSession()(c).(*service.Session)).Evaluate(form.Convert(), form.Score)
APIResponse(err)(c)
}