Merge remote-tracking branch 'origin/master'

This commit is contained in:
2021-04-28 10:00:58 +08:00
10 changed files with 114 additions and 74 deletions

View File

@@ -113,6 +113,7 @@ public class TableCache implements CacheService {
@Override
public boolean delete(String typeName) {
baseCache.delete(CacheType.baseCache.toString(), typeName);
return baseCache.delete(CacheType.tableCache.toString(), typeName);
}

View File

@@ -55,7 +55,7 @@ public class AuthController {
if (menus == null || menus.size() == 0) {
return ResultVO.getSuccess(new ArrayList<>());
}
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> resultMap = new HashMap<>(2);
resultMap.put("menu", authService.formatMenu(menus));
resultMap.put("auth", set);
return ResultVO.getSuccess(resultMap);

View File

@@ -39,12 +39,14 @@ public class MenuController {
@PostMapping("delete")
@ApiOperation(value = "删除功能级权限", notes = "删除后关联表数据也会被删除")
public ResultVO<Object> deleteMenu(@RequestParam List<Long> ids) {
redisUtil.del("auth");
return menuService.deleteMenu(ids);
}
@PutMapping("/{version}")
@ApiOperation(value = "更新功能级权限")
public ResultVO<Integer> updateMenu(@RequestParam Map<String, Object> data, @PathVariable Integer version) {
redisUtil.del("auth");
return menuService.updateMenu(data, version);
}

View File

@@ -3,6 +3,7 @@ package com.hcframe.user.module.auth.controller;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.redis.RedisUtil;
import com.hcframe.user.module.auth.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -25,9 +26,12 @@ import java.util.Map;
public class RoleController {
final RoleService roleService;
final RedisUtil redisUtil;
public RoleController(RoleService roleService) {
public RoleController(RoleService roleService,
RedisUtil redisUtil) {
this.roleService = roleService;
this.redisUtil = redisUtil;
}
@PostMapping()
@@ -39,12 +43,14 @@ public class RoleController {
@PutMapping("/{version}")
@ApiOperation(value = "更新role")
public ResultVO<Integer> updateRole(@RequestParam Map<String, Object> role, @PathVariable Integer version) {
redisUtil.del("auth");
return roleService.updateRole(role, version);
}
@DeleteMapping("/{ids}")
@ApiOperation(value = "删除role", notes = "删除后关联表数据也会被删除")
public ResultVO<Object> deleteOrg(@PathVariable String ids) {
public ResultVO<Object> deleteRole(@PathVariable String ids) {
redisUtil.del("auth");
return roleService.deleteRole(ids);
}

View File

@@ -1,50 +1,59 @@
package com.hcframe.user.module.auth.controller;
import com.hcframe.base.common.ResultVO;
import com.hcframe.redis.RedisUtil;
import com.hcframe.user.module.auth.service.RoleDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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
* @date 2021-4-20 17:15:09
* @description 描述
*/
@RestController
@RequestMapping("/roleDept")
@Api(tags="机构授权")
public class RoleDeptController {
final RoleDeptService roleDeptService;
final RedisUtil redisUtil;
public RoleDeptController(RoleDeptService roleDeptService) {
public RoleDeptController(RoleDeptService roleDeptService,
RedisUtil redisUtil) {
this.roleDeptService = roleDeptService;
this.redisUtil = redisUtil;
}
@PostMapping("role")
@ApiOperation(value = "角色机构绑定")
public ResultVO<Object> roleDeptBind(String deptId, String roleIds) {
redisUtil.del("auth");
return roleDeptService.roleDeptBind(deptId,roleIds);
}
@GetMapping("role")
@ApiOperation(value = "获取机构角色")
public ResultVO<Object> getDeptRole(String deptId) {
return roleDeptService.getDeptRole(deptId);
}
@PostMapping("roleGroup")
@ApiOperation(value = "角色机构组绑定")
public ResultVO<Object> roleGroupBind(String deptId, String groupIds) {
redisUtil.del("auth");
return roleDeptService.roleGroupBind(deptId,groupIds);
}
@GetMapping("roleGroup")
@ApiOperation(value = "获取角色机构组")
public ResultVO<Object> getDeptGroup(String deptId) {
return roleDeptService.getDeptGroup(deptId);
}

View File

@@ -3,6 +3,7 @@ package com.hcframe.user.module.auth.controller;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.redis.RedisUtil;
import com.hcframe.user.module.auth.service.RoleGroupServie;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -25,9 +26,12 @@ import java.util.Map;
public class RoleGroupController {
final RoleGroupServie roleGroupServie;
final RedisUtil redisUtil;
public RoleGroupController(RoleGroupServie roleGroupServie) {
public RoleGroupController(RoleGroupServie roleGroupServie,
RedisUtil redisUtil) {
this.roleGroupServie = roleGroupServie;
this.redisUtil = redisUtil;
}
@PostMapping()
@@ -39,12 +43,14 @@ public class RoleGroupController {
@PutMapping("/{version}")
@ApiOperation(value = "更新角色组")
public ResultVO<Integer> updateRole(@RequestParam Map<String, Object> roleGroup, @PathVariable Integer version) {
redisUtil.del("auth");
return roleGroupServie.update(roleGroup, version);
}
@DeleteMapping("/{ids}")
@ApiOperation(value = "删除角色组", notes = "删除后关联表数据也会被删除")
public ResultVO<Integer> deleteOrg(@PathVariable String ids) {
redisUtil.del("auth");
return roleGroupServie.delete(ids);
}
@@ -61,6 +67,7 @@ public class RoleGroupController {
@ApiImplicitParam(name = "roleIds", value = "角色ID数组",required = true)
})
public ResultVO<Object> bind(Integer groupId, String roleIds) {
redisUtil.del("auth");
return roleGroupServie.bind(groupId, roleIds);
}

View File

@@ -1,8 +1,10 @@
package com.hcframe.user.module.auth.controller;
import com.hcframe.base.common.ResultVO;
import com.hcframe.redis.RedisUtil;
import com.hcframe.user.module.auth.service.RoleUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -21,27 +23,36 @@ import org.springframework.web.bind.annotation.RestController;
public class RoleUserController {
final RoleUserService roleUserService;
final RedisUtil redisUtil;
public RoleUserController(RoleUserService roleUserService) {
public RoleUserController(RoleUserService roleUserService,
RedisUtil redisUtil) {
this.roleUserService = roleUserService;
this.redisUtil = redisUtil;
}
@PostMapping("role")
@ApiOperation(value = "用户角色绑定")
public ResultVO<Object> roleUserBind(String userId, String roleIds) {
redisUtil.del("auth");
return roleUserService.roleUserBind(userId,roleIds);
}
@GetMapping("role")
@ApiOperation(value = "获取用户角色")
public ResultVO<Object> getUserRole(String userId) {
return roleUserService.getUserRole(userId);
}
@PostMapping("roleGroup")
@ApiOperation(value = "用户角色组绑定")
public ResultVO<Object> roleGroupBind(String userId, String groupIds) {
redisUtil.del("auth");
return roleUserService.roleGroupBind(userId,groupIds);
}
@GetMapping("roleGroup")
@ApiOperation(value = "获取用户的角色组")
public ResultVO<Object> getUserGroup(String userId) {
return roleUserService.getUserGroup(userId);
}

View File

@@ -74,6 +74,7 @@ public class RoleGroupServiceImpl implements RoleGroupServie {
@Override
@Transactional(rollbackFor = Exception.class)
public ResultVO<Object> bind(Integer roleGroupId, String roleIds) {
JudgeException.isNull(roleGroupId,"roleGroupId 不能为空");
baseMapper.deleteByCondition(OS_REL_GROUP_ROLE, Condition.creatCriteria().andEqual(PK_ID,roleGroupId).build());
if (StringUtils.isEmpty(roleIds)) {
return ResultVO.getSuccess();

View File

@@ -1,74 +1,77 @@
package com.hcframe.user.module.userinfo.service.impl;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
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.cache.CacheService;
import com.hcframe.base.module.cache.impl.TableCache;
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.TitleService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
@Service
public class TitleServiceImpl implements TitleService{
private static final String TITLE_ID = "TITLE_ID";
private static final String OS_SYS_TITLE = "OS_SYS_TITLE";
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_TITLE).tablePk(TITLE_ID).build();
public class TitleServiceImpl implements TitleService {
final BaseMapper baseMapper;
private static final String TITLE_ID = "TITLE_ID";
private static final String OS_SYS_TITLE = "OS_SYS_TITLE";
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_TITLE).tablePk(TITLE_ID).build();
final TableService tableService;
final BaseMapper baseMapper;
public TitleServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService) {
this.baseMapper = baseMapper;
this.tableService = tableService;
}
@Override
public ResultVO<Object> checkExistTitle(String titlecode){
Condition condition = Condition.creatCriteria().andEqual("TITLE_CODE",titlecode).andEqual("DELETED",1).build();
Long i = baseMapper.count(OS_SYS_TITLE, condition);
if (i > 0L) {
return ResultVO.getFailed("职称编码不能重复");
}
return ResultVO.getSuccess();
}
@Override
public ResultVO<Object> addTitle(Map<String, Object> title) {
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, title));
}
final TableService tableService;
@Override
public ResultVO<Integer> updateTitle(Map<String, Object> title, Integer version) {
return tableService.updateWithDate(TABLE_INFO,title,version);
}
final CacheService tableCache;
@Override
@Transactional(rollbackFor = Exception.class)
public ResultVO<Object> deleteTitle(String ids) {
String[] idArr = ids.split(",");
tableService.delete(TABLE_INFO, ids);
return ResultVO.getSuccess();
}
public TitleServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService,
@Qualifier(TableCache.TABLE) CacheService cacheService) {
this.baseMapper = baseMapper;
this.tableService = tableService;
this.tableCache = cacheService;
}
@Override
public ResultVO<PageInfo<Map<String, Object>>> getTitleList(String data, WebPageInfo webPageInfo) {
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
return ResultVO.getSuccess(pageInfo);
}
@Override
public ResultVO<Object> checkExistTitle(String titlecode) {
Condition condition = Condition.creatCriteria().andEqual("TITLE_CODE", titlecode).andEqual("DELETED", 1).build();
Long i = baseMapper.count(OS_SYS_TITLE, condition);
if (i > 0L) {
return ResultVO.getFailed("职称编码不能重复");
}
return ResultVO.getSuccess();
}
@Override
public ResultVO<Object> addTitle(Map<String, Object> title) {
tableCache.delete("title");
return ResultVO.getSuccess(tableService.saveWithDate(TABLE_INFO, title));
}
@Override
public ResultVO<Integer> updateTitle(Map<String, Object> title, Integer version) {
tableCache.delete("title");
return tableService.updateWithDate(TABLE_INFO, title, version);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultVO<Object> deleteTitle(String ids) {
tableCache.delete("title");
tableService.delete(TABLE_INFO, ids);
return ResultVO.getSuccess();
}
@Override
public ResultVO<PageInfo<Map<String, Object>>> getTitleList(String data, WebPageInfo webPageInfo) {
PageInfo<Map<String, Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
return ResultVO.getSuccess(pageInfo);
}
}

View File

@@ -16,17 +16,17 @@ spring:
name: cloud-user
# 缓存设置
cache:
# redis缓存
# type: redis
# redis:
# time-to-live: 1d
# use-key-prefix: true
# cache-null-values: true
# key-prefix: cache.
# ehcache缓存
type: ehcache
ehcache:
config: classpath:ehcache.xml
# redis缓存
type: redis
redis:
time-to-live: 1d
use-key-prefix: true
cache-null-values: true
key-prefix: cache.
# # ehcache缓存
# type: ehcache
# ehcache:
# config: classpath:ehcache.xml
redis:
database: @redis.database@
host: @redis.host@