Browse Source

修复前端项目代码丢失,问题,修复角色拷贝功能

main
pixel 5 years ago
parent
commit
aa4fa94ce6
  1. 2
      server/api/v1/sys_authority.go
  2. 10
      server/service/sys_authority.go
  3. 4
      web/src/view/superAdmin/authority/authority.vue

2
server/api/v1/sys_authority.go

@ -42,7 +42,7 @@ func CopyAuthority(c *gin.Context) {
_ = c.ShouldBindJSON(&copyInfo) _ = c.ShouldBindJSON(&copyInfo)
err, authBack := service.CopyAuthority(copyInfo) err, authBack := service.CopyAuthority(copyInfo)
if err != nil { if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
response.FailWithMessage(fmt.Sprintf("拷贝失败,%v", err), c)
} else { } else {
response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c) response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
} }

10
server/service/sys_authority.go

@ -17,6 +17,11 @@ import (
// @return authority model.SysAuthority // @return authority model.SysAuthority
func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) { func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
var authorityBox model.SysAuthority
notHas := global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).Find(&authorityBox).RecordNotFound()
if !notHas {
return errors.New("存在相同角色id"), auth
}
err = global.GVA_DB.Create(&auth).Error err = global.GVA_DB.Create(&auth).Error
return err, auth return err, auth
} }
@ -29,6 +34,11 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
// @return authority model.SysAuthority // @return authority model.SysAuthority
func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) { func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) {
var authorityBox model.SysAuthority
notHas := global.GVA_DB.Where("authority_id = ?", copyInfo.Authority.AuthorityId).Find(&authorityBox).RecordNotFound()
if !notHas {
return errors.New("存在相同角色id"), authority
}
copyInfo.Authority.Children = []model.SysAuthority{} copyInfo.Authority.Children = []model.SysAuthority{}
err, menus := GetMenuAuthority(copyInfo.OldAuthorityId) err, menus := GetMenuAuthority(copyInfo.OldAuthorityId)
var baseMenu []model.SysBaseMenu var baseMenu []model.SysBaseMenu

4
web/src/view/superAdmin/authority/authority.vue

@ -130,11 +130,11 @@ export default {
this.dialogTitle = "拷贝角色" this.dialogTitle = "拷贝角色"
this.dialogType = "copy" this.dialogType = "copy"
for(let k in this.form) { for(let k in this.form) {
this.form[key] = row[key]
this.form[k] = row[k]
} }
this.copyForm = row this.copyForm = row
this.dialogFormVisible = true; this.dialogFormVisible = true;
}
},
opdendrawer(row) { opdendrawer(row) {
this.drawer = true this.drawer = true
this.activeRow = row this.activeRow = row

Loading…
Cancel
Save