feat: kpi支持界面控制状态修改英文名称

This commit is contained in:
TsMask
2025-08-20 16:46:50 +08:00
parent e0606971ae
commit 2f430d59b5
6 changed files with 1044 additions and 451 deletions

View File

@@ -7,6 +7,7 @@ import (
"be.ems/lib/log"
"be.ems/src/framework/datasource"
"be.ems/src/framework/i18n"
"be.ems/src/framework/resp"
"be.ems/src/framework/utils/ctx"
"be.ems/src/framework/vo/result"
"be.ems/src/modules/network_data/model"
@@ -120,3 +121,79 @@ func (s *PerfKPIController) Title(c *gin.Context) {
c.JSON(200, result.OkData(kpiTitles))
}
// 获取统计标题
//
// GET /title
//
// @Tags network_data/kpi
// @Accept json
// @Produce json
// @Param neType query string true "NE Type only IMS" Enums(IMS)
// @Param callerParty query string false "callerParty"
// @Param calledParty query string false "calledParty"
// @Param pageNum query number true "pageNum" default(1)
// @Param pageSize query number true "pageSize" default(10)
// @Success 200 {object} object "Response Results"
// @Security TokenAuth
// @Summary Get Statistical Headings
// @Description Get Statistical Headings
// @Router /neData/kpi/title/list [get]
func (s *PerfKPIController) TitleList(c *gin.Context) {
query := ctx.QueryMapString(c)
// 查询数据
rows, total := s.perfKPIService.TitleSelectByPage(query)
c.JSON(200, resp.OkData(map[string]any{"total": total, "rows": rows}))
}
// 统计标题修改
//
// PUT /title
//
// @Tags network_data/kpi
// @Accept json
// @Produce json
// @Param body body struct true "body"
// @Success 200 {object} object "Response Results"
// @Security TokenAuth
// @Summary Customize Title Modification
// @Description Customize Title Modification
// @Router /neData/kpi/title [put]
func (s PerfKPIController) TitleUpdate(c *gin.Context) {
var body struct {
ID string `json:"id" binding:"required"`
Title string `json:"enTitle"`
StatusFlag string `json:"statusFlag"`
}
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}
item := s.perfKPIService.TitleFind(model.GoldKPITitle{ID: body.ID})
if len(item) != 1 {
c.JSON(200, resp.ErrMsg("not found"))
return
}
itemInfo := item[0]
if itemInfo.StatusFlag == body.StatusFlag {
c.JSON(200, resp.ErrMsg("no change"))
return
}
if body.StatusFlag != "" && (body.StatusFlag == "0" || body.StatusFlag == "1") {
itemInfo.StatusFlag = body.StatusFlag
}
if body.Title != "" {
itemInfo.EnTitle = body.Title
}
rows := s.perfKPIService.TitleUpdate(itemInfo)
if rows > 0 {
c.JSON(200, resp.Ok(nil))
return
}
c.JSON(200, resp.Err(nil))
}

View File

@@ -2,12 +2,13 @@ package model
// GoldKPITitle 黄金指标标题信息对象 kpi_title
type GoldKPITitle struct {
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
NeType string `json:"neType" gorm:"column:ne_type"`
KPIID string `json:"kpiId" gorm:"column:kpi_id"`
TitleJson string `json:"titleJson" gorm:"column:title_json"`
CnTitle string `json:"cnTitle" gorm:"column:cn_title"`
EnTitle string `json:"enTitle" gorm:"column:en_title"`
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
NeType string `json:"neType" gorm:"column:ne_type"`
KPIID string `json:"kpiId" gorm:"column:kpi_id"`
TitleJson string `json:"titleJson" gorm:"column:title_json"`
CnTitle string `json:"cnTitle" gorm:"column:cn_title"`
EnTitle string `json:"enTitle" gorm:"column:en_title"`
StatusFlag string `json:"statusFlag" gorm:"column:status_flag"`
}
// TableName 表名称

View File

@@ -27,6 +27,14 @@ func Setup(router *gin.Engine) {
middleware.PreAuthorize(nil),
controller.NewPerfKPI.Title,
)
kpiGroup.GET("/title/list",
middleware.PreAuthorize(nil),
controller.NewPerfKPI.TitleList,
)
kpiGroup.PUT("/title",
middleware.PreAuthorize(nil),
controller.NewPerfKPI.TitleUpdate,
)
kpiGroup.GET("/data",
middleware.PreAuthorize(nil),
controller.NewPerfKPI.GoldKPI,

View File

@@ -45,6 +45,21 @@ func (r *PerfKPI) SelectGoldKPITitle(neType string) []model.GoldKPITitle {
return r.perfKPIRepository.SelectGoldKPITitle(neType)
}
// TitleSelectByPage 分页查询指标名称
func (r *PerfKPI) TitleSelectByPage(query map[string]string) ([]model.GoldKPITitle, int64) {
return r.perfKPIRepository.TitleSelectByPage(query)
}
// TitleFind 查询信息
func (r PerfKPI) TitleFind(param model.GoldKPITitle) []model.GoldKPITitle {
return r.perfKPIRepository.TitleSelect(param)
}
// TitleUpdate 修改指标状态
func (r *PerfKPI) TitleUpdate(param model.GoldKPITitle) int64 {
return r.perfKPIRepository.TitleUpdate(param)
}
// FindData 通过网元指标数据信息
func (s PerfKPI) FindData(query model.GoldKPIQuery) []map[string]any {
// 原始数据