|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- "applet/app/admin/md"
- "applet/app/admin/svc"
- "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.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForSchool),
- "value": enum.EnterprisePvdByCentralKitchenForSchool,
- },
- {
- "name": enum.EnterprisePvd.String(enum.EnterprisePvdByCentralKitchenForFactory),
- "value": enum.EnterprisePvdByCentralKitchenForFactory,
- },
- {
- "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForSchool),
- "value": enum.EnterprisePvdBySelfSupportForSchool,
- },
- {
- "name": enum.EnterprisePvd.String(enum.EnterprisePvdBySelfSupportForFactory),
- "value": enum.EnterprisePvdBySelfSupportForFactory,
- },
- {
- "name": enum.EnterprisePvd.String(enum.EnterprisePvdByNursingHome),
- "value": enum.EnterprisePvdByNursingHome,
- },
- },
- }, 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
- }
|