mod menu functions
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.hcframe.base.module.data.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.data.module.Condition;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
@@ -38,4 +40,6 @@ public interface TableService {
|
||||
PageInfo<Map<String,Object>> searchJoinTables(String data, WebPageInfo webPageInfo, OsSysTable tableName);
|
||||
|
||||
ResultVO<Integer> logicDelete(OsSysTable tableName, String ids);
|
||||
|
||||
Condition.ConditionBuilder getQueryBuilder(JSONArray query, Condition.ConditionBuilder builder);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,8 @@ public class TableServiceImpl implements TableService {
|
||||
return ResultVO.getSuccess(i);
|
||||
}
|
||||
|
||||
private Condition.ConditionBuilder getQueryBuilder(JSONArray query, Condition.ConditionBuilder builder) {
|
||||
@Override
|
||||
public Condition.ConditionBuilder getQueryBuilder(JSONArray query, Condition.ConditionBuilder builder) {
|
||||
for (Object qObj : query) {
|
||||
WebCondition webCondition = JSON.parseObject(String.valueOf(qObj), WebCondition.class);
|
||||
if (!StringUtils.isEmpty(webCondition.getLogic())) {
|
||||
|
||||
@@ -19,8 +19,8 @@ public @interface LogAnno {
|
||||
String operateType();
|
||||
// 记录日志主键
|
||||
String primaryKey() default "id";
|
||||
// 记录日志表
|
||||
String tableName() default "-";
|
||||
// 记录模块
|
||||
String moduleName() default "-";
|
||||
|
||||
boolean isBefore() default false;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CustomRealm extends AuthorizingRealm {
|
||||
if (frameConfig.getCas()) {
|
||||
Map<Object, Object> hashMap = (Map<Object, Object>) redisUtil.hget("session", accessToken);
|
||||
Long expireTime = (Long) hashMap.get("expireTime");
|
||||
expireTime = expireTime * 1000;
|
||||
AssertionImpl assertion = (AssertionImpl) hashMap.get("_const_cas_assertion_");
|
||||
Date validDate = assertion.getAuthenticationDate();
|
||||
AttributePrincipal attributePrincipal = assertion.getPrincipal();
|
||||
|
||||
@@ -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
|
||||
**/
|
||||
|
||||
@@ -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数据源
|
||||
|
||||
Binary file not shown.
@@ -24,9 +24,9 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.hcframe.user;
|
||||
|
||||
import com.hcframe.base.module.datasource.config.DataSourceConfiguration;
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import net.unicon.cas.client.configuration.EnableCasClient;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
@@ -24,7 +22,7 @@ import tk.mybatis.spring.annotation.MapperScan;
|
||||
@EnableCaching
|
||||
@MapperScan(basePackages = "com.hcframe.**.dao")
|
||||
@ComponentScan(basePackages = {"com.hcframe.**"},excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DataSourceConfiguration.class}))
|
||||
@EnableDiscoveryClient
|
||||
//@EnableDiscoveryClient
|
||||
@Import(CasClientConfigurationProperties.class)
|
||||
//@EnableCasClient
|
||||
public class UserApplication {
|
||||
|
||||
@@ -74,7 +74,6 @@ public class ShiroRealmConfig implements SystemRealm {
|
||||
map.put("/druid/**",ShiroType.ANON);
|
||||
map.put("/cas/valid",ShiroType.ANON);
|
||||
map.put("/cas/logout",ShiroType.ANON);
|
||||
map.put("/menu/tree",ShiroType.ANON);
|
||||
// 其余路径均拦截
|
||||
map.put("/**", ShiroType.AUTH);
|
||||
return map;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.jasig.cas.client.authentication.AttributePrincipal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -15,6 +16,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.module.auth.entity.FtUser;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
@@ -55,6 +57,8 @@ public class OprateLog {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
assert attributes != null;
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
HashMap<String,Object> user=(HashMap<String,Object>)SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
// 1.方法执行前的处理,相当于前置通知
|
||||
// 获取方法签名
|
||||
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
|
||||
@@ -67,17 +71,17 @@ public class OprateLog {
|
||||
result= (ResultVO) pjp.proceed();
|
||||
}
|
||||
|
||||
String operateType = logAnno.operateType();
|
||||
// 获取操作记录的日志表
|
||||
Map<String,Object> log=new HashMap<String,Object>();
|
||||
log.put("CREATE_TIME", new Date());
|
||||
log.put("IP", request.getRemoteAddr());
|
||||
log.put("CURL", request.getRequestURI());
|
||||
log.put("ACTTYPE", request.getMethod());
|
||||
log.put("CLOG", operateType + "参数:" + request.getQueryString());
|
||||
// log.put("USERID", value);
|
||||
log.put("STATUS", (byte) 1);
|
||||
|
||||
log.put("CLOG","参数:" + request.getQueryString());
|
||||
log.put("OPERATETYPE", logAnno.operateType());
|
||||
log.put("MODULENAME", logAnno.moduleName());
|
||||
log.put("USERID", user.get("LOGIN_NAME"));
|
||||
|
||||
tableService.saveWithDate(TABLE_INFO, log);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -25,7 +24,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
* @date 2021年4月13日
|
||||
* @description 角色管理
|
||||
*/
|
||||
@RestController
|
||||
@RestController("userMenuController")
|
||||
@Api(tags = "功能级权限管理")
|
||||
@RequestMapping("menu")
|
||||
public class MenuController {
|
||||
@@ -43,7 +42,7 @@ public class MenuController {
|
||||
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) {
|
||||
@@ -57,15 +56,9 @@ public class MenuController {
|
||||
}
|
||||
|
||||
@PostMapping("addRole")
|
||||
@ApiOperation(value = "角色授权", notes = "roleIds,menuIds,中间用逗号连接")
|
||||
public ResultVO<Object> addRoleMenu(@RequestParam List<Long> roleIds,@RequestParam List<Long> menuIds) {
|
||||
return menuService.addRoleMenu(roleIds, menuIds);
|
||||
}
|
||||
|
||||
@PostMapping("updateRole")
|
||||
@ApiOperation(value = "角色授权", notes = "roleIds,menuIds,中间用逗号连接")
|
||||
public ResultVO<Object> updateRoleMenu(@RequestParam List<Long> roleIds,@RequestParam List<Long> menuIds) {
|
||||
return menuService.updateRoleMenu(roleIds, menuIds);
|
||||
@ApiOperation(value = "角色授权", notes = "roleId,menuIds,中间用逗号连接")
|
||||
public ResultVO<Object> addRoleMenu(@RequestParam Long roleId,@RequestParam List<String> menuIds) {
|
||||
return menuService.addRoleMenu(roleId, menuIds);
|
||||
}
|
||||
|
||||
@GetMapping("tree")
|
||||
@@ -76,8 +69,20 @@ public class MenuController {
|
||||
|
||||
@GetMapping("selected")
|
||||
@ApiOperation(value = "获取当前角色已选中节点")
|
||||
public ResultVO<Object> getSelectedMenu(Long roldId) {
|
||||
return menuService.getSelectedMenu(roldId);
|
||||
public ResultVO<Object> getSelectedMenu(@RequestParam Long roleId) {
|
||||
return menuService.getSelectedMenu(roleId);
|
||||
}
|
||||
|
||||
@PostMapping("checkPath")
|
||||
@ApiOperation(value = "校验PATH是否唯一", notes = "")
|
||||
public ResultVO<Object> checkPath(@RequestParam Map<String, Object> data) {
|
||||
return menuService.checkPath(data);
|
||||
}
|
||||
|
||||
@GetMapping("oslist")
|
||||
@ApiOperation(value = "获取系统信息列表")
|
||||
public ResultVO<Object> getOsList() {
|
||||
return menuService.getOsList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.hcframe.user.module.auth.controller;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.user.module.auth.service.RoleDeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Li Xinlei
|
||||
* @version 1.0
|
||||
* @className RoleDeptController
|
||||
* @date 2021-4-20 17:15:09
|
||||
* @description 描述
|
||||
*/
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/roleDept")
|
||||
@Api(tags="机构授权")
|
||||
public class RoleDeptController {
|
||||
|
||||
final RoleDeptService roleDeptService;
|
||||
|
||||
public RoleDeptController(RoleDeptService roleDeptService) {
|
||||
this.roleDeptService = roleDeptService;
|
||||
}
|
||||
|
||||
@PostMapping("role")
|
||||
public ResultVO<Object> roleDeptBind(String deptId, String roleIds) {
|
||||
return roleDeptService.roleDeptBind(deptId,roleIds);
|
||||
}
|
||||
|
||||
@GetMapping("role")
|
||||
public ResultVO<Object> getDeptRole(String deptId) {
|
||||
return roleDeptService.getDeptRole(deptId);
|
||||
}
|
||||
|
||||
@PostMapping("roleGroup")
|
||||
public ResultVO<Object> roleGroupBind(String deptId, String groupIds) {
|
||||
return roleDeptService.roleGroupBind(deptId,groupIds);
|
||||
}
|
||||
|
||||
@GetMapping("roleGroup")
|
||||
public ResultVO<Object> getDeptGroup(String deptId) {
|
||||
return roleDeptService.getDeptGroup(deptId);
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,14 @@ public interface MenuService {
|
||||
|
||||
ResultVO<PageInfo<Map<String, Object>>> getMenuList(String data, WebPageInfo webPageInfo);
|
||||
|
||||
ResultVO<Object> addRoleMenu(List<Long> roleIds, List<Long> menuIds);
|
||||
ResultVO<Object> addRoleMenu(Long roleId, List<String> menuIds);
|
||||
|
||||
ResultVO<Object> getMenuTree();
|
||||
|
||||
ResultVO<Object> getSelectedMenu(Long roldId);
|
||||
|
||||
ResultVO<Object> updateRoleMenu(List<Long> roleIds, List<Long> menuIds);
|
||||
ResultVO<Object> checkPath(Map<String, Object> data);
|
||||
|
||||
ResultVO<Object> getOsList();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.hcframe.user.module.auth.service;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Li Xinlei
|
||||
* @version 1.0
|
||||
* @className RoleDeptService
|
||||
* @date 2021-4-20 17:16:50
|
||||
* @description 描述
|
||||
*/
|
||||
|
||||
public interface RoleDeptService {
|
||||
ResultVO<Object> roleDeptBind(String deptId, String roleIds);
|
||||
|
||||
ResultVO<Object> roleGroupBind(String deptId, String groupIds);
|
||||
|
||||
ResultVO<Object> getDeptRole(String deptId);
|
||||
|
||||
ResultVO<Object> getDeptGroup(String deptId);
|
||||
}
|
||||
@@ -25,14 +25,16 @@ import com.hcframe.user.module.auth.service.MenuService;
|
||||
* @date 2021年4月14日
|
||||
* @description 功能级权限增删改查
|
||||
*/
|
||||
@Service
|
||||
public class MenuServiceImpl2 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();
|
||||
|
||||
@Autowired BaseMapper baseMapper;
|
||||
@Autowired TableService tableService;
|
||||
@Service("userMenuService")
|
||||
public class MenuServiceImpl2 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();
|
||||
private static final OsSysTable OS_REL_ROLE_OS = OsSysTable.builder().tableName("OS_REL_ROLE_OS").tablePk("ROLE_OS_ID").build();
|
||||
|
||||
@Autowired BaseMapper baseMapper;
|
||||
@Autowired TableService tableService;
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addMenu(Map<String, Object> data) {
|
||||
@@ -46,27 +48,29 @@ public class MenuServiceImpl2 implements MenuService {
|
||||
return ResultVO.getFailed("PATH不能为空");
|
||||
}
|
||||
Condition condition = Condition.creatCriteria().andEqual("MENU_NAME", data.get("MENU_NAME")).andEqual("DELETED",1).build();
|
||||
if (baseMapper.count("OS_SYS_MENU", condition) > 0L) {
|
||||
return ResultVO.getFailed("菜单名称不能重复");
|
||||
}
|
||||
Condition condition1 = Condition.creatCriteria().andEqual("PATH", data.get("PATH")).andEqual("DELETED",1).build();
|
||||
if (baseMapper.count("OS_SYS_MENU", condition1) > 0L) {
|
||||
return ResultVO.getFailed("PATH不能重复");
|
||||
}
|
||||
tableService.saveWithDate(OS_SYS_MENU, data);
|
||||
if (baseMapper.count("OS_SYS_MENU", condition) > 0L) {
|
||||
return ResultVO.getFailed("菜单名称不能重复");
|
||||
}
|
||||
Condition condition1 = Condition.creatCriteria().andEqual("PATH", data.get("PATH")).andEqual("DELETED",1).build();
|
||||
if (baseMapper.count("OS_SYS_MENU", condition1) > 0L) {
|
||||
return ResultVO.getFailed("PATH不能重复");
|
||||
}
|
||||
tableService.saveWithDate(OS_SYS_MENU, data);
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@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);
|
||||
// 删除角色与系统功能关联表OS_REL_ROLE_MENU
|
||||
String rmIds = getRmList(familyIds);
|
||||
tableService.logicDelete(OS_REL_ROLE_MENU, rmIds);
|
||||
if (StringUtils.isNotBlank(rmIds)) {
|
||||
tableService.logicDelete(OS_REL_ROLE_MENU, rmIds);
|
||||
}
|
||||
});
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
@@ -75,20 +79,20 @@ public class MenuServiceImpl2 implements MenuService {
|
||||
String sql = "select ROLE_MENU_ID from OS_REL_ROLE_MENU where MENU_ID in(" + familyIds + ")";
|
||||
List<Map<String,Object>> ids = baseMapper.selectSql(sql);
|
||||
StringJoiner joiner = new StringJoiner(",");
|
||||
for (Map<String,Object> idm: ids) {
|
||||
joiner.add(idm.get("ROLE_MENU_ID").toString());
|
||||
}
|
||||
return joiner.toString();
|
||||
for (Map<String,Object> idm: ids) {
|
||||
joiner.add(idm.get("ROLE_MENU_ID").toString());
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
|
||||
private String getCascadeList(Long id) {
|
||||
String sql = "select MENU_ID from OS_SYS_MENU start with MENU_ID=" + id + " connect by prior MENU_ID=PARENT_ID";
|
||||
List<Map<String,Object>> ids = baseMapper.selectSql(sql);
|
||||
StringJoiner joiner = new StringJoiner(",");
|
||||
for (Map<String,Object> idm: ids) {
|
||||
joiner.add(idm.get("MENU_ID").toString());
|
||||
}
|
||||
return joiner.toString();
|
||||
for (Map<String,Object> idm: ids) {
|
||||
joiner.add(idm.get("MENU_ID").toString());
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,26 +106,30 @@ public class MenuServiceImpl2 implements MenuService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addRoleMenu(List<Long> roleIds, List<Long> menuIds) {
|
||||
roleIds.forEach(roleId -> {
|
||||
menuIds.forEach(menuId -> {
|
||||
@Transactional
|
||||
public ResultVO<Object> addRoleMenu(Long roleId, List<String> menuIds) {
|
||||
baseMapper.deleteByCondition(OS_REL_ROLE_OS.getTableName(), Condition.creatCriteria().andEqual("ROLE_ID", roleId).build());
|
||||
baseMapper.deleteByCondition(OS_REL_ROLE_MENU.getTableName(), Condition.creatCriteria().andEqual("ROLE_ID", roleId).build());
|
||||
menuIds.forEach(menuId -> {
|
||||
if (menuId.startsWith("OS")) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("ROLE_ID", roleId);
|
||||
data.put("OS_ID", Long.getLong(menuId.substring(2)));
|
||||
data.put("VERSION", 1);
|
||||
data.put("DELETED", 1);
|
||||
tableService.saveWithDate(OS_REL_ROLE_OS, data);
|
||||
} else {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("ROLE_ID", roleId);
|
||||
data.put("MENU_ID", menuId);
|
||||
data.put("VERSION", 1);
|
||||
data.put("DELETED", 1);
|
||||
tableService.saveWithDate(OS_REL_ROLE_MENU, data);
|
||||
});
|
||||
}
|
||||
});
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> updateRoleMenu(List<Long> roleIds, List<Long> menuIds) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> getMenuTree() {
|
||||
List<Map<String, Object>> osList = baseMapper.selectSql(
|
||||
@@ -137,37 +145,52 @@ public class MenuServiceImpl2 implements MenuService {
|
||||
|
||||
private Object buildTree(List<Map<String, Object>> menuList) {
|
||||
List<Map<String, Object>> tree = new ArrayList<>();
|
||||
for(Map<String, Object> node : menuList) {
|
||||
if((Long)node.get("pid") == 0L){
|
||||
tree.add(findChild(node,menuList));
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
for(Map<String, Object> node : menuList) {
|
||||
if((Long)node.get("pid") == 0L){
|
||||
tree.add(findChild(node,menuList));
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
private Map<String, Object> findChild(Map<String, Object> node, List<Map<String, Object>> menuList) {
|
||||
for(Map<String, Object> n:menuList){
|
||||
if(n.get("pid") == node.get("id")){
|
||||
if(node.get("children") == null){
|
||||
node.put("children", new ArrayList<Map<String, Object>>());
|
||||
}
|
||||
((List<Map<String,Object>>) node.get("children")).add(findChild(n,menuList));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
if(n.get("pid") == node.get("id")){
|
||||
if(node.get("children") == null){
|
||||
node.put("children", new ArrayList<Map<String, Object>>());
|
||||
}
|
||||
((List<Map<String,Object>>) node.get("children")).add(findChild(n,menuList));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> getSelectedMenu(Long roldId) {
|
||||
public ResultVO<Object> getSelectedMenu(Long roleId) {
|
||||
List<Object> ids = new ArrayList<>();
|
||||
List<Map<String, Object>> osList = baseMapper.selectSql("SELECT OS_ID FROM OS_REL_ROLE_OS WHERE DELETED=1 AND ROLE_ID=" + roldId);
|
||||
List<Map<String, Object>> osList = baseMapper.selectSql("SELECT OS_ID FROM OS_REL_ROLE_OS WHERE DELETED=1 AND ROLE_ID=" + roleId);
|
||||
osList.forEach(os -> {
|
||||
ids.add("OS" + os.get("OS_ID"));
|
||||
});
|
||||
List<Map<String, Object>> menuList = baseMapper.selectSql("SELECT MENU_ID FROM OS_REL_ROLE_MENU WHERE DELETED=1 AND ROLE_ID=" + roldId);
|
||||
List<Map<String, Object>> menuList = baseMapper.selectSql("SELECT MENU_ID FROM OS_REL_ROLE_MENU WHERE DELETED=1 AND ROLE_ID=" + roleId);
|
||||
menuList.forEach(menu -> {
|
||||
ids.add(menu.get("MENU_ID"));
|
||||
});
|
||||
return ResultVO.getSuccess(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> checkPath(Map<String, Object> data) {
|
||||
Condition condition1 = Condition.creatCriteria().andEqual("PATH", data.get("PATH")).andEqual("DELETED",1).build();
|
||||
if (baseMapper.count("OS_SYS_MENU", condition1) > 0L) {
|
||||
return ResultVO.getFailed("PATH不能重复");
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> getOsList() {
|
||||
List<Map<String, Object>> osList = baseMapper.selectSql("SELECT OS_ID,OS_NAME FROM OS_SYS_OS WHERE DELETED=1");
|
||||
return ResultVO.getSuccess(osList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.hcframe.user.module.auth.service.impl;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.utils.JudgeException;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
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.RoleDeptService;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Li Xinlei
|
||||
* @version 1.0
|
||||
* @className RoleDeptServiceImpl
|
||||
* @date 2021-4-20 17:24:17
|
||||
* @description 描述
|
||||
*/
|
||||
@Service
|
||||
public class RoleDeptServiceImpl implements RoleDeptService {
|
||||
|
||||
private static final String OS_REL_DEPT_ROLE = "OS_REL_DEPT_ROLE";
|
||||
private static final String DEPT_GROUP_ID = "DEPT_GROUP_ID";
|
||||
private static final String DEPT_ROLE_ID = "DEPT_ROLE_ID";
|
||||
private static final String OS_REL_DEPT_GROUP = "OS_REL_DEPT_GROUP";
|
||||
private static final String COMMA = ",";
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
public RoleDeptServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> roleDeptBind(String deptId, String roleIds) {
|
||||
JudgeException.isNull(deptId,"deptId 不能为空");
|
||||
OsSysTable osSysTable = OsSysTable.builder().tableName(OS_REL_DEPT_ROLE).tablePk(DEPT_ROLE_ID).build();
|
||||
Condition condition = Condition.creatCriteria().andEqual("DEPT_ID",deptId).build();
|
||||
baseMapper.deleteByCondition(OS_REL_DEPT_ROLE, condition);
|
||||
if (!StringUtils.isEmpty(roleIds)) {
|
||||
for (String roleId : roleIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("DEPT_ID", deptId.replaceAll("\"",""));
|
||||
map.put("ROLE_ID", Integer.parseInt(roleId));
|
||||
tableService.save(osSysTable, map);
|
||||
}
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> roleGroupBind(String deptId, String groupIds) {
|
||||
JudgeException.isNull(deptId,"deptId 不能为空");
|
||||
Condition condition = Condition.creatCriteria().andEqual("DEPT_ID",deptId).build();
|
||||
baseMapper.deleteByCondition(OS_REL_DEPT_GROUP, condition);
|
||||
OsSysTable osSysTable = OsSysTable.builder().tableName(OS_REL_DEPT_GROUP).tablePk(DEPT_GROUP_ID).build();
|
||||
if (!StringUtils.isEmpty(groupIds)) {
|
||||
for (String groupId : groupIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("DEPT_ID", deptId.replaceAll("\"",""));
|
||||
map.put("GROUP_ID", groupId);
|
||||
tableService.save(osSysTable, map);
|
||||
}
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> getDeptRole(String deptId) {
|
||||
Condition condition = Condition.creatCriteria().andEqual("DEPT_ID",deptId).build();
|
||||
List<Map<String,Object>> list = baseMapper.selectByCondition(OS_REL_DEPT_ROLE, condition);
|
||||
return ResultVO.getSuccess(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> getDeptGroup(String deptId) {
|
||||
Condition condition = Condition.creatCriteria().andEqual("DEPT_ID",deptId).build();
|
||||
List<Map<String,Object>> list = baseMapper.selectByCondition(OS_REL_DEPT_GROUP, condition);
|
||||
return ResultVO.getSuccess(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.hcframe.user.module.auth.service.RoleUserService;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -46,15 +47,16 @@ public class RoleUserServiceImpl implements RoleUserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> roleUserBind(String userId, String roleIds) {
|
||||
JudgeException.isNull(userId,"userId 不能为空");
|
||||
JudgeException.isNull(roleIds,"roleIds 不能为空");
|
||||
OsSysTable osSysTable = OsSysTable.builder().tableName(OS_REL_USER_ROLE).tablePk(USER_ROLE_ID).build();
|
||||
Condition condition = Condition.creatCriteria().andEqual("USER_ID",userId).build();
|
||||
baseMapper.deleteByCondition(OS_REL_USER_ROLE, condition);
|
||||
for (String roleId : roleIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("USER_ID", userId.replaceAll("\"",""));
|
||||
map.put("ROLE_ID", Integer.parseInt(roleId));
|
||||
tableService.save(osSysTable, map);
|
||||
if (!StringUtils.isEmpty(roleIds)) {
|
||||
for (String roleId : roleIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("USER_ID", userId.replaceAll("\"",""));
|
||||
map.put("ROLE_ID", Integer.parseInt(roleId));
|
||||
tableService.save(osSysTable, map);
|
||||
}
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
@@ -63,15 +65,16 @@ public class RoleUserServiceImpl implements RoleUserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> roleGroupBind(String userId, String groupIds) {
|
||||
JudgeException.isNull(userId,"userId 不能为空");
|
||||
JudgeException.isNull(groupIds,"roleIds 不能为空");
|
||||
Condition condition = Condition.creatCriteria().andEqual("USER_ID",userId).build();
|
||||
baseMapper.deleteByCondition(OS_REL_USER_GROUP, condition);
|
||||
OsSysTable osSysTable = OsSysTable.builder().tableName(OS_REL_USER_GROUP).tablePk(USER_GROUP_ID).build();
|
||||
for (String groupId : groupIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("USER_ID", userId.replaceAll("\"",""));
|
||||
map.put("GROUP_ID", groupId);
|
||||
tableService.save(osSysTable, map);
|
||||
if (!StringUtils.isEmpty(groupIds)) {
|
||||
for (String groupId : groupIds.split(COMMA)) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("USER_ID", userId.replaceAll("\"",""));
|
||||
map.put("GROUP_ID", groupId);
|
||||
tableService.save(osSysTable, map);
|
||||
}
|
||||
}
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
package com.hcframe.user.module.manage.controller;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.redis.RedisUtil;
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("cas")
|
||||
public class CasController {
|
||||
|
||||
final
|
||||
RedisUtil redisUtil;
|
||||
|
||||
final
|
||||
CasClientConfigurationProperties casClientConfigurationProperties;
|
||||
|
||||
public CasController(RedisUtil redisUtil, CasClientConfigurationProperties casClientConfigurationProperties) {
|
||||
this.redisUtil = redisUtil;
|
||||
this.casClientConfigurationProperties = casClientConfigurationProperties;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("valid")
|
||||
public ResultVO<String> casValid(HttpServletResponse response, HttpServletRequest request,String webUrl) {
|
||||
String token = "";
|
||||
// token = request.getHeader("X-Access-Token");
|
||||
try {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
for (Cookie cookie : cookies) {
|
||||
if ("X-Access-Token".equals(cookie.getName())) {
|
||||
token = cookie.getValue();
|
||||
response.addCookie(cookie);
|
||||
break;
|
||||
}
|
||||
}
|
||||
webUrl = URLDecoder.decode(webUrl, "utf-8");
|
||||
response.sendRedirect("http://"+webUrl+"/#/?token=" + token );
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("userinfo")
|
||||
@ResponseBody
|
||||
public ResultVO<Object> getUserInfo(String token) {
|
||||
// return ResultVO.getSuccess(redisUtil.hget("session", token));
|
||||
return ResultVO.getSuccess(SecurityUtils.getSubject().getPrincipal());
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
@ResponseBody
|
||||
public ResultVO<String> logout(HttpServletRequest request, @RequestHeader("X-Access-Token") String token) {
|
||||
Cookie cookie = new Cookie("X-Access-Token", null);
|
||||
cookie.setMaxAge(0);
|
||||
String headerToken = request.getHeader("X-Access-Token");
|
||||
redisUtil.hdel("session", token);
|
||||
redisUtil.hdel("session", headerToken);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
subject.logout();
|
||||
return ResultVO.getSuccess(casClientConfigurationProperties.getServerUrlPrefix()+"/logout");
|
||||
}
|
||||
}
|
||||
package com.hcframe.user.module.manage.controller;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.redis.RedisUtil;
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("cas")
|
||||
public class CasController {
|
||||
|
||||
final
|
||||
RedisUtil redisUtil;
|
||||
|
||||
final
|
||||
CasClientConfigurationProperties casClientConfigurationProperties;
|
||||
|
||||
public CasController(RedisUtil redisUtil, CasClientConfigurationProperties casClientConfigurationProperties) {
|
||||
this.redisUtil = redisUtil;
|
||||
this.casClientConfigurationProperties = casClientConfigurationProperties;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("valid")
|
||||
public ResultVO<String> casValid(HttpServletResponse response, HttpServletRequest request,String webUrl) {
|
||||
String token = "";
|
||||
// token = request.getHeader("X-Access-Token");
|
||||
try {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
for (Cookie cookie : cookies) {
|
||||
if ("X-Access-Token".equals(cookie.getName())) {
|
||||
token = cookie.getValue();
|
||||
response.addCookie(cookie);
|
||||
break;
|
||||
}
|
||||
}
|
||||
webUrl = URLDecoder.decode(webUrl, "utf-8");
|
||||
response.sendRedirect("http://"+webUrl+"/#/?token=" + token );
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("userinfo")
|
||||
@ResponseBody
|
||||
public ResultVO<Object> getUserInfo(String token) {
|
||||
// return ResultVO.getSuccess(redisUtil.hget("session", token));
|
||||
return ResultVO.getSuccess(SecurityUtils.getSubject().getPrincipal());
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
@ResponseBody
|
||||
public ResultVO<String> logout(HttpServletRequest request, @RequestHeader("X-Access-Token") String token) {
|
||||
Cookie cookie = new Cookie("X-Access-Token", null);
|
||||
cookie.setMaxAge(0);
|
||||
String headerToken = request.getHeader("X-Access-Token");
|
||||
redisUtil.hdel("session", token);
|
||||
redisUtil.hdel("session", headerToken);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
subject.logout();
|
||||
return ResultVO.getSuccess(casClientConfigurationProperties.getServerUrlPrefix()+"/logout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ public class ManageController {
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "获取用户列表", notes = "删除后职位也会被删除")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getUserList(String data, WebPageInfo webPageInfo) {
|
||||
return manageService.getUserList(data, webPageInfo);
|
||||
@ApiOperation(value = "获取用户列表" )
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getUserList(String data, WebPageInfo webPageInfo,String orgId) {
|
||||
return manageService.getUserList(data, webPageInfo,orgId);
|
||||
}
|
||||
|
||||
@PutMapping("disable/{version}")
|
||||
@@ -66,6 +66,12 @@ public class ManageController {
|
||||
public ResultVO<Integer> resetPassword(String userId,@PathVariable Integer version) {
|
||||
return manageService.resetPassword(userId,version);
|
||||
}
|
||||
|
||||
@PutMapping("changePassword")
|
||||
@ApiOperation(value = "修改密码",notes = "用户输入原密码和新密码")
|
||||
public ResultVO<Integer> changePassword(String pwd,String npwd,String npwd2) {
|
||||
return manageService.changePassword(pwd,npwd,npwd2);
|
||||
}
|
||||
|
||||
@GetMapping("/sync")
|
||||
public ResultVO<Object> sync() {
|
||||
|
||||
@@ -13,11 +13,13 @@ public interface ManageService {
|
||||
|
||||
ResultVO<Integer> deleteUser(String ids);
|
||||
|
||||
ResultVO<PageInfo<Map<String, Object>>> getUserList(String data, WebPageInfo webPageInfo);
|
||||
ResultVO<PageInfo<Map<String, Object>>> getUserList(String data, WebPageInfo webPageInfo, String orgId);
|
||||
|
||||
ResultVO<Integer> resetPassword(String userId, Integer version);
|
||||
|
||||
ResultVO<Integer> disable(Boolean enabled, String userId, Integer version);
|
||||
|
||||
ResultVO<Object> sync();
|
||||
|
||||
ResultVO<Integer> changePassword(String pwd, String npwd, String npwd2);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package com.hcframe.user.module.manage.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.ServiceException;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.common.utils.DateUtil;
|
||||
import com.hcframe.base.common.utils.JudgeException;
|
||||
import com.hcframe.base.module.data.constants.FieldConstants;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.module.Condition;
|
||||
import com.hcframe.base.module.data.module.DataMap;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
import com.hcframe.user.common.utils.MD5Utils;
|
||||
@@ -18,6 +23,7 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -26,11 +32,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
@@ -105,8 +109,31 @@ public class ManageServiceDataImpl implements ManageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getUserList(String data, WebPageInfo webPageInfo) {
|
||||
PageInfo<Map<String, Object>> page = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getUserList(String data, WebPageInfo webPageInfo, String orgId) {
|
||||
DataMap<Object> dataMap = DataMap.builder().sysOsTable(TABLE_INFO).build();
|
||||
Condition.ConditionBuilder builder = Condition.creatCriteria(dataMap);
|
||||
if (!StringUtils.isEmpty(orgId)) {
|
||||
orgId = orgId.replaceAll("\"", "");
|
||||
String sql = "select ID from GB_CAS_DEPT start with ID="+orgId+" connect by prior ID=ORG_ACCOUNT_ID";
|
||||
List<Map<String, Object>> list = baseMapper.selectSql(sql);
|
||||
List<Object> idList = new ArrayList<>();
|
||||
for (Map<String, Object> code : list) {
|
||||
idList.add(code.get("ID"));
|
||||
}
|
||||
builder.andIn("ORG_DEPARTMENT_ID",idList);
|
||||
}
|
||||
builder.andEqual("USER_TYPE", "GN");
|
||||
if (!StringUtils.isEmpty(data)) {
|
||||
try {
|
||||
data = URLDecoder.decode(data, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ServiceException(e);
|
||||
}
|
||||
JSONArray jsonArray = JSON.parseArray(data);
|
||||
builder = tableService.getQueryBuilder(jsonArray, builder);
|
||||
}
|
||||
builder.andEqual("DELETED", 1);
|
||||
PageInfo<Map<String,Object>> page = baseMapper.selectByCondition(builder.build(), webPageInfo);
|
||||
List<Map<String,Object>> list = page.getList();
|
||||
for (Map<String, Object> map : list) {
|
||||
map.remove("PASSWORD");
|
||||
@@ -171,4 +198,42 @@ public class ManageServiceDataImpl implements ManageService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Integer> changePassword(String pwd, String npwd, String npwd2) {
|
||||
|
||||
JudgeException.isNull(pwd,"密码不能为空");
|
||||
JudgeException.isNull(npwd,"新密码不能为空");
|
||||
|
||||
if(!npwd.equals(npwd2)) {
|
||||
return ResultVO.getFailed("两次新密码输入不一致");
|
||||
}
|
||||
|
||||
Map<String, Object> user = (Map<String, Object>) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String id = (String) user.get("ID");
|
||||
|
||||
Map<String, Object> data = baseMapper.selectByPk(TABLE_NAME,PK_ID,id);
|
||||
Integer version = Integer.parseInt(data.get(FieldConstants.VERSION.toString()).toString());
|
||||
|
||||
try {
|
||||
if(!data.get("PASSWORD").equals(MD5Utils.encode(pwd))) {
|
||||
return ResultVO.getFailed("原密码错误");
|
||||
}
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
logger.error("验证密码失败",e);
|
||||
throw new ServiceException(e);
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put(PK_ID, id);
|
||||
try {
|
||||
map.put("PASSWORD",MD5Utils.encode(npwd));
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
logger.error("重置密码失败",e);
|
||||
throw new ServiceException(e);
|
||||
}
|
||||
return tableService.updateWithDate(TABLE_INFO,map,version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.hcframe.user.module.userinfo.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.user.module.userinfo.service.DeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("dept")
|
||||
@Api(tags = "机构管理")
|
||||
public class DeptController {
|
||||
|
||||
final DeptService deptService;
|
||||
|
||||
|
||||
public DeptController(DeptService deptService) {
|
||||
this.deptService = deptService;
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@ApiOperation(value = "新增dept", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addDept(@RequestParam Map<String, Object> org) {
|
||||
return deptService.addDept(org);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@ApiOperation(value = "更新dept")
|
||||
public ResultVO<Integer> updateDept(@RequestParam Map<String, Object> org, @PathVariable Integer version) {
|
||||
return deptService.updateDept(org, version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation(value = "删除dept", notes = "删除后职位也会被删除")
|
||||
public ResultVO<Object> deleteDept(@PathVariable String ids) {
|
||||
return deptService.deleteDept(ids);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "获取机构列表", notes = "删除后职位也会被删除")
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getDeptList(String data, WebPageInfo webPageInfo) {
|
||||
return deptService.getDeptList(data, webPageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation(value = "获取机构树")
|
||||
public ResultVO<List<Map<String, Object>>> getDeptTree() {
|
||||
return deptService.getDeptTree();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.hcframe.user.module.userinfo.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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.userinfo.service.LogService;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("log")
|
||||
@Api(tags = "日志查询")
|
||||
public class LogController {
|
||||
|
||||
final LogService logService;
|
||||
|
||||
public LogController(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@ApiOperation(value = "日志查询模块")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getLogList(String data, WebPageInfo webPageInfo) {
|
||||
return logService.getLogList(data, webPageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ 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.base.module.log.annotation.LogAnno;
|
||||
import com.hcframe.user.module.userinfo.service.OrgService;
|
||||
import com.hcframe.user.module.userinfo.service.OsService;
|
||||
import com.hcframe.user.module.userinfo.service.TitleService;
|
||||
@@ -39,18 +40,21 @@ public class OsController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@LogAnno(operateType="新增系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "新增系统", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addOs(@RequestParam Map<String,Object> os) {
|
||||
return osService.addOs(os);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@LogAnno(operateType="更新系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "更新系统信息")
|
||||
public ResultVO<Integer> updateOs(@RequestParam Map<String,Object> os,@PathVariable Integer version) {
|
||||
return osService.updateOs(os,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@LogAnno(operateType="删除系统信息",moduleName="系统管理-权限管理-系统信息管理")
|
||||
@ApiOperation(value = "删除系统信息")
|
||||
public ResultVO<Object> deleteOs(@PathVariable String ids) {
|
||||
return osService.deleteOs(ids);
|
||||
|
||||
@@ -39,25 +39,27 @@ public class TitleController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@LogAnno(operateType="新增职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "新增title", notes = "将自动传承key-value对象模式即可")
|
||||
public ResultVO<Object> addTitle(@RequestParam Map<String,Object> title) {
|
||||
return titleService.addTitle(title);
|
||||
}
|
||||
|
||||
@PutMapping("/{version}")
|
||||
@LogAnno(operateType="更新职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "更新title")
|
||||
public ResultVO<Integer> updateTitle(@RequestParam Map<String,Object> title,@PathVariable Integer version) {
|
||||
return titleService.updateTitle(title,version);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@LogAnno(operateType="删除职称信息",moduleName="系统管理-用户管理-职称管理")
|
||||
@ApiOperation(value = "删除title")
|
||||
public ResultVO<Object> deleteTitle(@PathVariable String ids) {
|
||||
return titleService.deleteTitle(ids);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@LogAnno(operateType="getTitleList",tableName="title")
|
||||
@ApiOperation(value = "获取职称列表")
|
||||
public ResultVO<PageInfo<Map<String,Object>>> getTitleList(String data, WebPageInfo webPageInfo) {
|
||||
return titleService.getTitleList(data, webPageInfo);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hcframe.user.module.userinfo.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DeptService {
|
||||
ResultVO<Object> addDept(Map<String, Object> org);
|
||||
|
||||
ResultVO<Integer> updateDept(Map<String, Object> org, Integer version);
|
||||
|
||||
ResultVO<Object> deleteDept(String ids);
|
||||
|
||||
ResultVO<PageInfo<Map<String, Object>>> getDeptList(String data, WebPageInfo webPageInfo);
|
||||
|
||||
ResultVO<List<Map<String, Object>>> getDeptTree();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.hcframe.user.module.userinfo.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
|
||||
public interface LogService {
|
||||
ResultVO<PageInfo<Map<String, Object>>> getLogList(String data, WebPageInfo webPageInfo);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.hcframe.user.module.userinfo.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
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.userinfo.service.DeptService;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
*/
|
||||
@Service
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
|
||||
private static final String ID = "ID";
|
||||
private static final String GB_CAS_DEPT = "GB_CAS_DEPT";
|
||||
private static final String OS_SYS_POSITION = "OS_SYS_POSITION";
|
||||
private static final String ORG_ACCOUNT_ID = "ORG_ACCOUNT_ID";
|
||||
private static final String TYPE = "TYPE";
|
||||
private static final String NAME = "NAME";
|
||||
private static final String PATH = "PATH";
|
||||
private static final String SORT_ID = "SORT_ID";
|
||||
private static final String[] LABELCH = {"一级", "二级", "三级", "四级", "五级", "六级", "七级", "八级", "九级", "十级"};
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(GB_CAS_DEPT).tablePk(ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
|
||||
public DeptServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Object> addDept(Map<String, Object> org) {
|
||||
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, org));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<Integer> updateDept(Map<String, Object> org, Integer version) {
|
||||
return tableService.updateWithDate(TABLE_INFO, org, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Object> deleteDept(String ids) {
|
||||
String[] idArr = ids.split(",");
|
||||
Condition condition = Condition
|
||||
.creatCriteria()
|
||||
.andIn(ID, Arrays.asList(idArr))
|
||||
.build();
|
||||
baseMapper.deleteByCondition(OS_SYS_POSITION, condition);
|
||||
tableService.delete(TABLE_INFO, ids);
|
||||
return ResultVO.getSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getDeptList(String data, WebPageInfo webPageInfo) {
|
||||
PageInfo<Map<String, Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
return ResultVO.getSuccess(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO<List<Map<String, Object>>> getDeptTree() {
|
||||
// 获取全部
|
||||
String sql = "SELECT " + ID + "," + PATH + "," + TYPE + "," + NAME + " FROM " + GB_CAS_DEPT + " ORDER BY " + SORT_ID;
|
||||
List<Map<String, Object>> allDataList = baseMapper.selectSql(sql);
|
||||
// 根节点
|
||||
List<Map<String, Object>> rootList = new ArrayList<>();
|
||||
// 遍历list生成以父节点为key的map
|
||||
Map<String, List<Map<String, Object>>> pathMap = new HashMap<>();
|
||||
for (Map<String, Object> map : allDataList) {
|
||||
if (map != null && map.containsKey(PATH)) {
|
||||
String path = String.valueOf(map.get(PATH));
|
||||
if (path != null && path.length() > 4) {
|
||||
// 获取父节点路径
|
||||
String rootPath = path.substring(0, path.length() - 4);
|
||||
// 看当前orgAccountIdMap中是否有对应key,有则添加到list中,没有则创建list
|
||||
if (pathMap.containsKey(rootPath)) {
|
||||
List<Map<String, Object>> pathMapList = pathMap.get(rootPath);
|
||||
pathMapList.add(map);
|
||||
} else {
|
||||
List<Map<String, Object>> pathMapList = new ArrayList<>();
|
||||
pathMapList.add(map);
|
||||
pathMap.put(rootPath, pathMapList);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据map的type判断是否为根节点
|
||||
if (map != null && map.containsKey(TYPE)) {
|
||||
String type = String.valueOf(map.get(TYPE));
|
||||
if ("Account".equalsIgnoreCase(type)) {
|
||||
rootList.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
handleChildrenMap(pathMap, rootList, "");
|
||||
return ResultVO.getSuccess(rootList);
|
||||
}
|
||||
|
||||
|
||||
// 传入节点所有孩子节点,并在总pathMap中寻找孩子节点,为空的时候结束迭代
|
||||
private void handleChildrenMap(Map<String, List<Map<String, Object>>> pathMap, List<Map<String, Object>> list, String labelPre) {
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = list.get(i);
|
||||
if (map != null && map.containsKey(PATH)) {
|
||||
String path = String.valueOf(map.get(PATH));
|
||||
// 遍历map添加label信息
|
||||
int index = path.length() / 4 - 2;
|
||||
String labelch = LABELCH[index];
|
||||
int labelIndex = i + 1;
|
||||
map.put("label", labelch + " " + labelPre + labelIndex);
|
||||
map.put("labelNum", index);
|
||||
map.put("labelIndex", labelIndex);
|
||||
// 把rootMap中
|
||||
String rootMapPath = String.valueOf(path).substring(0, path.length() - 4);
|
||||
// 从orgAccountIdMap中获取所有pathMap为rootMapId的List取出添加到rootMap下,
|
||||
// 只到某Map的Id在orgAccountId在orgAccountIdMap检索不到为止
|
||||
List<Map<String, Object>> childrenMapList = new ArrayList<>();
|
||||
// 根据当前节点的path寻找pathMap中的内容
|
||||
if (pathMap.containsKey(path)) {
|
||||
childrenMapList = pathMap.get(path);
|
||||
handleChildrenMap(pathMap, childrenMapList, labelPre + labelIndex + "-");
|
||||
}
|
||||
map.put("children", childrenMapList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hcframe.user.module.userinfo.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
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;
|
||||
import com.hcframe.base.module.data.module.BaseMapper;
|
||||
import com.hcframe.base.module.data.module.BaseMapperImpl;
|
||||
import com.hcframe.base.module.data.service.TableService;
|
||||
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
|
||||
import com.hcframe.user.module.userinfo.service.LogService;
|
||||
|
||||
|
||||
@Service
|
||||
public class LogServiceImpl implements LogService{
|
||||
|
||||
private static final String LOG_ID = "LOG_ID";
|
||||
private static final String OS_SYS_TITLE = "GB_LOGS";
|
||||
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_TITLE).tablePk(LOG_ID).build();
|
||||
|
||||
final BaseMapper baseMapper;
|
||||
|
||||
final TableService tableService;
|
||||
|
||||
public LogServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
|
||||
TableService tableService) {
|
||||
this.baseMapper = baseMapper;
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultVO<PageInfo<Map<String, Object>>> getLogList(String data, WebPageInfo webPageInfo) {
|
||||
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
|
||||
return ResultVO.getSuccess(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@ spring:
|
||||
stat:
|
||||
merge-sql: false
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
connectionProperties: druid.stat.slowSqlMillis=5000
|
||||
mybatis:
|
||||
mapper-locations: classpath*:mapping/**/*.xml
|
||||
type-aliases-package: com.hcframe.**.entity
|
||||
|
||||
Reference in New Issue
Block a user