fix: 配置应用的数据读取支持当前操作应用下发
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"be.ems/src/framework/i18n"
|
"be.ems/src/framework/i18n"
|
||||||
"be.ems/src/framework/utils/ctx"
|
"be.ems/src/framework/utils/ctx"
|
||||||
"be.ems/src/framework/vo/result"
|
"be.ems/src/framework/vo/result"
|
||||||
@@ -26,6 +29,16 @@ type PtNeConfigApplyController struct {
|
|||||||
ptNeConfigDataService service.IPtNeConfigDataService
|
ptNeConfigDataService service.IPtNeConfigDataService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 班级学生列表 (仅教师操作)
|
||||||
|
//
|
||||||
|
// GET /students
|
||||||
|
func (s *PtNeConfigApplyController) Students(c *gin.Context) {
|
||||||
|
userName, _ := c.GetQuery("userName")
|
||||||
|
loginUser, _ := ctx.LoginUser(c)
|
||||||
|
data := s.ptNeConfigApplyService.SelectListByClass(loginUser.DeptID, userName)
|
||||||
|
c.JSON(200, result.OkData(data))
|
||||||
|
}
|
||||||
|
|
||||||
// 网元参数配置应用申请列表
|
// 网元参数配置应用申请列表
|
||||||
//
|
//
|
||||||
// GET /list
|
// GET /list
|
||||||
@@ -66,7 +79,7 @@ func (s *PtNeConfigApplyController) Add(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
s.ptNeConfigApplyService.Insert(model.PtNeConfigApply{
|
s.ptNeConfigApplyService.Insert(model.PtNeConfigApply{
|
||||||
CreateBy: currentUserName,
|
CreateBy: currentUserName,
|
||||||
Status: "0",
|
Status: body.Status,
|
||||||
NeType: body.NeType,
|
NeType: body.NeType,
|
||||||
})
|
})
|
||||||
c.JSON(200, result.OkMsg("Application Submission Complete!"))
|
c.JSON(200, result.OkMsg("Application Submission Complete!"))
|
||||||
@@ -82,7 +95,7 @@ func (s *PtNeConfigApplyController) Add(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
for _, v := range applyInfos {
|
for _, v := range applyInfos {
|
||||||
v.UpdateBy = currentUserName
|
v.UpdateBy = currentUserName
|
||||||
v.Status = "1"
|
v.Status = body.Status
|
||||||
s.ptNeConfigApplyService.Update(v)
|
s.ptNeConfigApplyService.Update(v)
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkMsg("Application Revocable Complete!"))
|
c.JSON(200, result.OkMsg("Application Revocable Complete!"))
|
||||||
@@ -96,8 +109,9 @@ func (s *PtNeConfigApplyController) Add(c *gin.Context) {
|
|||||||
func (s *PtNeConfigApplyController) Edit(c *gin.Context) {
|
func (s *PtNeConfigApplyController) Edit(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
var body struct {
|
||||||
ApplyId string `json:"applyId" binding:"required"` // 申请ID
|
ApplyId string `json:"applyId"` // 申请ID
|
||||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
BackId string `json:"backId"` // 批量退回申请ID,号分隔
|
||||||
|
NeType string `json:"neType"` // 网元类型
|
||||||
Status string `json:"status" binding:"required,oneof=2 3"` // 状态 2应用 3退回
|
Status string `json:"status" binding:"required,oneof=2 3"` // 状态 2应用 3退回
|
||||||
BackInfo string `json:"backInfo"` // 退回信息
|
BackInfo string `json:"backInfo"` // 退回信息
|
||||||
}
|
}
|
||||||
@@ -107,32 +121,63 @@ func (s *PtNeConfigApplyController) Edit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentUserName := ctx.LoginUserToUserName(c)
|
currentUserName := ctx.LoginUserToUserName(c)
|
||||||
applyInfos := s.ptNeConfigApplyService.SelectById(body.ApplyId)
|
// 不指定申请直接应用
|
||||||
if applyInfos.ID != body.ApplyId || applyInfos.Status != "0" {
|
if body.ApplyId == "" && body.NeType != "" && body.Status == "2" {
|
||||||
|
if err := s.ptNeConfigDataService.ApplyToNe(currentUserName, body.NeType); err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg("Application Failed! "+err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, result.OkMsg("Application Appliance Complete!"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不指定申请直接应用而是退回
|
||||||
|
if body.ApplyId == "" && body.BackId != "" && body.Status == "3" {
|
||||||
|
ids := strings.Split(body.BackId, ",")
|
||||||
|
num := 0
|
||||||
|
for _, id := range ids {
|
||||||
|
applyInfo := s.ptNeConfigApplyService.SelectById(id)
|
||||||
|
if applyInfo.ID == "" || applyInfo.Status != "0" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
applyInfo.UpdateBy = currentUserName
|
||||||
|
applyInfo.Status = body.Status
|
||||||
|
applyInfo.BackInfo = body.BackInfo
|
||||||
|
s.ptNeConfigApplyService.Update(applyInfo)
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(200, result.OkMsg(fmt.Sprintf("Application Return %d Complete!", num)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
applyInfo := s.ptNeConfigApplyService.SelectById(body.ApplyId)
|
||||||
|
if applyInfo.ID != body.ApplyId || applyInfo.Status != "0" {
|
||||||
|
// 申请信息不正确!
|
||||||
c.JSON(200, result.ErrMsg("Application Information Is Incorrect!"))
|
c.JSON(200, result.ErrMsg("Application Information Is Incorrect!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退回
|
// 退回
|
||||||
if body.Status == "3" {
|
if body.Status == "3" {
|
||||||
applyInfos.UpdateBy = currentUserName
|
applyInfo.UpdateBy = currentUserName
|
||||||
applyInfos.Status = "3"
|
applyInfo.Status = body.Status
|
||||||
applyInfos.BackInfo = body.BackInfo
|
applyInfo.BackInfo = body.BackInfo
|
||||||
s.ptNeConfigApplyService.Update(applyInfos)
|
s.ptNeConfigApplyService.Update(applyInfo)
|
||||||
c.JSON(200, result.OkMsg("Application Return Complete!"))
|
c.JSON(200, result.OkMsg("Application Return Complete!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 应用
|
// 应用
|
||||||
if body.Status == "2" {
|
if body.Status == "2" {
|
||||||
if err := s.ptNeConfigDataService.ApplyToNe(applyInfos.CreateBy, applyInfos.NeType); err != nil {
|
if err := s.ptNeConfigDataService.ApplyToNe(applyInfo.CreateBy, applyInfo.NeType); err != nil {
|
||||||
c.JSON(200, result.ErrMsg("Application Failed! "+err.Error()))
|
c.JSON(200, result.ErrMsg("Application Failed! "+err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
applyInfos.UpdateBy = currentUserName
|
applyInfo.UpdateBy = currentUserName
|
||||||
applyInfos.Status = "1"
|
applyInfo.Status = body.Status
|
||||||
applyInfos.BackInfo = ""
|
applyInfo.BackInfo = ""
|
||||||
s.ptNeConfigApplyService.Update(applyInfos)
|
s.ptNeConfigApplyService.Update(applyInfo)
|
||||||
c.JSON(200, result.OkMsg("Application Appliance Complete!"))
|
c.JSON(200, result.OkMsg("Application Appliance Complete!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ func (r *PtNeConfigDataService) SelectByStubType(param model.PtNeConfigData) mod
|
|||||||
|
|
||||||
// ApplyToNe 参数应用到网元
|
// ApplyToNe 参数应用到网元
|
||||||
func (r *PtNeConfigDataService) ApplyToNe(paramUser, neType string) error {
|
func (r *PtNeConfigDataService) ApplyToNe(paramUser, neType string) error {
|
||||||
ptConfs := r.SelectList(model.PtNeConfigData{CreateBy: paramUser, StubType: "2", NeType: neType})
|
ptConfs := r.SelectList(model.PtNeConfigData{CreateBy: paramUser, NeType: neType})
|
||||||
if len(ptConfs) == 0 {
|
if len(ptConfs) == 0 {
|
||||||
return fmt.Errorf("NeConfigData Not Found")
|
return fmt.Errorf("NeConfigData Not Found")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user