作者 Your Name

更新事故管理

... ... @@ -11,4 +11,5 @@ type SaveProductTroubleCommand struct {
AmountLoss float64 `json:"amountLoss"` // 损失的金额
Types int `json:"types"` // 事故类型 1 安全事故 ,2 质量事故, 3 金属事故 ,4 非金属事故
RecordDate string `json:"recordDate"` // 事故发生的日期
SaveAndApprove bool `json:"saveAndApprove"` //保存并审核
}
... ...
... ... @@ -89,6 +89,18 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
if param.SaveAndApprove {
var approveUser *domain.User
userService := domainService.NewUserService()
approveUser, err = userService.User(operateInfo.UserId)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取审核人信息失败,"+err.Error())
}
err = troubleData.Approve(approveUser)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
}
_, err = productTroubleRepo.Save(troubleData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -174,6 +186,10 @@ func (srv ProductTroubleService) DeleteProductTrouble(id int64) error {
return nil
}
// func (srv ProductTroubleService) approveProductTrouble(operateInfo *domain.OperateInfo, param *domain.ProductTrouble) error {
// return nil
// }
func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.OperateInfo, id int64) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ...
... ... @@ -62,3 +62,13 @@ func (c *ProductTroubleController) ListProductTrouble() {
total, data, err := srv.ListProductTrouble(&getQuery)
ResponseGrid(c.BaseController, total, data, err)
}
// 审核事故记录
func (c *ProductTroubleController) ApproveProductTrouble() {
srv := service.NewProductTroubleService(nil)
getQuery := &query.GetProductTroubleQuery{}
Must(c.Unmarshal(getQuery))
operater := ParseOperateInfo(c.BaseController)
err := srv.ApproveProductTrouble(operater, int64(getQuery.Id))
c.Response(nil, err)
}
... ...
... ... @@ -11,4 +11,6 @@ func init() {
web.Router("/product_trouble/:id", &controllers.ProductTroubleController{}, "Get:GetProductTrouble")
web.Router("/product_trouble/remove", &controllers.ProductTroubleController{}, "Post:DeleteProductTrouble")
web.Router("/product_trouble/search", &controllers.ProductTroubleController{}, "Post:ListProductTrouble")
web.Router("/product_trouble/approve", &controllers.ProductTroubleController{}, "Post:ApproveProductTrouble")
}
... ...