From bf9cdd854927ea0676df321232039c8faa28ae7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sun, 21 Aug 2022 22:18:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(report):=E5=AE=8C=E6=88=90=E5=BE=85?= =?UTF-8?q?=E6=91=8A=E8=96=84=E8=B4=B9=E7=94=A8=E6=9D=A1=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/report.go | 16 ++++++++++++++++ service/report.go | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/controller/report.go b/controller/report.go index 4ac36d7..912c5cd 100644 --- a/controller/report.go +++ b/controller/report.go @@ -30,6 +30,7 @@ func InitializeReportController(router *gin.Engine) { 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) + router.DELETE("/report/:rid/maintenance/:mid", security.EnterpriseAuthorize, deleteTemporaryWillDilutedFee) } func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool { @@ -322,3 +323,18 @@ func modifyWillDilutedFee(c *gin.Context) { } result.Updated("指定待摊薄费用信息已经更新。") } + +func deleteTemporaryWillDilutedFee(c *gin.Context) { + result := response.NewResult(c) + requestReportId := c.Param("rid") + if !ensureReportBelongs(c, result, requestReportId) { + return + } + requestFeeId := c.Param("mid") + err := service.ReportService.DeleteWillDilutedFee(requestFeeId) + if err != nil { + result.Error(http.StatusInternalServerError, err.Error()) + return + } + result.Deleted("指定待摊薄费用信息已经删除。") +} diff --git a/service/report.go b/service/report.go index 2c716b5..1005185 100644 --- a/service/report.go +++ b/service/report.go @@ -250,3 +250,8 @@ func (_ReportService) UpdateMaintenanceFee(feeId string, updates map[string]inte _, err = global.DBConn.Table(new(model.WillDilutedFee)).ID(feeId).Update(updates) return } + +func (_ReportService) DeleteWillDilutedFee(fee string) (err error) { + _, err = global.DBConn.ID(fee).NoAutoCondition().Delete(new(model.WillDilutedFee)) + return +}