mirror of https://github.com/mindoc-org/mindoc.git
parent
3aa1552c5c
commit
4eb8aeb999
|
@ -248,12 +248,15 @@ func (c *ManagerController) DeleteMember() {
|
|||
c.JsonResult(404,"参数错误")
|
||||
}
|
||||
|
||||
_ ,err := models.NewMember().Find(member_id)
|
||||
member ,err := models.NewMember().Find(member_id)
|
||||
|
||||
if err != nil {
|
||||
beego.Error(err)
|
||||
c.JsonResult(500,"用户不存在")
|
||||
}
|
||||
if member.Role == conf.MemberSuperRole {
|
||||
c.JsonResult(500,"不能删除超级管理员")
|
||||
}
|
||||
superMember,err := models.NewMember().FindByFieldFirst("role",0)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -390,11 +390,26 @@ func (m *Member) Delete(oldId int,newId int) error {
|
|||
|
||||
if err == nil {
|
||||
for _,relationship := range relationship_list {
|
||||
if o.QueryTable(relationship.TableNameWithPrefix()).Filter("book_id",relationship.BookId).Exist() {
|
||||
o.Delete(relationship)
|
||||
}else{
|
||||
//如果存在创始人,则删除
|
||||
if relationship.RoleId == 0 {
|
||||
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
|
||||
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