|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 UserList(c *gin.Context) {
- var req md.UserListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- list, err := svc.UserList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "user_identity_kind_list": []map[string]interface{}{
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
- "value": enum.UserIdentityForCentralKitchenForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
- "value": enum.UserIdentityForCentralKitchenForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
- "value": enum.UserIdentityForCentralKitchenForWorker,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
- "value": enum.UserIdentityForSelfSupportForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
- "value": enum.UserIdentityForSelfSupportForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
- "value": enum.UserIdentityForSelfSupportForWorker,
- },
- },
- "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 CentralKitchenForSchoolUserList(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
- }
-
- resp, err := svc2.EnterpriseUserListByCentralKitchenForSchoolV2(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, resp, nil)
- return
- }
-
- func CentralKitchenForSchoolUserUpdate(c *gin.Context) {
- var req md.CentralKitchenForSchoolUserUpdateReqV2
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- err = svc2.CentralKitchenForSchoolUserUpdateV2(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func CentralKitchenForSchoolUserDelete(c *gin.Context) {
- var req md.CentralKitchenForSchoolUserDeleteReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- err = svc2.CentralKitchenForSchoolUserDeleteV2(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func UserUpdate(c *gin.Context) {
- var req md.UserList
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- err = svc.UserUpdate(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func UserDelete(c *gin.Context) {
- id := c.Param("id")
- //TODO::判断当前用户下是否还绑定了身份
- userIdentityDb := db.UserIdentityDb{}
- userIdentityDb.Set(utils.StrToInt(id))
- identity, err := userIdentityDb.FindUserIdentity()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if len(*identity) > 0 {
- e.OutErr(c, e.ERR_DB_ORM, "当前用户下存在未解绑身份")
- return
- }
-
- userDb := db.UserDb{}
- userDb.Set()
- _, err = userDb.DeleteUser(utils.StrToInt(id))
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
|