feat: 网元信令跟踪功能
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/utils/ctx"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
"be.ems/src/framework/vo/result"
|
||||
traceService "be.ems/src/modules/trace/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -20,43 +19,60 @@ var NewTraceData = &TraceDataController{
|
||||
//
|
||||
// PATH /data
|
||||
type TraceDataController struct {
|
||||
// 跟踪_数据信息服务
|
||||
traceDataService *traceService.TraceData
|
||||
traceDataService *traceService.TraceData // 跟踪_数据信息服务
|
||||
}
|
||||
|
||||
// 跟踪任务数据列表
|
||||
//
|
||||
// GET /list
|
||||
func (s *TraceDataController) List(c *gin.Context) {
|
||||
query := ctx.QueryMap(c)
|
||||
query := reqctx.QueryMap(c)
|
||||
rows, total := s.traceDataService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
data := s.traceDataService.SelectPage(query)
|
||||
c.JSON(200, result.Ok(data))
|
||||
// 跟踪任务数据信息
|
||||
//
|
||||
// GET /:id
|
||||
func (s *TraceDataController) Info(c *gin.Context) {
|
||||
id := parse.Number(c.Param("id"))
|
||||
if id <= 0 {
|
||||
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
data := s.traceDataService.FindById(id)
|
||||
if data.ID == id {
|
||||
c.JSON(200, resp.OkData(data))
|
||||
return
|
||||
}
|
||||
c.JSON(200, resp.Err(nil))
|
||||
}
|
||||
|
||||
// 跟踪任务数据删除
|
||||
//
|
||||
// DELETE /:ids
|
||||
// DELETE /:id
|
||||
func (s *TraceDataController) Remove(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
rowIds := c.Param("ids")
|
||||
if rowIds == "" {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
// 处理字符转id数组后去重
|
||||
ids := strings.Split(rowIds, ",")
|
||||
uniqueIDs := parse.RemoveDuplicates(ids)
|
||||
if len(uniqueIDs) <= 0 {
|
||||
c.JSON(200, result.Err(nil))
|
||||
return
|
||||
uniqueIDs := parse.RemoveDuplicatesToArray(id, ",")
|
||||
// 转换成int64数组类型
|
||||
ids := make([]int64, 0)
|
||||
for _, v := range uniqueIDs {
|
||||
ids = append(ids, parse.Number(v))
|
||||
}
|
||||
rows, err := s.traceDataService.DeleteByIds(uniqueIDs)
|
||||
|
||||
rows, err := s.traceDataService.DeleteByIds(ids)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
}
|
||||
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
c.JSON(200, resp.OkMsg(msg))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user