Skip to content

Commit

Permalink
修复编辑API时RoleApi错误的问题,MenuName不允许编辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Junvary committed Jul 14, 2023
1 parent 4143120 commit 45e8136
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
22 changes: 14 additions & 8 deletions GQA-BACKEND/service/private/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@ func (s *ServiceApi) EditApi(toEditApi model.SysApi) (err error) {
Find(&oldRoleApiList).Error; err != nil {
return err
}
// 将oldRoleApiList中的ApiGroup、ApiMethod、ApiPath替换成toEditApi中的ApiGroup、ApiMethod、ApiPath并保存回数据库
if err = tx.Where("api_group = ? and api_method = ? and api_path = ?", oldApi.ApiGroup, oldApi.ApiMethod, oldApi.ApiPath).
Delete(&model.SysRoleApi{}).Error; err != nil {
return err
}
var newRoleApiList []model.SysRoleApi
for _, oldRoleApi := range oldRoleApiList {
oldRoleApi.ApiGroup = toEditApi.ApiGroup
oldRoleApi.ApiMethod = toEditApi.ApiMethod
oldRoleApi.ApiPath = toEditApi.ApiPath
if err = tx.Where("api_group = ? and api_method = ? and api_path = ?", oldApi.ApiGroup, oldApi.ApiMethod, oldApi.ApiPath).
Updates(&oldRoleApi).Error; err != nil {
return err
}
newRoleApiList = append(newRoleApiList, model.SysRoleApi{
RoleCode: oldRoleApi.RoleCode,
ApiGroup: oldApi.ApiGroup,
ApiMethod: oldApi.ApiMethod,
ApiPath: oldApi.ApiPath,
})
}
if err = tx.Create(&newRoleApiList).Error; err != nil {
return err
}
return nil
})
Expand Down
3 changes: 3 additions & 0 deletions GQA-BACKEND/service/private/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (s *ServiceMenu) EditMenu(toEditMenu model.SysMenu) (err error) {
if sysMenu.Stable == "yesNo_yes" {
return errors.New(utils.GqaI18n("StableCantDo") + toEditMenu.Title)
}
if sysMenu.Name != toEditMenu.Name {
return errors.New(utils.GqaI18n("EditFailed") + sysMenu.Name)
}
return global.GqaDb.Transaction(func(tx *gorm.DB) error {
//先删除关联button表中menu_name的记录
var menuButton model.SysButton
Expand Down
2 changes: 1 addition & 1 deletion GQA-BACKEND/service/private/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *ServiceUser) EditUser(toEditUser model.SysUser) (err error) {
return err
}
toEditUser.Password = sysUser.Password
//err = global.GqaDb.Updates(&toEditUser).Error
//err = tx.Updates(&toEditUser).Error
err = tx.Save(&toEditUser).Error
return err
})
Expand Down
5 changes: 2 additions & 3 deletions GQA-FRONTEND/src/pages/System/Menu/modules/recordDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
</div>
<div class="row q-gutter-md">
<q-input outlined hint="" class="col" v-model="recordDetail.value.title"
:label="$t('Menu') + $t('Name')"
:rules="[val => val && val.length > 0 || $t('NeetInput')]" />
:label="$t('Menu') + $t('Name')" :rules="[val => val && val.length > 0 || $t('NeetInput')]" />
<q-input outlined hint="" class="col" v-model="recordDetail.value.name"
:label="$t('Menu') + $t('Code')"
:label="$t('Menu') + $t('Code')" :disable="formType === 'edit'"
:rules="[val => val && val.length > 0 || $t('NeetInput')]" />
<q-input outlined hint="" class="col" v-model="recordDetail.value.parent_code"
:label="$t('Parent') + $t('Code')" />
Expand Down

0 comments on commit 45e8136

Please sign in to comment.