feat: 迁移预警处理审核与备注附件流程
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user