package svc import ( "applet/app/db" "applet/app/db/model" "applet/app/enum" "errors" ) func DeleteUserIdentityForCentralKitchenForStudent(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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、删除 class_with_user _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) if err != nil { return } return } func DeleteUserIdentityForCentralKitchenForTeacher(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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 } func DeleteUserIdentityForSelfSupportForStudent(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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、删除 class_with_user _, err = db.Db.In("user_identity_id", userIdentityId).Delete(model.ClassWithUser{}) if err != nil { return } return } func DeleteUserIdentityForSelfSupportForTeacher(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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 } func DeleteUserIdentityForSelfSupportForWorker(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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 } func DeleteUserIdentityForFactory(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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 } func DeleteUserIdentityForNursingHome(userIdentityId int) (err error) { //1、删除 user_identity(将`state`变成"冻结"状态) userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(0) identity, err := userIdentityDb.GetUserIdentity(userIdentityId) if err != nil { 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 }