From 572f5fb37b71d2481bdc152cbacf0ba21e19d2bc Mon Sep 17 00:00:00 2001 From: dengbiao Date: Fri, 6 Sep 2024 14:08:28 +0800 Subject: [PATCH] 1 --- .../hdl_central_kitchen_for_school.go | 65 +++++++++++++++++++ .../hdl_self_support_for_school.go | 65 +++++++++++++++++++ app/admin/md/md_enterprise_manage.go | 14 ++++ .../svc_central_kitchen_for_school.go | 12 ++++ .../svc_self_support_for_school.go | 12 ++++ app/router/admin_router.go | 4 ++ 6 files changed, 172 insertions(+) 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 debb2b1..993d0b3 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 @@ -1662,6 +1662,39 @@ func CentralKitchenForSchoolOrdDetail(c *gin.Context) { return } +func CentralKitchenForSchoolPeriodList(c *gin.Context) { + var req md.CentralKitchenForSchoolPeriodListReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + enterpriseDb := db.EnterpriseDb{} + enterpriseDb.Set() + enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if enterprise == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") + return + } + + resp, total, err := svc2.CentralKitchenForSchoolPeriodList(req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "list": resp, + "total": total, + }, nil) + return +} + func CentralKitchenForSchoolGradeList(c *gin.Context) { var req md.CentralKitchenForSchoolGradeListReq err := c.ShouldBindJSON(&req) @@ -1760,6 +1793,38 @@ func CentralKitchenForSchoolGradeDelete(c *gin.Context) { return } +func CentralKitchenForSchoolPeriodDelete(c *gin.Context) { + periodId := c.Param("id") + //1、查找当前学段 + periodDb := db.PeriodDb{} + periodDb.Set(0) + period, err := periodDb.GetPeriod(utils.StrToInt(periodId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + //2、查找当前年级下是否还包含年级 + gradeDb := db.GradeDb{} + gradeDb.Set(0) + grade, err := gradeDb.FindGradeByPeriodId(utils.StrToInt(periodId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if len(*grade) > 0 { + e.OutErr(c, e.ERR, "当前学段下存在未删除的年级!") + return + } + _, err = periodDb.PeriodDeleteBySession(period.Id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + func CentralKitchenForSchoolClassDelete(c *gin.Context) { classId := c.Param("id") classWithUserDb := db.ClassWithUserDb{} diff --git a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go index 202940b..5c4190b 100644 --- a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go @@ -525,6 +525,71 @@ func SelfSupportForSchoolGradeList(c *gin.Context) { return } +func SelfSupportForSchoolPeriodList(c *gin.Context) { + var req md.SelfSupportForSchoolPeriodListReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + enterpriseDb := db.EnterpriseDb{} + enterpriseDb.Set() + enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if enterprise == nil { + e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") + return + } + + resp, total, err := svc2.SelfSupportForSchoolPeriodList(req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "list": resp, + "total": total, + }, nil) + return +} + +func SelfSupportForSchoolPeriodDelete(c *gin.Context) { + periodId := c.Param("id") + //1、查找当前学段 + periodDb := db.PeriodDb{} + periodDb.Set(0) + period, err := periodDb.GetPeriod(utils.StrToInt(periodId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + //2、查找当前年级下是否还包含年级 + gradeDb := db.GradeDb{} + gradeDb.Set(0) + grade, err := gradeDb.FindGradeByPeriodId(utils.StrToInt(periodId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if len(*grade) > 0 { + e.OutErr(c, e.ERR, "当前学段下存在未删除的年级!") + return + } + _, err = periodDb.PeriodDeleteBySession(period.Id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + func SelfSupportForSchoolClassList(c *gin.Context) { var req md.SelfSupportForSchoolClassListReq err := c.ShouldBindJSON(&req) diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 5c786b3..42d94f7 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -494,6 +494,13 @@ type CentralKitchenForSchoolGradeListReq struct { Name string `json:"name" label:"名称"` } +type CentralKitchenForSchoolPeriodListReq struct { + EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` + Limit int `json:"limit" binding:"required"` + Page int `json:"page" binding:"required"` + Name string `json:"name" label:"名称"` +} + type CentralKitchenForSchoolClassListReq struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` GradeId int `json:"grade_id" label:"年级id"` @@ -509,6 +516,13 @@ type SelfSupportForSchoolGradeListReq struct { Name string `json:"name" label:"名称"` } +type SelfSupportForSchoolPeriodListReq struct { + EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` + Limit int `json:"limit" binding:"required"` + Page int `json:"page" binding:"required"` + Name string `json:"name" label:"名称"` +} + type SelfSupportForSchoolClassListReq struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` GradeId int `json:"grade_id" label:"年级id"` diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index 10541e5..191de07 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -2551,6 +2551,18 @@ func CentralKitchenForSchoolGradeList(req md.CentralKitchenForSchoolGradeListReq return } +func CentralKitchenForSchoolPeriodList(req md.CentralKitchenForSchoolPeriodListReq) (m []*model.Period, count int64, err error) { + sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) + if req.Name != "" { + sess.And("name like ?", "%"+req.Name+"%") + } + count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) + if err != nil { + return nil, 0, err + } + return +} + func CentralKitchenForSchoolClassList(req md.CentralKitchenForSchoolClassListReq) (m []*model.Class, count int64, err error) { sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) if req.Name != "" { diff --git a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go index 1978985..65a4a22 100644 --- a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go @@ -567,6 +567,18 @@ func SelfSupportForSchoolGradeList(req md.SelfSupportForSchoolGradeListReq) (m [ return } +func SelfSupportForSchoolPeriodList(req md.SelfSupportForSchoolPeriodListReq) (m []*model.Period, count int64, err error) { + sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) + if req.Name != "" { + sess.And("name like ?", "%"+req.Name+"%") + } + count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) + if err != nil { + return nil, 0, err + } + return +} + func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m []*model.Class, count int64, err error) { sess := db.Db.Where("enterprise_id =?", req.EnterpriseId) if req.Name != "" { diff --git a/app/router/admin_router.go b/app/router/admin_router.go index f10de63..195c34e 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -192,6 +192,8 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.POST("/centralKitchenForSchool/teacherDelete", hdl.CentralKitchenForSchoolTeacherDelete) //"央厨-学校"教师删除 r.POST("/centralKitchenForSchool/gradeList", hdl.CentralKitchenForSchoolGradeList) //"央厨-学校"年级列表 r.DELETE("/centralKitchenForSchool/gradeDelete/:id", hdl.CentralKitchenForSchoolGradeDelete) //"央厨-学校"年级删除 + r.POST("/centralKitchenForSchool/periodList", hdl.CentralKitchenForSchoolPeriodList) //"央厨-学校"学段列表 + r.DELETE("/centralKitchenForSchool/periodDelete/:id", hdl.CentralKitchenForSchoolPeriodDelete) //"央厨-学校"学段删除 r.POST("/centralKitchenForSchool/classList", hdl.CentralKitchenForSchoolClassList) //"央厨-学校"班级列表 r.DELETE("/centralKitchenForSchool/classDelete/:id", hdl.CentralKitchenForSchoolClassDelete) //"央厨-学校"班级删除 r.GET("/centralKitchenForSchool/classDeleteCheck/:id", hdl.CentralKitchenForSchoolClassDeleteCheck) //"央厨-学校"检测班级删除 @@ -235,6 +237,8 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.DELETE("/selfSupportForSchool/gradeDelete/:id", hdl.SelfSupportForSchoolGradeDelete) //"自营-学校"年级删除 r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassList) //"自营-学校"班级列表 r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 + r.POST("/selfSupportForSchool/periodList", hdl.SelfSupportForSchoolPeriodList) //"央厨-学校"学段列表 + r.DELETE("/selfSupportForSchool/periodDelete/:id", hdl.SelfSupportForSchoolPeriodDelete) //"央厨-学校"学段删除 r.GET("/selfSupportForSchool/classDeleteCheck/:id", hdl.SelfSupportForSchoolClassDeleteCheck) //"自营-学校"班级删除 r.POST("/selfSupportForSchool/addStudent", hdl.SelfSupportForSchoolAddStudent) //"自营-学校"添加学生 r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员