feat: 参数配置变更日志查询删除功能接口
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
|||||||
"be.ems/src/framework/utils/ctx"
|
"be.ems/src/framework/utils/ctx"
|
||||||
"be.ems/src/framework/utils/parse"
|
"be.ems/src/framework/utils/parse"
|
||||||
"be.ems/src/framework/vo/result"
|
"be.ems/src/framework/vo/result"
|
||||||
"be.ems/src/modules/practical_training/model"
|
|
||||||
"be.ems/src/modules/practical_training/service"
|
"be.ems/src/modules/practical_training/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -29,44 +28,26 @@ type PtNeConfigDataLog struct {
|
|||||||
//
|
//
|
||||||
// GET /
|
// GET /
|
||||||
func (s *PtNeConfigDataLog) Info(c *gin.Context) {
|
func (s *PtNeConfigDataLog) Info(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
query := ctx.QueryMap(c)
|
||||||
var querys struct {
|
// 指定查询个人的数据
|
||||||
NeType string `form:"neType" binding:"required"`
|
query["stubType"] = "2"
|
||||||
ParamName string `form:"paramName" binding:"required"`
|
data := s.ptNeConfigDataLogService.SelectPage(query)
|
||||||
}
|
|
||||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
|
||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 优先查询个人的数据,没有就向系统取
|
c.JSON(200, result.Ok(data))
|
||||||
param := model.PtNeConfigDataLog{
|
|
||||||
NeType: querys.NeType,
|
|
||||||
StubType: "2",
|
|
||||||
ParamName: querys.ParamName,
|
|
||||||
}
|
|
||||||
info := s.ptNeConfigDataLogService.SelectList(param)
|
|
||||||
|
|
||||||
// 输出数据内容
|
|
||||||
if len(info) > 0 {
|
|
||||||
c.JSON(200, result.OkData(info[0]))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(200, result.Err(nil))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 网元参数配置数据变更日志删除
|
// 网元参数配置数据变更日志删除
|
||||||
//
|
//
|
||||||
// DELETE /:ids
|
// DELETE /
|
||||||
func (s *PtNeConfigDataLog) Remove(c *gin.Context) {
|
func (s *PtNeConfigDataLog) Remove(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
ids := c.Param("ids")
|
id, idOk := c.GetQuery("id")
|
||||||
if ids == "" {
|
if id == "" || !idOk {
|
||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 处理字符转id数组后去重
|
// 处理字符转id数组后去重
|
||||||
idsArr := strings.Split(ids, ",")
|
idsArr := strings.Split(id, ",")
|
||||||
uniqueIDs := parse.RemoveDuplicates(idsArr)
|
uniqueIDs := parse.RemoveDuplicates(idsArr)
|
||||||
if len(uniqueIDs) <= 0 {
|
if len(uniqueIDs) <= 0 {
|
||||||
c.JSON(200, result.Err(nil))
|
c.JSON(200, result.Err(nil))
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func Setup(router *gin.Engine) {
|
|||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
controller.NewPtNeConfigDataLog.Info,
|
controller.NewPtNeConfigDataLog.Info,
|
||||||
)
|
)
|
||||||
paramConfigLogGroup.DELETE("/:ids",
|
paramConfigLogGroup.DELETE("",
|
||||||
middleware.PreAuthorize(map[string][]string{"hasRoles": {"admin"}}),
|
middleware.PreAuthorize(map[string][]string{"hasRoles": {"admin"}}),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfigDataLog", collectlogs.BUSINESS_TYPE_DELETE)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfigDataLog", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||||
controller.NewPtNeConfigDataLog.Remove,
|
controller.NewPtNeConfigDataLog.Remove,
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ func (r *PtNeConfigDataLogRepository) SelectPage(query map[string]any) map[strin
|
|||||||
conditions = append(conditions, "ne_type = ?")
|
conditions = append(conditions, "ne_type = ?")
|
||||||
params = append(params, v)
|
params = append(params, v)
|
||||||
}
|
}
|
||||||
|
if v, ok := query["stubType"]; ok && v != "" {
|
||||||
|
conditions = append(conditions, "stub_type = ?")
|
||||||
|
params = append(params, v)
|
||||||
|
}
|
||||||
if v, ok := query["paramName"]; ok && v != "" {
|
if v, ok := query["paramName"]; ok && v != "" {
|
||||||
conditions = append(conditions, "param_name = ?")
|
conditions = append(conditions, "param_name = ?")
|
||||||
params = append(params, v)
|
params = append(params, v)
|
||||||
@@ -89,7 +93,7 @@ func (r *PtNeConfigDataLogRepository) SelectPage(query map[string]any) map[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询数量 长度为0直接返回
|
// 查询数量 长度为0直接返回
|
||||||
totalSql := "select count(1) as 'total' from pt_ne_config_data"
|
totalSql := "select count(1) as 'total' from pt_ne_config_data_log"
|
||||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("total err => %v", err)
|
logger.Errorf("total err => %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user