feat: 迁移预警处理审核与备注附件流程
This commit is contained in:
@@ -26,6 +26,7 @@ func NewGinEngine(runtime *config.Store, access *systemservice.AccessControlServ
|
||||
|
||||
func emptyHandlers() *handler.Set {
|
||||
return &handler.Set{
|
||||
AlertRecord: &handler.AlertRecord{},
|
||||
AlertRule: &handler.AlertRule{},
|
||||
BusinessPromote: &handler.BusinessPromote{},
|
||||
Business: &handler.Business{},
|
||||
@@ -100,7 +101,7 @@ func TestGinStartupLogsEveryRegisteredRoute(t *testing.T) {
|
||||
if got, want := strings.Count(text, `"msg":"router registered"`), len(engine.Routes()); got != want {
|
||||
t.Fatalf("registered route log count = %d, want %d", got, want)
|
||||
}
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":219`) {
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":227`) {
|
||||
t.Fatalf("startup route summary is missing: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-kratos/kratos/v3/errors"
|
||||
businessbiz "kra/internal/biz/business"
|
||||
"kra/internal/service/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type AlertRecord struct{ service *business.AlertRecordService }
|
||||
|
||||
func NewAlertRecord(service *business.AlertRecordService) *AlertRecord {
|
||||
return &AlertRecord{service: service}
|
||||
}
|
||||
|
||||
func (h *AlertRecord) List(c *gin.Context) {
|
||||
var req dto.AlertRecordQuery
|
||||
if c.ShouldBindQuery(&req) != nil {
|
||||
Fail(c, "查询参数不正确")
|
||||
return
|
||||
}
|
||||
page, err := h.service.List(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, page)
|
||||
}
|
||||
|
||||
func (h *AlertRecord) Detail(c *gin.Context) {
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
Fail(c, "预警记录 ID 不正确")
|
||||
return
|
||||
}
|
||||
detail, err := h.service.Detail(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, detail)
|
||||
}
|
||||
|
||||
func (h *AlertRecord) Process(action businessbiz.AlertAction) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 1<<20)
|
||||
var req dto.AlertProcessRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
Fail(c, "预警记录参数不正确")
|
||||
return
|
||||
}
|
||||
if err := h.service.Process(c.Request.Context(), &req, action); err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *AlertRecord) AddNote(c *gin.Context) {
|
||||
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 1<<20)
|
||||
var req dto.AlertNoteRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
Fail(c, "预警记录参数不正确")
|
||||
return
|
||||
}
|
||||
if err := h.service.AddNote(c.Request.Context(), &req); err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ var ProviderSet = wire.NewSet(
|
||||
NewBusinessPassword,
|
||||
NewBusinessPromote,
|
||||
NewAlertRule,
|
||||
NewAlertRecord,
|
||||
NewAuthority, NewMenu, NewAPI, NewPermission, NewOrganization,
|
||||
NewAnnouncement, NewEmail, NewPayment, NewTask, NewMedia, NewAudit,
|
||||
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
type Set struct {
|
||||
AlertRecord *AlertRecord
|
||||
AlertRule *AlertRule
|
||||
BusinessPromote *BusinessPromote
|
||||
Business *Business
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"kra/internal/biz/business"
|
||||
"kra/internal/server/handler"
|
||||
)
|
||||
|
||||
func RegisterAlertRecord(private *gin.RouterGroup, h *handler.AlertRecord) {
|
||||
g := private.Group("/sw/alertRecord")
|
||||
g.GET("/list", h.List)
|
||||
g.GET("/detail/:id", h.Detail)
|
||||
g.POST("/startProcess", h.Process(business.AlertStart))
|
||||
g.POST("/submitAudit", h.Process(business.AlertSubmit))
|
||||
g.POST("/approve", h.Process(business.AlertApprove))
|
||||
g.POST("/reject", h.Process(business.AlertReject))
|
||||
g.POST("/reProcess", h.Process(business.AlertReprocess))
|
||||
g.POST("/addNote", h.AddNote)
|
||||
}
|
||||
@@ -20,6 +20,7 @@ func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.En
|
||||
return
|
||||
}
|
||||
registrations := []func(){
|
||||
func() { RegisterAlertRecord(private, r.handlers.AlertRecord) },
|
||||
func() { RegisterAlertRule(private, r.handlers.AlertRule) },
|
||||
func() { private.GET("/sw/business/:userId/promotes", r.handlers.BusinessPromote.List) },
|
||||
func() { RegisterBusiness(private, r.handlers.Business) },
|
||||
|
||||
Reference in New Issue
Block a user