|
- package hdl
-
- import (
- "applet/app/customer/lib/validate"
- "applet/app/customer/md"
- "applet/app/customer/svc"
- "applet/app/db"
- "applet/app/e"
- "applet/app/enum"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- )
-
- func EnterpriseList(c *gin.Context) {
- var req md.EnterpriseListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- if req.Limit == 0 {
- req.Limit = 10
- }
- if req.Page == 0 {
- req.Page = 10
- }
- enterprises, total, err := svc.EnterpriseList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": enterprises,
- "total": total,
- "kind": []map[string]interface{}{
- {
- "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
- "value": enum.EnterpriseKindByCentralKitchenForSchool,
- },
- {
- "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
- "value": enum.EnterpriseKindByCentralKitchenForFactory,
- },
- {
- "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
- "value": enum.EnterpriseKindBySelfSupportForSchool,
- },
- {
- "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
- "value": enum.EnterpriseKindBySelfSupportForFactory,
- },
- },
- }, nil)
- return
- }
-
- func EnterpriseInfo(c *gin.Context) {
- enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(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
- }
-
- var resp interface{}
- //判断单位类型
- if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
- err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- if enterprise.Kind == enum.EnterpriseKindByNursingHome {
- err, resp = svc.NursingHomePackageInfo(enterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
-
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, enum.NursingHomeReserveMealTime, enum.NursingHomeCancelMealTime)
- e.OutSuc(c, map[string]interface{}{
- "info": resp,
- "set_center": res,
- "enterprise_kind_list": []map[string]interface{}{
- {
- "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
- "value": enum.EnterpriseKindByCentralKitchenForSchool,
- },
- {
- "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
- "value": enum.EnterpriseKindByCentralKitchenForFactory,
- },
- {
- "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
- "value": enum.EnterpriseKindBySelfSupportForSchool,
- },
- {
- "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
- "value": enum.EnterpriseKindBySelfSupportForFactory,
- },
- {
- "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
- "value": enum.EnterpriseKindByNursingHome,
- },
- },
- }, nil)
- return
- }
-
- func SchoolBelowGrade(c *gin.Context) {
- enterpriseId := c.DefaultQuery("enterprise_id", "")
- gradeDb := db.GradeDb{}
- gradeDb.Set(utils.StrToInt(enterpriseId))
- gradeList, err := gradeDb.FindGrade()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": gradeList,
- }, nil)
- return
- }
-
- func SchoolGradeBelowClass(c *gin.Context) {
- gradeId := c.DefaultQuery("grade_id", "")
- classDb := db.ClassDb{}
- classDb.Set(utils.StrToInt(gradeId))
- classList, err := classDb.FindClass()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": classList,
- }, nil)
- return
- }
|