mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-04-05 20:17:53 +08:00
修复删除用户BUG
This commit is contained in:
parent
3aa1552c5c
commit
4eb8aeb999
@ -248,12 +248,15 @@ func (c *ManagerController) DeleteMember() {
|
|||||||
c.JsonResult(404,"参数错误")
|
c.JsonResult(404,"参数错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
_ ,err := models.NewMember().Find(member_id)
|
member ,err := models.NewMember().Find(member_id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error(err)
|
beego.Error(err)
|
||||||
c.JsonResult(500,"用户不存在")
|
c.JsonResult(500,"用户不存在")
|
||||||
}
|
}
|
||||||
|
if member.Role == conf.MemberSuperRole {
|
||||||
|
c.JsonResult(500,"不能删除超级管理员")
|
||||||
|
}
|
||||||
superMember,err := models.NewMember().FindByFieldFirst("role",0)
|
superMember,err := models.NewMember().FindByFieldFirst("role",0)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -390,11 +390,26 @@ func (m *Member) Delete(oldId int,newId int) error {
|
|||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _,relationship := range relationship_list {
|
for _,relationship := range relationship_list {
|
||||||
if o.QueryTable(relationship.TableNameWithPrefix()).Filter("book_id",relationship.BookId).Exist() {
|
//如果存在创始人,则删除
|
||||||
o.Delete(relationship)
|
if relationship.RoleId == 0 {
|
||||||
}else{
|
rel := NewRelationship()
|
||||||
|
|
||||||
|
err = o.QueryTable(relationship.TableNameWithPrefix()).Filter("book_id",relationship.BookId).Filter("member_id",newId).One(rel)
|
||||||
|
if err == nil {
|
||||||
|
if _,err := o.Delete(relationship) ; err != nil{
|
||||||
|
beego.Error(err)
|
||||||
|
}
|
||||||
|
relationship.RelationshipId = rel.RelationshipId
|
||||||
|
}
|
||||||
relationship.MemberId = newId
|
relationship.MemberId = newId
|
||||||
o.Update(relationship)
|
relationship.RoleId = 0
|
||||||
|
if _,err := o.Update(relationship) ; err != nil{
|
||||||
|
beego.Error(err)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if _,err := o.Delete(relationship) ; err != nil{
|
||||||
|
beego.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user