瀏覽代碼

update

add_mode
DengBiao 1 年之前
父節點
當前提交
49c8b57f15
共有 3 個文件被更改,包括 64 次插入0 次删除
  1. +16
    -0
      app/admin/hdl/hdl_enterprise.go
  2. +13
    -0
      app/admin/md/md_enterprise_v2.go
  3. +35
    -0
      app/admin/svc/svc_enterprise.go

+ 16
- 0
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())


+ 13
- 0
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"`
}

+ 35
- 0
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()


Loading…
取消
儲存