feat(god):完成天神模式的控制器,整体功能待测。
This commit is contained in:
parent
86de5fd3ad
commit
7be45d3ffc
|
@ -1,8 +1,11 @@
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"electricity_bill_calc/exceptions"
|
||||||
"electricity_bill_calc/response"
|
"electricity_bill_calc/response"
|
||||||
"electricity_bill_calc/security"
|
"electricity_bill_calc/security"
|
||||||
|
"electricity_bill_calc/service"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -11,10 +14,169 @@ func InitializeGodModeController(router *gin.Engine) {
|
||||||
gmR := router.Group("/gm")
|
gmR := router.Group("/gm")
|
||||||
{
|
{
|
||||||
gmR.DELETE("/report/:rid/summary", security.SingularityAuthorize, gmResetReportSummary)
|
gmR.DELETE("/report/:rid/summary", security.SingularityAuthorize, gmResetReportSummary)
|
||||||
|
gmR.DELETE("/report/:rid/maintenance", security.SingularityAuthorize, gmResetReportMaintenance)
|
||||||
|
gmR.DELETE("/report/:rid/meters", security.SingularityAuthorize, gmResetReportEndUserRecord)
|
||||||
|
gmR.DELETE("/report/:rid", security.SingularityAuthorize, gmResetReport)
|
||||||
|
gmR.DELETE("/report/:rid/force", security.SingularityAuthorize, gmDeleteReport)
|
||||||
|
gmR.DELETE("/park/:pid/maintenance/:mid", security.SingularityAuthorize, gmDeleteSpecificMaintenance)
|
||||||
|
gmR.DELETE("/park/:pid/maintenance", security.SingularityAuthorize, gmDeleteAllMaintenance)
|
||||||
|
gmR.DELETE("/park/:pid/meters", security.SingularityAuthorize, gmDeleteAllMeters)
|
||||||
|
gmR.DELETE("/park/:pid/force", security.SingularityAuthorize, gmDeletePark)
|
||||||
|
gmR.DELETE("/enterprise/:uid/force", security.SingularityAuthorize, gmDeleteUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gmResetReportSummary(c *gin.Context) {
|
func gmResetReportSummary(c *gin.Context) {
|
||||||
result := response.NewResult(c)
|
result := response.NewResult(c)
|
||||||
|
requestReportId := c.Param("rid")
|
||||||
|
done, err := service.GodModeService.ClearReportSummary(requestReportId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功重置指定报表的园区总览部分。")
|
||||||
|
return
|
||||||
|
}
|
||||||
result.Success("指定报表的园区总览已经重置。")
|
result.Success("指定报表的园区总览已经重置。")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gmResetReportMaintenance(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestReportId := c.Param("rid")
|
||||||
|
done, err := service.GodModeService.ClearReportMaintenances(requestReportId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功重置指定报表的配电维护费部分。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定报表的配电维护费已经重置。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmResetReportEndUserRecord(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestReportId := c.Param("rid")
|
||||||
|
done, err := service.GodModeService.ResetEndUserRegisterRecords(requestReportId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功重置指定报表的抄表记录部分。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定报表的抄表记录已经重置。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmResetReport(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestReportId := c.Param("rid")
|
||||||
|
done, err := service.GodModeService.ResetReport(requestReportId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功重置指定报表。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定报表已经重置。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeleteReport(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestReportId := c.Param("rid")
|
||||||
|
done, err := service.GodModeService.DeleteReport(requestReportId)
|
||||||
|
if err != nil {
|
||||||
|
if ipErr, ok := err.(exceptions.ImproperOperateError); ok {
|
||||||
|
result.NotAccept(ipErr.Message)
|
||||||
|
} else {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除指定报表。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定报表已经删除。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeleteSpecificMaintenance(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestParkId := c.Param("pid")
|
||||||
|
requestMaintenanceId := c.Param("mid")
|
||||||
|
done, err := service.GodModeService.RemoveSpecificMaintenance(requestParkId, requestMaintenanceId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除指定的维护费用记录。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定维护费用记录已经删除。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeleteAllMaintenance(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestParkId := c.Param("pid")
|
||||||
|
done, err := service.GodModeService.RemoveAllMaintenance(requestParkId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除全部维护费用记录。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("全部维护费用记录已经删除。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeleteAllMeters(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestParkId := c.Param("pid")
|
||||||
|
done, err := service.GodModeService.RemoveAllMeters(requestParkId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除全部终端表计档案记录。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("全部终端表计档案记录已经删除。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeletePark(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestParkId := c.Param("pid")
|
||||||
|
done, err := service.GodModeService.RemovePark(requestParkId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除指定的园区。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定的园区已经删除。")
|
||||||
|
}
|
||||||
|
|
||||||
|
func gmDeleteUser(c *gin.Context) {
|
||||||
|
result := response.NewResult(c)
|
||||||
|
requestUserId := c.Param("uid")
|
||||||
|
done, err := service.GodModeService.DeleteUser(requestUserId)
|
||||||
|
if err != nil {
|
||||||
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !done {
|
||||||
|
result.Error(http.StatusInternalServerError, "未能成功删除指定的用户。")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result.Success("指定的用户及其关联信息已经删除。")
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ func Router() *gin.Engine {
|
||||||
controller.InitializeEndUserController(router)
|
controller.InitializeEndUserController(router)
|
||||||
controller.InitializeWithdrawController(router)
|
controller.InitializeWithdrawController(router)
|
||||||
controller.InitializeStatisticsController(router)
|
controller.InitializeStatisticsController(router)
|
||||||
|
controller.InitializeGodModeController(router)
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user