From 2a663b7e9eff0f81e7434178197c6d19cdbd102d Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 24 Aug 2023 10:52:30 +0800 Subject: [PATCH] update --- app/admin/md/md_enterprise_manage.go | 1 + .../svc_central_kitchen_for_school.go | 2 + app/customer/hdl/hdl_user_identity.go | 6 +- app/customer/svc/svc_user_identity.go | 100 +++++++++++++----- ..._central_kitchen_for_school_package_ord.go | 1 + 5 files changed, 84 insertions(+), 26 deletions(-) diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 4f49932..9641efc 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -175,6 +175,7 @@ type CentralKitchenForSchoolOrdRefundReq struct { type CentralKitchenForSchoolOrdListResp struct { EnterpriseId int `json:"enterprise_id" ` + EnterpriseName string `json:"enterprise_name" ` Uid int `json:"uid" ` UserIdentityId int `json:"user_identity_id" ` UserIdentityName string `json:"user_identity_name" ` diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index 81e7fbc..2d69c6d 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -440,6 +440,7 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r var m []*db.CentralKitchenForSchoolPackageOrdWithUserIdentity count, err = sess. Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). + Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id"). Join("LEFT", "class", "class_with_user.class_id = class.id"). Join("LEFT", "grade", "class.grade_id = grade.id"). @@ -451,6 +452,7 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r for _, v := range m { resp = append(resp, md.CentralKitchenForSchoolOrdListResp{ EnterpriseId: v.UserIdentity.EnterpriseId, + EnterpriseName: v.Enterprise.Name, Uid: v.UserIdentity.Uid, UserIdentityId: v.UserIdentity.Id, UserIdentityName: v.CentralKitchenForSchoolPackageOrd.UserIdentityName, diff --git a/app/customer/hdl/hdl_user_identity.go b/app/customer/hdl/hdl_user_identity.go index c26763c..02cd8f7 100644 --- a/app/customer/hdl/hdl_user_identity.go +++ b/app/customer/hdl/hdl_user_identity.go @@ -85,7 +85,8 @@ func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) { //4、修改身份信息 isHasUserIdentity.Uid = user.Id isHasUserIdentity.Name = req.Name - _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name") + isHasUserIdentity.State = enum.UserIdentityStateForNormal + _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state") if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return @@ -207,7 +208,8 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { //4、修改身份信息 isHasUserIdentity.Uid = user.Id isHasUserIdentity.Name = req.Name - _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name") + isHasUserIdentity.State = enum.UserIdentityStateForNormal + _, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state") if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return diff --git a/app/customer/svc/svc_user_identity.go b/app/customer/svc/svc_user_identity.go index cceb216..b65fa2b 100644 --- a/app/customer/svc/svc_user_identity.go +++ b/app/customer/svc/svc_user_identity.go @@ -3,61 +3,113 @@ package svc import ( "applet/app/db" "applet/app/db/model" + "applet/app/enum" + "errors" ) func DeleteUserIdentityForCentralKitchenForStudent(userIdentityId int) (err error) { - //1、删除 class_with_user - _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) + //1、删除 user_identity(将`state`变成"冻结"状态) + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { - return + return err + } + identity.State = enum.UserIdentityStateForFreeze + updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") + if err != nil { + return err + } + if updateAffected <= 0 { + return errors.New("删除用户信息数据失败") } - //2、删除 user_identity - _, err = db.Db.Where("id =?", userIdentityId).Delete(model.UserIdentity{}) + //2、删除 class_with_user + _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) if err != nil { return } - return nil + return } func DeleteUserIdentityForCentralKitchenForTeacher(userIdentityId int) (err error) { - //删除 user_identity - _, err = db.Db.Where("id =?", userIdentityId).Delete(model.UserIdentity{}) + //1、删除 user_identity(将`state`变成"冻结"状态) + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { - return + return err + } + identity.State = enum.UserIdentityStateForFreeze + updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") + if err != nil { + return err } - return nil + if updateAffected <= 0 { + return errors.New("删除用户信息数据失败") + } + return } func DeleteUserIdentityForSelfSupportForStudent(userIdentityId int) (err error) { - //1、删除 class_with_user - _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) + //1、删除 user_identity(将`state`变成"冻结"状态) + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { - return + return err + } + identity.State = enum.UserIdentityStateForFreeze + updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") + if err != nil { + return err + } + if updateAffected <= 0 { + return errors.New("删除用户信息数据失败") } - //2、删除 user_identity - _, err = db.Db.Where("id =?", userIdentityId).Delete(model.UserIdentity{}) + //2、删除 class_with_user + _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) if err != nil { return } - return nil + return } func DeleteUserIdentityForSelfSupportForTeacher(userIdentityId int) (err error) { - //删除 user_identity - _, err = db.Db.Where("id =?", userIdentityId).Delete(model.UserIdentity{}) + //1、删除 user_identity(将`state`变成"冻结"状态) + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { - return + return err + } + identity.State = enum.UserIdentityStateForFreeze + updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") + if err != nil { + return err + } + if updateAffected <= 0 { + return errors.New("删除用户信息数据失败") } - return nil + return } func DeleteUserIdentityForSelfSupportForWorker(userIdentityId int) (err error) { - //删除 user_identity - _, err = db.Db.Where("id =?", userIdentityId).Delete(model.UserIdentity{}) + //1、删除 user_identity(将`state`变成"冻结"状态) + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { - return + return err + } + identity.State = enum.UserIdentityStateForFreeze + updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") + if err != nil { + return err + } + if updateAffected <= 0 { + return errors.New("删除用户信息数据失败") } - return nil + return } diff --git a/app/db/db_central_kitchen_for_school_package_ord.go b/app/db/db_central_kitchen_for_school_package_ord.go index b8adf5b..68701d7 100644 --- a/app/db/db_central_kitchen_for_school_package_ord.go +++ b/app/db/db_central_kitchen_for_school_package_ord.go @@ -96,6 +96,7 @@ func (centralKitchenForSchoolPackageOrdDb *CentralKitchenForSchoolPackageOrd) Ce type CentralKitchenForSchoolPackageOrdWithUserIdentity struct { model.CentralKitchenForSchoolPackageOrd `xorm:"extends"` model.UserIdentity `xorm:"extends"` + model.Enterprise `xorm:"extends"` model.ClassWithUser `xorm:"extends"` model.Class `xorm:"extends"` model.Grade `xorm:"extends"`