正在显示
4 个修改的文件
包含
29 行增加
和
0 行删除
@@ -11,4 +11,5 @@ type SaveProductTroubleCommand struct { | @@ -11,4 +11,5 @@ type SaveProductTroubleCommand struct { | ||
11 | AmountLoss float64 `json:"amountLoss"` // 损失的金额 | 11 | AmountLoss float64 `json:"amountLoss"` // 损失的金额 |
12 | Types int `json:"types"` // 事故类型 1 安全事故 ,2 质量事故, 3 金属事故 ,4 非金属事故 | 12 | Types int `json:"types"` // 事故类型 1 安全事故 ,2 质量事故, 3 金属事故 ,4 非金属事故 |
13 | RecordDate string `json:"recordDate"` // 事故发生的日期 | 13 | RecordDate string `json:"recordDate"` // 事故发生的日期 |
14 | + SaveAndApprove bool `json:"saveAndApprove"` //保存并审核 | ||
14 | } | 15 | } |
@@ -89,6 +89,18 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI | @@ -89,6 +89,18 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI | ||
89 | if err != nil { | 89 | if err != nil { |
90 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 90 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
91 | } | 91 | } |
92 | + if param.SaveAndApprove { | ||
93 | + var approveUser *domain.User | ||
94 | + userService := domainService.NewUserService() | ||
95 | + approveUser, err = userService.User(operateInfo.UserId) | ||
96 | + if err != nil { | ||
97 | + return nil, application.ThrowError(application.ARG_ERROR, "获取审核人信息失败,"+err.Error()) | ||
98 | + } | ||
99 | + err = troubleData.Approve(approveUser) | ||
100 | + if err != nil { | ||
101 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
102 | + } | ||
103 | + } | ||
92 | _, err = productTroubleRepo.Save(troubleData) | 104 | _, err = productTroubleRepo.Save(troubleData) |
93 | if err != nil { | 105 | if err != nil { |
94 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 106 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -174,6 +186,10 @@ func (srv ProductTroubleService) DeleteProductTrouble(id int64) error { | @@ -174,6 +186,10 @@ func (srv ProductTroubleService) DeleteProductTrouble(id int64) error { | ||
174 | return nil | 186 | return nil |
175 | } | 187 | } |
176 | 188 | ||
189 | +// func (srv ProductTroubleService) approveProductTrouble(operateInfo *domain.OperateInfo, param *domain.ProductTrouble) error { | ||
190 | +// return nil | ||
191 | +// } | ||
192 | + | ||
177 | func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.OperateInfo, id int64) error { | 193 | func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.OperateInfo, id int64) error { |
178 | transactionContext, err := factory.CreateTransactionContext(nil) | 194 | transactionContext, err := factory.CreateTransactionContext(nil) |
179 | if err != nil { | 195 | if err != nil { |
@@ -62,3 +62,13 @@ func (c *ProductTroubleController) ListProductTrouble() { | @@ -62,3 +62,13 @@ func (c *ProductTroubleController) ListProductTrouble() { | ||
62 | total, data, err := srv.ListProductTrouble(&getQuery) | 62 | total, data, err := srv.ListProductTrouble(&getQuery) |
63 | ResponseGrid(c.BaseController, total, data, err) | 63 | ResponseGrid(c.BaseController, total, data, err) |
64 | } | 64 | } |
65 | + | ||
66 | +// 审核事故记录 | ||
67 | +func (c *ProductTroubleController) ApproveProductTrouble() { | ||
68 | + srv := service.NewProductTroubleService(nil) | ||
69 | + getQuery := &query.GetProductTroubleQuery{} | ||
70 | + Must(c.Unmarshal(getQuery)) | ||
71 | + operater := ParseOperateInfo(c.BaseController) | ||
72 | + err := srv.ApproveProductTrouble(operater, int64(getQuery.Id)) | ||
73 | + c.Response(nil, err) | ||
74 | +} |
@@ -11,4 +11,6 @@ func init() { | @@ -11,4 +11,6 @@ func init() { | ||
11 | web.Router("/product_trouble/:id", &controllers.ProductTroubleController{}, "Get:GetProductTrouble") | 11 | web.Router("/product_trouble/:id", &controllers.ProductTroubleController{}, "Get:GetProductTrouble") |
12 | web.Router("/product_trouble/remove", &controllers.ProductTroubleController{}, "Post:DeleteProductTrouble") | 12 | web.Router("/product_trouble/remove", &controllers.ProductTroubleController{}, "Post:DeleteProductTrouble") |
13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") | 13 | web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble") |
14 | + web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble") | ||
15 | + | ||
14 | } | 16 | } |
-
请 注册 或 登录 后发表评论