Skip to content

Commit

Permalink
fix:the menu permission issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jzfai committed Dec 13, 2023
1 parent b7a669f commit 1d8858e
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public R<HashMap<String, Object>> getUserInfo(Integer platformId) {
*/
@GetMapping("getMenu")
public R<List<SysMenu>> getMenu(Integer platformId) {

List<SysMenu> menus = rbacService.selectMenuByUserId(LoginHelper.getUserId(), platformId);
return R.ok(menus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ public R<Void> remove(@PathVariable Long[] sysMenuIds) {
return R.result(sysMenuService.deleteSysMenuByIds(sysMenuIds));
}


/**
* 删除单个sysMenu
*
* @param sysMenuId sysMenuID
*/
@DeleteMapping("/{sysMenuId}")
public R<Void> remove(@PathVariable Long sysMenuId) {
return R.result(sysMenuService.deleteSysMenuById(sysMenuId));
}

/**
* 获取sysMenu选择框列表
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.hugo.admin.entity.SysMenu;
import top.hugo.admin.mapper.SysMenuMapper;
import top.hugo.admin.query.SysMenuQuery;
import top.hugo.admin.vo.SysMenuVo;
import top.hugo.domain.TableDataInfo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -86,8 +88,10 @@ public SysMenu selectSysMenuById(Long sysMenuId) {
* @param sysMenuId 平台ID
* @return 结果
*/

@Transactional(rollbackFor = Exception.class)
public int deleteSysMenuById(Long sysMenuId) {
ArrayList<Long> childrenIdListByMeuId = getChildrenIdListByMeuId(sysMenuId);
sysMenuMapper.deleteBatchIds(childrenIdListByMeuId);
return sysMenuMapper.deleteById(sysMenuId);
}

Expand All @@ -107,8 +111,9 @@ public int deleteSysMenuByIds(Long[] sysMenuIds) {
* @param sysMenu 平台信息
* @return 结果
*/

public int insertSysMenu(SysMenu sysMenu) {


return sysMenuMapper.insert(sysMenu);
}

Expand All @@ -119,9 +124,50 @@ public int insertSysMenu(SysMenu sysMenu) {
* @param sysMenu 平台信息
* @return 结果
*/

@Transactional(rollbackFor = Exception.class)
public int updateSysMenu(SysMenu sysMenu) {
//如果是父级菜单统一设置状态
ArrayList<SysMenu> childrenIdList = getChildrenIdList(sysMenu.getMenuId(), sysMenu.getStatus());
if (childrenIdList.size() > 0) {
sysMenuMapper.updateBatchById(childrenIdList);
}
return sysMenuMapper.updateById(sysMenu);
}


/*
* 查询该memuId下的所有子元素
* */
public ArrayList<SysMenu> getChildrenIdList(Long menuId, String status) {
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>();
lqw.eq(SysMenu::getParentId, menuId);
ArrayList<SysMenu> menuList = new ArrayList<>();
List<SysMenu> sysMenus = sysMenuMapper.selectList(lqw);
if (sysMenus.size() > 0) {
sysMenus.forEach(f -> {
f.setStatus(status);
menuList.add(f);
getChildrenIdList(f.getMenuId(), status);
});
}
return menuList;
}


/*
* 查询该memuId下的所有子元素id
* */
public ArrayList<Long> getChildrenIdListByMeuId(Long menuId) {
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>();
lqw.eq(SysMenu::getParentId, menuId);
ArrayList<Long> menuList = new ArrayList<>();
List<SysMenu> sysMenus = sysMenuMapper.selectList(lqw);
if (sysMenus.size() > 0) {
sysMenus.forEach(f -> {
menuList.add(f.getMenuId());
getChildrenIdListByMeuId(f.getMenuId());
});
}
return menuList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class ConfigSaveController {
* @return
*/
@GetMapping("/listPage")
public R<TableDataInfo<ConfigSaveVo>> list(@Validated ConfigSaveQuery configSave) {
public TableDataInfo<ConfigSaveVo> list(@Validated ConfigSaveQuery configSave) {
TableDataInfo<ConfigSaveVo> list = configSaveService.selectPageConfigSaveList(configSave);
return R.ok(list);
return list;
}

/**
Expand Down Expand Up @@ -82,15 +82,22 @@ public R<Void> edit(@Validated @RequestBody ConfigSaveDto configSaveDto) {
return R.result(configSaveService.updateConfigSave(configSave));
}


@DeleteMapping("/{configSaveIds}")
public R<Void> remove(@PathVariable Long configSaveIds) {
return R.result(configSaveService.deleteConfigSaveById(configSaveIds));
}


/**
* 删除configSave
*
* @param configSaveIds configSaveID串
*/
//@SaCheckPermission("system:configSave:remove")
//@Log(title = "configSave管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configSaveIds}")
public R<Void> remove(@PathVariable Long[] configSaveIds) {
@DeleteMapping("deleteBatchIds")
public R<Void> remove(@RequestBody Long[] configSaveIds) {
return R.result(configSaveService.deleteConfigSaveByIds(configSaveIds));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/generator")
@RequestMapping("/generator/templateFile")
public class GeneratorController {
private final GeneratorService generatorService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
@RestController
@RequestMapping("/generator/templateFile")
public class TemplateFileController {

private final TemplateFileService templateFileService;

/**
* 获取templateFile列表(分页)
*/
@GetMapping("/listPage")
public R<TableDataInfo<TemplateFileVo>> list(@Validated TemplateFileQuery templateFile) {
public TableDataInfo<TemplateFileVo> list(@Validated TemplateFileQuery templateFile) {
TableDataInfo<TemplateFileVo> list = templateFileService.selectPageTemplateFileList(templateFile);
return R.ok(list);
return list;
}

/**
Expand Down Expand Up @@ -81,6 +81,17 @@ public R<Void> edit(@Validated @RequestBody TemplateFileDto templateFileDto) {
return R.result(templateFileService.updateTemplateFile(templateFile));
}


/**
* 删除templateFile
*
* @param templateFileId templateFileID串
*/
@DeleteMapping("deleteById/{templateFileId}")
public R<Void> deleteTemplateFileById(@PathVariable Long templateFileId) {
return R.result(templateFileService.deleteTemplateFileById(templateFileId));
}

/**
* 删除templateFile
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public class ConfigSaveDto {
*/
@NotBlank(message = "name不能为空")
private String name;

/**
* id
*/
private Integer id;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package top.hugo.generator.dto;

import lombok.Data;
import top.hugo.generator.entity.TemplateFile;

@Data
public class TemplateChangeDto extends TemplateFile {
public class TemplateChangeDto {
private String fileName;
private String code;
/**
* id
*/
private Integer id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public class TemplateFileDto {
* 文件存储名
*/
private String name;
/**
* id
*/
private Integer id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ public class ConfigSaveVo implements Serializable {
*/
@ExcelProperty(value = "配置名称")
private String name;

/**
* 配置名称
*/
private Integer id;
}
12 changes: 9 additions & 3 deletions hugo-admin-service/src/main/resources/mapper/RbacMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@
</sql>
<select id="selectMenuAll" resultType="SysMenu">
<include refid="selectMenuVo"/>
where m.menu_type!="F" and m.platform_id=#{platformId} order by m.order_num
where m.menu_type!="F" and m.platform_id=#{platformId}
and m.status="0"
order by m.order_num
</select>
<select id="selectMenuByUserId" resultType="SysMenu">
<include refid="selectMenuVo"/>
where sur.user_id = #{userId} and m.menu_type!="F" and m.platform_id=#{platformId} order by m.order_num
where sur.user_id = #{userId} and m.menu_type!="F" and m.platform_id=#{platformId}
and m.status="0"
order by m.order_num
</select>
<select id="selectBtnPermByUserId" resultType="SysMenu">
<include refid="selectMenuVo"/>
where sur.user_id = #{userId} and m.menu_type = "F" and m.platform_id=#{platformId} order by m.order_num
where sur.user_id = #{userId} and m.menu_type = "F" and m.platform_id=#{platformId}
and m.status="0"
order by m.order_num
</select>


Expand Down

0 comments on commit 1d8858e

Please sign in to comment.