product_trouble_controller.go
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/service"
)
type ProductTroubleController struct {
beego.BaseController
}
// 创建事故记录
func (c *ProductTroubleController) CreatedProductTrouble() {
srv := service.NewProductTroubleService(nil)
createCommand := &command.SaveProductTroubleCommand{}
Must(c.Unmarshal(createCommand))
operater := ParseOperateInfo(c.BaseController)
data, err := srv.SaveProductTrouble(operater, createCommand)
c.Response(data, err)
}
// 更新事故记录
func (c *ProductTroubleController) UpdateProductTrouble() {
srv := service.NewProductTroubleService(nil)
createCommand := &command.SaveProductTroubleCommand{}
Must(c.Unmarshal(createCommand))
id, _ := c.GetInt(":id")
createCommand.Id = id
operater := ParseOperateInfo(c.BaseController)
data, err := srv.SaveProductTrouble(operater, createCommand)
c.Response(data, err)
}
// 获取事故记录
func (c *ProductTroubleController) GetProductTrouble() {
srv := service.NewProductTroubleService(nil)
id, _ := c.GetInt(":id")
data, err := srv.GetProductTrouble(id)
c.Response(data, err)
}
// 删除事故记录
func (c RewardStandardController) DeleteProductTrouble() {
srv := service.NewProductTroubleService(nil)
getQuery := &query.GetProductTroubleQuery{}
Must(c.Unmarshal(getQuery))
err := srv.DeleteProductTrouble(int64(getQuery.Id))
c.Response(nil, err)
}