|
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- "applet/app/admin/md"
- "applet/app/admin/svc"
- svc2 "applet/app/admin/svc/enterprise_manage"
- "applet/app/db"
- "applet/app/e"
- "applet/app/enum"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- )
-
- func EnterpriseManageInfo(c *gin.Context) {
- enterpriseId := c.DefaultQuery("enterprise_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 == 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(utils.StrToInt(enterpriseId))
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool {
- err, resp = svc.SelfSupportForSchoolInfo(utils.StrToInt(enterpriseId))
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- if enterprise.Kind == enum.EnterpriseKindByNursingHome {
- err, resp = svc.NursingHomeInfo(utils.StrToInt(enterpriseId))
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
-
- e.OutSuc(c, map[string]interface{}{
- "info": resp,
- "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,
- },
- {
- "name": enum.EnterpriseKind(enum.EnterpriseKindByNursingHome).String(),
- "value": enum.EnterpriseKindByNursingHome,
- },
- },
- }, nil)
- return
- }
-
- func UserIdentityList(c *gin.Context) {
- var req md.EnterpriseUserListReq
- 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
- }
-
- var resp interface{}
- //判断校企类型
- if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
- resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool {
- resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- if enterprise.Kind == enum.EnterpriseKindByNursingHome {
- resp, err = svc2.EnterpriseUserListByNursingHome(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- e.OutSuc(c, resp, nil)
- return
- }
|