From e2d3d9517083657223d4381825bdd38d2fb611fe Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Fri, 13 Oct 2023 12:27:35 +0800 Subject: [PATCH] update --- .../hdl_central_kitchen_for_school.go | 23 ++++++++++++++++++- app/router/admin_router.go | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go index 7ef8432..62ff635 100644 --- a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go @@ -1332,6 +1332,8 @@ func CentralKitchenForSchoolGradeDelete(c *gin.Context) { func CentralKitchenForSchoolClassDelete(c *gin.Context) { classId := c.Param("id") + classWithUserDb := db.ClassWithUserDb{} + //1、查找当前年级 classDb := db.ClassDb{} classDb.Set(0) @@ -1347,7 +1349,6 @@ func CentralKitchenForSchoolClassDelete(c *gin.Context) { } //2、删除当前班级下的所有关联学生 - classWithUserDb := db.ClassWithUserDb{} classWithUserDb.Set() _, err = classWithUserDb.DeleteClassWithUserByClass(classId) if err != nil { @@ -1357,3 +1358,23 @@ func CentralKitchenForSchoolClassDelete(c *gin.Context) { e.OutSuc(c, "success", nil) return } + +func CentralKitchenForSchoolClassDeleteCheck(c *gin.Context) { + classId := c.Param("id") + classWithUserDb := db.ClassWithUserDb{} + classWithUserDb.Set() + classWithUsers, err := classWithUserDb.FindUserIdentity(classId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + var isHasStudent = false + if len(*classWithUsers) > 0 { + isHasStudent = true + } + + e.OutSuc(c, map[string]interface{}{ + "is_has_student": isHasStudent, + }, nil) + return +} diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 78a816d..4bb2ab9 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -172,6 +172,7 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.DELETE("/centralKitchenForSchool/gradeDelete/:id", hdl.CentralKitchenForSchoolGradeDelete) //"央厨-学校"年级删除 r.POST("/centralKitchenForSchool/classList", hdl.CentralKitchenForSchoolClassList) //"央厨-学校"班级列表 r.DELETE("/centralKitchenForSchool/classDelete/:id", hdl.CentralKitchenForSchoolClassDelete) //"央厨-学校"班级删除 + r.DELETE("/centralKitchenForSchool/classDeleteCheck/:id", hdl.CentralKitchenForSchoolClassDeleteCheck) //"央厨-学校"检测班级删除 r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //"央厨-学校"订单列表 r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款