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