修复bean冲突,修复角色管理问题

This commit is contained in:
lhc
2021-04-19 18:12:13 +08:00
parent 067e87c2b8
commit 92c96e46b6
5 changed files with 37 additions and 42 deletions

View File

@@ -61,7 +61,7 @@ public class ShiroConfig {
/**
* @author lhc
* @description // 自定义session管理器
* @date 4:52 下午 2021/4/19
* @date 5:50 下午 2021/4/19
* @params []
* @return org.apache.shiro.session.mgt.SessionManager
**/

View File

@@ -54,7 +54,8 @@ spring:
druid:
# 配置sqlite文件路径需要填写绝对路径推荐将sqlite文件放入到服务器上而非程序jar包或war包中
driver-class-name: org.sqlite.JDBC
url: jdbc:sqlite:/Volumes/DATA/ideaProject/common-frame/hcframe/hcframe-parent/hcframe-config/src/main/resources/datasource.db
# url: jdbc:sqlite:/Volumes/DATA/ideaProject/common-frame/hcframe/hcframe-parent/hcframe-config/src/main/resources/datasource.db
url: jdbc:sqlite:D:/cloud/datasource.db
username:
password:
#使用Druid数据源

View File

@@ -1,68 +1,63 @@
package com.hcframe.user.module.auth.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.user.module.auth.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author wewe
* @date 2021年4月13日
* @description 角色管理
*/
@RestController
@RestController("userMenuController")
@Api(tags = "功能级权限管理")
@RequestMapping("menu")
public class MenuController {
@Autowired MenuService menuService;
final MenuService menuService;
public MenuController(@Qualifier("userMenuService") MenuService menuService) {
this.menuService = menuService;
}
@PostMapping()
@ApiOperation(value = "新增功能级权限", notes = "给后台传key-value对象模式即可")
public ResultVO<Object> addMenu(@RequestParam Map<String, Object> data) {
return menuService.addMenu(data);
}
@DeleteMapping()
@ApiOperation(value = "删除功能级权限", notes = "删除后关联表数据也会被删除")
public ResultVO<Object> deleteMenu(@RequestParam List<Long> ids) {
return menuService.deleteMenu(ids);
}
@PutMapping("/{version}")
@ApiOperation(value = "更新功能级权限")
public ResultVO<Integer> updateMenu(@RequestParam Map<String, Object> data, @PathVariable Integer version) {
return menuService.updateMenu(data, version);
}
@GetMapping()
@ApiOperation(value = "查询功能级权限列表")
public ResultVO<PageInfo<Map<String, Object>>> getMenuList(String data, WebPageInfo webPageInfo) {
return menuService.getMenuList(data, webPageInfo);
}
@PostMapping()
@PostMapping("/role")
@ApiOperation(value = "角色授权", notes = "roleIds,menuIds,中间用逗号连接")
public ResultVO<Object> addRoleMenu(@RequestParam List<Long> roleIds,@RequestParam List<Long> menuIds) {
return menuService.addRoleMenu(roleIds, menuIds);
}
@PostMapping()
@DeleteMapping("/role")
@ApiOperation(value = "删除角色授权", notes = "ids,中间用逗号连接")
public ResultVO<Object> deleteRoleMenu(@RequestParam String ids) {
return menuService.deleteRoleMenu(ids);

View File

@@ -1,15 +1,5 @@
package com.hcframe.user.module.auth.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
@@ -18,15 +8,24 @@ import com.hcframe.base.module.data.module.Condition;
import com.hcframe.base.module.data.service.TableService;
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
import com.hcframe.user.module.auth.service.MenuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
/**
* @author wewe
* @date 2021年4月14日
* @description 功能级权限增删改查
*/
@Service
@Service("userMenuService")
public class MenuServiceImpl implements MenuService {
private static final OsSysTable OS_SYS_MENU = OsSysTable.builder().tableName("OS_SYS_MENU").tablePk("MENU_ID").build();
private static final OsSysTable OS_REL_ROLE_MENU = OsSysTable.builder().tableName("OS_REL_ROLE_MENU").tablePk("ROLE_MENU_ID").build();
@@ -53,7 +52,7 @@ public class MenuServiceImpl implements MenuService {
@Override
@Transactional(rollbackFor = Exception.class)
public ResultVO<Object> deleteMenu(List<Long> ids) {
ids.forEach(id -> {
ids.forEach(id -> {
// 删除菜单及子菜单
String familyIds = getCascadeList(id);
tableService.logicDelete(OS_SYS_MENU, familyIds);

View File

@@ -27,8 +27,8 @@ import java.util.Map;
@Service
public class RoleServiceImpl implements RoleService {
private static final String PK_ID = "MENU_ID";
private static final String TABLE_NAME = "OS_SYS_MENU";
private static final String PK_ID = "ROLE_ID";
private static final String TABLE_NAME = "OS_SYS_ROLE";
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(TABLE_NAME).tablePk(PK_ID).build();
final BaseMapper baseMapper;