diff --git a/app/admin/hdl/hdl_enterprise.go b/app/admin/hdl/hdl_enterprise.go index 0d366bd..821d30b 100644 --- a/app/admin/hdl/hdl_enterprise.go +++ b/app/admin/hdl/hdl_enterprise.go @@ -78,6 +78,22 @@ func EnterpriseList(c *gin.Context) { func Detail(c *gin.Context) { enterpriseId := c.DefaultQuery("id", "") + enterpriseDb := db.EnterpriseDb{} + enterpriseDb.Set() + enterprise, err := enterpriseDb.GetEnterprise(utils.StrToInt(enterpriseId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if enterprise.Kind == enum.EnterprisePvdBySelfSupportForSchool { + detail, err := svc.EnterpriseDetailV2(utils.StrToInt(enterpriseId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, detail, nil) + return + } detail, err := svc.EnterpriseDetail(utils.StrToInt(enterpriseId)) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/app/admin/md/md_enterprise_v2.go b/app/admin/md/md_enterprise_v2.go new file mode 100644 index 0000000..8ff98e3 --- /dev/null +++ b/app/admin/md/md_enterprise_v2.go @@ -0,0 +1,13 @@ +package md + +import "applet/app/db/model" + +type EnterpriseDetailRespV2 struct { + Enterprise model.Enterprise `json:"enterprise"` + GradeList []GradeListStructV2 `json:"grade_list"` +} + +type GradeListStructV2 struct { + Grade model.Grade `json:"grade"` + ClassList []model.Class `json:"class_list"` +} diff --git a/app/admin/svc/svc_enterprise.go b/app/admin/svc/svc_enterprise.go index 77f3bbd..2ae6b8b 100644 --- a/app/admin/svc/svc_enterprise.go +++ b/app/admin/svc/svc_enterprise.go @@ -92,6 +92,41 @@ func EnterpriseDetail(enterpriseId int) (data md.EnterpriseDetailResp, err error return } +func EnterpriseDetailV2(enterpriseId int) (data md.EnterpriseDetailRespV2, err error) { + //1、查找所在单位 + enterpriseDb := db.EnterpriseDb{} + enterpriseDb.Set() + enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) + if err != nil { + return + } + data.Enterprise = *enterprise + + //2、查找对应年级 + gradeDb := db.GradeDb{} + gradeDb.Set(enterpriseId) + gradeList, err := gradeDb.FindGrade() + if err != nil { + return + } + + for _, v := range *gradeList { + //3、查找对应班级 + classDb := db.ClassDb{} + classDb.Set(v.Id) + classes, err1 := classDb.FindClass() + if err1 != nil { + err = err1 + return + } + data.GradeList = append(data.GradeList, md.GradeListStructV2{ + Grade: v, + ClassList: *classes, + }) + } + return +} + func EnterpriseDelete(enterpriseIds []int) (err error) { session := db.Db.NewSession() defer session.Close()