From 2de7721ece0b8278cb353eec971838afef30d06a Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 30 May 2025 14:40:40 +0800 Subject: [PATCH 1/7] =?UTF-8?q?chore:=20=E5=8F=91=E5=B8=83=E7=89=88?= =?UTF-8?q?=E6=9C=AC=202.2505.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9db180..464aa89f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # 版本发布日志 +## 2.2505.4-20250530 + +- 修复 socket异常退出捕获,停止信号退出循环读取 +- 新增 OMC参数配置添加NE信令跟踪服务开关 +- 修复 网元激活申请码提取两行中的激活码 +- 修复 修改命令执行函数的超时处理和输出文件名 +- 调整 目录变更系统配置和引导初始化 +- 修复 增加ne_list字段的长度限制,修改相关SQL脚本 +- 修复 系统菜单和角色分配菜单缺失 +- 修复 忽略特定SQL执行错误重复字段、索引和未知字段错误 + ## 2.2505.3-20250523 - 修复 增加对转发邮箱和手机号码为空的错误处理 From 0d6d42a4304b25a04399ae7f2cf74a53b2511bb0 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 5 Jun 2025 19:46:19 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20sshsvc=E6=9C=8D=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E7=A7=81=E9=92=A5=E6=96=87=E4=BB=B6=E5=88=A4=E6=96=AD=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sshsvc/sshsvc.go | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/sshsvc/sshsvc.go b/sshsvc/sshsvc.go index 52d3802a..d0526ff8 100644 --- a/sshsvc/sshsvc.go +++ b/sshsvc/sshsvc.go @@ -7,6 +7,7 @@ import ( "net" "os" "os/exec" + "path/filepath" "strconv" "strings" "sync" @@ -50,24 +51,41 @@ func init() { logmml.InitMmlLogger(conf.Logmml.File, conf.Logmml.Duration, conf.Logmml.Count, "omc", config.GetLogMmlLevel()) } -func main() { - // 生成SSH密钥对 +// readPrivateKey 读取SSH私钥,如果不存在则生成新的密钥对 +func readPrivateKey() ssh.Signer { + // 检查私钥文件是否存在 + if _, err := os.Stat(conf.Sshd.PrivateKey); os.IsNotExist(err) { + // 如果文件不存在,创建目录并生成密钥 + dir := filepath.Dir(conf.Sshd.PrivateKey) + if err := os.MkdirAll(dir, 0700); err != nil { + log.Fatal("Failed to create .ssh directory:", err) + os.Exit(2) + } + + // 使用ssh-keygen命令生成密钥对 + cmd := exec.Command("ssh-keygen", "-t", "rsa", "-P", "", "-f", conf.Sshd.PrivateKey) + if err := cmd.Run(); err != nil { + log.Fatal("Failed to generate SSH key:", err) + os.Exit(2) + } + } + + // 读取SSH密钥对 privateKeyBytes, err := os.ReadFile(conf.Sshd.PrivateKey) if err != nil { - // ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa - // ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" -y - exec.Command("ssh-keygen", "-t", "rsa", "-P", "", "-f", conf.Sshd.PrivateKey, "-N", "", "-y").Run() log.Fatal("Failed to ReadFile", err) os.Exit(2) } privateKey, err := ssh.ParsePrivateKey(privateKeyBytes) if err != nil { - exec.Command("ssh-keygen", "-t", "rsa", "-P", "", "-f", conf.Sshd.PrivateKey, "-N", "", "-y").Run() log.Fatal("Failed to ParsePrivateKey", err) os.Exit(3) } + return privateKey +} +func main() { // 配置SSH服务器 serverConfig := &ssh.ServerConfig{ PasswordCallback: func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) { @@ -106,6 +124,7 @@ func main() { }, } + privateKey := readPrivateKey() serverConfig.AddHostKey(privateKey) // 启动SSH服务器 From 7c045fc0365599203dda7cd8820e89436c55dadc Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 6 Jun 2025 14:29:23 +0800 Subject: [PATCH 3/7] =?UTF-8?q?del:=20=E7=A7=BB=E9=99=A4=E6=97=A7=E8=B7=9F?= =?UTF-8?q?=E8=B8=AA=E4=BB=BB=E5=8A=A1=E7=9B=B8=E5=85=B3=E7=9A=84=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/trace/trace.go | 383 ---------------------------------------- lib/routes/routes.go | 10 -- 2 files changed, 393 deletions(-) delete mode 100644 features/trace/trace.go diff --git a/features/trace/trace.go b/features/trace/trace.go deleted file mode 100644 index 78ff36cf..00000000 --- a/features/trace/trace.go +++ /dev/null @@ -1,383 +0,0 @@ -package trace - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "strings" - - "github.com/go-resty/resty/v2" - - "be.ems/lib/config" - "be.ems/lib/dborm" - "be.ems/lib/global" - "be.ems/lib/log" - "be.ems/lib/services" -) - -var ( - UriTraceTaskV1 = config.DefaultUriPrefix + "/traceManagement/v1/subscriptions" - UriTraceTask = config.DefaultUriPrefix + "/traceManagement/{apiVersion}/subscriptions" - - CustomUriTraceTaskV1 = config.UriPrefix + "/traceManagement/v1/subscriptions" - CustomUriTraceTask = config.UriPrefix + "/traceManagement/{apiVersion}/subscriptions" -) - -type TraceTask struct { - Id int `json:"id" xorm:"pk 'id' autoincr"` - TraceType string `json:"traceType"` - StartTime string `json:"startTime"` - EndTime string `json:"endTime"` - Imsi string `json:"imsi"` - Msisdn string `json:"msisdn"` - SrcIp string `json:"srcIp"` - DstIp string `json:"dstIp"` - SignalPort int16 `json:"signalPort"` - NeType string `json:"neType"` - NeId string `json:"neId"` - UeIp string `json:"ueIp"` - Interfaces []string `json:"interfaces"` - NotifyUrl string `json:"notifyUrl" xorm:"-"` - Status string `json:"-" xorm:"status"` - SuccNEs []string `json:"-" xorm:"succ_nes"` - FailNEs []string `json:"-" xorm:"fail_nes"` - AccountID string `json:"accountId" xorm:"account_id"` - Comment string `json:"comment" xorm:"comment"` - UpdateTime string `json:"-" xorm:"-"` -} - -var client = resty.New() - -/* -func init() { - client.SetTimeout(3 * time.Second) -} -*/ - -// Post trace task to NF/NFs -func PostTraceTaskToNF(w http.ResponseWriter, r *http.Request) { - log.Debug("PostTraceTaskToNF processing... ") - - //vars := mux.Vars(r) - - // token, err := services.CheckFrontValidRequest(w, r) - // if err != nil { - // log.Error("Request error:", err) - // return - // } - // log.Debug("AccessToken:", token) - - body, err := io.ReadAll(io.LimitReader(r.Body, int64(config.GetYamlConfig().Params.UriMaxLen))) - if err != nil { - log.Error("io.ReadAll is failed:", err) - services.ResponseNotFound404UriNotExist(w, r) - return - } - log.Trace("body:", string(body)) - - traceTask := new(TraceTask) - _ = json.Unmarshal(body, traceTask) - log.Debug("traceTask:", traceTask) - - var neTypes []string - // do not set device - if traceTask.NeType == "" { - // query neType by interface - if len(traceTask.Interfaces) > 0 { - err := dborm.XormGetSingleColStringArrayByIn("trace_info", "ne_type", "interface", traceTask.Interfaces, &neTypes) - if err != nil { - log.Error("Failed to dborm.XormGetSingleCol:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } else { - neTypes = []string{"AMF", "SMF", "UDM", "AUSF", "UPF"} - } - } else { - neTypes = append(neTypes, traceTask.NeType) - } - log.Debug("neTypes:", neTypes) - - traceTask.Status = "Inactive" - _, err = dborm.XormInsertTableOne("trace_task", traceTask) - if err != nil { - log.Error("Failed to dborm.XormInsertTableOne:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - - traceTask.NotifyUrl = config.GetYamlConfig().OMC.GtpUri - log.Trace("traceTask:", traceTask) - - for _, neType := range neTypes { - var neInfos []dborm.NeInfo - if traceTask.NeId == "" { - err := dborm.XormGetNeInfoByNeType(neType, &neInfos) - if err != nil { - log.Error("Failed to dborm.XormGetNeInfoByNeType:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } else { - neInfo, err := dborm.XormGetNeInfo(neType, traceTask.NeId) - if err != nil { - log.Error("Failed to dborm.XormGetNeInfoByNeType:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - neInfos = append(neInfos, *neInfo) - } - for _, neInfo := range neInfos { - hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) - requestURI2NF := fmt.Sprintf("%s%s", hostUri, UriTraceTaskV1) - log.Debug("requestURI2NF:", requestURI2NF) - - body, _ := json.Marshal(traceTask) - log.Debug("body:", string(body)) - resp, err := client.R(). - EnableTrace(). - SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). - SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). - SetBody(body). - Post(requestURI2NF) - if err != nil { - log.Error("Failed to Post:", err) - failNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.FailNEs = append(traceTask.FailNEs, failNE) - } else { - switch resp.StatusCode() { - case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted: - succNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.SuccNEs = append(traceTask.SuccNEs, succNE) - default: - log.Warnf("Post return code:%d, message:%s", resp.StatusCode(), string(resp.Body())) - failNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.FailNEs = append(traceTask.FailNEs, failNE) - } - } - } - } - - if len(traceTask.SuccNEs) > 0 { - traceTask.Status = "Active" - _, err = dborm.XormUpdateTableById(traceTask.Id, "trace_task", traceTask) - if err != nil { - log.Error("Failed to dborm.XormUpdateTableById:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - services.ResponseStatusOK204NoContent(w) - } else { - traceTask.Status = "Failed" - _, err = dborm.XormUpdateTableById(traceTask.Id, "trace_task", traceTask) - if err != nil { - log.Error("Failed to dborm.XormUpdateTableById:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - err = global.ErrTraceFailedDistributeToNEs - log.Error(err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } -} - -func PutTraceTaskToNF(w http.ResponseWriter, r *http.Request) { - log.Debug("PutTraceTaskToNF processing... ") - - //vars := mux.Vars(r) - - // token, err := services.CheckFrontValidRequest(w, r) - // if err != nil { - // log.Error("Request error:", err) - // return - // } - // log.Debug("AccessToken:", token) - - body, err := io.ReadAll(io.LimitReader(r.Body, int64(config.GetYamlConfig().Params.UriMaxLen))) - if err != nil { - log.Error("io.ReadAll is failed:", err) - services.ResponseNotFound404UriNotExist(w, r) - return - } - - traceTask := new(TraceTask) - _ = json.Unmarshal(body, traceTask) - - traceTask.NotifyUrl = config.GetYamlConfig().OMC.GtpUri - log.Debug("traceTask:", traceTask) - - var neTypes []string - // do not set device - if traceTask.NeType == "" { - // query neType by interface - if len(traceTask.Interfaces) > 0 { - err := dborm.XormGetSingleColStringArrayByIn("trace_info", "ne_type", "interface", traceTask.Interfaces, &neTypes) - if err != nil { - log.Error("Failed to dborm.XormGetSingleColStringArrayByIn:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } else { - neTypes = []string{"AMF", "SMF", "UDM", "AUSF", "UPF"} - } - - } else { - neTypes = append(neTypes, traceTask.NeType) - } - log.Debug("neTypes:", neTypes) - - for _, neType := range neTypes { - var neInfos []dborm.NeInfo - if traceTask.NeId == "" { - err := dborm.XormGetNeInfoByNeType(neType, &neInfos) - if err != nil { - log.Error("Failed to dborm.XormGetNeInfoByNeType:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } else { - neInfo, err := dborm.XormGetNeInfo(neType, traceTask.NeId) - if err != nil { - log.Error("Failed to dborm.XormGetNeInfoByNeType:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - neInfos = append(neInfos, *neInfo) - } - for _, neInfo := range neInfos { - hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) - requestURI2NF := fmt.Sprintf("%s%s", hostUri, UriTraceTaskV1) - log.Debug("requestURI2NF:", requestURI2NF) - - body, _ := json.Marshal(traceTask) - log.Debug("body:", string(body)) - resp, err := client.R(). - EnableTrace(). - SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). - SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). - SetBody(body). - Put(requestURI2NF) - if err != nil { - log.Error("Failed to Put:", err) - failNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.FailNEs = append(traceTask.FailNEs, failNE) - } else { - switch resp.StatusCode() { - case http.StatusOK, http.StatusCreated, http.StatusNoContent, http.StatusAccepted: - succNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.SuccNEs = append(traceTask.SuccNEs, succNE) - default: - log.Warn("Post return code:%d, message:%s", resp.StatusCode(), string(resp.Body())) - failNE := fmt.Sprintf("%s.%s", neInfo.NeType, neInfo.NeId) - traceTask.FailNEs = append(traceTask.FailNEs, failNE) - } - } - - } - } - - if len(traceTask.SuccNEs) > 0 { - traceTask.Status = "Active" - _, err = dborm.XormUpdateTableById(traceTask.Id, "trace_task", traceTask) - if err != nil { - log.Error("Failed to dborm.XormUpdateTableById:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - services.ResponseStatusOK204NoContent(w) - } else { - traceTask.Status = "Failed" - _, err = dborm.XormUpdateTableById(traceTask.Id, "trace_task", traceTask) - if err != nil { - log.Error("Failed to dborm.XormUpdateTableById:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - err = global.ErrTraceFailedDistributeToNEs - log.Error(err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } -} - -func DeleteTraceTaskToNF(w http.ResponseWriter, r *http.Request) { - log.Debug("DeleteTraceTaskToNF processing... ") - - // token, err := services.CheckFrontValidRequest(w, r) - // if err != nil { - // log.Error("Request error:", err) - // return - // } - // log.Debug("AccessToken:", token) - - vars := r.URL.Query() - ids, ok := vars["id"] - if !ok || len(ids) == 0 { - err := global.ErrTraceNotCarriedTaskID - log.Error(err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - log.Debug("ids:", ids) - - for _, id := range ids { - log.Debug("id:", id) - - var succNes []string - err := dborm.XormGetColStringArrayByWhere("trace_task", "succ_nes", fmt.Sprintf("id=%s", id), &succNes) - if err != nil { - log.Error("Failed to dborm.XormGetSingleColStringArrayByWhere:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - log.Debug("succNes:", succNes) - nes := new([]string) - if len(succNes) > 0 { - _ = json.Unmarshal([]byte(succNes[0]), nes) - } - log.Debug("nes:", nes) - - for _, ne := range *nes { - i := strings.Index(ne, ".") - neType := ne[0:i] - neId := ne[i+1:] - log.Debugf("ne:%s neType:%s neId:%s", ne, neType, neId) - neInfo, err := dborm.XormGetNeInfo(neType, neId) - if err != nil { - log.Error("Failed to dborm.XormGetNeInfo:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - - hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port) - requestURI2NF := fmt.Sprintf("%s%s?id=%s", hostUri, UriTraceTaskV1, id) - log.Debug("requestURI2NF:", requestURI2NF) - - _, err = client.R(). - EnableTrace(). - SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}). - SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}). - Delete(requestURI2NF) - if err != nil { - log.Error("Failed to Delete:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } - - _, err = dborm.XormDeleteDataByWhere(fmt.Sprintf("id=%s", id), "trace_task") - if err != nil { - log.Error("Failed to dborm.XormDeleteDataByWhere:", err) - services.ResponseInternalServerError500ProcessError(w, err) - return - } - } - services.ResponseStatusOK204NoContent(w) -} - -func GetRawMessage(w http.ResponseWriter, r *http.Request) { - log.Debug("GetRawMessage processing... ") - -} diff --git a/lib/routes/routes.go b/lib/routes/routes.go index 1b91d233..e276ef18 100644 --- a/lib/routes/routes.go +++ b/lib/routes/routes.go @@ -18,7 +18,6 @@ import ( "be.ems/features/security" "be.ems/features/sm" "be.ems/features/state" - "be.ems/features/trace" "be.ems/features/ue" "be.ems/lib/midware" "be.ems/lib/services" @@ -207,15 +206,6 @@ func init() { Register("PUT", cm.CustomUriSoftwareNE, cm.ActiveSoftwareToNF, nil) Register("PATCH", cm.CustomUriSoftwareNE, cm.RollBackSoftwareToNF, nil) - // Trace management 跟踪任务 - Register("POST", trace.UriTraceTask, trace.PostTraceTaskToNF, midware.LogOperate(collectlogs.OptionNew("Trace Task", collectlogs.BUSINESS_TYPE_INSERT))) - Register("PUT", trace.UriTraceTask, trace.PutTraceTaskToNF, midware.LogOperate(collectlogs.OptionNew("Trace Task", collectlogs.BUSINESS_TYPE_UPDATE))) - Register("DELETE", trace.UriTraceTask, trace.DeleteTraceTaskToNF, midware.LogOperate(collectlogs.OptionNew("Trace Task", collectlogs.BUSINESS_TYPE_DELETE))) - - Register("POST", trace.CustomUriTraceTask, trace.PostTraceTaskToNF, nil) - Register("PUT", trace.CustomUriTraceTask, trace.PutTraceTaskToNF, nil) - Register("DELETE", trace.CustomUriTraceTask, trace.DeleteTraceTaskToNF, nil) - // file management Register("POST", file.UriFile, file.UploadFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_INSERT))) Register("GET", file.UriFile, file.DownloadFile, midware.LogOperate(collectlogs.OptionNew("File", collectlogs.BUSINESS_TYPE_OTHER))) From c67fbb7998290ca69044eb2b8c2b0783d974202a Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 6 Jun 2025 15:02:45 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=BB=9F=E4=B8=80=E6=94=BE=E5=88=B0/usr/local/omc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 ++++++----- .../network_element/controller/action.go | 2 +- .../service/ne_config_backup.go | 4 +-- src/modules/trace/controller/packet.go | 2 +- src/modules/trace/controller/trace_task.go | 2 +- src/modules/trace/service/packet.go | 2 +- src/modules/trace/service/tcpdump.go | 28 +++++++++---------- .../trace/service/trace_task_udp_data.go | 2 +- 8 files changed, 31 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e0c32353..2c88408e 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,16 @@ ## 文件资源 -| 路径 | 说明 | -| --------------------- | -------------------------- | -| /usr/local/omc/static | 网管静态资源文件路径 | -| /usr/local/omc/upload | 网管上传文件资源路径 | -| /usr/local/omc/backup | 网管备份网元的数据路径 | -| /usr/local/etc/omc | 网管与网元之间相关文件 | -| /tmp/omc | 存放从网元拉取到本地的文件 | +| 路径 | 说明 | +| ---------------------- | -------------------------- | +| /usr/local/omc/static | 网管静态资源文件路径 | +| /usr/local/omc/upload | 网管上传文件资源路径 | +| /usr/local/omc/backup | 网管备份网元的数据路径 | +| /usr/local/omc/trace | 网管跟踪相关的数据路径 | +| /usr/local/omc/tcpdump | 网管 tcpdump 抓包件路径 | +| /usr/local/omc/packet | 网管信令抓包的数据路径 | +| /usr/local/etc/omc | 网管与网元之间相关文件 | +| /tmp/omc | 存放从网元拉取到本地的文件 | ## 端口 diff --git a/src/modules/network_element/controller/action.go b/src/modules/network_element/controller/action.go index 79722c99..6b3b5f24 100644 --- a/src/modules/network_element/controller/action.go +++ b/src/modules/network_element/controller/action.go @@ -83,7 +83,7 @@ func (s *NeActionController) PushFile(c *gin.Context) { // 本地文件 localFilePath := file.ParseUploadFileAbsPath(body.UploadPath) // 网元端临时目录 - sshClient.RunCMD("mkdir -p /tmp/omc/push && sudo chmod 777 -R /tmp/omc") + sshClient.RunCMD("sudo mkdir -p /tmp/omc/push && sudo chmod 755 -R /tmp/omc") neFilePath := filepath.ToSlash(filepath.Join("/tmp/omc/push", filepath.Base(localFilePath))) // 复制到远程 if err = sftpClient.CopyFileLocalToRemote(localFilePath, neFilePath); err != nil { diff --git a/src/modules/network_element/service/ne_config_backup.go b/src/modules/network_element/service/ne_config_backup.go index 784fac87..cdd623e0 100644 --- a/src/modules/network_element/service/ne_config_backup.go +++ b/src/modules/network_element/service/ne_config_backup.go @@ -94,7 +94,7 @@ func (s NeConfigBackup) FileLocalToNe(neInfo model.NeInfo, localFile string) err // 网元配置端上的临时目录 neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId) - sshClient.RunCMD(fmt.Sprintf("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc && sudo rm -rf %s", neDirTemp)) + sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p /tmp/omc/ne_config && sudo chmod 755 -R /tmp/omc && sudo rm -rf %s", neDirTemp)) // 复制到网元端 if err = sftpClient.CopyDirLocalToRemote(localDirPath, neDirTemp); err != nil { return fmt.Errorf("copy config to ne err") @@ -154,7 +154,7 @@ func (s NeConfigBackup) FileNeToLocal(neInfo model.NeInfo) (string, error) { localDirPath := fmt.Sprintf("%s/%s/%s/from_ne_tmp", omcPath, neTypeLower, neInfo.NeId) // 网元配置文件先复制到临时目录 - sshClient.RunCMD("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc") + sshClient.RunCMD("sudo mkdir -p /tmp/omc/ne_config && sudo chmod 755 -R /tmp/omc") neDirTemp := fmt.Sprintf("/tmp/omc/ne_config/%s/%s", neTypeLower, neInfo.NeId) if neTypeLower == "ims" { // ims目录 diff --git a/src/modules/trace/controller/packet.go b/src/modules/trace/controller/packet.go index 4eabce03..94ccf9e3 100644 --- a/src/modules/trace/controller/packet.go +++ b/src/modules/trace/controller/packet.go @@ -141,7 +141,7 @@ func (s *PacketController) FilePull(c *gin.Context) { return } fileName := fmt.Sprintf("%s.pcap", querys.TaskNo) - localFilePath := filepath.Join("/tmp/omc/packet", fileName) + localFilePath := filepath.Join("/usr/local/omc/packet", fileName) if runtime.GOOS == "windows" { localFilePath = fmt.Sprintf("C:%s", localFilePath) } diff --git a/src/modules/trace/controller/trace_task.go b/src/modules/trace/controller/trace_task.go index ae79e7a3..53f87757 100644 --- a/src/modules/trace/controller/trace_task.go +++ b/src/modules/trace/controller/trace_task.go @@ -121,7 +121,7 @@ func (s *TraceTaskController) FilePull(c *gin.Context) { } fileName := fmt.Sprintf("task_%s.pcap", querys.TraceId) - localFilePath := filepath.Join("/tmp/omc/trace", fileName) + localFilePath := filepath.Join("/usr/local/omc/trace", fileName) if runtime.GOOS == "windows" { localFilePath = fmt.Sprintf("C:%s", localFilePath) } diff --git a/src/modules/trace/service/packet.go b/src/modules/trace/service/packet.go index 5b92be60..eea0fd19 100644 --- a/src/modules/trace/service/packet.go +++ b/src/modules/trace/service/packet.go @@ -119,7 +119,7 @@ func (s *Packet) LiveStart(taskNo, deviceName, filterBPF string, outputPCAP bool var f *os.File if outputPCAP { // 网管本地路径 - localFilePath := fmt.Sprintf("/tmp/omc/packet/%s.pcap", taskNo) + localFilePath := fmt.Sprintf("/usr/local/omc/packet/%s.pcap", taskNo) if runtime.GOOS == "windows" { localFilePath = fmt.Sprintf("C:%s", localFilePath) } diff --git a/src/modules/trace/service/tcpdump.go b/src/modules/trace/service/tcpdump.go index e691b51d..baa772b8 100644 --- a/src/modules/trace/service/tcpdump.go +++ b/src/modules/trace/service/tcpdump.go @@ -54,9 +54,9 @@ func (s *TCPdump) DumpStart(neType, neId, cmdStr string) (string, error) { } taskCode := time.Now().Format("20060102150405") - // 存放文件目录 /tmp/omc/tcpdump/udm/001/20240817104241 - neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode) - sshClient.RunCMD(fmt.Sprintf("mkdir -p %s && sudo chmod 777 -R /tmp/omc", neDirTemp)) + // 存放文件目录 /usr/local/omc/tcpdump/udm/001/20240817104241 + neDirTemp := fmt.Sprintf("/usr/local/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode) + sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p %s && sudo chmod 755 -R /usr/local/omc/tcpdump", neDirTemp)) // 命令拼装 logPath := fmt.Sprintf("%s/tcpdump.log", neDirTemp) @@ -65,8 +65,8 @@ func (s *TCPdump) DumpStart(neType, neId, cmdStr string) (string, error) { filePath = fmt.Sprintf("%s/part_%%Y%%m%%d%%H%%M%%S.pcap ", neDirTemp) } sendCmd := fmt.Sprintf("sudo timeout 60m sudo tcpdump -i any %s -w %s > %s 2>&1 & echo $!", cmdStr, filePath, logPath) - // sudo timeout 60m sudo tcpdump -i any -n -s 0 -v -G 60 -W 6 -w /tmp/omc/tcpdump/udm/001/20240817104241/part_%Y-%m-%d_%H:%M:%S.pcap > /tmp/omc/tcpdump/udm/001/20240817104241/tcpdump.log 2>&1 & echo $! - // sudo timeout 60m sudo tcpdump -i any -n -s 0 -v -w /tmp/omc/tcpdump/udm/001/20240817105440/part_2024-08-17_10:54:40.pcap > /tmp/omc/tcpdump/udm/001/20240817105440/tcpdump.log 2>&1 & echo $! + // sudo timeout 60m sudo tcpdump -i any -n -s 0 -v -G 60 -W 6 -w /usr/local/omc/tcpdump/udm/001/20240817104241/part_%Y-%m-%d_%H:%M:%S.pcap > /usr/local/omc/tcpdump/udm/001/20240817104241/tcpdump.log 2>&1 & echo $! + // sudo timeout 60m sudo tcpdump -i any -n -s 0 -v -w /usr/local/omc/tcpdump/udm/001/20240817105440/part_2024-08-17_10:54:40.pcap > /usr/local/omc/tcpdump/udm/001/20240817105440/tcpdump.log 2>&1 & echo $! // // timeout 超时60分钟后发送kill命令,1分钟后强制终止命令。tcpdump -G 文件轮转间隔时间(秒) -W 文件轮转保留最近数量 // sudo timeout --kill-after=1m 60m sudo tcpdump -i any -n -s 0 -v -G 10 -W 7 -w /tmp/part_%Y%m%d%H%M%S.pcap > /tmp/part.log 2>&1 & echo $! @@ -119,11 +119,11 @@ func (s *TCPdump) DumpStop(neType, neId, taskCode string) ([]string, error) { } s.logFileLastLineToFile(PIDMap.(map[string]string), sshClient) - // 存放文件目录 /tmp/omc/tcpdump/udm/001/20240817104241 - neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode) + // 存放文件目录 /usr/local/omc/tcpdump/udm/001/20240817104241 + neDirTemp := fmt.Sprintf("/usr/local/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode) // 命令拼装 sendCmd := fmt.Sprintf("pids=$(pgrep -P %s) && [ -n \"$pids\" ] && sudo kill $pids;sudo timeout 2s ls %s", pid, neDirTemp) - // pids=$(pgrep -P 1914341) && [ -n "$pids" ] && sudo kill $pids;sudo timeout 2s ls /tmp/omc/tcpdump/udm/001/20240817104241 + // pids=$(pgrep -P 1914341) && [ -n "$pids" ] && sudo kill $pids;sudo timeout 2s ls /usr/local/omc/tcpdump/udm/001/20240817104241 output, err := sshClient.RunCMD(sendCmd) output = strings.TrimSpace(output) if err != nil || strings.HasPrefix(output, "ls: ") { @@ -158,7 +158,7 @@ func (s *TCPdump) logFileLastLine(neType string, sshClient *ssh.ConnSSH) map[str } for _, v := range logFileArr { - lastLine, err := sshClient.RunCMD(fmt.Sprintf("sed -n '$=' %s", v)) + lastLine, err := sshClient.RunCMD(fmt.Sprintf("sudo sed -n '$=' %s", v)) lastLine = strings.TrimSpace(lastLine) if err != nil || strings.HasPrefix(lastLine, "sed: can't") { logger.Errorf("logFileLastLine err: %s => %s", lastLine, err.Error()) @@ -181,9 +181,9 @@ func (s *TCPdump) logFileLastLineToFile(PIDMap map[string]string, sshClient *ssh neType := PIDMap["neType"] neId := PIDMap["neId"] taskCode := PIDMap["taskCode"] - // 存放文件目录 /tmp/omc/tcpdump/udm/001/20240817104241 - sshClient.RunCMD("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc") - neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", strings.ToLower(neType), neId, taskCode) + // 存放文件目录 /usr/local/omc/tcpdump/udm/001/20240817104241 + neDirTemp := fmt.Sprintf("/usr/local/omc/tcpdump/%s/%s/%s", strings.ToLower(neType), neId, taskCode) + sshClient.RunCMD(fmt.Sprintf("sudo mkdir -p %s && sudo chmod 755 -R /usr/local/omc/tcpdump", neDirTemp)) lastLineMap := s.logFileLastLine(neType, sshClient) for lastLogFile, lastFileLine := range lastLineMap { @@ -193,8 +193,8 @@ func (s *TCPdump) logFileLastLineToFile(PIDMap map[string]string, sshClient *ssh startFileLine = "1" // 起始行号从第一行开始 } outputFile := fmt.Sprintf("%s/%s", neDirTemp, filepath.Base(lastLogFile)) - sendCmd := fmt.Sprintf("sed -n \"%s,%sp\" \"%s\" > \"%s\"", startFileLine, lastFileLine, lastLogFile, outputFile) - // sed -n "1,5p" "/var/log/amf.log" > "/tmp/omc/tcpdump/amf/001/20241008141336/amf.log" + sendCmd := fmt.Sprintf("sudo sed -n \"%s,%sp\" \"%s\" | sudo tee \"%s\" > /dev/null", startFileLine, lastFileLine, lastLogFile, outputFile) + // sudo sed -n "1,5p" "/var/log/amf.log" | sudo tee "/usr/local/omc/tcpdump/amf/001/20241008141336/amf.log" > /dev/null output, err := sshClient.RunCMD(sendCmd) if err != nil || strings.HasPrefix(output, "stderr:") { logger.Errorf("logFileLastLineToFile err: %s => %s", strings.TrimSpace(output), err.Error()) diff --git a/src/modules/trace/service/trace_task_udp_data.go b/src/modules/trace/service/trace_task_udp_data.go index e4390bd5..7bd8c6f6 100644 --- a/src/modules/trace/service/trace_task_udp_data.go +++ b/src/modules/trace/service/trace_task_udp_data.go @@ -34,7 +34,7 @@ func traceHandler(data []byte) (*TraceMsgToOamTraceData, error) { } // 输出到文件 - filePath := fmt.Sprintf("/tmp/omc/trace/task_%d.pcap", decodeData.NfTraceMsg.TraceId) + filePath := fmt.Sprintf("/usr/local/omc/trace/task_%d.pcap", decodeData.NfTraceMsg.TraceId) if runtime.GOOS == "windows" { filePath = fmt.Sprintf("C:%s", filePath) } From 33b95a6e300e9d3c09887f92c5e3817177878dd5 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 7 Jun 2025 16:32:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix::=20=E8=AF=B7=E6=B1=82=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E7=A0=81=E7=94=A8=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/errorcatch/errorcatch.go | 6 +- src/framework/middleware/authorize_oauth2.go | 8 +- src/framework/middleware/authorize_user.go | 8 +- .../middleware/collectlogs/operate_log.go | 2 +- src/framework/middleware/crypto_api.go | 4 +- src/framework/middleware/operate_log.go | 2 +- src/framework/middleware/rate_limit.go | 26 +++---- src/framework/middleware/repeat_submit.go | 11 ++- src/framework/resp/api.go | 17 ---- src/framework/resp/code.go | 78 +++++++++++++++++++ src/modules/auth/controller/account.go | 10 +-- src/modules/auth/controller/register.go | 2 +- src/modules/chart/controller/chart_graph.go | 6 +- src/modules/common/controller/bootloader.go | 2 +- src/modules/common/controller/common.go | 2 +- src/modules/common/controller/file.go | 28 +++---- src/modules/monitor/controller/monitor.go | 2 +- src/modules/monitor/controller/sys_cache.go | 8 +- src/modules/monitor/controller/sys_job.go | 16 ++-- src/modules/monitor/controller/sys_job_log.go | 4 +- .../monitor/controller/sys_user_online.go | 2 +- .../network_data/controller/all_alarm.go | 10 +-- .../controller/all_alarm_forward.go | 2 +- .../network_data/controller/all_alarm_log.go | 4 +- .../network_data/controller/all_backup.go | 4 +- .../network_data/controller/all_kpi.go | 4 +- .../network_data/controller/all_nb_state.go | 4 +- .../network_data/controller/all_ne_state.go | 2 +- src/modules/network_data/controller/amf.go | 10 +-- src/modules/network_data/controller/ims.go | 8 +- src/modules/network_data/controller/mme.go | 10 +-- src/modules/network_data/controller/pcf.go | 12 +-- src/modules/network_data/controller/sgwc.go | 6 +- src/modules/network_data/controller/smf.go | 10 +-- src/modules/network_data/controller/smsc.go | 6 +- .../network_data/controller/udm_auth.go | 30 +++---- .../network_data/controller/udm_sub.go | 30 +++---- .../network_data/controller/udm_voip.go | 24 +++--- .../network_data/controller/udm_volte_ims.go | 22 +++--- src/modules/network_data/controller/upf.go | 2 +- .../network_element/controller/action.go | 12 +-- .../network_element/controller/ne_config.go | 18 ++--- .../controller/ne_config_backup.go | 10 +-- .../network_element/controller/ne_host.go | 18 ++--- .../network_element/controller/ne_host_cmd.go | 8 +- .../network_element/controller/ne_info.go | 24 +++--- .../network_element/controller/ne_license.go | 8 +- .../network_element/controller/ne_software.go | 14 ++-- .../network_element/controller/ne_version.go | 4 +- src/modules/oauth2/controller/oauth2.go | 14 ++-- .../oauth2/controller/oauth2_client.go | 12 +-- src/modules/system/controller/sys_config.go | 16 ++-- src/modules/system/controller/sys_dept.go | 20 ++--- .../system/controller/sys_dict_data.go | 14 ++-- .../system/controller/sys_dict_type.go | 12 +-- .../system/controller/sys_log_login.go | 2 +- src/modules/system/controller/sys_menu.go | 14 ++-- src/modules/system/controller/sys_post.go | 10 +-- src/modules/system/controller/sys_profile.go | 14 ++-- src/modules/system/controller/sys_role.go | 22 +++--- src/modules/system/controller/sys_user.go | 20 ++--- src/modules/tool/controller/iperf.go | 8 +- src/modules/tool/controller/ping.go | 10 +-- src/modules/trace/controller/packet.go | 10 +-- src/modules/trace/controller/tcpdump.go | 6 +- src/modules/trace/controller/trace_data.go | 4 +- src/modules/trace/controller/trace_task.go | 10 +-- .../trace/controller/trace_task_hlr.go | 18 ++--- src/modules/ws/controller/ws.go | 4 +- src/modules/ws/controller/ws_redis.go | 4 +- src/modules/ws/controller/ws_ssh.go | 4 +- src/modules/ws/controller/ws_telnet.go | 4 +- src/modules/ws/controller/ws_view.go | 4 +- 73 files changed, 441 insertions(+), 375 deletions(-) create mode 100644 src/framework/resp/code.go diff --git a/src/framework/errorcatch/errorcatch.go b/src/framework/errorcatch/errorcatch.go index 83f842b7..65cf82d2 100644 --- a/src/framework/errorcatch/errorcatch.go +++ b/src/framework/errorcatch/errorcatch.go @@ -20,14 +20,14 @@ func ErrorCatch() gin.HandlerFunc { // 返回错误响应给客户端 if config.Env() == "prod" { - c.JSON(500, resp.CodeMsg(500001, "Internal Server Errors")) + c.JSON(500, resp.CodeMsg(resp.CODE_INTERNAL, resp.MSG_INTERNAL)) } else { // 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获 switch v := err.(type) { case error: - c.JSON(500, resp.CodeMsg(500001, v.Error())) + c.JSON(500, resp.CodeMsg(resp.CODE_INTERNAL, v.Error())) default: - c.JSON(500, resp.CodeMsg(500001, fmt.Sprint(err))) + c.JSON(500, resp.CodeMsg(resp.CODE_INTERNAL, fmt.Sprint(err))) } } diff --git a/src/framework/middleware/authorize_oauth2.go b/src/framework/middleware/authorize_oauth2.go index 4705d6b7..c692448f 100644 --- a/src/framework/middleware/authorize_oauth2.go +++ b/src/framework/middleware/authorize_oauth2.go @@ -19,7 +19,7 @@ func AuthorizeOauth2(scope []string) gin.HandlerFunc { // 获取请求头标识信息 tokenStr := reqctx.Authorization(c) if tokenStr == "" { - c.JSON(401, resp.CodeMsg(401003, "authorization token is empty")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_NOTOKEN, "authorization token is empty")) c.Abort() // 停止执行后续的处理函数 return } @@ -27,7 +27,7 @@ func AuthorizeOauth2(scope []string) gin.HandlerFunc { // 验证令牌 claims, err := token.Oauth2TokenVerify(tokenStr, "access") if err != nil { - c.JSON(401, resp.CodeMsg(401001, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH, err.Error())) c.Abort() // 停止执行后续的处理函数 return } @@ -35,7 +35,7 @@ func AuthorizeOauth2(scope []string) gin.HandlerFunc { // 获取缓存的用户信息 info := token.Oauth2InfoGet(claims) if info.ClientId == "" { - c.JSON(401, resp.CodeMsg(401002, "invalid login user information")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, "invalid login user information")) c.Abort() // 停止执行后续的处理函数 return } @@ -54,7 +54,7 @@ func AuthorizeOauth2(scope []string) gin.HandlerFunc { } if !hasScope { msg := fmt.Sprintf("unauthorized access %s %s", c.Request.Method, c.Request.RequestURI) - c.JSON(403, resp.CodeMsg(403001, msg)) + c.JSON(403, resp.CodeMsg(resp.CODE_PERMISSION, msg)) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/authorize_user.go b/src/framework/middleware/authorize_user.go index f34d487e..45a6d51c 100644 --- a/src/framework/middleware/authorize_user.go +++ b/src/framework/middleware/authorize_user.go @@ -68,7 +68,7 @@ func AuthorizeUser(options map[string][]string) gin.HandlerFunc { // 获取请求头标识信息 tokenStr := reqctx.Authorization(c) if tokenStr == "" { - c.JSON(401, resp.CodeMsg(401003, "authorization token is empty")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_NOTOKEN, "authorization token is empty")) c.Abort() // 停止执行后续的处理函数 return } @@ -76,7 +76,7 @@ func AuthorizeUser(options map[string][]string) gin.HandlerFunc { // 验证令牌 claims, err := token.UserTokenVerify(tokenStr, "access") if err != nil { - c.JSON(401, resp.CodeMsg(401001, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH, err.Error())) c.Abort() // 停止执行后续的处理函数 return } @@ -84,7 +84,7 @@ func AuthorizeUser(options map[string][]string) gin.HandlerFunc { // 获取缓存的用户信息 info := token.UserInfoGet(claims) if info.UserId <= 0 { - c.JSON(401, resp.CodeMsg(401002, "invalid login user information")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, "invalid login user information")) c.Abort() // 停止执行后续的处理函数 return } @@ -100,7 +100,7 @@ func AuthorizeUser(options map[string][]string) gin.HandlerFunc { verifyOk := verifyRolePermission(roles, perms, options) if !verifyOk { msg := fmt.Sprintf("unauthorized access %s %s", c.Request.Method, c.Request.RequestURI) - c.JSON(403, resp.CodeMsg(403001, msg)) + c.JSON(403, resp.CodeMsg(resp.CODE_PERMISSION, msg)) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/collectlogs/operate_log.go b/src/framework/middleware/collectlogs/operate_log.go index 7407ce12..bf2490fd 100644 --- a/src/framework/middleware/collectlogs/operate_log.go +++ b/src/framework/middleware/collectlogs/operate_log.go @@ -103,7 +103,7 @@ func OperateLog(options Options) gin.HandlerFunc { // 获取登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/crypto_api.go b/src/framework/middleware/crypto_api.go index 5e98b2c5..db1b588d 100644 --- a/src/framework/middleware/crypto_api.go +++ b/src/framework/middleware/crypto_api.go @@ -51,7 +51,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc { // 是否存在data字段数据 if contentDe == "" { - c.JSON(422, resp.CodeMsg(422002, "decrypt not found field data")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "decrypt not found field data")) c.Abort() // 停止执行后续的处理函数 return } @@ -61,7 +61,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc { dataBodyStr, err := crypto.AESDecryptBase64(contentDe, apiKey) if err != nil { logger.Errorf("CryptoApi decrypt err => %v", err) - c.JSON(422, resp.CodeMsg(422001, "decrypted data could not be parsed")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, "decrypted data could not be parsed")) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/operate_log.go b/src/framework/middleware/operate_log.go index d31c6d63..61346792 100644 --- a/src/framework/middleware/operate_log.go +++ b/src/framework/middleware/operate_log.go @@ -88,7 +88,7 @@ func OperateLog(options Options) gin.HandlerFunc { // 获取登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, "invalid login user information")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, "invalid login user information")) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/rate_limit.go b/src/framework/middleware/rate_limit.go index d5cefe70..0a76a0bd 100644 --- a/src/framework/middleware/rate_limit.go +++ b/src/framework/middleware/rate_limit.go @@ -2,7 +2,6 @@ package middleware import ( "fmt" - "strings" "time" "github.com/gin-gonic/gin" @@ -12,6 +11,7 @@ import ( "be.ems/src/framework/ip2region" "be.ems/src/framework/reqctx" "be.ems/src/framework/resp" + "be.ems/src/framework/utils/crypto" ) const ( @@ -39,7 +39,7 @@ type LimitOption struct { // 参数表示:5秒内,最多请求10次,限制类型为 IP // // 使用 USER 时,请在用户身份授权认证校验后使用 -// 以便获取登录用户信息,无用户信息时默认为 GLOBAL +// 以便获取登录用户信息,无用户信息时默认为 LIMIT_GLOBAL func RateLimit(option LimitOption) gin.HandlerFunc { return func(c *gin.Context) { // 初始可选参数数据 @@ -55,38 +55,38 @@ func RateLimit(option LimitOption) gin.HandlerFunc { // 获取执行函数名称 funcName := c.HandlerName() - lastDotIndex := strings.LastIndex(funcName, "/") - funcName = funcName[lastDotIndex+1:] // 生成限流key - limitKey := constants.CACHE_RATE_LIMIT + ":" + funcName + limitKey := constants.CACHE_RATE_LIMIT + ":" + crypto.MD5(funcName) // 用户 if option.Type == LIMIT_USER { - loginUser, err := reqctx.LoginUser(c) - if err != nil { - c.JSON(401, resp.CodeMsg(401002, "invalid login user information")) + userId := reqctx.LoginUserToUserID(c) + if userId <= 0 { + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, "invalid login user information")) c.Abort() // 停止执行后续的处理函数 return } - limitKey = fmt.Sprintf("%s:%d:%s", constants.CACHE_RATE_LIMIT, loginUser.UserId, funcName) + funcMd5 := crypto.MD5(fmt.Sprintf("%d:%s", userId, funcName)) + limitKey = constants.CACHE_RATE_LIMIT + ":" + funcMd5 } // IP if option.Type == LIMIT_IP { clientIP := ip2region.ClientIP(c.ClientIP()) - limitKey = constants.CACHE_RATE_LIMIT + ":" + clientIP + ":" + funcName + funcMd5 := crypto.MD5(fmt.Sprintf("%s:%s", clientIP, funcName)) + limitKey = constants.CACHE_RATE_LIMIT + ":" + funcMd5 } // 在Redis查询并记录请求次数 rateCount, err := redis.RateLimit("", limitKey, option.Time, option.Count) if err != nil { - c.JSON(200, resp.ErrMsg("access too often, please try again later")) + c.JSON(200, resp.CodeMsg(resp.CODE_RATELIMIT, resp.MSG_RATELIMIT)) c.Abort() // 停止执行后续的处理函数 return } rateTime, err := redis.GetExpire("", limitKey) if err != nil { - c.JSON(200, resp.ErrMsg("access too often, please try again later")) + c.JSON(200, resp.CodeMsg(resp.CODE_RATELIMIT, resp.MSG_RATELIMIT)) c.Abort() // 停止执行后续的处理函数 return } @@ -97,7 +97,7 @@ func RateLimit(option LimitOption) gin.HandlerFunc { c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+rateTime)) // 重置时间戳 if rateCount >= option.Count { - c.JSON(200, resp.ErrMsg("access too often, please try again later")) + c.JSON(200, resp.CodeMsg(resp.CODE_RATELIMIT, resp.MSG_RATELIMIT)) c.Abort() // 停止执行后续的处理函数 return } diff --git a/src/framework/middleware/repeat_submit.go b/src/framework/middleware/repeat_submit.go index ccc69043..2ae4b4cc 100644 --- a/src/framework/middleware/repeat_submit.go +++ b/src/framework/middleware/repeat_submit.go @@ -2,7 +2,7 @@ package middleware import ( "encoding/json" - "strconv" + "fmt" "time" "github.com/gin-gonic/gin" @@ -13,6 +13,7 @@ import ( "be.ems/src/framework/logger" "be.ems/src/framework/reqctx" "be.ems/src/framework/resp" + "be.ems/src/framework/utils/crypto" ) // repeatParam 重复提交参数的类型定义 @@ -40,9 +41,12 @@ func RepeatSubmit(interval int64) gin.HandlerFunc { } paramsJSONStr := string(paramsJSONByte) + // 获取执行函数名称 + funcName := c.HandlerName() // 唯一标识(指定key + 客户端IP + 请求地址) clientIP := ip2region.ClientIP(c.ClientIP()) - repeatKey := constants.CACHE_REPEAT_SUBMIT + ":" + clientIP + ":" + c.Request.RequestURI + funcMd5 := crypto.MD5(fmt.Sprintf("%s:%s", clientIP, funcName)) + repeatKey := constants.CACHE_REPEAT_SUBMIT + ":" + funcMd5 // 在Redis查询并记录请求次数 repeatStr, _ := redis.Get("", repeatKey) @@ -56,7 +60,8 @@ func RepeatSubmit(interval int64) gin.HandlerFunc { compareParams := rp.Params == paramsJSONStr // 设置重复提交声明响应头(毫秒) - c.Header("X-RepeatSubmit-Rest", strconv.FormatInt(time.Now().Add(time.Duration(compareTime)*time.Second).UnixNano()/int64(time.Millisecond), 10)) + t := time.Now().Add(time.Duration(compareTime) * time.Second) + c.Header("X-RepeatSubmit-Rest", fmt.Sprint(t.UnixMilli())) // 小于间隔时间且参数内容一致 if compareTime < interval && compareParams { diff --git a/src/framework/resp/api.go b/src/framework/resp/api.go index 4b6422cf..5bfbd7d3 100644 --- a/src/framework/resp/api.go +++ b/src/framework/resp/api.go @@ -1,22 +1,5 @@ package resp -const ( - // CODE_ERROR 响应-code错误失败 - CODE_ERROR = 400001 - // MSG_ERROR 响应-msg错误失败 - MSG_ERROR = "error" - - // CODE_SUCCESS 响应-msg正常成功 - CODE_SUCCESS = 200001 - // MSG_SUCCCESS 响应-code正常成功 - MSG_SUCCCESS = "success" - - // 响应-code加密数据 - CODE_ENCRYPT = 200999 - // 响应-msg加密数据 - MSG_ENCRYPT = "encrypt" -) - // Resp 响应结构体 type Resp struct { Code int `json:"code"` // 响应状态码 diff --git a/src/framework/resp/code.go b/src/framework/resp/code.go new file mode 100644 index 00000000..bd6a5ed9 --- /dev/null +++ b/src/framework/resp/code.go @@ -0,0 +1,78 @@ +package resp + +// |HTTP|状态码|描述|排查建议| +// |----|----|----|----| +// |500 |500001 |internal error|服务内部错误| +// |200 |200999 |encrypt|正常请求加密数据| +// |200 |200001 |request success|正常请求成功| +// |200 |400001 |exist error|正常请求错误信息| +// |200 |400002 |ratelimit over|请求限流| +// |401 |401001 |authentication error|身份认证失败或者过期| +// |401 |401002 |authentication invalid error|无效身份信息| +// |401 |401003 |authorization token error|令牌字符为空| +// |401 |401004 |device fingerprint mismatch|设备指纹信息不匹配| +// |403 |403001 |permission error|权限未分配| +// |422 |422001 |params error|参数接收解析错误| +// |422 |422002 |params error|参数属性传入错误| + +// ====== 500 ====== +const ( + // CODE_ERROR_INTERNAL 响应-code服务内部错误 + CODE_INTERNAL = 500001 + // MSG_ERROR_INTERNAL 响应-msg服务内部错误 + MSG_INTERNAL = "internal error" +) + +// ====== 200 ====== +const ( + // CODE_ENCRYPT 响应-code加密数据 + CODE_ENCRYPT = 200999 + // MSG_ENCRYPT 响应-msg加密数据 + MSG_ENCRYPT = "encrypt" + + // CODE_SUCCESS 响应-code正常成功 + CODE_SUCCESS = 200001 + // MSG_SUCCCESS 响应-msg正常成功 + MSG_SUCCCESS = "success" + + // CODE_ERROR 响应-code错误失败 + CODE_ERROR = 400001 + // MSG_ERROR 响应-msg错误失败 + MSG_ERROR = "error" + + // CODE_RATELIMIT 响应-code错误失败 + CODE_RATELIMIT = 400002 + // MSG_RATELIMIT 响应-msg错误失败 + MSG_RATELIMIT = "access too often, please try again later" +) + +// ====== 401 ====== +const ( + // CODE_ERROR 响应-code身份认证失败或者过期 + CODE_AUTH = 401001 + + // CODE_AUTH_INVALID 响应-code无效身份信息 + CODE_AUTH_INVALID = 401002 + + // CODE_AUTH_NOTOKEN 响应-code令牌字符为空 + CODE_AUTH_NOTOKEN = 401003 + + // CODE_AUTH_DEVICE 响应-code设备指纹信息不匹配 + CODE_AUTH_DEVICE = 401004 + // MSG_AUTH_DEVICE 响应-msg设备指纹信息不匹配 + MSG_AUTH_DEVICE = "device fingerprint mismatch" +) + +// ====== 403 ====== +const ( + // CODE_PERMISSION 响应-code权限未分配 + CODE_PERMISSION = 403001 +) + +// ====== 422 ====== +const ( + // CODE_PARAM_PARSER 响应-code参数接收解析错误 + CODE_PARAM_PARSER = 422001 + // CODE_PARAM_CHEACK 响应-code参数属性传入错误 + CODE_PARAM_CHEACK = 422002 +) diff --git a/src/modules/auth/controller/account.go b/src/modules/auth/controller/account.go index 8592b597..e3584682 100644 --- a/src/modules/auth/controller/account.go +++ b/src/modules/auth/controller/account.go @@ -50,7 +50,7 @@ func (s AccountController) Login(c *gin.Context) { var body model.LoginBody if err := c.ShouldBindJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -154,14 +154,14 @@ func (s AccountController) RefreshToken(c *gin.Context) { } if err := c.ShouldBindJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 验证刷新令牌是否有效 claims, err := token.UserTokenVerify(body.RefreshToken, "refresh") if err != nil { - c.JSON(401, resp.CodeMsg(401001, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, err.Error())) return } userId := parse.Number(claims[constants.JWT_USER_ID]) @@ -177,7 +177,7 @@ func (s AccountController) RefreshToken(c *gin.Context) { deviceId := fmt.Sprint(claims[constants.JWT_DEVICE_ID]) deviceFingerprint := reqctx.DeviceFingerprint(c, userId) if deviceId != deviceFingerprint { - c.JSON(200, resp.ErrMsg("device fingerprint mismatch")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_DEVICE, resp.MSG_AUTH_DEVICE)) return } @@ -238,7 +238,7 @@ func (s AccountController) Me(c *gin.Context) { language := reqctx.AcceptLanguage(c) info, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, err.Error())) return } diff --git a/src/modules/auth/controller/register.go b/src/modules/auth/controller/register.go index ba436ed4..cb77b715 100644 --- a/src/modules/auth/controller/register.go +++ b/src/modules/auth/controller/register.go @@ -37,7 +37,7 @@ func (s RegisterController) Register(c *gin.Context) { var body model.RegisterBody if err := c.ShouldBindJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/chart/controller/chart_graph.go b/src/modules/chart/controller/chart_graph.go index e55b4e9c..58c6458e 100644 --- a/src/modules/chart/controller/chart_graph.go +++ b/src/modules/chart/controller/chart_graph.go @@ -60,7 +60,7 @@ func (s *ChartGraphController) Load(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -92,7 +92,7 @@ func (s *ChartGraphController) Save(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -125,7 +125,7 @@ func (s *ChartGraphController) Save(c *gin.Context) { func (s *ChartGraphController) Delete(c *gin.Context) { group := c.Param("group") if group == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: group is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: group is empty")) return } diff --git a/src/modules/common/controller/bootloader.go b/src/modules/common/controller/bootloader.go index 74b0e3cc..9ee3b068 100644 --- a/src/modules/common/controller/bootloader.go +++ b/src/modules/common/controller/bootloader.go @@ -146,7 +146,7 @@ func (s *BootloaderController) Account(c *gin.Context) { } if err := c.ShouldBindJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/common/controller/common.go b/src/modules/common/controller/common.go index a8ae0708..ce24fe05 100644 --- a/src/modules/common/controller/common.go +++ b/src/modules/common/controller/common.go @@ -33,7 +33,7 @@ func (s CommonController) Hash(c *gin.Context) { } if err := c.ShouldBindJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/common/controller/file.go b/src/modules/common/controller/file.go index 52ad5b87..b212e66c 100644 --- a/src/modules/common/controller/file.go +++ b/src/modules/common/controller/file.go @@ -34,13 +34,13 @@ func (s *FileController) Download(c *gin.Context) { language := reqctx.AcceptLanguage(c) filePath := c.Param("filePath") if len(filePath) < 8 { - c.JSON(422, resp.CodeMsg(422002, i18n.TKey(language, "app.common.err400"))) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, i18n.TKey(language, "app.common.err400"))) return } // base64解析出地址 decodedBytes, err := base64.StdEncoding.DecodeString(filePath) if err != nil { - c.JSON(422, resp.CodeMsg(422002, err.Error())) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, err.Error())) return } routerPath := string(decodedBytes) @@ -87,14 +87,14 @@ func (s *FileController) Upload(c *gin.Context) { // 上传的文件 formFile, err := c.FormFile("file") if err != nil { - c.JSON(422, resp.CodeMsg(422002, "bind err: file is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: file is empty")) return } // 子路径需要在指定范围内 subPath := c.PostForm("subPath") _, ok := constants.UPLOAD_SUB_PATH[subPath] if subPath != "" && !ok { - c.JSON(422, resp.CodeMsg(422002, "bind err: subPath not in range")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: subPath not in range")) return } if subPath == "" { @@ -136,7 +136,7 @@ func (s *FileController) ChunkCheck(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -170,12 +170,12 @@ func (s *FileController) ChunkMerge(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 子路径需要在指定范围内 if _, ok := constants.UPLOAD_SUB_PATH[body.SubPath]; body.SubPath != "" && !ok { - c.JSON(422, resp.CodeMsg(422002, "bind err: subPath not in range")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: subPath not in range")) return } if body.SubPath == "" { @@ -218,13 +218,13 @@ func (s *FileController) ChunkUpload(c *gin.Context) { // 切片唯一标识 identifier := c.PostForm("identifier") if index == "" || identifier == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: index and identifier must be set")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: index and identifier must be set")) return } // 上传的文件 formFile, err := c.FormFile("file") if err != nil { - c.JSON(422, resp.CodeMsg(422002, "bind err: file is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: file is empty")) return } @@ -262,7 +262,7 @@ func (s *FileController) List(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -322,12 +322,12 @@ func (s *FileController) File(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 检查路径是否在允许的目录范围内 - allowedPaths := []string{"/var/log", "/tmp", "/usr/local/omc/backup"} + allowedPaths := []string{"/var/log", "/tmp", "/usr/local/omc"} allowed := false for _, p := range allowedPaths { if strings.HasPrefix(querys.Path, p) { @@ -373,7 +373,7 @@ func (s *FileController) Remove(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -418,7 +418,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/monitor/controller/monitor.go b/src/modules/monitor/controller/monitor.go index e2387b3d..e421abdc 100644 --- a/src/modules/monitor/controller/monitor.go +++ b/src/modules/monitor/controller/monitor.go @@ -50,7 +50,7 @@ func (s *MonitorController) Load(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/monitor/controller/sys_cache.go b/src/modules/monitor/controller/sys_cache.go index 8cf61a31..73679b77 100644 --- a/src/modules/monitor/controller/sys_cache.go +++ b/src/modules/monitor/controller/sys_cache.go @@ -73,7 +73,7 @@ func (s SysCacheController) Keys(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -96,7 +96,7 @@ func (s SysCacheController) Value(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -165,7 +165,7 @@ func (s SysCacheController) CleanKeys(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if constants.CACHE_TOKEN_DEVICE == query.CacheName { @@ -196,7 +196,7 @@ func (s SysCacheController) CleanValue(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/monitor/controller/sys_job.go b/src/modules/monitor/controller/sys_job.go index f325e852..2dbdc953 100644 --- a/src/modules/monitor/controller/sys_job.go +++ b/src/modules/monitor/controller/sys_job.go @@ -64,7 +64,7 @@ func (s *SysJobController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) jobId := parse.Number(c.Param("jobId")) if jobId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: jobId is empty")) return } @@ -87,11 +87,11 @@ func (s *SysJobController) Add(c *gin.Context) { var body model.SysJob if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.JobId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: jobId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: jobId not is empty")) return } @@ -143,11 +143,11 @@ func (s *SysJobController) Edit(c *gin.Context) { var body model.SysJob if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.JobId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: jobId is empty")) return } @@ -229,7 +229,7 @@ func (s *SysJobController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) jobId := c.Param("jobId") if jobId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: jobId is empty")) return } @@ -261,7 +261,7 @@ func (s *SysJobController) Status(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -299,7 +299,7 @@ func (s *SysJobController) Run(c *gin.Context) { language := reqctx.AcceptLanguage(c) jobId := parse.Number(c.Param("jobId")) if jobId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: jobId is empty")) return } diff --git a/src/modules/monitor/controller/sys_job_log.go b/src/modules/monitor/controller/sys_job_log.go index 633654a8..8b4d60d0 100644 --- a/src/modules/monitor/controller/sys_job_log.go +++ b/src/modules/monitor/controller/sys_job_log.go @@ -73,7 +73,7 @@ func (s *SysJobLogController) List(c *gin.Context) { func (s *SysJobLogController) Info(c *gin.Context) { logId := parse.Number(c.Param("logId")) if logId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: logId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: logId is empty")) return } @@ -92,7 +92,7 @@ func (s *SysJobLogController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) logId := c.Param("logId") if logId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: logId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: logId is empty")) return } diff --git a/src/modules/monitor/controller/sys_user_online.go b/src/modules/monitor/controller/sys_user_online.go index 0e275d92..4cc8d8d5 100644 --- a/src/modules/monitor/controller/sys_user_online.go +++ b/src/modules/monitor/controller/sys_user_online.go @@ -122,7 +122,7 @@ func (s *SysUserOnlineController) List(c *gin.Context) { func (s SysUserOnlineController) Logout(c *gin.Context) { tokenIdStr := c.Param("tokenId") if tokenIdStr == "" || strings.Contains(tokenIdStr, "*") { - c.JSON(422, resp.CodeMsg(422002, "bind err: tokenId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: tokenId is empty")) return } diff --git a/src/modules/network_data/controller/all_alarm.go b/src/modules/network_data/controller/all_alarm.go index a0840116..c2918524 100644 --- a/src/modules/network_data/controller/all_alarm.go +++ b/src/modules/network_data/controller/all_alarm.go @@ -57,7 +57,7 @@ func (s AlarmController) List(c *gin.Context) { var query model.AlarmQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查询数据 @@ -72,7 +72,7 @@ func (s AlarmController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -102,7 +102,7 @@ func (s AlarmController) Clear(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -125,7 +125,7 @@ func (s AlarmController) Ack(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -168,7 +168,7 @@ func (s AlarmController) Export(c *gin.Context) { var query model.AlarmQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 diff --git a/src/modules/network_data/controller/all_alarm_forward.go b/src/modules/network_data/controller/all_alarm_forward.go index a54960c4..688b83f1 100644 --- a/src/modules/network_data/controller/all_alarm_forward.go +++ b/src/modules/network_data/controller/all_alarm_forward.go @@ -43,7 +43,7 @@ func (s AlarmForwardController) List(c *gin.Context) { var query model.AlarmForwardLogQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查询数据 diff --git a/src/modules/network_data/controller/all_alarm_log.go b/src/modules/network_data/controller/all_alarm_log.go index cbcb759d..4817d475 100644 --- a/src/modules/network_data/controller/all_alarm_log.go +++ b/src/modules/network_data/controller/all_alarm_log.go @@ -49,7 +49,7 @@ func (s AlarmLogController) List(c *gin.Context) { var query model.AlarmLogQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查询数据 @@ -82,7 +82,7 @@ func (s AlarmLogController) Event(c *gin.Context) { var query model.AlarmEventQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查询数据 diff --git a/src/modules/network_data/controller/all_backup.go b/src/modules/network_data/controller/all_backup.go index 3b4d4c55..77a9d0ea 100644 --- a/src/modules/network_data/controller/all_backup.go +++ b/src/modules/network_data/controller/all_backup.go @@ -35,7 +35,7 @@ func (s BackupController) FTPUpdate(c *gin.Context) { var body model.BackupDataFTP if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -72,7 +72,7 @@ func (s BackupController) FTPPush(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 判断路径是否合法 diff --git a/src/modules/network_data/controller/all_kpi.go b/src/modules/network_data/controller/all_kpi.go index 96112389..6ba91898 100644 --- a/src/modules/network_data/controller/all_kpi.go +++ b/src/modules/network_data/controller/all_kpi.go @@ -49,7 +49,7 @@ func (s KPIController) KPIData(c *gin.Context) { var querys model.KPIQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -82,7 +82,7 @@ func (s KPIController) KPIData(c *gin.Context) { func (s KPIController) KPITitle(c *gin.Context) { neType := c.Query("neType") if neType == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neType is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neType is empty")) return } kpiTitles := s.kpiReportService.FindTitle(neType) diff --git a/src/modules/network_data/controller/all_nb_state.go b/src/modules/network_data/controller/all_nb_state.go index 8b95b553..2813d405 100644 --- a/src/modules/network_data/controller/all_nb_state.go +++ b/src/modules/network_data/controller/all_nb_state.go @@ -53,7 +53,7 @@ func (s NBStateController) List(c *gin.Context) { var query model.NBStateQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -89,7 +89,7 @@ func (s NBStateController) Export(c *gin.Context) { var querys model.NBStateQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 diff --git a/src/modules/network_data/controller/all_ne_state.go b/src/modules/network_data/controller/all_ne_state.go index 66862313..7173ef7c 100644 --- a/src/modules/network_data/controller/all_ne_state.go +++ b/src/modules/network_data/controller/all_ne_state.go @@ -49,7 +49,7 @@ func (s NEStateController) List(c *gin.Context) { var query model.NEStateQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/amf.go b/src/modules/network_data/controller/amf.go index d15c0589..51cc8fbb 100644 --- a/src/modules/network_data/controller/amf.go +++ b/src/modules/network_data/controller/amf.go @@ -52,7 +52,7 @@ func (s *AMFController) UEList(c *gin.Context) { var querys model.UEEventAMFQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -86,7 +86,7 @@ func (s *AMFController) UERemove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -126,7 +126,7 @@ func (s *AMFController) UEExport(c *gin.Context) { var querys model.UEEventAMFQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 @@ -181,7 +181,7 @@ func (s *AMFController) NbInfoList(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -221,7 +221,7 @@ func (s *AMFController) NbStateList(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Query("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } diff --git a/src/modules/network_data/controller/ims.go b/src/modules/network_data/controller/ims.go index f726bbf6..08861dd2 100644 --- a/src/modules/network_data/controller/ims.go +++ b/src/modules/network_data/controller/ims.go @@ -53,7 +53,7 @@ func (s *IMSController) CDRList(c *gin.Context) { var querys model.CDREventIMSQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -127,7 +127,7 @@ func (s *IMSController) CDRExport(c *gin.Context) { var querys model.CDREventIMSQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 @@ -177,7 +177,7 @@ func (s *IMSController) UeSessionNum(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Query("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } @@ -222,7 +222,7 @@ func (s *IMSController) UeSessionList(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/mme.go b/src/modules/network_data/controller/mme.go index 47c5dca5..a64e15da 100644 --- a/src/modules/network_data/controller/mme.go +++ b/src/modules/network_data/controller/mme.go @@ -52,7 +52,7 @@ func (s *MMEController) UEList(c *gin.Context) { var querys model.UEEventMMEQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -86,7 +86,7 @@ func (s *MMEController) UERemove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -126,7 +126,7 @@ func (s *MMEController) UEExport(c *gin.Context) { var querys model.UEEventMMEQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 @@ -181,7 +181,7 @@ func (s *MMEController) NbInfoList(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -221,7 +221,7 @@ func (s *MMEController) NbStateList(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Query("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } diff --git a/src/modules/network_data/controller/pcf.go b/src/modules/network_data/controller/pcf.go index 697746f6..ffdaa745 100644 --- a/src/modules/network_data/controller/pcf.go +++ b/src/modules/network_data/controller/pcf.go @@ -48,7 +48,7 @@ func (s PCFController) RuleInfoList(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -104,7 +104,7 @@ func (s PCFController) RuleInfoAdd(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -161,7 +161,7 @@ func (s PCFController) RuleInfoEdit(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -210,7 +210,7 @@ func (s PCFController) RuleInfoRemove(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -257,7 +257,7 @@ func (s PCFController) RuleInfoExport(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -304,7 +304,7 @@ func (s PCFController) RuleInfoImport(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/sgwc.go b/src/modules/network_data/controller/sgwc.go index c233b6e7..8c72f621 100644 --- a/src/modules/network_data/controller/sgwc.go +++ b/src/modules/network_data/controller/sgwc.go @@ -53,7 +53,7 @@ func (s *SGWCController) CDRList(c *gin.Context) { var querys model.CDREventSGWCQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -87,7 +87,7 @@ func (s *SGWCController) CDRRemove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -127,7 +127,7 @@ func (s *SGWCController) CDRExport(c *gin.Context) { var querys model.CDREventSGWCQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 diff --git a/src/modules/network_data/controller/smf.go b/src/modules/network_data/controller/smf.go index 003d8058..9e382bff 100644 --- a/src/modules/network_data/controller/smf.go +++ b/src/modules/network_data/controller/smf.go @@ -55,7 +55,7 @@ func (s *SMFController) CDRList(c *gin.Context) { var querys model.CDREventSMFQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -89,7 +89,7 @@ func (s *SMFController) CDRRemove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -129,7 +129,7 @@ func (s *SMFController) CDRExport(c *gin.Context) { var querys model.CDREventSMFQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 @@ -182,7 +182,7 @@ func (s *SMFController) SubUserNum(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -231,7 +231,7 @@ func (s *SMFController) SubUserList(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/smsc.go b/src/modules/network_data/controller/smsc.go index bb7df155..fc9420e0 100644 --- a/src/modules/network_data/controller/smsc.go +++ b/src/modules/network_data/controller/smsc.go @@ -52,7 +52,7 @@ func (s *SMSCController) CDRList(c *gin.Context) { var querys model.CDREventSMSCQuery if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -86,7 +86,7 @@ func (s *SMSCController) CDRRemove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -126,7 +126,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) { var querys model.CDREventSMSCQuery if err := c.ShouldBindBodyWithJSON(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 限制导出数据集 diff --git a/src/modules/network_data/controller/udm_auth.go b/src/modules/network_data/controller/udm_auth.go index b84d0619..f2e62e98 100644 --- a/src/modules/network_data/controller/udm_auth.go +++ b/src/modules/network_data/controller/udm_auth.go @@ -51,7 +51,7 @@ type UDMAuthController struct { func (s *UDMAuthController) ResetData(c *gin.Context) { neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } @@ -100,7 +100,7 @@ func (s *UDMAuthController) Info(c *gin.Context) { neId := c.Param("neId") imsi := c.Param("imsi") if neId == "" || imsi == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi is empty")) return } @@ -155,18 +155,18 @@ func (s *UDMAuthController) Add(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMAuthUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty")) return } @@ -220,18 +220,18 @@ func (s *UDMAuthController) Adds(c *gin.Context) { neId := c.Param("neId") num := c.Param("num") if neId == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/num is empty")) return } var body model.UDMAuthUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty")) return } @@ -283,18 +283,18 @@ func (s *UDMAuthController) Edit(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMAuthUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty")) return } @@ -347,7 +347,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) { neId := c.Param("neId") imsi := c.Param("imsi") if neId == "" || imsi == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi is empty")) return } @@ -413,7 +413,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) { imsi := c.Param("imsi") num := c.Param("num") if neId == "" || imsi == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi/num is empty")) return } @@ -469,7 +469,7 @@ func (s *UDMAuthController) Export(c *gin.Context) { neId := c.Query("neId") fileType := c.Query("type") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } if !(fileType == "csv" || fileType == "txt") { @@ -557,7 +557,7 @@ func (s *UDMAuthController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/udm_sub.go b/src/modules/network_data/controller/udm_sub.go index bd0450ab..6a1d40a1 100644 --- a/src/modules/network_data/controller/udm_sub.go +++ b/src/modules/network_data/controller/udm_sub.go @@ -50,7 +50,7 @@ type UDMSubController struct { func (s *UDMSubController) ResetData(c *gin.Context) { neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } @@ -100,7 +100,7 @@ func (s *UDMSubController) Info(c *gin.Context) { neId := c.Param("neId") imsi := c.Param("imsi") if neId == "" || imsi == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or imsi is empty")) return } @@ -155,18 +155,18 @@ func (s *UDMSubController) Add(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMSubUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if len(body.IMSI) != 15 { - c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: IMSI length is not 15 bits")) return } @@ -221,18 +221,18 @@ func (s *UDMSubController) Adds(c *gin.Context) { neId := c.Param("neId") num := c.Param("num") if neId == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/num is empty")) return } var body model.UDMSubUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if len(body.IMSI) != 15 { - c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: IMSI length is not 15 bits")) return } @@ -287,18 +287,18 @@ func (s *UDMSubController) Edit(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMSubUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if len(body.IMSI) != 15 { - c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: IMSI length is not 15 bits")) return } @@ -352,7 +352,7 @@ func (s *UDMSubController) Remove(c *gin.Context) { neId := c.Param("neId") imsi := c.Param("imsi") if neId == "" || len(imsi) < 15 { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi is empty")) return } @@ -418,7 +418,7 @@ func (s *UDMSubController) Removes(c *gin.Context) { imsi := c.Param("imsi") num := c.Param("num") if neId == "" || len(imsi) < 15 || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi/num is empty")) return } @@ -475,7 +475,7 @@ func (s *UDMSubController) Export(c *gin.Context) { neId := c.Query("neId") fileType := c.Query("type") if neId == "" || fileType == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or type is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or type is empty")) return } if !(fileType == "csv" || fileType == "txt") { @@ -555,7 +555,7 @@ func (s *UDMSubController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/udm_voip.go b/src/modules/network_data/controller/udm_voip.go index ff19519f..933092fb 100644 --- a/src/modules/network_data/controller/udm_voip.go +++ b/src/modules/network_data/controller/udm_voip.go @@ -50,7 +50,7 @@ type UDMVOIPController struct { func (s *UDMVOIPController) ResetData(c *gin.Context) { neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } @@ -99,7 +99,7 @@ func (s *UDMVOIPController) Info(c *gin.Context) { neId := c.Param("neId") username := c.Param("username") if neId == "" || username == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or username is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or username is empty")) return } @@ -158,18 +158,18 @@ func (s *UDMVOIPController) Add(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMVOIPUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.UserName == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: username is empty")) return } @@ -222,18 +222,18 @@ func (s *UDMVOIPController) Adds(c *gin.Context) { neId := c.Param("neId") num := c.Param("num") if neId == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or num is empty")) return } var body model.UDMVOIPUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.UserName == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: username is empty")) return } @@ -285,7 +285,7 @@ func (s *UDMVOIPController) Remove(c *gin.Context) { neId := c.Param("neId") username := c.Param("username") if neId == "" || username == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or username is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or username is empty")) return } @@ -351,7 +351,7 @@ func (s *UDMVOIPController) Removes(c *gin.Context) { username := c.Param("username") num := c.Param("num") if neId == "" || username == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/username/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/username/num is empty")) return } @@ -407,7 +407,7 @@ func (s *UDMVOIPController) Export(c *gin.Context) { neId := c.Query("neId") fileType := c.Query("type") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } if !(fileType == "csv" || fileType == "txt") { @@ -485,7 +485,7 @@ func (s *UDMVOIPController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/udm_volte_ims.go b/src/modules/network_data/controller/udm_volte_ims.go index d210a933..878059dc 100644 --- a/src/modules/network_data/controller/udm_volte_ims.go +++ b/src/modules/network_data/controller/udm_volte_ims.go @@ -50,7 +50,7 @@ type UDMVolteIMSController struct { func (s *UDMVolteIMSController) ResetData(c *gin.Context) { neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } @@ -101,11 +101,11 @@ func (s *UDMVolteIMSController) Info(c *gin.Context) { imsi := c.Param("imsi") msisdn := c.Query("msisdn") if neId == "" || imsi == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId or imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or imsi is empty")) return } if msisdn == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: msisdn is required")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: msisdn is required")) return } @@ -164,18 +164,18 @@ func (s *UDMVolteIMSController) Add(c *gin.Context) { language := reqctx.AcceptLanguage(c) neId := c.Param("neId") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } var body model.UDMVolteIMSUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty")) return } @@ -242,11 +242,11 @@ func (s *UDMVolteIMSController) Adds(c *gin.Context) { var body model.UDMVolteIMSUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty")) return } @@ -382,7 +382,7 @@ func (s *UDMVolteIMSController) Removes(c *gin.Context) { imsi := c.Param("imsi") num := c.Param("num") if neId == "" || imsi == "" || num == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi/num is empty")) return } @@ -438,7 +438,7 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) { neId := c.Query("neId") fileType := c.Query("type") if neId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty")) return } if !(fileType == "csv" || fileType == "txt") { @@ -514,7 +514,7 @@ func (s *UDMVolteIMSController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_data/controller/upf.go b/src/modules/network_data/controller/upf.go index 2b60d0d4..9f2b2065 100644 --- a/src/modules/network_data/controller/upf.go +++ b/src/modules/network_data/controller/upf.go @@ -49,7 +49,7 @@ func (s UPFController) FlowTotal(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); querys.Day < 0 || err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_element/controller/action.go b/src/modules/network_element/controller/action.go index 6b3b5f24..524e6689 100644 --- a/src/modules/network_element/controller/action.go +++ b/src/modules/network_element/controller/action.go @@ -54,7 +54,7 @@ func (s *NeActionController) PushFile(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -127,7 +127,7 @@ func (s *NeActionController) PullFile(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -199,7 +199,7 @@ func (s *NeActionController) PullDirZip(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -280,7 +280,7 @@ func (s *NeActionController) ViewFile(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -341,7 +341,7 @@ func (s *NeActionController) Files(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -413,7 +413,7 @@ func (s *NeActionController) Service(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_element/controller/ne_config.go b/src/modules/network_element/controller/ne_config.go index c668ec4f..3fd08c2e 100644 --- a/src/modules/network_element/controller/ne_config.go +++ b/src/modules/network_element/controller/ne_config.go @@ -47,7 +47,7 @@ func (s NeConfigController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Query("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -73,7 +73,7 @@ func (s NeConfigController) Add(c *gin.Context) { var body model.NeConfig if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -101,7 +101,7 @@ func (s NeConfigController) Edit(c *gin.Context) { var body model.NeConfig if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -136,7 +136,7 @@ func (s NeConfigController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Query("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -173,7 +173,7 @@ func (s NeConfigController) Remove(c *gin.Context) { func (s NeConfigController) ListByNeType(c *gin.Context) { neType := c.Param("neType") if neType == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: neType is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neType is empty")) return } data := s.neConfigService.FindByNeType(neType) @@ -204,7 +204,7 @@ func (s NeConfigController) DataInfo(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -264,7 +264,7 @@ func (s NeConfigController) DataEdit(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -330,7 +330,7 @@ func (s NeConfigController) DataAdd(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -388,7 +388,7 @@ func (s NeConfigController) DataRemove(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_element/controller/ne_config_backup.go b/src/modules/network_element/controller/ne_config_backup.go index 25a669b5..dac18864 100644 --- a/src/modules/network_element/controller/ne_config_backup.go +++ b/src/modules/network_element/controller/ne_config_backup.go @@ -50,7 +50,7 @@ func (s NeConfigBackupController) Download(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Query("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -80,7 +80,7 @@ func (s NeConfigBackupController) Edit(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -110,7 +110,7 @@ func (s NeConfigBackupController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Query("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -144,7 +144,7 @@ func (s NeConfigBackupController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if !strings.HasSuffix(body.Path, ".zip") { @@ -181,7 +181,7 @@ func (s NeConfigBackupController) Export(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查网元 diff --git a/src/modules/network_element/controller/ne_host.go b/src/modules/network_element/controller/ne_host.go index 65daa5f9..ba7344b7 100644 --- a/src/modules/network_element/controller/ne_host.go +++ b/src/modules/network_element/controller/ne_host.go @@ -75,11 +75,11 @@ func (s NeHostController) Add(c *gin.Context) { var body model.NeHost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ID != 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id not is empty")) return } @@ -116,11 +116,11 @@ func (s NeHostController) Edit(c *gin.Context) { var body model.NeHost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ID <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -196,7 +196,7 @@ func (s NeHostController) Test(c *gin.Context) { var body model.NeHost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -278,7 +278,7 @@ func (s NeHostController) Cmd(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -358,7 +358,7 @@ func (s NeHostController) CheckBySSH(c *gin.Context) { var body model.NeHost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -460,11 +460,11 @@ func (s NeHostController) AuthorizedBySSH(c *gin.Context) { var body model.NeHost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.AuthMode == "2" { - c.JSON(422, resp.CodeMsg(422002, "bind err: auth mode not equals 2")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: auth mode not equals 2")) return } diff --git a/src/modules/network_element/controller/ne_host_cmd.go b/src/modules/network_element/controller/ne_host_cmd.go index 06e88996..519aed9e 100644 --- a/src/modules/network_element/controller/ne_host_cmd.go +++ b/src/modules/network_element/controller/ne_host_cmd.go @@ -41,7 +41,7 @@ func (s NeHostCmdController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -63,7 +63,7 @@ func (s NeHostCmdController) Add(c *gin.Context) { var body model.NeHostCmd if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -93,7 +93,7 @@ func (s NeHostCmdController) Edit(c *gin.Context) { var body model.NeHostCmd if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -130,7 +130,7 @@ func (s NeHostCmdController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } diff --git a/src/modules/network_element/controller/ne_info.go b/src/modules/network_element/controller/ne_info.go index 5786227d..0a221b81 100644 --- a/src/modules/network_element/controller/ne_info.go +++ b/src/modules/network_element/controller/ne_info.go @@ -58,7 +58,7 @@ func (s NeInfoController) State(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -122,7 +122,7 @@ func (s NeInfoController) NeTypeAndID(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -160,7 +160,7 @@ func (s NeInfoController) ListAll(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -202,7 +202,7 @@ func (s NeInfoController) Para5GFileWrite(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -224,7 +224,7 @@ func (s NeInfoController) OAMFileRead(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -249,7 +249,7 @@ func (s NeInfoController) OAMFileWrite(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -312,7 +312,7 @@ func (s NeInfoController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -345,11 +345,11 @@ func (s NeInfoController) Add(c *gin.Context) { err := c.ShouldBindBodyWithJSON(&body) if err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ID != 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id not is empty")) return } @@ -441,11 +441,11 @@ func (s NeInfoController) Edit(c *gin.Context) { err := c.ShouldBindBodyWithJSON(&body) if err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ID <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -555,7 +555,7 @@ func (s NeInfoController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } diff --git a/src/modules/network_element/controller/ne_license.go b/src/modules/network_element/controller/ne_license.go index 9399e4dd..cf34f9b3 100644 --- a/src/modules/network_element/controller/ne_license.go +++ b/src/modules/network_element/controller/ne_license.go @@ -67,7 +67,7 @@ func (s *NeLicenseController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -103,7 +103,7 @@ func (s *NeLicenseController) NeTypeAndID(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -139,7 +139,7 @@ func (s *NeLicenseController) Code(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -187,7 +187,7 @@ func (s *NeLicenseController) Change(c *gin.Context) { err := c.ShouldBindBodyWithJSON(&body) if err != nil || body.LicensePath == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_element/controller/ne_software.go b/src/modules/network_element/controller/ne_software.go index 837ba6c8..a13708a2 100644 --- a/src/modules/network_element/controller/ne_software.go +++ b/src/modules/network_element/controller/ne_software.go @@ -55,7 +55,7 @@ func (s NeSoftwareController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -86,11 +86,11 @@ func (s NeSoftwareController) Add(c *gin.Context) { var body model.NeSoftware if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.Path == "" || body.ID > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: path is empty or id is not empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: path is empty or id is not empty")) return } // 找到已存在的删除后重新添加 @@ -130,11 +130,11 @@ func (s NeSoftwareController) Edit(c *gin.Context) { var body model.NeSoftware if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.Path == "" || body.ID == 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: path or id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: path or id is empty")) return } @@ -171,7 +171,7 @@ func (s NeSoftwareController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -209,7 +209,7 @@ func (s NeSoftwareController) NewNeVersion(c *gin.Context) { var body model.NeSoftware if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/network_element/controller/ne_version.go b/src/modules/network_element/controller/ne_version.go index cb9777a2..0ee0d1f3 100644 --- a/src/modules/network_element/controller/ne_version.go +++ b/src/modules/network_element/controller/ne_version.go @@ -40,7 +40,7 @@ func (s *NeVersionController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -77,7 +77,7 @@ func (s *NeVersionController) Operate(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/oauth2/controller/oauth2.go b/src/modules/oauth2/controller/oauth2.go index f49a9b2b..bb8fceb3 100644 --- a/src/modules/oauth2/controller/oauth2.go +++ b/src/modules/oauth2/controller/oauth2.go @@ -38,7 +38,7 @@ func (s Oauth2Controller) Authorize(c *gin.Context) { var query model.CodeQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -69,11 +69,11 @@ func (s Oauth2Controller) Token(c *gin.Context) { var body model.TokenBody if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.GrantType != "authorization_code" || body.Code == "" { - c.JSON(422, resp.CodeMsg(422002, "grantType or code error")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "grantType or code error")) return } @@ -137,18 +137,18 @@ func (s Oauth2Controller) RefreshToken(c *gin.Context) { var body model.TokenBody if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.GrantType != "refresh_token" || body.RefreshToken == "" { - c.JSON(422, resp.CodeMsg(422002, "grantType or refreshToken error")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "grantType or refreshToken error")) return } // 验证刷新令牌是否有效 claims, err := token.Oauth2TokenVerify(body.RefreshToken, "refresh") if err != nil { - c.JSON(401, resp.CodeMsg(401001, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, err.Error())) return } clientId := fmt.Sprint(claims[constants.JWT_CLIENT_ID]) @@ -173,7 +173,7 @@ func (s Oauth2Controller) RefreshToken(c *gin.Context) { deviceId := fmt.Sprint(claims[constants.JWT_DEVICE_ID]) deviceFingerprint := reqctx.DeviceFingerprint(c, clientId) if deviceId != deviceFingerprint { - c.JSON(200, resp.ErrMsg("device fingerprint mismatch")) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_DEVICE, resp.MSG_AUTH_DEVICE)) return } diff --git a/src/modules/oauth2/controller/oauth2_client.go b/src/modules/oauth2/controller/oauth2_client.go index 846d18f3..30d0bbf5 100644 --- a/src/modules/oauth2/controller/oauth2_client.go +++ b/src/modules/oauth2/controller/oauth2_client.go @@ -41,7 +41,7 @@ func (s Oauth2ClientController) List(c *gin.Context) { func (s Oauth2ClientController) Info(c *gin.Context) { clientId := c.Param("clientId") if clientId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: clientId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: clientId is empty")) return } @@ -60,11 +60,11 @@ func (s Oauth2ClientController) Add(c *gin.Context) { var body model.Oauth2Client if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.Id > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id not is empty")) return } @@ -98,11 +98,11 @@ func (s Oauth2ClientController) Edit(c *gin.Context) { var body model.Oauth2Client if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.Id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -146,7 +146,7 @@ func (s Oauth2ClientController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } diff --git a/src/modules/system/controller/sys_config.go b/src/modules/system/controller/sys_config.go index 363136b4..88781ce3 100644 --- a/src/modules/system/controller/sys_config.go +++ b/src/modules/system/controller/sys_config.go @@ -74,7 +74,7 @@ func (s *SysConfigController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) configId := parse.Number(c.Param("configId")) if configId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configId is empty")) return } @@ -98,11 +98,11 @@ func (s *SysConfigController) Add(c *gin.Context) { var body model.SysConfig if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ConfigId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: configId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configId not is empty")) return } @@ -132,11 +132,11 @@ func (s *SysConfigController) Edit(c *gin.Context) { var body model.SysConfig if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ConfigId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configId is empty")) return } @@ -197,7 +197,7 @@ func (s SysConfigController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) configId := c.Param("configId") if configId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configId is empty")) return } @@ -234,7 +234,7 @@ func (s SysConfigController) Refresh(c *gin.Context) { func (s SysConfigController) ConfigKey(c *gin.Context) { configKey := c.Param("configKey") if configKey == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: configKey is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configKey is empty")) return } key := s.sysConfigService.FindValueByKey(configKey) @@ -319,7 +319,7 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/system/controller/sys_dept.go b/src/modules/system/controller/sys_dept.go index e7d644c0..434f5d53 100644 --- a/src/modules/system/controller/sys_dept.go +++ b/src/modules/system/controller/sys_dept.go @@ -54,7 +54,7 @@ func (s *SysDeptController) List(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -90,7 +90,7 @@ func (s SysDeptController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) deptId := parse.Number(c.Param("deptId")) if deptId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId is empty")) return } data := s.sysDeptService.FindById(deptId) @@ -111,11 +111,11 @@ func (s SysDeptController) Add(c *gin.Context) { var body model.SysDept if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DeptId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId not is empty")) return } @@ -169,11 +169,11 @@ func (s SysDeptController) Edit(c *gin.Context) { var body model.SysDept if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DeptId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId is empty")) return } @@ -253,7 +253,7 @@ func (s SysDeptController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) deptId := parse.Number(c.Param("deptId")) if deptId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId is empty")) return } @@ -299,7 +299,7 @@ func (s SysDeptController) Remove(c *gin.Context) { func (s *SysDeptController) ExcludeChild(c *gin.Context) { deptIdStr := c.Param("deptId") if deptIdStr == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId is empty")) return } deptId := parse.Number(deptIdStr) @@ -333,7 +333,7 @@ func (s *SysDeptController) Tree(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } sysDept := model.SysDept{ @@ -367,7 +367,7 @@ func (s *SysDeptController) TreeRole(c *gin.Context) { language := reqctx.AcceptLanguage(c) roleId := parse.Number(c.Param("roleId")) if roleId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } diff --git a/src/modules/system/controller/sys_dict_data.go b/src/modules/system/controller/sys_dict_data.go index f38d5c8b..5b2da699 100644 --- a/src/modules/system/controller/sys_dict_data.go +++ b/src/modules/system/controller/sys_dict_data.go @@ -78,7 +78,7 @@ func (s SysDictDataController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) dataId := parse.Number(c.Param("dataId")) if dataId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: deptId is empty")) return } data := s.sysDictDataService.FindById(dataId) @@ -102,11 +102,11 @@ func (s SysDictDataController) Add(c *gin.Context) { var body model.SysDictData if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DataId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: dataId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dataId not is empty")) return } @@ -153,11 +153,11 @@ func (s SysDictDataController) Edit(c *gin.Context) { var body model.SysDictData if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DataId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: dataId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dataId is empty")) return } @@ -232,7 +232,7 @@ func (s SysDictDataController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) dataId := c.Param("dataId") if dataId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: dataId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dataId is empty")) return } @@ -261,7 +261,7 @@ func (s SysDictDataController) DictType(c *gin.Context) { language := reqctx.AcceptLanguage(c) dictType := c.Param("dictType") if dictType == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: dictType is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dictType is empty")) return } diff --git a/src/modules/system/controller/sys_dict_type.go b/src/modules/system/controller/sys_dict_type.go index 56aeef84..a515b90c 100644 --- a/src/modules/system/controller/sys_dict_type.go +++ b/src/modules/system/controller/sys_dict_type.go @@ -73,7 +73,7 @@ func (s *SysDictTypeController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) dictId := parse.Number(c.Param("dictId")) if dictId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dictId is empty")) return } data := s.sysDictTypeService.FindById(dictId) @@ -95,11 +95,11 @@ func (s *SysDictTypeController) Add(c *gin.Context) { var body model.SysDictType if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DictId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: dictId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dictId not is empty")) return } @@ -138,11 +138,11 @@ func (s *SysDictTypeController) Edit(c *gin.Context) { var body model.SysDictType if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.DictId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dictId is empty")) return } @@ -205,7 +205,7 @@ func (s SysDictTypeController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) dictId := c.Param("dictId") if dictId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: dictId is empty")) return } diff --git a/src/modules/system/controller/sys_log_login.go b/src/modules/system/controller/sys_log_login.go index 1231c11e..7f454fe6 100644 --- a/src/modules/system/controller/sys_log_login.go +++ b/src/modules/system/controller/sys_log_login.go @@ -81,7 +81,7 @@ func (s SysLogLoginController) Unlock(c *gin.Context) { language := reqctx.AcceptLanguage(c) userName := c.Param("userName") if userName == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: userName is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userName is empty")) return } ok := s.accountService.CleanLoginRecordCache(userName) diff --git a/src/modules/system/controller/sys_menu.go b/src/modules/system/controller/sys_menu.go index 75d1ff44..2a9ef531 100644 --- a/src/modules/system/controller/sys_menu.go +++ b/src/modules/system/controller/sys_menu.go @@ -82,7 +82,7 @@ func (s *SysMenuController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) menuId := parse.Number(c.Param("menuId")) if menuId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: menuId is empty")) return } @@ -105,11 +105,11 @@ func (s *SysMenuController) Add(c *gin.Context) { var body model.SysMenu if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.MenuId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: menuId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: menuId not is empty")) return } @@ -158,11 +158,11 @@ func (s *SysMenuController) Edit(c *gin.Context) { var body model.SysMenu if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.MenuId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: menuId is empty")) return } @@ -278,7 +278,7 @@ func (s SysMenuController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) menuId := parse.Number(c.Param("menuId")) if menuId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: menuId is empty")) return } @@ -359,7 +359,7 @@ func (s *SysMenuController) TreeRole(c *gin.Context) { language := reqctx.AcceptLanguage(c) roleId := parse.Number(c.Param("roleId")) if roleId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } diff --git a/src/modules/system/controller/sys_post.go b/src/modules/system/controller/sys_post.go index 854cfd58..3c655886 100644 --- a/src/modules/system/controller/sys_post.go +++ b/src/modules/system/controller/sys_post.go @@ -95,11 +95,11 @@ func (s *SysPostController) Add(c *gin.Context) { var body model.SysPost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.PostId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: postId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: postId not is empty")) return } @@ -138,11 +138,11 @@ func (s *SysPostController) Edit(c *gin.Context) { var body model.SysPost if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.PostId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: postId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: postId is empty")) return } @@ -206,7 +206,7 @@ func (s SysPostController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) postId := c.Param("postId") if postId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: postId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: postId is empty")) return } diff --git a/src/modules/system/controller/sys_profile.go b/src/modules/system/controller/sys_profile.go index 4afbcecf..659fcf08 100644 --- a/src/modules/system/controller/sys_profile.go +++ b/src/modules/system/controller/sys_profile.go @@ -49,7 +49,7 @@ func (s *SysProfileController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } @@ -104,14 +104,14 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 登录用户信息 info, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, err.Error())) return } userId := info.UserId @@ -202,14 +202,14 @@ func (s *SysProfileController) PasswordUpdate(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 登录用户信息 info, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, err.Error())) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, err.Error())) return } userId := info.UserId @@ -264,7 +264,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -278,7 +278,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/system/controller/sys_role.go b/src/modules/system/controller/sys_role.go index 7c94ffc0..91ebb417 100644 --- a/src/modules/system/controller/sys_role.go +++ b/src/modules/system/controller/sys_role.go @@ -75,7 +75,7 @@ func (s *SysRoleController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) roleId := parse.Number(c.Param("roleId")) if roleId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } data := s.sysRoleService.FindById(roleId) @@ -96,11 +96,11 @@ func (s *SysRoleController) Add(c *gin.Context) { var body model.SysRole if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.RoleId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId not is empty")) return } @@ -139,11 +139,11 @@ func (s *SysRoleController) Edit(c *gin.Context) { var body model.SysRole if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.RoleId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } @@ -219,7 +219,7 @@ func (s *SysRoleController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) roleId := c.Param("roleId") if roleId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } @@ -261,7 +261,7 @@ func (s SysRoleController) Status(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -311,7 +311,7 @@ func (s *SysRoleController) DataScope(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -350,7 +350,7 @@ func (s SysRoleController) UserAuthList(c *gin.Context) { language := reqctx.AcceptLanguage(c) roleId := parse.Number(c.Query("roleId")) if roleId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: roleId is empty")) return } @@ -380,11 +380,11 @@ func (s SysRoleController) UserAuthChecked(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if len(body.UserIds) <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: userIds is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userIds is empty")) return } diff --git a/src/modules/system/controller/sys_user.go b/src/modules/system/controller/sys_user.go index 84961a9d..60758dc3 100644 --- a/src/modules/system/controller/sys_user.go +++ b/src/modules/system/controller/sys_user.go @@ -81,7 +81,7 @@ func (s *SysUserController) Info(c *gin.Context) { language := reqctx.AcceptLanguage(c) userId := parse.Number(c.Param("userId")) if userId < 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userId is empty")) return } @@ -165,7 +165,7 @@ func (s *SysUserController) Add(c *gin.Context) { var body model.SysUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -175,13 +175,13 @@ func (s *SysUserController) Add(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&bodyPassword); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } body.Password = bodyPassword.Password if body.UserId > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: userId not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userId not is empty")) return } if !regular.ValidUsername(body.UserName) { @@ -279,11 +279,11 @@ func (s *SysUserController) Edit(c *gin.Context) { var body model.SysUser if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.UserId <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userId is empty")) return } @@ -379,7 +379,7 @@ func (s *SysUserController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) userId := c.Param("userId") if userId == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: userId is empty")) return } @@ -427,7 +427,7 @@ func (s *SysUserController) Password(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -478,7 +478,7 @@ func (s *SysUserController) Status(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -648,7 +648,7 @@ func (s *SysUserController) Import(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/tool/controller/iperf.go b/src/modules/tool/controller/iperf.go index 84327487..1c7705fa 100644 --- a/src/modules/tool/controller/iperf.go +++ b/src/modules/tool/controller/iperf.go @@ -55,7 +55,7 @@ func (s *IPerfController) Version(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -90,7 +90,7 @@ func (s *IPerfController) Install(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -128,14 +128,14 @@ func (s *IPerfController) Run(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/tool/controller/ping.go b/src/modules/tool/controller/ping.go index 302b7145..48056c8f 100644 --- a/src/modules/tool/controller/ping.go +++ b/src/modules/tool/controller/ping.go @@ -49,7 +49,7 @@ func (s *PingController) Statistics(c *gin.Context) { var body model.Ping if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -79,7 +79,7 @@ func (s *PingController) StatisticsOn(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } @@ -124,7 +124,7 @@ func (s *PingController) Version(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -163,14 +163,14 @@ func (s *PingController) Run(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/trace/controller/packet.go b/src/modules/trace/controller/packet.go index 94ccf9e3..9978d520 100644 --- a/src/modules/trace/controller/packet.go +++ b/src/modules/trace/controller/packet.go @@ -46,7 +46,7 @@ func (s *PacketController) Start(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -68,7 +68,7 @@ func (s *PacketController) Stop(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -90,7 +90,7 @@ func (s *PacketController) Filter(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -112,7 +112,7 @@ func (s *PacketController) KeepAlive(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -137,7 +137,7 @@ func (s *PacketController) FilePull(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } fileName := fmt.Sprintf("%s.pcap", querys.TaskNo) diff --git a/src/modules/trace/controller/tcpdump.go b/src/modules/trace/controller/tcpdump.go index eac35807..e81b66e5 100644 --- a/src/modules/trace/controller/tcpdump.go +++ b/src/modules/trace/controller/tcpdump.go @@ -45,7 +45,7 @@ func (s *TCPdumpController) DumpStart(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -79,7 +79,7 @@ func (s *TCPdumpController) DumpStop(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -113,7 +113,7 @@ func (s *TCPdumpController) UPFTrace(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/trace/controller/trace_data.go b/src/modules/trace/controller/trace_data.go index ae7e1602..b694ff4e 100644 --- a/src/modules/trace/controller/trace_data.go +++ b/src/modules/trace/controller/trace_data.go @@ -37,7 +37,7 @@ func (s *TraceDataController) List(c *gin.Context) { func (s *TraceDataController) Info(c *gin.Context) { id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -56,7 +56,7 @@ func (s *TraceDataController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } diff --git a/src/modules/trace/controller/trace_task.go b/src/modules/trace/controller/trace_task.go index 53f87757..75a4db94 100644 --- a/src/modules/trace/controller/trace_task.go +++ b/src/modules/trace/controller/trace_task.go @@ -43,7 +43,7 @@ func (s *TraceTaskController) List(c *gin.Context) { func (s *TraceTaskController) Info(c *gin.Context) { id := parse.Number(c.Param("id")) if id <= 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -63,11 +63,11 @@ func (s *TraceTaskController) Add(c *gin.Context) { var body model.TraceTask if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.ID > 0 { - c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id not is empty")) return } @@ -86,7 +86,7 @@ func (s *TraceTaskController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -116,7 +116,7 @@ func (s *TraceTaskController) FilePull(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } diff --git a/src/modules/trace/controller/trace_task_hlr.go b/src/modules/trace/controller/trace_task_hlr.go index 7e14138f..5bd30031 100644 --- a/src/modules/trace/controller/trace_task_hlr.go +++ b/src/modules/trace/controller/trace_task_hlr.go @@ -39,7 +39,7 @@ func (s *TraceTaskHlrController) List(c *gin.Context) { var query model.TraceTaskHlrQuery if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -54,7 +54,7 @@ func (s *TraceTaskHlrController) Remove(c *gin.Context) { language := reqctx.AcceptLanguage(c) id := c.Param("id") if id == "" { - c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty")) return } @@ -88,12 +88,12 @@ func (s *TraceTaskHlrController) Start(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if body.IMSI == "" && body.MSISDN == "" { - c.JSON(422, resp.CodeMsg(422002, "imsi amd msisdn is empty")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "imsi amd msisdn is empty")) return } @@ -122,7 +122,7 @@ func (s *TraceTaskHlrController) Stop(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } @@ -162,13 +162,13 @@ func (s *TraceTaskHlrController) File(c *gin.Context) { } if err := c.ShouldBindBodyWithJSON(&body); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } task := s.traceTaskHlrService.FindById(body.ID) if task.ID == 0 || task.ID != body.ID { - c.JSON(422, resp.CodeMsg(422002, "task not found")) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "task not found")) return } @@ -194,14 +194,14 @@ func (s *TraceTaskHlrController) FilePull(c *gin.Context) { } if err := c.ShouldBindQuery(&querys); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 查询网元获取IP neInfo := s.neInfoService.FindByNeTypeAndNeID(querys.NeType, querys.NeID) if neInfo.NeId != querys.NeID || neInfo.IP == "" { - c.JSON(422, resp.CodeMsg(422002, i18n.TKey(language, "app.common.noNEInfo"))) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, i18n.TKey(language, "app.common.noNEInfo"))) return } diff --git a/src/modules/ws/controller/ws.go b/src/modules/ws/controller/ws.go index 32a7bb70..2f7ce802 100644 --- a/src/modules/ws/controller/ws.go +++ b/src/modules/ws/controller/ws.go @@ -48,7 +48,7 @@ func (s *WSController) WS(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } @@ -92,7 +92,7 @@ func (s *WSController) Test(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/ws/controller/ws_redis.go b/src/modules/ws/controller/ws_redis.go index 48a149d9..b4dd473d 100644 --- a/src/modules/ws/controller/ws_redis.go +++ b/src/modules/ws/controller/ws_redis.go @@ -23,14 +23,14 @@ func (s *WSController) Redis(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/ws/controller/ws_ssh.go b/src/modules/ws/controller/ws_ssh.go index e020ae46..a626a053 100644 --- a/src/modules/ws/controller/ws_ssh.go +++ b/src/modules/ws/controller/ws_ssh.go @@ -27,7 +27,7 @@ func (s *WSController) SSH(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if query.Cols < 80 || query.Cols > 400 { @@ -40,7 +40,7 @@ func (s *WSController) SSH(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/ws/controller/ws_telnet.go b/src/modules/ws/controller/ws_telnet.go index 6d3af843..eb94d205 100644 --- a/src/modules/ws/controller/ws_telnet.go +++ b/src/modules/ws/controller/ws_telnet.go @@ -27,7 +27,7 @@ func (s *WSController) Telnet(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if query.Cols < 120 || query.Cols > 400 { @@ -40,7 +40,7 @@ func (s *WSController) Telnet(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } diff --git a/src/modules/ws/controller/ws_view.go b/src/modules/ws/controller/ws_view.go index 11bdf4cd..38b52997 100644 --- a/src/modules/ws/controller/ws_view.go +++ b/src/modules/ws/controller/ws_view.go @@ -40,7 +40,7 @@ func (s *WSController) ShellView(c *gin.Context) { } if err := c.ShouldBindQuery(&query); err != nil { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) - c.JSON(422, resp.CodeMsg(422001, errMsgs)) + c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs)) return } if query.Cols < 120 || query.Cols > 400 { @@ -53,7 +53,7 @@ func (s *WSController) ShellView(c *gin.Context) { // 登录用户信息 loginUser, err := reqctx.LoginUser(c) if err != nil { - c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error()))) + c.JSON(401, resp.CodeMsg(resp.CODE_AUTH_INVALID, i18n.TKey(language, err.Error()))) return } From d87f1f487419c7b99ba2efd8c2df08747d1826e8 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 7 Jun 2025 16:32:37 +0800 Subject: [PATCH 6/7] =?UTF-8?q?style:=20=E6=A0=87=E6=B3=A8=E5=91=8A?= =?UTF-8?q?=E8=AD=A6neId=E6=8E=A5=E6=94=B6=E6=98=AFrmUID=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/fm/alarm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/fm/alarm.go b/features/fm/alarm.go index 49b8d8ed..e5f624fe 100644 --- a/features/fm/alarm.go +++ b/features/fm/alarm.go @@ -66,7 +66,7 @@ const ( type Alarm struct { AlarmSeq int `json:"alarmSeq"` AlarmId string `json:"alarmId" xorm:"alarm_id"` - NeId string `json:"neId"` + NeId string `json:"neId"` // 收到实际是rmUID AlarmCode int `json:"alarmCode"` AlarmTitle string `json:"alarmTitle"` EventTime string `json:"eventTime"` From c7501a952dbbc98e3f5e2e609af7a00242938244 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 7 Jun 2025 16:35:20 +0800 Subject: [PATCH 7/7] =?UTF-8?q?chore:=20=E5=8F=91=E5=B8=83=E7=89=88?= =?UTF-8?q?=E6=9C=AC=202.2506.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 464aa89f..758e7bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 版本发布日志 +## 2.2506.1-20250607 + +- 修复 sshsvc服务的私钥文件判断生成 +- 移除 旧跟踪任务相关的路由注册 +- 优化 文件资源统一放到/usr/local/omc +- 优化 请求响应码用常量 +- 注释 标注告警neId接收是rmUID数据 + ## 2.2505.4-20250530 - 修复 socket异常退出捕获,停止信号退出循环读取