|
|
@@ -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 |
|
|
|
} |