@@ -78,6 +78,22 @@ func EnterpriseList(c *gin.Context) { | |||||
func Detail(c *gin.Context) { | func Detail(c *gin.Context) { | ||||
enterpriseId := c.DefaultQuery("id", "") | 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)) | detail, err := svc.EnterpriseDetail(utils.StrToInt(enterpriseId)) | ||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
@@ -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"` | |||||
} |
@@ -92,6 +92,41 @@ func EnterpriseDetail(enterpriseId int) (data md.EnterpriseDetailResp, err error | |||||
return | 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) { | func EnterpriseDelete(enterpriseIds []int) (err error) { | ||||
session := db.Db.NewSession() | session := db.Db.NewSession() | ||||
defer session.Close() | defer session.Close() | ||||