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, }, }, "user_identity_cert_type_list": []map[string]interface{}{ { "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForIdCard), "value": enum.UserIdentityCertTypeForIdCard, }, { "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForStudentId), "value": enum.UserIdentityCertTypeForStudentId, }, //{ // "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport), // "value": enum.UserIdentityCertTypeForPassport, //}, }, }, 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 }