fix: 教学配置应用教师可操作申请中的学生应用和退回

This commit is contained in:
TsMask
2024-07-18 15:07:26 +08:00
parent 3db0f83dcc
commit 7e0013c1e6
2 changed files with 48 additions and 5 deletions

View File

@@ -110,19 +110,62 @@ func (s *PtNeConfigApplyController) Edit(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var body struct {
ApplyId string `json:"applyId"` // 申请ID
BackId string `json:"backId"` // 批量退回申请ID,号分隔
NeType string `json:"neType"` // 网元类型
Status string `json:"status" binding:"required,oneof=2 3"` // 状态 2应用 3退回
BackInfo string `json:"backInfo"` // 退回信息
BackId string `json:"backId"` // 批量退回申请ID,号分隔
Student string `json:"student"` // 学生用户账号
}
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
currentUserName := ctx.LoginUserToUserName(c)
// 不指定申请直接应用
// 指定有申请的学生直接应用 (管理/教师自身操作)
if body.ApplyId == "" && body.NeType != "" && body.Student != "" {
applyInfos := s.ptNeConfigApplyService.SelectList(model.PtNeConfigApply{CreateBy: body.Student})
if len(applyInfos) == 0 {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
applyInfo := applyInfos[0]
if applyInfo.CreateBy != body.Student || applyInfo.Status != "0" {
// 申请信息不正确!
c.JSON(200, result.ErrMsg("Application Information Is Incorrect!"))
return
}
// 应用
if body.Status == "2" {
if err := s.ptNeConfigDataService.ApplyToNe(applyInfo.CreateBy, applyInfo.NeType); err != nil {
c.JSON(200, result.ErrMsg("Application Failed! "+err.Error()))
return
}
applyInfo.UpdateBy = currentUserName
applyInfo.Status = body.Status
applyInfo.BackInfo = ""
s.ptNeConfigApplyService.Update(applyInfo)
c.JSON(200, result.OkMsg("Application Appliance Complete!"))
return
}
// 退回
if body.Status == "3" {
applyInfo.UpdateBy = currentUserName
applyInfo.Status = body.Status
applyInfo.BackInfo = body.BackInfo
s.ptNeConfigApplyService.Update(applyInfo)
c.JSON(200, result.OkMsg("Application Return Complete!"))
return
}
}
// 不指定申请直接应用 (管理/教师自身操作)
if body.ApplyId == "" && body.NeType != "" && body.Status == "2" {
if body.Student != "" {
currentUserName = body.Student
}
if err := s.ptNeConfigDataService.ApplyToNe(currentUserName, body.NeType); err != nil {
c.JSON(200, result.ErrMsg("Application Failed! "+err.Error()))
return
@@ -131,7 +174,7 @@ func (s *PtNeConfigApplyController) Edit(c *gin.Context) {
return
}
// 不指定申请直接应用而是退回
// 不指定申请直接应用而是批量退回
if body.ApplyId == "" && body.BackId != "" && body.Status == "3" {
ids := strings.Split(body.BackId, ",")
num := 0

View File

@@ -261,7 +261,7 @@ func (r *PtNeConfigApplyRepository) SelectListByClass(deptId, userName string) [
// 查询数据
querySql := `SELECT
u.user_Id as userId, u.user_name as userName, u.nick_name as nickName, u.login_ip as loginIp, u.login_date AS loginDate,
COALESCE(pnca.status, '') as applyStatus
COALESCE(pnca.id, '') as applyId, COALESCE(pnca.status, '') as applyStatus
FROM sys_user u
LEFT JOIN sys_dept d ON u.dept_id = d.dept_id
LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id