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 }