去除非必要软件
This commit is contained in:
parent
46cb3f7f05
commit
e4e31e0237
@ -63,9 +63,6 @@ public class Oauth2Realm extends AuthorizingRealm {
|
||||
SysUserEntity userEntity = shiroService.getUser(tokenEntity.getUserId());
|
||||
//转换成UserDetail对象
|
||||
UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class);
|
||||
//获取用户对应的部门数据权限
|
||||
List<Long> deptIdList = shiroService.getDataScopeList(userDetail.getId());
|
||||
userDetail.setDeptIdList(deptIdList);
|
||||
//账号锁定
|
||||
if (userDetail.getStatus() == 0) {
|
||||
throw new LockedAccountException("账号已被锁定!");
|
||||
|
@ -28,10 +28,5 @@ public interface ShiroService {
|
||||
*/
|
||||
SysUserEntity getUser(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户对应的部门数据权限
|
||||
* @param userId 用户ID
|
||||
* @return 返回部门ID列表
|
||||
*/
|
||||
List<Long> getDataScopeList(Long userId);
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import io.modules.security.dao.SysUserTokenDao;
|
||||
import io.modules.security.entity.SysUserTokenEntity;
|
||||
import io.modules.security.service.ShiroService;
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.modules.sys.dao.SysMenuDao;
|
||||
import io.modules.sys.dao.SysRoleDataScopeDao;
|
||||
import io.modules.sys.dao.SysUserDao;
|
||||
import io.modules.sys.entity.SysUserEntity;
|
||||
import io.modules.sys.enums.SuperAdminEnum;
|
||||
@ -23,29 +21,13 @@ import java.util.Set;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ShiroServiceImpl implements ShiroService {
|
||||
private final SysMenuDao sysMenuDao;
|
||||
private final SysUserDao sysUserDao;
|
||||
private final SysUserTokenDao sysUserTokenDao;
|
||||
private final SysRoleDataScopeDao sysRoleDataScopeDao;
|
||||
|
||||
@Override
|
||||
public Set<String> getUserPermissions(UserDetail user) {
|
||||
//系统管理员,拥有最高权限
|
||||
List<String> permissionsList;
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||
permissionsList = sysMenuDao.getPermissionsList();
|
||||
} else {
|
||||
permissionsList = sysMenuDao.getUserPermissionsList(user.getId());
|
||||
}
|
||||
|
||||
//用户权限列表
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String permissions : permissionsList) {
|
||||
if (StrUtil.isBlank(permissions)) {
|
||||
continue;
|
||||
}
|
||||
permsSet.addAll(Arrays.asList(permissions.trim().split(",")));
|
||||
}
|
||||
|
||||
return permsSet;
|
||||
}
|
||||
@ -60,8 +42,4 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
return sysUserDao.selectById(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getDataScopeList(Long userId) {
|
||||
return sysRoleDataScopeDao.getDataScopeList(userId);
|
||||
}
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.SysDeptDTO;
|
||||
import io.modules.sys.service.SysDeptService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/dept")
|
||||
@Tag(name = "部门管理")
|
||||
@AllArgsConstructor
|
||||
public class SysDeptController {
|
||||
private final SysDeptService sysDeptService;
|
||||
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@RequiresPermissions("sys:dept:list")
|
||||
public Result<List<SysDeptDTO>> list() {
|
||||
List<SysDeptDTO> list = sysDeptService.list(new HashMap<>(1));
|
||||
|
||||
return new Result<List<SysDeptDTO>>().ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:dept:info")
|
||||
public Result<SysDeptDTO> get(@PathVariable("id") Long id) {
|
||||
SysDeptDTO data = sysDeptService.get(id);
|
||||
|
||||
return new Result<SysDeptDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:dept:save")
|
||||
public Result save(@RequestBody SysDeptDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
sysDeptService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:dept:update")
|
||||
public Result update(@RequestBody SysDeptDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysDeptService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:dept:delete")
|
||||
public Result delete(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtils.isNull(id, "id");
|
||||
|
||||
sysDeptService.delete(id);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.SysDictDataDTO;
|
||||
import io.modules.sys.service.SysDictDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
*
|
||||
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/dict/data")
|
||||
@Tag(name = "字典数据")
|
||||
@AllArgsConstructor
|
||||
public class SysDictDataController {
|
||||
private final SysDictDataService sysDictDataService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "字典数据")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "dictLabel", description = "字典标签", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "dictValue", description = "字典值", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:dict:page")
|
||||
public Result<PageData<SysDictDataDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
//字典类型
|
||||
PageData<SysDictDataDTO> page = sysDictDataService.page(params);
|
||||
|
||||
return new Result<PageData<SysDictDataDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:dict:info")
|
||||
public Result<SysDictDataDTO> get(@PathVariable("id") Long id) {
|
||||
SysDictDataDTO data = sysDictDataService.get(id);
|
||||
|
||||
return new Result<SysDictDataDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:dict:save")
|
||||
public Result save(@RequestBody SysDictDataDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
|
||||
|
||||
sysDictDataService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:dict:update")
|
||||
public Result update(@RequestBody SysDictDataDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysDictDataService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:dict:delete")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
sysDictDataService.delete(ids);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.SysDictTypeDTO;
|
||||
import io.modules.sys.entity.DictType;
|
||||
import io.modules.sys.service.SysDictTypeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/dict/type")
|
||||
@Tag(name = "字典类型")
|
||||
@AllArgsConstructor
|
||||
public class SysDictTypeController {
|
||||
private final SysDictTypeService sysDictTypeService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "字典类型")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "dictType", description = "字典类型", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "dictName", description = "字典名称", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:dict:page")
|
||||
public Result<PageData<SysDictTypeDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
//字典类型
|
||||
PageData<SysDictTypeDTO> page = sysDictTypeService.page(params);
|
||||
|
||||
return new Result<PageData<SysDictTypeDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:dict:info")
|
||||
public Result<SysDictTypeDTO> get(@PathVariable("id") Long id) {
|
||||
SysDictTypeDTO data = sysDictTypeService.get(id);
|
||||
|
||||
return new Result<SysDictTypeDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:dict:save")
|
||||
public Result save(@RequestBody SysDictTypeDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
|
||||
|
||||
sysDictTypeService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:dict:update")
|
||||
public Result update(@RequestBody SysDictTypeDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysDictTypeService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:dict:delete")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
sysDictTypeService.delete(ids);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("all")
|
||||
@Operation(summary = "所有字典数据")
|
||||
public Result<List<DictType>> all() {
|
||||
List<DictType> list = sysDictTypeService.getAllList();
|
||||
|
||||
return new Result<List<DictType>>().ok(list);
|
||||
}
|
||||
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.modules.security.service.ShiroService;
|
||||
import io.modules.security.user.SecurityUser;
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.exception.ErrorCode;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.modules.sys.dto.SysMenuDTO;
|
||||
import io.modules.sys.enums.MenuTypeEnum;
|
||||
import io.modules.sys.service.SysMenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/menu")
|
||||
@Tag(name = "菜单管理")
|
||||
@AllArgsConstructor
|
||||
public class SysMenuController {
|
||||
private final SysMenuService sysMenuService;
|
||||
private final ShiroService shiroService;
|
||||
|
||||
@GetMapping("nav")
|
||||
@Operation(summary = "导航")
|
||||
public Result<List<SysMenuDTO>> nav() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, MenuTypeEnum.MENU.value());
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("permissions")
|
||||
@Operation(summary = "权限标识")
|
||||
public Result<Set<String>> permissions() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
Set<String> set = shiroService.getUserPermissions(user);
|
||||
|
||||
return new Result<Set<String>>().ok(set);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@Parameter(name = "type", description = "菜单类型 0:菜单 1:按钮 null:全部", in = ParameterIn.QUERY, ref = "int")
|
||||
@RequiresPermissions("sys:menu:list")
|
||||
public Result<List<SysMenuDTO>> list(Integer type) {
|
||||
List<SysMenuDTO> list = sysMenuService.getAllMenuList(type);
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:menu:info")
|
||||
public Result<SysMenuDTO> get(@PathVariable("id") Long id) {
|
||||
SysMenuDTO data = sysMenuService.get(id);
|
||||
|
||||
return new Result<SysMenuDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:menu:save")
|
||||
public Result save(@RequestBody SysMenuDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
|
||||
|
||||
sysMenuService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:menu:update")
|
||||
public Result update(@RequestBody SysMenuDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, DefaultGroup.class);
|
||||
|
||||
sysMenuService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:menu:delete")
|
||||
public Result delete(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtils.isNull(id, "id");
|
||||
|
||||
//判断是否有子菜单或按钮
|
||||
List<SysMenuDTO> list = sysMenuService.getListPid(id);
|
||||
if (list.size() > 0) {
|
||||
return new Result().error("先删除子菜单或按钮!");
|
||||
}
|
||||
sysMenuService.delete(id);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("select")
|
||||
@Operation(summary = "角色菜单权限")
|
||||
@RequiresPermissions("sys:menu:select")
|
||||
public Result<List<SysMenuDTO>> select() {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, null);
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.utils.ExcelUtils;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.SysParamsDTO;
|
||||
import io.modules.sys.excel.SysParamsExcel;
|
||||
import io.modules.sys.service.SysParamsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/params")
|
||||
@Tag(name = "参数管理")
|
||||
@AllArgsConstructor
|
||||
public class SysParamsController {
|
||||
private final SysParamsService sysParamsService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "paramCode", description = "参数编码", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:params:page")
|
||||
public Result<PageData<SysParamsDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysParamsDTO> page = sysParamsService.page(params);
|
||||
|
||||
return new Result<PageData<SysParamsDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:params:info")
|
||||
public Result<SysParamsDTO> get(@PathVariable("id") Long id) {
|
||||
SysParamsDTO data = sysParamsService.get(id);
|
||||
|
||||
return new Result<SysParamsDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:params:save")
|
||||
public Result save(@RequestBody SysParamsDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
sysParamsService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:params:update")
|
||||
public Result update(@RequestBody SysParamsDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysParamsService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:params:delete")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
sysParamsService.delete(ids);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@LogOperation("导出")
|
||||
@RequiresPermissions("sys:params:export")
|
||||
@Parameter(name = "paramCode", description = "参数编码", in = ParameterIn.QUERY, ref = "String")
|
||||
public void export(@Parameter(hidden = true) @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<SysParamsDTO> list = sysParamsService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, "参数管理", list, SysParamsExcel.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.controller;
|
||||
|
||||
import io.common.annotation.LogOperation;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.utils.Result;
|
||||
import io.common.validator.AssertUtils;
|
||||
import io.common.validator.ValidatorUtils;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.SysRoleDTO;
|
||||
import io.modules.sys.service.SysRoleDataScopeService;
|
||||
import io.modules.sys.service.SysRoleMenuService;
|
||||
import io.modules.sys.service.SysRoleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色管理
|
||||
*
|
||||
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/role")
|
||||
@Tag(name = "角色管理")
|
||||
@AllArgsConstructor
|
||||
public class SysRoleController {
|
||||
private final SysRoleService sysRoleService;
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
private final SysRoleDataScopeService sysRoleDataScopeService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "name", description = "角色名", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:role:page")
|
||||
public Result<PageData<SysRoleDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysRoleDTO> page = sysRoleService.page(params);
|
||||
|
||||
return new Result<PageData<SysRoleDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@RequiresPermissions("sys:role:list")
|
||||
public Result<List<SysRoleDTO>> list() {
|
||||
List<SysRoleDTO> data = sysRoleService.list(new HashMap<>(1));
|
||||
|
||||
return new Result<List<SysRoleDTO>>().ok(data);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:role:info")
|
||||
public Result<SysRoleDTO> get(@PathVariable("id") Long id) {
|
||||
SysRoleDTO data = sysRoleService.get(id);
|
||||
|
||||
//查询角色对应的菜单
|
||||
List<Long> menuIdList = sysRoleMenuService.getMenuIdList(id);
|
||||
data.setMenuIdList(menuIdList);
|
||||
|
||||
//查询角色对应的数据权限
|
||||
List<Long> deptIdList = sysRoleDataScopeService.getDeptIdList(id);
|
||||
data.setDeptIdList(deptIdList);
|
||||
|
||||
return new Result<SysRoleDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:role:save")
|
||||
public Result save(@RequestBody SysRoleDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
sysRoleService.save(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:role:update")
|
||||
public Result update(@RequestBody SysRoleDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysRoleService.update(dto);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:role:delete")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
sysRoleService.delete(ids);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
}
|
@ -19,15 +19,12 @@ import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.sys.dto.PasswordDTO;
|
||||
import io.modules.sys.dto.SysUserDTO;
|
||||
import io.modules.sys.excel.SysUserExcel;
|
||||
import io.modules.sys.service.SysRoleUserService;
|
||||
import io.modules.sys.service.SysUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -47,7 +44,6 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
public class SysUserController {
|
||||
private final SysUserService sysUserService;
|
||||
private final SysRoleUserService sysRoleUserService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@ -71,9 +67,6 @@ public class SysUserController {
|
||||
@RequiresPermissions("sys:user:info")
|
||||
public Result<SysUserDTO> get(@PathVariable("id") Long id) {
|
||||
SysUserDTO data = sysUserService.get(id);
|
||||
//用户角色列表
|
||||
List<Long> roleIdList = sysRoleUserService.getRoleIdList(id);
|
||||
data.setRoleIdList(roleIdList);
|
||||
return new Result<SysUserDTO>().ok(data);
|
||||
}
|
||||
|
||||
@ -132,13 +125,4 @@ public class SysUserController {
|
||||
sysUserService.deleteBatchIds(Arrays.asList(ids));
|
||||
return new Result();
|
||||
}
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@LogOperation("导出")
|
||||
@RequiresPermissions("sys:user:export")
|
||||
@Parameter(name = "username", description = "用户名", in = ParameterIn.QUERY, ref = "String")
|
||||
public void export(@Parameter(hidden = true) @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<SysUserDTO> list = sysUserService.list(params);
|
||||
ExcelUtils.exportExcelToTarget(response, null, "用户管理", list, SysUserExcel.class);
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysDeptEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDeptDao extends BaseDao<SysDeptEntity> {
|
||||
|
||||
List<SysDeptEntity> getList(Map<String, Object> params);
|
||||
|
||||
SysDeptEntity getById(Long id);
|
||||
|
||||
/**
|
||||
* 获取所有部门的id、pid列表
|
||||
*/
|
||||
List<SysDeptEntity> getIdAndPidList();
|
||||
|
||||
/**
|
||||
* 根据部门ID,获取所有子部门ID列表
|
||||
* @param id 部门ID
|
||||
*/
|
||||
List<Long> getSubDeptIdList(String id);
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.DictData;
|
||||
import io.modules.sys.entity.SysDictDataEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictDataDao extends BaseDao<SysDictDataEntity> {
|
||||
|
||||
/**
|
||||
* 字典数据列表
|
||||
*/
|
||||
List<DictData> getDictDataList();
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.DictType;
|
||||
import io.modules.sys.entity.SysDictTypeEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictTypeDao extends BaseDao<SysDictTypeEntity> {
|
||||
|
||||
/**
|
||||
* 字典类型列表
|
||||
*/
|
||||
List<DictType> getDictTypeList();
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysMenuEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
||||
|
||||
SysMenuEntity getById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 查询所有菜单列表
|
||||
*
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuEntity> getMenuList(@Param("menuType") Integer menuType);
|
||||
|
||||
/**
|
||||
* 查询用户菜单列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuEntity> getUserMenuList(@Param("userId") Long userId, @Param("menuType") Integer menuType);
|
||||
|
||||
/**
|
||||
* 查询用户权限列表
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
List<String> getUserPermissionsList(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有权限列表
|
||||
*/
|
||||
List<String> getPermissionsList();
|
||||
|
||||
/**
|
||||
* 根据父菜单,查询子菜单
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
List<SysMenuEntity> getListPid(Long pid);
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysParamsEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysParamsDao extends BaseDao<SysParamsEntity> {
|
||||
/**
|
||||
* 根据参数编码,查询value
|
||||
* @param paramCode 参数编码
|
||||
* @return 参数值
|
||||
*/
|
||||
String getValueByCode(String paramCode);
|
||||
|
||||
/**
|
||||
* 获取参数编码列表
|
||||
* @param ids ids
|
||||
* @return 返回参数编码列表
|
||||
*/
|
||||
List<String> getParamCodeList(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据参数编码,更新value
|
||||
* @param paramCode 参数编码
|
||||
* @param paramValue 参数值
|
||||
*/
|
||||
int updateValueByCode(@Param("paramCode") String paramCode, @Param("paramValue") String paramValue);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysRoleEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 角色管理
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleDao extends BaseDao<SysRoleEntity> {
|
||||
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysRoleDataScopeEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色数据权限
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleDataScopeDao extends BaseDao<SysRoleDataScopeEntity> {
|
||||
|
||||
/**
|
||||
* 根据角色ID,获取部门ID列表
|
||||
*/
|
||||
List<Long> getDeptIdList(Long roleId);
|
||||
|
||||
/**
|
||||
* 获取用户的部门数据权限列表
|
||||
*/
|
||||
List<Long> getDataScopeList(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色id,删除角色数据权限关系
|
||||
* @param roleIds 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleIds);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysRoleMenuEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与菜单对应关系
|
||||
*
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMenuDao extends BaseDao<SysRoleMenuEntity> {
|
||||
|
||||
/**
|
||||
* 根据角色ID,获取菜单ID列表
|
||||
*/
|
||||
List<Long> getMenuIdList(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据角色id,删除角色菜单关系
|
||||
* @param roleIds 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 根据菜单id,删除角色菜单关系
|
||||
* @param menuId 菜单id
|
||||
*/
|
||||
void deleteByMenuId(Long menuId);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dao;
|
||||
|
||||
import io.modules.sys.entity.SysRoleUserEntity;
|
||||
import io.common.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色用户关系
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleUserDao extends BaseDao<SysRoleUserEntity> {
|
||||
|
||||
/**
|
||||
* 根据角色ids,删除角色用户关系
|
||||
* @param roleIds 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 根据用户id,删除角色用户关系
|
||||
* @param userIds 用户ids
|
||||
*/
|
||||
void deleteByUserIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 角色ID列表
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Long> getRoleIdList(Long userId);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.utils.TreeNode;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(title = "部门管理")
|
||||
public class SysDeptDTO extends TreeNode implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "上级ID")
|
||||
@NotNull(message="{sysdept.pid.require}", groups = DefaultGroup.class)
|
||||
private Long pid;
|
||||
|
||||
@Schema(title = "部门名称")
|
||||
@NotBlank(message="{sysdept.name.require}", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
|
||||
@Schema(title = "排序")
|
||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "上级部门名称")
|
||||
private String parentName;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPid(Long pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "字典数据")
|
||||
public class SysDictDataDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "字典类型ID")
|
||||
@NotNull(message="{sysdict.type.require}", groups = DefaultGroup.class)
|
||||
private Long dictTypeId;
|
||||
|
||||
@Schema(title = "字典标签")
|
||||
@NotBlank(message="{sysdict.label.require}", groups = DefaultGroup.class)
|
||||
private String dictLabel;
|
||||
|
||||
@Schema(title = "字典值")
|
||||
private String dictValue;
|
||||
|
||||
@Schema(title = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(title = "排序")
|
||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "更新时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date updateDate;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "字典类型")
|
||||
public class SysDictTypeDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "字典类型")
|
||||
@NotBlank(message="{sysdict.type.require}", groups = DefaultGroup.class)
|
||||
private String dictType;
|
||||
|
||||
@Schema(title = "字典名称")
|
||||
@NotBlank(message="{sysdict.name.require}", groups = DefaultGroup.class)
|
||||
private String dictName;
|
||||
|
||||
@Schema(title = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(title = "排序")
|
||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "更新时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date updateDate;
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.utils.TreeNode;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(title = "菜单管理")
|
||||
public class SysMenuDTO extends TreeNode<SysMenuDTO> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "上级ID")
|
||||
@NotNull(message="{sysmenu.pid.require}", groups = DefaultGroup.class)
|
||||
private Long pid;
|
||||
|
||||
@Schema(title = "菜单名称")
|
||||
@NotBlank(message="菜单名称不能为空", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
|
||||
@Schema(title = "菜单URL")
|
||||
private String url;
|
||||
|
||||
@Schema(title = "类型 0:菜单 1:按钮")
|
||||
@Range(min=0, max=1, message = "{sysmenu.type.range}", groups = DefaultGroup.class)
|
||||
private Integer menuType;
|
||||
|
||||
@Schema(title = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Schema(title = "授权(多个用逗号分隔,如:sys:user:list,sys:user:save)")
|
||||
private String permissions;
|
||||
|
||||
@Schema(title = "排序")
|
||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "上级菜单名称")
|
||||
private String parentName;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPid(Long pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "参数管理")
|
||||
public class SysParamsDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "参数编码")
|
||||
@NotBlank(message="{sysparams.paramcode.require}", groups = DefaultGroup.class)
|
||||
private String paramCode;
|
||||
|
||||
@Schema(title = "参数值")
|
||||
@NotBlank(message="{sysparams.paramvalue.require}", groups = DefaultGroup.class)
|
||||
private String paramValue;
|
||||
|
||||
@Schema(title = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "更新时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date updateDate;
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "角色管理")
|
||||
public class SysRoleDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Null(message="ID必须为空", groups = AddGroup.class)
|
||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "角色名称")
|
||||
@NotBlank(message="{sysrole.name.require}", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
|
||||
@Schema(title = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "菜单ID列表")
|
||||
private List<Long> menuIdList;
|
||||
|
||||
@Schema(title = "部门ID列表")
|
||||
private List<Long> deptIdList;
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 系统数据
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(title = "系统数据")
|
||||
public class SystemDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long sysTime;
|
||||
private String osName;
|
||||
private String osArch;
|
||||
private String osVersion;
|
||||
private String userLanguage;
|
||||
private String userDir;
|
||||
private Long totalPhysical;
|
||||
private Long freePhysical;
|
||||
private BigDecimal memoryRate;
|
||||
private Integer processors;
|
||||
private String jvmName;
|
||||
private String javaVersion;
|
||||
private String javaHome;
|
||||
private Long javaTotalMemory;
|
||||
private Long javaFreeMemory;
|
||||
private Long javaMaxMemory;
|
||||
private String userName;
|
||||
private BigDecimal systemCpuLoad;
|
||||
private String userTimezone;
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典数据
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
public class DictData {
|
||||
@JsonIgnore
|
||||
private Long dictTypeId;
|
||||
private String dictLabel;
|
||||
private String dictValue;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
public class DictType {
|
||||
@JsonIgnore
|
||||
private Long id;
|
||||
private String dictType;
|
||||
private List<DictData> dataList = new ArrayList<>();
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_dept")
|
||||
public class SysDeptEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 上级ID
|
||||
*/
|
||||
private Long pid;
|
||||
/**
|
||||
* 所有上级ID,用逗号分开
|
||||
*/
|
||||
private String pids;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
/**
|
||||
* 上级部门名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_dict_data")
|
||||
public class SysDictDataEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 字典类型ID
|
||||
*/
|
||||
private Long dictTypeId;
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
private String dictLabel;
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String dictValue;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_dict_type")
|
||||
public class SysDictTypeEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_menu")
|
||||
public class SysMenuEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 父菜单ID,一级菜单为0
|
||||
*/
|
||||
private Long pid;
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 菜单URL
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 授权(多个用逗号分隔,如:sys:user:list,sys:user:save)
|
||||
*/
|
||||
private String permissions;
|
||||
/**
|
||||
* 类型 0:菜单 1:按钮
|
||||
*/
|
||||
private Integer menuType;
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
/**
|
||||
* 上级菜单名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_params")
|
||||
public class SysParamsEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 参数编码
|
||||
*/
|
||||
private String paramCode;
|
||||
/**
|
||||
* 参数值
|
||||
*/
|
||||
private String paramValue;
|
||||
/**
|
||||
* 类型 0:系统参数 1:非系统参数
|
||||
*/
|
||||
private Integer paramType;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色数据权限
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_role_data_scope")
|
||||
public class SysRoleDataScopeEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*
|
||||
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_role")
|
||||
public class SysRoleEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long deptId;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long updater;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateDate;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色菜单关系
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_role_menu")
|
||||
public class SysRoleMenuEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
private Long menuId;
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色用户关系
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("sys_role_user")
|
||||
public class SysRoleUserEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class SysParamsExcel {
|
||||
@ExcelProperty("参数编码")
|
||||
private String paramCode;
|
||||
@ExcelProperty("参数值")
|
||||
private String paramValue;
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import io.modules.sys.excel.converter.GenderConverter;
|
||||
import io.modules.sys.excel.converter.StatusConverter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class SysUserExcel {
|
||||
@ExcelProperty("用户名")
|
||||
private String username;
|
||||
@ExcelProperty("姓名")
|
||||
private String realName;
|
||||
@ExcelProperty(value = "性别", converter = GenderConverter.class)
|
||||
private Integer gender;
|
||||
@ExcelProperty("邮箱")
|
||||
private String email;
|
||||
@ExcelProperty("手机号")
|
||||
private String mobile;
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
@ExcelProperty(value = "状态", converter = StatusConverter.class)
|
||||
private Integer status;
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package io.modules.sys.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
|
||||
public class GenderConverter implements Converter<Integer> {
|
||||
|
||||
|
||||
@Override
|
||||
public Class<Integer> supportJavaTypeKey() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(cellData.getStringValue().equals("男")){
|
||||
return 0;
|
||||
}else if(cellData.getStringValue().equals("女")){
|
||||
return 1;
|
||||
}else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if(value == 0){
|
||||
return new WriteCellData<>("男");
|
||||
}else if(value == 1){
|
||||
return new WriteCellData<>("女");
|
||||
}else {
|
||||
return new WriteCellData<>("保密");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package io.modules.sys.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
public class StatusConverter implements Converter<Integer> {
|
||||
@Override
|
||||
public Class<Integer> supportJavaTypeKey() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
return cellData.getStringValue().equals("正常") ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
return new WriteCellData<>(value == 1 ? "正常" : "停用");
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysDeptDTO;
|
||||
import io.modules.sys.entity.SysDeptEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysDeptService extends BaseService<SysDeptEntity> {
|
||||
|
||||
List<SysDeptDTO> list(Map<String, Object> params);
|
||||
|
||||
SysDeptDTO get(Long id);
|
||||
|
||||
void save(SysDeptDTO dto);
|
||||
|
||||
void update(SysDeptDTO dto);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 根据部门ID,获取本部门及子部门ID列表
|
||||
* @param id 部门ID
|
||||
*/
|
||||
List<Long> getSubDeptIdList(Long id);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysDictDataDTO;
|
||||
import io.modules.sys.entity.SysDictDataEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysDictDataService extends BaseService<SysDictDataEntity> {
|
||||
|
||||
PageData<SysDictDataDTO> page(Map<String, Object> params);
|
||||
|
||||
SysDictDataDTO get(Long id);
|
||||
|
||||
void save(SysDictDataDTO dto);
|
||||
|
||||
void update(SysDictDataDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysDictTypeDTO;
|
||||
import io.modules.sys.entity.DictType;
|
||||
import io.modules.sys.entity.SysDictTypeEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysDictTypeService extends BaseService<SysDictTypeEntity> {
|
||||
|
||||
PageData<SysDictTypeDTO> page(Map<String, Object> params);
|
||||
|
||||
SysDictTypeDTO get(Long id);
|
||||
|
||||
void save(SysDictTypeDTO dto);
|
||||
|
||||
void update(SysDictTypeDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
|
||||
/**
|
||||
* 获取所有字典
|
||||
*/
|
||||
List<DictType> getAllList();
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysMenuDTO;
|
||||
import io.modules.sys.entity.SysMenuEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysMenuService extends BaseService<SysMenuEntity> {
|
||||
|
||||
SysMenuDTO get(Long id);
|
||||
|
||||
void save(SysMenuDTO dto);
|
||||
|
||||
void update(SysMenuDTO dto);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuDTO> getAllMenuList(Integer menuType);
|
||||
|
||||
/**
|
||||
* 用户菜单列表
|
||||
*
|
||||
* @param user 用户
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType);
|
||||
|
||||
/**
|
||||
* 根据父菜单,查询子菜单
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
List<SysMenuDTO> getListPid(Long pid);
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysParamsDTO;
|
||||
import io.modules.sys.entity.SysParamsEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysParamsService extends BaseService<SysParamsEntity> {
|
||||
|
||||
PageData<SysParamsDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysParamsDTO> list(Map<String, Object> params);
|
||||
|
||||
SysParamsDTO get(Long id);
|
||||
|
||||
void save(SysParamsDTO dto);
|
||||
|
||||
void update(SysParamsDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据参数编码,获取参数的value值
|
||||
*
|
||||
* @param paramCode 参数编码
|
||||
*/
|
||||
String getValue(String paramCode);
|
||||
|
||||
/**
|
||||
* 根据参数编码,获取value的Object对象
|
||||
* @param paramCode 参数编码
|
||||
* @param clazz Object对象
|
||||
*/
|
||||
<T> T getValueObject(String paramCode, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 根据参数编码,更新value
|
||||
* @param paramCode 参数编码
|
||||
* @param paramValue 参数值
|
||||
*/
|
||||
int updateValueByCode(String paramCode, String paramValue);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.entity.SysRoleDataScopeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色数据权限
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysRoleDataScopeService extends BaseService<SysRoleDataScopeEntity> {
|
||||
|
||||
/**
|
||||
* 根据角色ID,获取部门ID列表
|
||||
*/
|
||||
List<Long> getDeptIdList(Long roleId);
|
||||
|
||||
/**
|
||||
* 保存或修改
|
||||
* @param roleId 角色ID
|
||||
* @param deptIdList 部门ID列表
|
||||
*/
|
||||
void saveOrUpdate(Long roleId, List<Long> deptIdList);
|
||||
|
||||
/**
|
||||
* 根据角色id,删除角色数据权限关系
|
||||
* @param roleId 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleId);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.entity.SysRoleMenuEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 角色与菜单对应关系
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysRoleMenuService extends BaseService<SysRoleMenuEntity> {
|
||||
|
||||
/**
|
||||
* 根据角色ID,获取菜单ID列表
|
||||
*/
|
||||
List<Long> getMenuIdList(Long roleId);
|
||||
|
||||
/**
|
||||
* 保存或修改
|
||||
* @param roleId 角色ID
|
||||
* @param menuIdList 菜单ID列表
|
||||
*/
|
||||
void saveOrUpdate(Long roleId, List<Long> menuIdList);
|
||||
|
||||
/**
|
||||
* 根据角色id,删除角色菜单关系
|
||||
* @param roleIds 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 根据菜单id,删除角色菜单关系
|
||||
* @param menuId 菜单id
|
||||
*/
|
||||
void deleteByMenuId(Long menuId);
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.dto.SysRoleDTO;
|
||||
import io.modules.sys.entity.SysRoleEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*
|
||||
|
||||
*/
|
||||
public interface SysRoleService extends BaseService<SysRoleEntity> {
|
||||
|
||||
PageData<SysRoleDTO> page(Map<String, Object> params);
|
||||
|
||||
List<SysRoleDTO> list(Map<String, Object> params);
|
||||
|
||||
SysRoleDTO get(Long id);
|
||||
|
||||
void save(SysRoleDTO dto);
|
||||
|
||||
void update(SysRoleDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service;
|
||||
|
||||
import io.common.service.BaseService;
|
||||
import io.modules.sys.entity.SysRoleUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色用户关系
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface SysRoleUserService extends BaseService<SysRoleUserEntity> {
|
||||
|
||||
/**
|
||||
* 保存或修改
|
||||
* @param userId 用户ID
|
||||
* @param roleIdList 角色ID列表
|
||||
*/
|
||||
void saveOrUpdate(Long userId, List<Long> roleIdList);
|
||||
|
||||
/**
|
||||
* 根据角色ids,删除角色用户关系
|
||||
* @param roleIds 角色ids
|
||||
*/
|
||||
void deleteByRoleIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 根据用户id,删除角色用户关系
|
||||
* @param userIds 用户ids
|
||||
*/
|
||||
void deleteByUserIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 角色ID列表
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
List<Long> getRoleIdList(Long userId);
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import com.qiniu.util.StringUtils;
|
||||
import io.modules.security.user.SecurityUser;
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.exception.ErrorCode;
|
||||
import io.common.exception.RenException;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.common.utils.TreeUtils;
|
||||
import io.modules.sys.dao.SysDeptDao;
|
||||
import io.modules.sys.dao.SysUserDao;
|
||||
import io.modules.sys.dto.SysDeptDTO;
|
||||
import io.modules.sys.entity.SysDeptEntity;
|
||||
import io.modules.sys.enums.SuperAdminEnum;
|
||||
import io.modules.sys.service.SysDeptService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntity> implements SysDeptService {
|
||||
private final SysUserDao sysUserDao;
|
||||
|
||||
@Override
|
||||
public List<SysDeptDTO> list(Map<String, Object> params) {
|
||||
//普通管理员,只能查询所属部门及子部门的数据
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||
params.put("deptIdList", getSubDeptIdList(user.getDeptId()));
|
||||
}
|
||||
|
||||
//查询部门列表
|
||||
List<SysDeptEntity> entityList = baseDao.getList(params);
|
||||
|
||||
List<SysDeptDTO> dtoList = ConvertUtils.sourceToTarget(entityList, SysDeptDTO.class);
|
||||
|
||||
return TreeUtils.build(dtoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDeptDTO get(Long id) {
|
||||
//超级管理员,部门ID为null
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SysDeptEntity entity = baseDao.getById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysDeptDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysDeptDTO dto) {
|
||||
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class);
|
||||
|
||||
entity.setPids(getPidList(entity.getPid()));
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysDeptDTO dto) {
|
||||
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class);
|
||||
|
||||
//上级部门不能为自身
|
||||
if (entity.getId().equals(entity.getPid())) {
|
||||
throw new RenException("上级部门不能为自身!");
|
||||
}
|
||||
|
||||
//上级部门不能为下级部门
|
||||
List<Long> subDeptList = getSubDeptIdList(entity.getId());
|
||||
if (subDeptList.contains(entity.getPid())) {
|
||||
throw new RenException("上级部门不能为下级部门");
|
||||
}
|
||||
|
||||
entity.setPids(getPidList(entity.getPid()));
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
//判断是否有子部门
|
||||
List<Long> subList = getSubDeptIdList(id);
|
||||
if (subList.size() > 1) {
|
||||
throw new RenException("存在子部门!");
|
||||
}
|
||||
|
||||
//判断部门下面是否有用户
|
||||
int count = sysUserDao.getCountByDeptId(id);
|
||||
if (count > 0) {
|
||||
throw new RenException("部门下面是有用户!");
|
||||
}
|
||||
|
||||
//删除
|
||||
baseDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getSubDeptIdList(Long id) {
|
||||
List<Long> deptIdList = baseDao.getSubDeptIdList("%" + id + "%");
|
||||
deptIdList.add(id);
|
||||
|
||||
return deptIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有上级部门ID
|
||||
*
|
||||
* @param pid 上级ID
|
||||
*/
|
||||
private String getPidList(Long pid) {
|
||||
//顶级部门,无上级部门
|
||||
if (Constant.DEPT_ROOT.equals(pid)) {
|
||||
return Constant.DEPT_ROOT + "";
|
||||
}
|
||||
|
||||
//所有部门的id、pid列表
|
||||
List<SysDeptEntity> deptList = baseDao.getIdAndPidList();
|
||||
|
||||
//list转map
|
||||
Map<Long, SysDeptEntity> map = new HashMap<>(deptList.size());
|
||||
for (SysDeptEntity entity : deptList) {
|
||||
map.put(entity.getId(), entity);
|
||||
}
|
||||
|
||||
//递归查询所有上级部门ID列表
|
||||
List<Long> pidList = new ArrayList<>();
|
||||
getPidTree(pid, map, pidList);
|
||||
|
||||
return StringUtils.join(pidList, ",");
|
||||
}
|
||||
|
||||
private void getPidTree(Long pid, Map<Long, SysDeptEntity> map, List<Long> pidList) {
|
||||
//顶级部门,无上级部门
|
||||
if (Constant.DEPT_ROOT.equals(pid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//上级部门存在
|
||||
SysDeptEntity parent = map.get(pid);
|
||||
if (parent != null) {
|
||||
getPidTree(parent.getPid(), map, pidList);
|
||||
}
|
||||
|
||||
pidList.add(pid);
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.modules.sys.dao.SysDictDataDao;
|
||||
import io.modules.sys.dto.SysDictDataDTO;
|
||||
import io.modules.sys.entity.SysDictDataEntity;
|
||||
import io.modules.sys.service.SysDictDataService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Service
|
||||
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysDictDataEntity> implements SysDictDataService {
|
||||
|
||||
@Override
|
||||
public PageData<SysDictDataDTO> page(Map<String, Object> params) {
|
||||
IPage<SysDictDataEntity> page = baseDao.selectPage(
|
||||
getPage(params, "sort", true),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysDictDataDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysDictDataEntity> getWrapper(Map<String, Object> params){
|
||||
Long dictTypeId = Long.parseLong((String) params.get("dictTypeId"));
|
||||
String dictLabel = (String) params.get("dictLabel");
|
||||
String dictValue = (String) params.get("dictValue");
|
||||
|
||||
QueryWrapper<SysDictDataEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("dict_type_id", dictTypeId);
|
||||
wrapper.like(StrUtil.isNotBlank(dictLabel), "dict_label", dictLabel);
|
||||
wrapper.like(StrUtil.isNotBlank(dictValue), "dict_value", dictValue);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDictDataDTO get(Long id) {
|
||||
SysDictDataEntity entity = baseDao.selectById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysDictDataDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysDictDataDTO dto) {
|
||||
SysDictDataEntity entity = ConvertUtils.sourceToTarget(dto, SysDictDataEntity.class);
|
||||
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysDictDataDTO dto) {
|
||||
SysDictDataEntity entity = ConvertUtils.sourceToTarget(dto, SysDictDataEntity.class);
|
||||
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
//删除
|
||||
deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.modules.sys.dao.SysDictDataDao;
|
||||
import io.modules.sys.dao.SysDictTypeDao;
|
||||
import io.modules.sys.dto.SysDictTypeDTO;
|
||||
import io.modules.sys.entity.DictData;
|
||||
import io.modules.sys.entity.DictType;
|
||||
import io.modules.sys.entity.SysDictTypeEntity;
|
||||
import io.modules.sys.service.SysDictTypeService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*
|
||||
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysDictTypeEntity> implements SysDictTypeService {
|
||||
private final SysDictDataDao sysDictDataDao;
|
||||
|
||||
@Override
|
||||
public PageData<SysDictTypeDTO> page(Map<String, Object> params) {
|
||||
IPage<SysDictTypeEntity> page = baseDao.selectPage(
|
||||
getPage(params, "sort", true),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysDictTypeDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysDictTypeEntity> getWrapper(Map<String, Object> params) {
|
||||
String dictType = (String) params.get("dictType");
|
||||
String dictName = (String) params.get("dictName");
|
||||
|
||||
QueryWrapper<SysDictTypeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(dictType), "dict_type", dictType);
|
||||
wrapper.like(StrUtil.isNotBlank(dictName), "dict_name", dictName);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDictTypeDTO get(Long id) {
|
||||
SysDictTypeEntity entity = baseDao.selectById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysDictTypeDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysDictTypeDTO dto) {
|
||||
SysDictTypeEntity entity = ConvertUtils.sourceToTarget(dto, SysDictTypeEntity.class);
|
||||
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysDictTypeDTO dto) {
|
||||
SysDictTypeEntity entity = ConvertUtils.sourceToTarget(dto, SysDictTypeEntity.class);
|
||||
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
//删除
|
||||
deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictType> getAllList() {
|
||||
List<DictType> typeList = baseDao.getDictTypeList();
|
||||
List<DictData> dataList = sysDictDataDao.getDictDataList();
|
||||
for (DictType type : typeList) {
|
||||
for (DictData data : dataList) {
|
||||
if (type.getId().equals(data.getDictTypeId())) {
|
||||
type.getDataList().add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeList;
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.exception.ErrorCode;
|
||||
import io.common.exception.RenException;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.common.utils.TreeUtils;
|
||||
import io.modules.sys.dao.SysMenuDao;
|
||||
import io.modules.sys.dto.SysMenuDTO;
|
||||
import io.modules.sys.entity.SysMenuEntity;
|
||||
import io.modules.sys.enums.SuperAdminEnum;
|
||||
import io.modules.sys.service.SysMenuService;
|
||||
import io.modules.sys.service.SysRoleMenuService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntity> implements SysMenuService {
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
|
||||
@Override
|
||||
public SysMenuDTO get(Long id) {
|
||||
SysMenuEntity entity = baseDao.getById(id);
|
||||
|
||||
SysMenuDTO dto = ConvertUtils.sourceToTarget(entity, SysMenuDTO.class);
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysMenuDTO dto) {
|
||||
SysMenuEntity entity = ConvertUtils.sourceToTarget(dto, SysMenuEntity.class);
|
||||
|
||||
//保存菜单
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysMenuDTO dto) {
|
||||
SysMenuEntity entity = ConvertUtils.sourceToTarget(dto, SysMenuEntity.class);
|
||||
|
||||
//上级菜单不能为自身
|
||||
if (entity.getId().equals(entity.getPid())) {
|
||||
throw new RenException("上级菜单不能为自身!");
|
||||
}
|
||||
|
||||
//更新菜单
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
//删除菜单
|
||||
deleteById(id);
|
||||
//删除角色菜单关系
|
||||
sysRoleMenuService.deleteByMenuId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuDTO> getAllMenuList(Integer menuType) {
|
||||
List<SysMenuEntity> menuList = baseDao.getMenuList(menuType);
|
||||
|
||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||
|
||||
return TreeUtils.build(dtoList, Constant.MENU_ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType) {
|
||||
List<SysMenuEntity> menuList;
|
||||
|
||||
//系统管理员,拥有最高权限
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||
menuList = baseDao.getMenuList(menuType);
|
||||
} else {
|
||||
menuList = baseDao.getUserMenuList(user.getId(), menuType);
|
||||
}
|
||||
|
||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||
|
||||
return TreeUtils.build(dtoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuDTO> getListPid(Long pid) {
|
||||
List<SysMenuEntity> menuList = baseDao.getListPid(pid);
|
||||
|
||||
return ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.exception.ErrorCode;
|
||||
import io.common.exception.RenException;
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.common.utils.JsonUtils;
|
||||
import io.modules.sys.dao.SysParamsDao;
|
||||
import io.modules.sys.dto.SysParamsDTO;
|
||||
import io.modules.sys.entity.SysParamsEntity;
|
||||
import io.modules.sys.service.SysParamsService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParamsEntity> implements SysParamsService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageData<SysParamsDTO> page(Map<String, Object> params) {
|
||||
IPage<SysParamsEntity> page = baseDao.selectPage(
|
||||
getPage(params, Constant.CREATE_DATE, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysParamsDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysParamsDTO> list(Map<String, Object> params) {
|
||||
List<SysParamsEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysParamsDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysParamsEntity> getWrapper(Map<String, Object> params) {
|
||||
String paramCode = (String) params.get("paramCode");
|
||||
|
||||
QueryWrapper<SysParamsEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("param_type", 1);
|
||||
wrapper.like(StrUtil.isNotBlank(paramCode), "param_code", paramCode);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysParamsDTO get(Long id) {
|
||||
SysParamsEntity entity = baseDao.selectById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysParamsDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysParamsDTO dto) {
|
||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||
insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysParamsDTO dto) {
|
||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
//删除Redis数据
|
||||
List<String> paramCodeList = baseDao.getParamCodeList(ids);
|
||||
String[] paramCodes = paramCodeList.toArray(new String[paramCodeList.size()]);
|
||||
//删除
|
||||
deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(String paramCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T getValueObject(String paramCode, Class<T> clazz) {
|
||||
String paramValue = getValue(paramCode);
|
||||
if (StrUtil.isNotBlank(paramValue)) {
|
||||
return JsonUtils.parseObject(paramValue, clazz);
|
||||
}
|
||||
|
||||
try {
|
||||
return clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RenException("参数错误!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateValueByCode(String paramCode, String paramValue) {
|
||||
int count = baseDao.updateValueByCode(paramCode, paramValue);
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.modules.sys.dao.SysRoleDataScopeDao;
|
||||
import io.modules.sys.entity.SysRoleDataScopeEntity;
|
||||
import io.modules.sys.service.SysRoleDataScopeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色数据权限
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleDataScopeServiceImpl extends BaseServiceImpl<SysRoleDataScopeDao, SysRoleDataScopeEntity>
|
||||
implements SysRoleDataScopeService {
|
||||
|
||||
@Override
|
||||
public List<Long> getDeptIdList(Long roleId) {
|
||||
return baseDao.getDeptIdList(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpdate(Long roleId, List<Long> deptIdList) {
|
||||
//先删除角色数据权限关系
|
||||
deleteByRoleIds(new Long[]{roleId});
|
||||
|
||||
//角色没有一个数据权限的情况
|
||||
if(CollUtil.isEmpty(deptIdList)){
|
||||
return ;
|
||||
}
|
||||
|
||||
//保存角色数据权限关系
|
||||
for(Long deptId : deptIdList){
|
||||
SysRoleDataScopeEntity sysRoleDataScopeEntity = new SysRoleDataScopeEntity();
|
||||
sysRoleDataScopeEntity.setDeptId(deptId);
|
||||
sysRoleDataScopeEntity.setRoleId(roleId);
|
||||
|
||||
//保存
|
||||
insert(sysRoleDataScopeEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByRoleIds(Long[] roleIds) {
|
||||
baseDao.deleteByRoleIds(roleIds);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.modules.sys.dao.SysRoleMenuDao;
|
||||
import io.modules.sys.entity.SysRoleMenuEntity;
|
||||
import io.modules.sys.service.SysRoleMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 角色与菜单对应关系
|
||||
*
|
||||
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends BaseServiceImpl<SysRoleMenuDao, SysRoleMenuEntity> implements SysRoleMenuService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpdate(Long roleId, List<Long> menuIdList) {
|
||||
//先删除角色菜单关系
|
||||
deleteByRoleIds(new Long[]{roleId});
|
||||
|
||||
//角色没有一个菜单权限的情况
|
||||
if(CollUtil.isEmpty(menuIdList)){
|
||||
return ;
|
||||
}
|
||||
|
||||
//保存角色菜单关系
|
||||
for(Long menuId : menuIdList){
|
||||
SysRoleMenuEntity sysRoleMenuEntity = new SysRoleMenuEntity();
|
||||
sysRoleMenuEntity.setMenuId(menuId);
|
||||
sysRoleMenuEntity.setRoleId(roleId);
|
||||
|
||||
//保存
|
||||
insert(sysRoleMenuEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getMenuIdList(Long roleId){
|
||||
return baseDao.getMenuIdList(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByRoleIds(Long[] roleIds) {
|
||||
baseDao.deleteByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByMenuId(Long menuId) {
|
||||
baseDao.deleteByMenuId(menuId);
|
||||
}
|
||||
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.modules.security.user.SecurityUser;
|
||||
import io.modules.security.user.UserDetail;
|
||||
import io.modules.sys.service.*;
|
||||
import io.common.constant.Constant;
|
||||
import io.common.page.PageData;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.common.utils.ConvertUtils;
|
||||
import io.modules.sys.dao.SysRoleDao;
|
||||
import io.modules.sys.dto.SysRoleDTO;
|
||||
import io.modules.sys.entity.SysRoleEntity;
|
||||
import io.modules.sys.enums.SuperAdminEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*
|
||||
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService {
|
||||
private final SysRoleMenuService sysRoleMenuService;
|
||||
private final SysRoleDataScopeService sysRoleDataScopeService;
|
||||
private final SysRoleUserService sysRoleUserService;
|
||||
private final SysDeptService sysDeptService;
|
||||
|
||||
@Override
|
||||
public PageData<SysRoleDTO> page(Map<String, Object> params) {
|
||||
IPage<SysRoleEntity> page = baseDao.selectPage(
|
||||
getPage(params, Constant.CREATE_DATE, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
|
||||
return getPageData(page, SysRoleDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRoleDTO> list(Map<String, Object> params) {
|
||||
List<SysRoleEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysRoleDTO.class);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysRoleEntity> getWrapper(Map<String, Object> params) {
|
||||
String name = (String) params.get("name");
|
||||
|
||||
QueryWrapper<SysRoleEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(name), "name", name);
|
||||
|
||||
//普通管理员,只能查询所属部门及子部门的数据
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||
List<Long> deptIdList = sysDeptService.getSubDeptIdList(user.getDeptId());
|
||||
wrapper.in(deptIdList != null, "dept_id", deptIdList);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRoleDTO get(Long id) {
|
||||
SysRoleEntity entity = baseDao.selectById(id);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entity, SysRoleDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysRoleDTO dto) {
|
||||
SysRoleEntity entity = ConvertUtils.sourceToTarget(dto, SysRoleEntity.class);
|
||||
|
||||
//保存角色
|
||||
insert(entity);
|
||||
|
||||
//保存角色菜单关系
|
||||
sysRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList());
|
||||
|
||||
//保存角色数据权限关系
|
||||
sysRoleDataScopeService.saveOrUpdate(entity.getId(), dto.getDeptIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysRoleDTO dto) {
|
||||
SysRoleEntity entity = ConvertUtils.sourceToTarget(dto, SysRoleEntity.class);
|
||||
|
||||
//更新角色
|
||||
updateById(entity);
|
||||
|
||||
//更新角色菜单关系
|
||||
sysRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList());
|
||||
|
||||
//更新角色数据权限关系
|
||||
sysRoleDataScopeService.saveOrUpdate(entity.getId(), dto.getDeptIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
//删除角色
|
||||
baseDao.deleteBatchIds(Arrays.asList(ids));
|
||||
|
||||
//删除角色用户关系
|
||||
sysRoleUserService.deleteByRoleIds(ids);
|
||||
|
||||
//删除角色菜单关系
|
||||
sysRoleMenuService.deleteByRoleIds(ids);
|
||||
|
||||
//删除角色数据权限关系
|
||||
sysRoleDataScopeService.deleteByRoleIds(ids);
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
|
||||
|
||||
package io.modules.sys.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import io.common.service.impl.BaseServiceImpl;
|
||||
import io.modules.sys.dao.SysRoleUserDao;
|
||||
import io.modules.sys.entity.SysRoleUserEntity;
|
||||
import io.modules.sys.service.SysRoleUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色用户关系
|
||||
*
|
||||
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService {
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
|
||||
//先删除角色用户关系
|
||||
deleteByUserIds(new Long[]{userId});
|
||||
|
||||
//用户没有一个角色权限的情况
|
||||
if(CollUtil.isEmpty(roleIdList)){
|
||||
return ;
|
||||
}
|
||||
|
||||
//保存角色用户关系
|
||||
for(Long roleId : roleIdList){
|
||||
SysRoleUserEntity sysRoleUserEntity = new SysRoleUserEntity();
|
||||
sysRoleUserEntity.setUserId(userId);
|
||||
sysRoleUserEntity.setRoleId(roleId);
|
||||
|
||||
//保存
|
||||
insert(sysRoleUserEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByRoleIds(Long[] roleIds) {
|
||||
baseDao.deleteByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(Long[] userIds) {
|
||||
baseDao.deleteByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getRoleIdList(Long userId) {
|
||||
|
||||
return baseDao.getRoleIdList(userId);
|
||||
}
|
||||
}
|
@ -15,13 +15,10 @@ import io.modules.sys.dao.SysUserDao;
|
||||
import io.modules.sys.dto.SysUserDTO;
|
||||
import io.modules.sys.entity.SysUserEntity;
|
||||
import io.modules.sys.enums.SuperAdminEnum;
|
||||
import io.modules.sys.service.SysDeptService;
|
||||
import io.modules.sys.service.SysRoleUserService;
|
||||
import io.modules.sys.service.SysUserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -35,8 +32,6 @@ import java.util.Map;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
|
||||
private final SysRoleUserService sysRoleUserService;
|
||||
private final SysDeptService sysDeptService;
|
||||
|
||||
@Override
|
||||
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
||||
@ -46,28 +41,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||
//分页
|
||||
IPage<SysUserEntity> page = getPage(params, Constant.CREATE_DATE, false);
|
||||
|
||||
//普通管理员,只能查询所属部门及子部门的数据
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||
params.put("deptIdList", sysDeptService.getSubDeptIdList(user.getDeptId()));
|
||||
}
|
||||
|
||||
//查询
|
||||
List<SysUserEntity> list = baseDao.getList(params);
|
||||
|
||||
return getPageData(list, page.getTotal(), SysUserDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserDTO> list(Map<String, Object> params) {
|
||||
//普通管理员,只能查询所属部门及子部门的数据
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||
params.put("deptIdList", sysDeptService.getSubDeptIdList(user.getDeptId()));
|
||||
}
|
||||
|
||||
List<SysUserEntity> entityList = baseDao.getList(params);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
||||
}
|
||||
|
||||
@ -96,9 +77,6 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||
//保存用户
|
||||
entity.setSuperAdmin(SuperAdminEnum.NO.value());
|
||||
insert(entity);
|
||||
|
||||
//保存角色用户关系
|
||||
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,17 +95,12 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||
//更新用户
|
||||
updateById(entity);
|
||||
|
||||
//更新角色用户关系
|
||||
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long[] ids) {
|
||||
//删除用户
|
||||
baseDao.deleteBatchIds(Arrays.asList(ids));
|
||||
|
||||
//删除角色用户关系
|
||||
sysRoleUserService.deleteByUserIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.job.dao.ScheduleJobDao">
|
||||
|
||||
<!-- 批量更新状态 -->
|
||||
<update id="updateBatch">
|
||||
update schedule_job set status = #{status} where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.job.dao.ScheduleJobLogDao">
|
||||
|
||||
|
||||
</mapper>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.log.dao.SysLogErrorDao">
|
||||
|
||||
</mapper>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.log.dao.SysLogLoginDao">
|
||||
|
||||
</mapper>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.log.dao.SysLogOperationDao">
|
||||
|
||||
</mapper>
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysDeptDao">
|
||||
|
||||
<select id="getList" resultType="io.modules.sys.entity.SysDeptEntity">
|
||||
select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1
|
||||
<where>
|
||||
<if test="deptIdList != null">
|
||||
t1.id in
|
||||
<foreach item="id" collection="deptIdList" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by t1.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="io.modules.sys.entity.SysDeptEntity">
|
||||
select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1
|
||||
where t1.id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="getIdAndPidList" resultType="io.modules.sys.entity.SysDeptEntity">
|
||||
select t1.id, t1.pid from sys_dept t1
|
||||
</select>
|
||||
|
||||
<select id="getSubDeptIdList" resultType="long">
|
||||
select id from sys_dept where pids like #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysDictDataDao">
|
||||
|
||||
<select id="getDictDataList" resultType="io.modules.sys.entity.DictData">
|
||||
select dict_type_id, dict_label, dict_value from sys_dict_data order by dict_type_id, sort
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysDictTypeDao">
|
||||
|
||||
<select id="getDictTypeList" resultType="io.modules.sys.entity.DictType">
|
||||
select id, dict_type from sys_dict_type order by dict_type, sort
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysMenuDao">
|
||||
|
||||
<select id="getById" resultType="io.modules.sys.entity.SysMenuEntity">
|
||||
select t1.*, (select name from sys_menu t2 where t2.id=t1.pid) as parentName from sys_menu t1
|
||||
where t1.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getMenuList" resultType="io.modules.sys.entity.SysMenuEntity">
|
||||
select t1.* from sys_menu t1
|
||||
<where>
|
||||
<if test="menuType != null">
|
||||
t1.menu_type = #{menuType}
|
||||
</if>
|
||||
</where>
|
||||
order by t1.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getUserMenuList" resultType="io.modules.sys.entity.SysMenuEntity">
|
||||
select t3.* from sys_role_user t1
|
||||
left join sys_role_menu t2 on t1.role_id = t2.role_id
|
||||
left join sys_menu t3 on t2.menu_id = t3.id
|
||||
where t1.user_id = #{userId}
|
||||
<if test="menuType != null">
|
||||
and t3.menu_type = #{menuType}
|
||||
</if>
|
||||
order by t3.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getUserPermissionsList" resultType="string">
|
||||
select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id
|
||||
left join sys_menu t3 on t2.menu_id = t3.id
|
||||
where t1.user_id = #{userId} order by t3.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getPermissionsList" resultType="string">
|
||||
select permissions from sys_menu
|
||||
</select>
|
||||
|
||||
<select id="getListPid" resultType="io.modules.sys.entity.SysMenuEntity">
|
||||
select * from sys_menu where pid = #{value}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysParamsDao">
|
||||
|
||||
<!-- 根据参数编码,查询value -->
|
||||
<select id="getValueByCode" resultType="String">
|
||||
select param_value from sys_params where param_code = #{value}
|
||||
</select>
|
||||
|
||||
<!-- 获取参数编码列表 -->
|
||||
<select id="getParamCodeList" resultType="String">
|
||||
select param_code from sys_params where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 根据参数编码,更新value -->
|
||||
<update id="updateValueByCode">
|
||||
update sys_params set param_value = #{paramValue} where param_code = #{paramCode}
|
||||
</update>
|
||||
</mapper>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysRoleDao">
|
||||
|
||||
|
||||
</mapper>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysRoleDataScopeDao">
|
||||
|
||||
<select id="getDeptIdList" resultType="long">
|
||||
select dept_id from sys_role_data_scope where role_id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="getDataScopeList" resultType="long">
|
||||
select t2.dept_id from sys_role_user t1, sys_role_data_scope t2
|
||||
where t1.user_id = #{value} and t1.role_id = t2.role_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteByRoleIds">
|
||||
delete from sys_role_data_scope where role_id in
|
||||
<foreach item="roleId" collection="array" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysRoleMenuDao">
|
||||
|
||||
<select id="getMenuIdList" resultType="long">
|
||||
select menu_id from sys_role_menu where role_id = #{value}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByRoleIds">
|
||||
delete from sys_role_menu where role_id in
|
||||
<foreach item="roleId" collection="array" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByMenuId">
|
||||
delete from sys_role_menu where menu_id = #{value}
|
||||
</delete>
|
||||
</mapper>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.modules.sys.dao.SysRoleUserDao">
|
||||
|
||||
<delete id="deleteByRoleIds">
|
||||
delete from sys_role_user where role_id in
|
||||
<foreach item="roleId" collection="array" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByUserIds">
|
||||
delete from sys_role_user where user_id in
|
||||
<foreach item="userId" collection="array" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getRoleIdList" resultType="long">
|
||||
select role_id from sys_role_user where user_id = #{value}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user