feat(report):完成修改指定待摊薄费用信息的功能。
This commit is contained in:
parent
ef8bd0c617
commit
ea929fd106
|
@ -29,6 +29,7 @@ func InitializeReportController(router *gin.Engine) {
|
|||
router.GET("/report/:rid/maintenance", security.EnterpriseAuthorize, fetchWillDilutedFees)
|
||||
router.POST("/report/:rid/maintenance", security.EnterpriseAuthorize, createTemporaryWillDilutedFee)
|
||||
router.POST("/report/:rid/maintenance/import", security.EnterpriseAuthorize, importPredefinedMaintenanceFees)
|
||||
router.PUT("/report/:rid/maintenance/:mid", security.EnterpriseAuthorize, modifyWillDilutedFee)
|
||||
}
|
||||
|
||||
func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool {
|
||||
|
@ -297,3 +298,27 @@ func importPredefinedMaintenanceFees(c *gin.Context) {
|
|||
}
|
||||
result.Created("预定义的配电维护费已经导入。")
|
||||
}
|
||||
|
||||
type DilutedFeeModificationFormData struct {
|
||||
Name *string `json:"name,omitempty" form:"name"`
|
||||
Fee decimal.Decimal `json:"fee" form:"fee"`
|
||||
Memo *string `json:"memo,omitempty" form:"memo"`
|
||||
}
|
||||
|
||||
func modifyWillDilutedFee(c *gin.Context) {
|
||||
result := response.NewResult(c)
|
||||
requestReportId := c.Param("rid")
|
||||
if !ensureReportBelongs(c, result, requestReportId) {
|
||||
return
|
||||
}
|
||||
requestFeeId := c.Param("mid")
|
||||
formData := new(DilutedFeeModificationFormData)
|
||||
c.BindJSON(formData)
|
||||
updateValues := tools.ConvertStructToMap(formData)
|
||||
err := service.ReportService.UpdateMaintenanceFee(requestFeeId, updateValues)
|
||||
if err != nil {
|
||||
result.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
result.Updated("指定待摊薄费用信息已经更新。")
|
||||
}
|
||||
|
|
|
@ -237,3 +237,8 @@ func (_ReportService) BatchSaveMaintenanceFee(fees []model.WillDilutedFee) error
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ReportService) UpdateMaintenanceFee(feeId string, updates map[string]interface{}) (err error) {
|
||||
_, err = global.DBConn.Table(new(model.WillDilutedFee)).ID(feeId).Update(updates)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user