Compare commits
11 Commits
4ef1f0609a
...
b423ea902c
| Author | SHA1 | Date | |
|---|---|---|---|
| b423ea902c | |||
| 94438d1271 | |||
|
|
425dd27bfd | ||
|
|
6290495df4 | ||
|
|
845b8f8a4d | ||
|
|
cfddc12cc9 | ||
|
|
bcd9e88a09 | ||
|
|
f4b8484139 | ||
|
|
b4ee809710 | ||
|
|
9c0e7e7390 | ||
|
|
a7a68ecb03 |
@@ -36,8 +36,8 @@ buildNumber.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### Example user template template
|
||||
### Example user template
|
||||
### Example userDetail template template
|
||||
### Example userDetail template
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
- bash maven.sh
|
||||
|
||||
- name: build-docker # 制作docker镜像
|
||||
image: docker # 使用官方docker镜像
|
||||
image: 10.7.127.190:38080/docker/docker # 使用官方docker镜像
|
||||
volumes: # 将容器内目录挂载到宿主机
|
||||
- name: maven-build
|
||||
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.fateverse.admin.dto;
|
||||
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.fateverse.admin.dto;
|
||||
|
||||
import cn.fateverse.admin.entity.UserBase;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -83,8 +83,8 @@ public class UserDto{
|
||||
private List<Long> roleIds;
|
||||
|
||||
|
||||
public UserBase toUser() {
|
||||
return UserBase.builder()
|
||||
public User toUser() {
|
||||
return User.builder()
|
||||
.userId(userId)
|
||||
.deptId(deptId)
|
||||
.userName(userName)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.fateverse.admin.dubbo;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +18,7 @@ public interface DubboUserService {
|
||||
* @param username 用户名称
|
||||
* @return 用户信息
|
||||
*/
|
||||
User getUserByUsername(String username);
|
||||
UserVo getUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 根据用户id查询用户信息
|
||||
@@ -25,7 +26,7 @@ public interface DubboUserService {
|
||||
* @param userId 用户id
|
||||
* @return 用户信息
|
||||
*/
|
||||
User getUserByUserId(Long userId);
|
||||
UserVo getUserByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据roleId查询用户列表
|
||||
@@ -57,4 +58,12 @@ public interface DubboUserService {
|
||||
* @return 所有用户的id
|
||||
*/
|
||||
List<Long> searchAllUserIds();
|
||||
|
||||
/**
|
||||
* 通过用户名获取用户详细信息
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return {@link UserDetails }
|
||||
*/
|
||||
UserDetail getUserDetailsByUserName(String userName);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class DeptVo implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
@@ -47,7 +47,7 @@ public class IpBackVo {
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
@Excel("创建时间")
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public static IpBackVo toIpBackVo(IpBack ipBack) {
|
||||
return IpBackVo.builder()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.fateverse.admin.vo;
|
||||
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.fateverse.admin.vo;
|
||||
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.fateverse.admin.vo;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
@@ -14,11 +14,10 @@ import java.util.List;
|
||||
* @date 2022/11/4
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@ApiModel("用户详细信息")
|
||||
public class UserDetailVo {
|
||||
@ApiModelProperty("用户基本细腻系")
|
||||
private User user;
|
||||
private UserDetail user;
|
||||
|
||||
@ApiModelProperty("用户所在的岗位")
|
||||
private List<Long> postIds;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package cn.fateverse.admin.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
@@ -71,12 +69,4 @@ public class UserVo implements Serializable {
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
public boolean checkEmail(){
|
||||
if (StrUtil.isEmpty(email)){
|
||||
return false;
|
||||
}
|
||||
Pattern pattern =Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
|
||||
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
|
||||
return pattern.matcher(email).matches();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-mybatis</artifactId>
|
||||
<artifactId>common-mybatis-puls</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
@@ -52,6 +52,10 @@
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-decrypt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package cn.fateverse.admin.controller;
|
||||
|
||||
import cn.fateverse.admin.dto.DeptDto;
|
||||
import cn.fateverse.admin.facade.DeptFacade;
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import cn.fateverse.admin.service.DeptService;
|
||||
import cn.fateverse.common.core.constant.UserConstants;
|
||||
import cn.fateverse.admin.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.OptionTree;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -25,14 +24,10 @@ import java.util.List;
|
||||
@Api(tags = "部门接口")
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
@RequiredArgsConstructor
|
||||
public class DeptController {
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
|
||||
public DeptController(DeptService deptService) {
|
||||
this.deptService = deptService;
|
||||
}
|
||||
private final DeptFacade deptFacade;
|
||||
|
||||
|
||||
@ApiOperation("获取列表信息")
|
||||
@@ -41,7 +36,7 @@ public class DeptController {
|
||||
public Result<List<DeptVo>> list(
|
||||
@ApiParam(name="deptName",value="部门名称") String deptName,
|
||||
@ApiParam(name="state",value="状态(1: 正常 0 : 停用)") Integer state){
|
||||
List<DeptVo> deptVoList = deptService.searchTree(deptName, state);
|
||||
List<DeptVo> deptVoList = deptFacade.searchTree(deptName, state);
|
||||
return Result.ok(deptVoList);
|
||||
}
|
||||
|
||||
@@ -51,23 +46,21 @@ public class DeptController {
|
||||
public Result<DeptVo> info(
|
||||
@ApiParam(name="deptId",value="部门id")
|
||||
@PathVariable Long deptId){
|
||||
checkDeptId(deptId);
|
||||
DeptVo deptVo = deptService.searchById(deptId);
|
||||
DeptVo deptVo = deptFacade.searchById(deptId);
|
||||
return Result.ok(deptVo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取树形接口的option")
|
||||
@GetMapping("/option")
|
||||
public Result<List<OptionTree>> option(){
|
||||
List<OptionTree> optionTreeList = deptService.searchTreeOption();
|
||||
List<OptionTree> optionTreeList = deptFacade.searchTreeOption();
|
||||
return Result.ok(optionTreeList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取修改时的部门列表")
|
||||
@GetMapping("/option/exclude/{deptId}")
|
||||
public Result<List<OptionTree>> exclude(@PathVariable Long deptId){
|
||||
checkDeptId(deptId);
|
||||
List<OptionTree> deptVoList = deptService.searchExcludeTree(deptId);
|
||||
List<OptionTree> deptVoList = deptFacade.searchExcludeTree(deptId);
|
||||
return Result.ok(deptVoList);
|
||||
}
|
||||
|
||||
@@ -76,12 +69,7 @@ public class DeptController {
|
||||
@PreAuthorize("@ss.hasPermission('admin:dept:add')")
|
||||
@Log(title = "新增部门",businessType = BusinessType.INSERT)
|
||||
public Result<Void> add(@RequestBody @Validated DeptDto deptDto){
|
||||
Dept dept = new Dept();
|
||||
BeanUtils.copyProperties(deptDto,dept);
|
||||
if (UserConstants.DEPT_DISABLE.equals(deptService.checkNameUnique(dept))){
|
||||
return Result.error("新增部门: "+ dept.getDeptName() +"'失败,部门名称以存在!");
|
||||
}
|
||||
deptService.save(dept);
|
||||
deptFacade.save(deptDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -90,15 +78,7 @@ public class DeptController {
|
||||
@PreAuthorize("@ss.hasPermission('admin:dept:edit')")
|
||||
@Log(title = "修改部门",businessType = BusinessType.UPDATE)
|
||||
public Result<Void> edit(@RequestBody @Validated DeptDto deptDto){
|
||||
Dept dept = new Dept();
|
||||
BeanUtils.copyProperties(deptDto,dept);
|
||||
if (UserConstants.DEPT_DISABLE.equals(deptService.checkNameUnique(dept))){
|
||||
return Result.error("修改部门: "+ dept.getDeptName() +"'失败,部门名称以存在!");
|
||||
}else if (dept.getDeptId().equals(dept.getParentId())){
|
||||
return Result.error("修改部门: "+ dept.getDeptName() +"'失败,上级部门不能为自己!");
|
||||
}
|
||||
checkDeptId(dept.getDeptId());
|
||||
deptService.edit(dept);
|
||||
deptFacade.edit(deptDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -108,26 +88,11 @@ public class DeptController {
|
||||
@PreAuthorize("@ss.hasPermission('admin:dept:del')")
|
||||
@Log(title = "删除部门",businessType = BusinessType.DELETE)
|
||||
public Result<Void> delete(@PathVariable Long deptId){
|
||||
checkDeptId(deptId);
|
||||
if (deptService.hasChildById(deptId)){
|
||||
return Result.error("存在下级部门,不允许删除");
|
||||
}else if (deptService.checkExistUser(deptId)){
|
||||
return Result.error("该部门下存在用户,不允许删除");
|
||||
}
|
||||
deptService.remove(deptId);
|
||||
deptFacade.remove(deptId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查部门id是都为空
|
||||
*/
|
||||
private void checkDeptId(Long deptId){
|
||||
if (null == deptId){
|
||||
throw new CustomException("部门id不能为空!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.fateverse.admin.controller;
|
||||
import cn.fateverse.admin.dto.RoleDto;
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.facade.RoleFacade;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.common.core.entity.IdWrapper;
|
||||
@@ -16,13 +17,14 @@ import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -38,30 +40,21 @@ import java.util.Set;
|
||||
@Api(tags = "角色管理")
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@RequiredArgsConstructor
|
||||
public class RoleController {
|
||||
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private final RoleFacade roleFacade;
|
||||
private final UserService userService;
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
private final TokenService tokenService;
|
||||
|
||||
public RoleController(RoleService roleService, UserService userService, MenuService menuService, TokenService tokenService) {
|
||||
this.roleService = roleService;
|
||||
this.userService = userService;
|
||||
this.menuService = menuService;
|
||||
this.tokenService = tokenService;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取角色列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('admin:role:list')")
|
||||
public Result<TableDataInfo<RoleVo>> list(RoleQuery query) {
|
||||
TableDataInfo<RoleVo> dataInfo = roleService.searchList(query);
|
||||
TableDataInfo<RoleVo> dataInfo = roleFacade.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@@ -70,30 +63,30 @@ public class RoleController {
|
||||
@GetMapping("/{roleId}")
|
||||
@PreAuthorize("@ss.hasPermission('admin:role:info')")
|
||||
public Result<RoleVo> info(@PathVariable Long roleId) {
|
||||
checkRoleId(roleId);
|
||||
RoleVo vo = roleService.searchById(roleId);
|
||||
RoleVo vo = roleFacade.searchById(roleId);
|
||||
return Result.ok(vo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据菜单id获取角色列表")
|
||||
@GetMapping("/menu/list")
|
||||
public Result<TableDataInfo<RoleVo>> roleExcludeMenuId(Long menuId, String roleName, String roleKey) {
|
||||
if (ObjectUtils.isEmpty(menuId)) {
|
||||
return Result.error("菜单id不能为空!");
|
||||
}
|
||||
TableDataInfo<RoleVo> dataInfo = roleService.searchListExcludeMenuId(menuId, roleName, roleKey);
|
||||
public Result<TableDataInfo<RoleVo>> roleExcludeMenuId(@RequestParam Long menuId,
|
||||
@RequestParam String roleName,
|
||||
@RequestParam String roleKey) {
|
||||
TableDataInfo<RoleVo> dataInfo = roleFacade.searchListExcludeMenuId(menuId, roleName, roleKey);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据菜单id获取分配的角色信息")
|
||||
@GetMapping("/menu")
|
||||
public Result<TableDataInfo<RoleVo>> menuRole(Long menuId, String roleName, String roleKey) {
|
||||
public Result<TableDataInfo<RoleVo>> menuRole(@RequestParam Long menuId,
|
||||
@RequestParam String roleName,
|
||||
@RequestParam String roleKey) {
|
||||
if (ObjectUtils.isEmpty(menuId)) {
|
||||
return Result.error("菜单id不能为空!");
|
||||
}
|
||||
TableDataInfo<RoleVo> dataInfo = roleService.searchListByMenuId(menuId, roleName, roleKey);
|
||||
TableDataInfo<RoleVo> dataInfo = roleFacade.searchListByMenuId(menuId, roleName, roleKey);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@@ -105,7 +98,7 @@ public class RoleController {
|
||||
public Result<Void> bindRole(@RequestBody IdWrapper wrapper) {
|
||||
checkRoleIds(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
|
||||
roleService.bindMenu(wrapper.getId(), wrapper.getIds());
|
||||
roleFacade.bindMenu(wrapper.getId(), wrapper.getIds());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -117,7 +110,7 @@ public class RoleController {
|
||||
public Result<Void> unBindMenu(@RequestBody IdWrapper wrapper) {
|
||||
checkRoleIds(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
|
||||
roleService.unBindMenu(wrapper.getId(), wrapper.getIds());
|
||||
roleFacade.unBindMenu(wrapper.getId(), wrapper.getIds());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -127,7 +120,7 @@ public class RoleController {
|
||||
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
|
||||
public Result<Void> unBindAllMenu(@RequestBody IdWrapper wrapper) {
|
||||
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
|
||||
roleService.unBindAllMenu(wrapper.getId());
|
||||
roleFacade.unBindAllMenu(wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -135,7 +128,7 @@ public class RoleController {
|
||||
@ApiOperation("查询角色信息")
|
||||
@GetMapping("/option")
|
||||
public Result<List<Option>> option() {
|
||||
List<Option> option = roleService.searchOption();
|
||||
List<Option> option = roleFacade.searchOption();
|
||||
return Result.ok(option);
|
||||
}
|
||||
|
||||
@@ -146,7 +139,7 @@ public class RoleController {
|
||||
@PreAuthorize("@ss.hasPermission('admin:role:add')")
|
||||
public Result<Void> add(@RequestBody @Validated RoleDto role) {
|
||||
checkNameAndKey(role);
|
||||
roleService.save(role);
|
||||
roleFacade.save(role);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -157,7 +150,7 @@ public class RoleController {
|
||||
public Result<Void> edit(@NotNull @RequestBody @Validated RoleDto role) {
|
||||
checkRoleId(role.getRoleId());
|
||||
checkNameAndKey(role);
|
||||
roleService.edit(role);
|
||||
roleFacade.edit(role);
|
||||
checkUserRoleUpdate(role);
|
||||
return Result.ok();
|
||||
}
|
||||
@@ -173,7 +166,7 @@ public class RoleController {
|
||||
if (StrUtil.isEmpty(role.getState())) {
|
||||
return Result.error("状态不能为空!");
|
||||
}
|
||||
roleService.editState(role.getRoleId(), role.getState());
|
||||
roleFacade.editState(role.getRoleId(), role.getState());
|
||||
checkUserRoleUpdate(role);
|
||||
return Result.ok();
|
||||
}
|
||||
@@ -185,7 +178,7 @@ public class RoleController {
|
||||
@PreAuthorize("@ss.hasPermission('admin:role:del')")
|
||||
public Result<Void> delete(@PathVariable Long roleId) {
|
||||
checkRoleId(roleId);
|
||||
roleService.remove(roleId);
|
||||
roleFacade.remove(roleId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -213,10 +206,10 @@ public class RoleController {
|
||||
* 检查角色名称和角色关键词
|
||||
*/
|
||||
private void checkNameAndKey(RoleDto dto) {
|
||||
if (roleService.checkNameUnique(dto)) {
|
||||
if (roleFacade.checkNameUnique(dto)) {
|
||||
throw new CustomException("角色名称已存在!");
|
||||
}
|
||||
if (roleService.checkRoleKeyUnique(dto)) {
|
||||
if (roleFacade.checkRoleKeyUnique(dto)) {
|
||||
throw new CustomException("角色权限名称已存在!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package cn.fateverse.admin.controller;
|
||||
|
||||
import cn.fateverse.admin.dto.UserDto;
|
||||
import cn.fateverse.admin.facade.RoleFacade;
|
||||
import cn.fateverse.admin.facade.UserFacade;
|
||||
import cn.fateverse.admin.query.UserQuery;
|
||||
import cn.fateverse.admin.service.PostService;
|
||||
import cn.fateverse.admin.vo.UserChooseVo;
|
||||
import cn.fateverse.admin.vo.UserDetailVo;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.IdWrapper;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.admin.service.PostService;
|
||||
import cn.fateverse.admin.service.RoleService;
|
||||
import cn.fateverse.admin.service.UserService;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.common.security.annotation.Anonymity;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.fateverse.common.security.annotation.Anonymity;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -37,31 +38,20 @@ import java.util.regex.Pattern;
|
||||
@Api(tags = "用户管理")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private final UserFacade userFacade;
|
||||
private final RoleFacade roleFacade;
|
||||
private final PostService postService;
|
||||
|
||||
public UserController(UserService userService,
|
||||
RoleService roleService,
|
||||
PostService postService) {
|
||||
this.userService = userService;
|
||||
this.roleService = roleService;
|
||||
this.postService = postService;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('admin:user:list')")
|
||||
public Result<TableDataInfo<UserVo>> list(UserQuery userQuery) {
|
||||
PageUtils.startPage();
|
||||
List<UserVo> userVos = userService.searchList(userQuery);
|
||||
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userVos);
|
||||
TableDataInfo<UserVo> dataTable = userFacade.searchList(userQuery);
|
||||
return Result.ok(dataTable);
|
||||
}
|
||||
|
||||
@@ -72,7 +62,7 @@ public class UserController {
|
||||
if (null == type || null == chooseId || type > 1 || type < 0) {
|
||||
return Result.error("参数异常!");
|
||||
}
|
||||
List<UserChooseVo> userChooseList = userService.searchUserChooseRoleOrDept(type, chooseId);
|
||||
List<UserChooseVo> userChooseList = userFacade.searchUserChooseRoleOrDept(type, chooseId);
|
||||
return Result.ok(userChooseList);
|
||||
}
|
||||
|
||||
@@ -80,9 +70,8 @@ public class UserController {
|
||||
@GetMapping("/info/{userId}")
|
||||
@PreAuthorize("@ss.hasPermission('admin:user:info')")
|
||||
public Result<UserDetailVo> info(@PathVariable Long userId) {
|
||||
checkUserId(userId);
|
||||
UserDetailVo userDetail = userService.searchByUserId(userId);
|
||||
List<Option> roleOption = roleService.searchOption();
|
||||
UserDetailVo userDetail = userFacade.searchDetailByUserId(userId);
|
||||
List<Option> roleOption = roleFacade.searchOption();
|
||||
List<Option> postOption = postService.searchOption();
|
||||
userDetail.setRoleList(roleOption);
|
||||
userDetail.setPostList(postOption);
|
||||
@@ -94,7 +83,7 @@ public class UserController {
|
||||
public Result<TableDataInfo<UserVo>> role(@PathVariable Long roleId, String userName, String phoneNumber) {
|
||||
LongUtils.checkId(roleId, "角色id不能为空!");
|
||||
PageUtils.startPage();
|
||||
List<UserVo> userList = userService.searchListByRoleId(roleId, userName, phoneNumber);
|
||||
List<UserVo> userList = userFacade.searchListByRoleId(roleId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
|
||||
return Result.ok(dataTable);
|
||||
}
|
||||
@@ -103,7 +92,7 @@ public class UserController {
|
||||
@GetMapping("/role/exclude/{roleId}")
|
||||
public Result<TableDataInfo<UserVo>> excludeRole(@PathVariable Long roleId, String userName, String phoneNumber) {
|
||||
LongUtils.checkId(roleId, "角色id不能为空!");
|
||||
TableDataInfo<UserVo> table = userService.searchUserListByExcludeRoleId(roleId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludeRoleId(roleId, userName, phoneNumber);
|
||||
return Result.ok(table);
|
||||
}
|
||||
|
||||
@@ -114,7 +103,7 @@ public class UserController {
|
||||
public Result<Void> bindRole(@RequestBody IdWrapper wrapper) {
|
||||
checkUserId(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
|
||||
userService.bindRole(wrapper.getIds(), wrapper.getId());
|
||||
userFacade.bindRole(wrapper.getIds(), wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -125,7 +114,7 @@ public class UserController {
|
||||
public Result<Void> unBindRole(@RequestBody IdWrapper wrapper) {
|
||||
checkUserId(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
|
||||
userService.unBindRole(wrapper.getIds(), wrapper.getId());
|
||||
userFacade.unBindRole(wrapper.getIds(), wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -135,7 +124,7 @@ public class UserController {
|
||||
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
|
||||
public Result<Void> unBindAllRole(@RequestBody IdWrapper wrapper) {
|
||||
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
|
||||
userService.unBindAllRole(wrapper.getId());
|
||||
userFacade.unBindAllRole(wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -144,7 +133,7 @@ public class UserController {
|
||||
public Result<TableDataInfo<UserVo>> dept(@PathVariable Long deptId, String userName, String phoneNumber) {
|
||||
LongUtils.checkId(deptId, "角色id不能为空!");
|
||||
PageUtils.startPage();
|
||||
List<UserVo> userList = userService.searchListByDeptId(deptId, userName, phoneNumber);
|
||||
List<UserVo> userList = userFacade.searchListByDeptId(deptId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
|
||||
return Result.ok(dataTable);
|
||||
}
|
||||
@@ -153,7 +142,7 @@ public class UserController {
|
||||
// @GetMapping("/dept/exclude/{deptId}")
|
||||
public Result<TableDataInfo<UserVo>> excludeDept(@PathVariable Long deptId, String userName, String phoneNumber) {
|
||||
LongUtils.checkId(deptId, "角色id不能为空!");
|
||||
TableDataInfo<UserVo> table = userService.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
|
||||
return Result.ok(table);
|
||||
}
|
||||
|
||||
@@ -164,7 +153,7 @@ public class UserController {
|
||||
public Result<Void> unBindDept(@PathVariable List<Long> userIds, @PathVariable Long deptId) {
|
||||
checkUserId(userIds);
|
||||
LongUtils.checkId(deptId, "角色id不能为空");
|
||||
userService.unBindDept(userIds, deptId);
|
||||
userFacade.unBindDept(userIds, deptId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -174,7 +163,7 @@ public class UserController {
|
||||
// @Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
|
||||
public Result<Void> unBindAllDept(@PathVariable Long deptId) {
|
||||
LongUtils.checkId(deptId, "角色id不能为空");
|
||||
userService.unBindAllDept(deptId);
|
||||
userFacade.unBindAllDept(deptId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -185,7 +174,7 @@ public class UserController {
|
||||
return Result.error("岗位id不能为空!");
|
||||
}
|
||||
PageUtils.startPage();
|
||||
List<UserVo> userList = userService.searchListByPostId(postId, userName, phoneNumber);
|
||||
List<UserVo> userList = userFacade.searchListByPostId(postId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
|
||||
return Result.ok(dataTable);
|
||||
}
|
||||
@@ -195,7 +184,7 @@ public class UserController {
|
||||
@GetMapping("/post/exclude/{postId}")
|
||||
public Result<TableDataInfo<UserVo>> excludePost(@PathVariable Long postId, String userName, String phoneNumber) {
|
||||
LongUtils.checkId(postId, "角色id不能为空!");
|
||||
TableDataInfo<UserVo> table = userService.searchUserListByExcludePostId(postId, userName, phoneNumber);
|
||||
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludePostId(postId, userName, phoneNumber);
|
||||
return Result.ok(table);
|
||||
}
|
||||
|
||||
@@ -207,7 +196,7 @@ public class UserController {
|
||||
public Result<Void> bindPost(@RequestBody IdWrapper wrapper) {
|
||||
checkUserId(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
|
||||
userService.bindPost(wrapper.getIds(), wrapper.getId());
|
||||
userFacade.bindPost(wrapper.getIds(), wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -218,7 +207,7 @@ public class UserController {
|
||||
public Result<Void> unBindPost(@RequestBody IdWrapper wrapper) {
|
||||
checkUserId(wrapper.getIds());
|
||||
LongUtils.checkId(wrapper.getId(), "岗位id不能为空");
|
||||
userService.unBindPost(wrapper.getIds(), wrapper.getId());
|
||||
userFacade.unBindPost(wrapper.getIds(), wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -228,7 +217,7 @@ public class UserController {
|
||||
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
|
||||
public Result<Void> unBindAllPost(@RequestBody IdWrapper wrapper) {
|
||||
LongUtils.checkId(wrapper.getId(), "岗位id不能为空");
|
||||
userService.unBindAllPost(wrapper.getId());
|
||||
userFacade.unBindAllPost(wrapper.getId());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -241,7 +230,7 @@ public class UserController {
|
||||
return Result.error("初始密码不能为空");
|
||||
}
|
||||
checkPhone(user.getPhoneNumber());
|
||||
userService.save(user);
|
||||
userFacade.save(user);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -253,7 +242,7 @@ public class UserController {
|
||||
public Result<Void> edit(@NotNull @RequestBody @Validated UserDto user) {
|
||||
checkUserId(user.getUserId());
|
||||
checkPhone(user.getPhoneNumber());
|
||||
userService.edit(user);
|
||||
userFacade.edit(user);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -263,7 +252,7 @@ public class UserController {
|
||||
@Log(title = "删除用户", businessType = BusinessType.DELETE)
|
||||
public Result<Void> del(@PathVariable Long userId) {
|
||||
checkUserId(userId);
|
||||
userService.remove(userId);
|
||||
userFacade.remove(userId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.fateverse.admin.convert;
|
||||
|
||||
import cn.fateverse.admin.dto.DeptDto;
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import cn.fateverse.common.core.convert.BaseConvertDefine;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface DeptConvert extends BaseConvertDefine<DeptDto, Dept, DeptVo> {
|
||||
DeptConvert INSTANCE = Mappers.getMapper(DeptConvert.class);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.fateverse.admin.convert;
|
||||
|
||||
|
||||
import cn.fateverse.admin.dto.RoleDto;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.common.core.convert.BaseConvertDefine;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface RoleConvert extends BaseConvertDefine<RoleDto, Role, RoleVo> {
|
||||
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.fateverse.admin.convert;
|
||||
|
||||
import cn.fateverse.admin.dto.UserDto;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.convert.BaseConvertDefine;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface UserConvert extends BaseConvertDefine<UserDto, User, UserVo> {
|
||||
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
|
||||
|
||||
/**
|
||||
* 实体到细节
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link UserDetail }
|
||||
*/
|
||||
UserDetail entityToDetail(User user);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.fateverse.admin.dubbo;
|
||||
|
||||
import cn.fateverse.admin.service.DeptService;
|
||||
import cn.fateverse.admin.facade.DeptFacade;
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,18 +12,15 @@ import java.util.List;
|
||||
* @date 2023-02-20
|
||||
*/
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class DubboDeptServiceImpl implements DubboDeptService {
|
||||
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
public DubboDeptServiceImpl(DeptService deptService) {
|
||||
this.deptService = deptService;
|
||||
}
|
||||
private final DeptFacade deptFacade;
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeptVo> searchDeptByDeptId(List<Long> deptIds) {
|
||||
return deptService.searchByIds(deptIds);
|
||||
return deptFacade.searchByIds(deptIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.fateverse.admin.dubbo;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.service.UserService;
|
||||
import cn.fateverse.admin.facade.UserFacade;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
@@ -15,24 +16,21 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class DubboUserServiceImpl implements DubboUserService {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public DubboUserServiceImpl(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
private final UserFacade userFacade;
|
||||
|
||||
|
||||
@Override
|
||||
public User getUserByUsername(String username) {
|
||||
public UserVo getUserByUsername(String username) {
|
||||
log.info("用户登录:{}", username);
|
||||
return userService.searchByUserName(username);
|
||||
return userFacade.searchByUserName(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserByUserId(Long userId) {
|
||||
return userService.searchUserInfoByUserId(userId);
|
||||
public UserVo getUserByUserId(Long userId) {
|
||||
return userFacade.searchByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +38,7 @@ public class DubboUserServiceImpl implements DubboUserService {
|
||||
if (roleIds.isEmpty()) {
|
||||
throw new CustomException("角色id不能为空");
|
||||
}
|
||||
return userService.searchListByRoleIds(roleIds);
|
||||
return userFacade.searchListByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +46,7 @@ public class DubboUserServiceImpl implements DubboUserService {
|
||||
if (userIds.isEmpty()) {
|
||||
throw new CustomException("用户id不能为空");
|
||||
}
|
||||
return userService.searchByUserIds(userIds);
|
||||
return userFacade.searchByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,11 +54,16 @@ public class DubboUserServiceImpl implements DubboUserService {
|
||||
if (deptIds.isEmpty()) {
|
||||
throw new CustomException("部门id不能为空");
|
||||
}
|
||||
return userService.searchByDeptIds(deptIds);
|
||||
return userFacade.searchByDeptIds(deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> searchAllUserIds() {
|
||||
return userService.searchAllUserIds();
|
||||
return userFacade.searchAllUserIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetail getUserDetailsByUserName(String userName) {
|
||||
return userFacade.getUserDetailsByUserName(userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package cn.fateverse.admin.facade;
|
||||
|
||||
import cn.fateverse.admin.convert.DeptConvert;
|
||||
import cn.fateverse.admin.dto.DeptDto;
|
||||
import cn.fateverse.admin.service.DeptService;
|
||||
import cn.fateverse.admin.service.UserService;
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import cn.fateverse.common.core.constant.BaseConstant;
|
||||
import cn.fateverse.common.core.constant.UserConstants;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.OptionTree;
|
||||
import cn.fateverse.common.core.utils.AssertUtil;
|
||||
import cn.fateverse.common.core.utils.convert.TreeUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeptFacade {
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
/**
|
||||
* 查询树形结构信息
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param state 状态
|
||||
* @return {@link List }<{@link DeptVo }>
|
||||
*/
|
||||
public List<DeptVo> searchTree(String deptName, Integer state) {
|
||||
List<Dept> deptList = deptService.list(deptName, state);
|
||||
return TreeUtil.build(deptList, DeptVo.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setExclude("phone");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 按id查询
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return {@link DeptVo }
|
||||
*/
|
||||
public DeptVo searchById(Long deptId) {
|
||||
Dept dept = deptService.getById(deptId);
|
||||
return DeptConvert.INSTANCE.entityToVo(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门选择的树形结构
|
||||
*
|
||||
* @return {@link List }<{@link OptionTree }> 部门树形选择对象
|
||||
*/
|
||||
public List<OptionTree> searchTreeOption() {
|
||||
List<Dept> deptList = deptService.list(null, null);
|
||||
return TreeUtil.build(deptList, OptionTree.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setOption("deptId", "deptName");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索排除树
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return {@link List }<{@link OptionTree }>
|
||||
*/
|
||||
public List<OptionTree> searchExcludeTree(Long deptId) {
|
||||
Dept dept = deptService.getById(deptId);
|
||||
if (BaseConstant.ZERO.equals(dept.getParentId())) {
|
||||
return List.of();
|
||||
}
|
||||
List<Dept> deptList = deptService.searchExcludeTree(deptId);
|
||||
return TreeUtil.build(deptList, OptionTree.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setOption("deptId", "deptName");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param deptDto 部门dto
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(DeptDto deptDto) {
|
||||
Dept dept = DeptConvert.INSTANCE.dtoToEntity(deptDto);
|
||||
deptService.checkNameUnique(dept);
|
||||
deptService.save(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param deptDto 部门dto
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(DeptDto deptDto) {
|
||||
Dept dept = DeptConvert.INSTANCE.dtoToEntity(deptDto);
|
||||
deptService.checkNameUnique(dept);
|
||||
AssertUtil.isTrue(!dept.getDeptId().equals(dept.getParentId()), "修改部门: {} '失败,上级部门不能为自己!", dept.getDeptName());
|
||||
|
||||
Dept newParentDept = deptService.getById(dept.getParentId());
|
||||
Dept oldDept = deptService.getById(dept.getDeptId());
|
||||
if (null != newParentDept && null != oldDept) {
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
if (null != newParentDept && UserConstants.DEPT_DISABLE.equals(newParentDept.getState())) {
|
||||
updateParentDept(dept);
|
||||
}
|
||||
deptService.save(dept);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新字元素的ancestors
|
||||
*
|
||||
* @param deptId
|
||||
* @param newAncestors
|
||||
* @param odlAncestors
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String newAncestors, String odlAncestors) {
|
||||
List<Dept> children = deptService.selectChildrenById(deptId);
|
||||
List<Dept> newChildren = children.stream().peek(child -> {
|
||||
child.setAncestors(child.getAncestors().replace(odlAncestors, newAncestors));
|
||||
}).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(newChildren)) {
|
||||
deptService.updateBatchById(newChildren);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新父级部门的状态
|
||||
*
|
||||
* @param dept
|
||||
*/
|
||||
public void updateParentDept(Dept dept) {
|
||||
Dept parent = deptService.getById(dept.getParentId());
|
||||
parent.setState(dept.getState());
|
||||
deptService.updateById(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param deptId 部门id
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void remove(Long deptId) {
|
||||
AssertUtil.isTrue(!deptService.hasChildById(deptId), "存在下级部门,不允许删除");
|
||||
AssertUtil.isTrue(!userService.checkExistUser(deptId), "该部门下存在用户,不允许删除");
|
||||
deptService.removeById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按id搜索
|
||||
*
|
||||
* @param deptIds 部门id
|
||||
* @return {@link List }<{@link DeptVo }>
|
||||
*/
|
||||
public List<DeptVo> searchByIds(List<Long> deptIds) {
|
||||
List<Dept> deptList = deptService.searchByIds(deptIds);
|
||||
return DeptConvert.INSTANCE.entityToVOList(deptList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.fateverse.admin.facade;
|
||||
|
||||
import cn.fateverse.admin.convert.RoleConvert;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.service.RoleService;
|
||||
import cn.fateverse.admin.service.UserRoleService;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RoleFacade {
|
||||
|
||||
private final RoleService roleService;
|
||||
private final UserRoleService userRoleService;
|
||||
|
||||
/**
|
||||
* 搜索选项
|
||||
*
|
||||
* @return {@link List }<{@link Option }>
|
||||
*/
|
||||
public List<Option> searchOption() {
|
||||
List<Role> list = roleService.list();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表
|
||||
*
|
||||
* @param query 查询
|
||||
* @return {@link TableDataInfo }<{@link RoleVo }>
|
||||
*/
|
||||
public TableDataInfo<RoleVo> searchList(RoleQuery query) {
|
||||
IPage<Role> page = roleService.searchList(query);
|
||||
return PageConditionUtil.convertDataTable(page, RoleConvert.INSTANCE::entityToVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按id查询
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return {@link RoleVo }
|
||||
*/
|
||||
public RoleVo searchById(Long roleId) {
|
||||
Role role = roleService.getById(roleId);
|
||||
return RoleConvert.INSTANCE.entityToVo(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表排除菜单id
|
||||
*
|
||||
* @param menuId 菜单id
|
||||
* @param roleName 角色名
|
||||
* @param roleKey 关键角色
|
||||
* @return {@link TableDataInfo }<{@link RoleVo }>
|
||||
*/
|
||||
public TableDataInfo<RoleVo> searchListExcludeMenuId(Long menuId, String roleName, String roleKey) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package cn.fateverse.admin.facade;
|
||||
|
||||
import cn.fateverse.admin.convert.UserConvert;
|
||||
import cn.fateverse.admin.query.UserQuery;
|
||||
import cn.fateverse.admin.service.*;
|
||||
import cn.fateverse.admin.vo.UserChooseVo;
|
||||
import cn.fateverse.admin.vo.UserDetailVo;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserFacade {
|
||||
|
||||
private final UserService userService;
|
||||
private final UserRoleService userRoleService;
|
||||
private final UserPostService userPostService;
|
||||
private final DeptService deptService;
|
||||
private final RoleService roleService;
|
||||
|
||||
|
||||
/**
|
||||
* 按用户名搜索
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return {@link UserVo }
|
||||
*/
|
||||
public UserVo searchByUserName(String username) {
|
||||
User user = userService.searchByUserName(username);
|
||||
return UserConvert.INSTANCE.entityToVo(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户id搜索
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return {@link UserVo }
|
||||
*/
|
||||
public UserVo searchByUserId(Long userId) {
|
||||
User user = userService.getById(userId);
|
||||
return UserConvert.INSTANCE.entityToVo(user);
|
||||
}
|
||||
|
||||
public UserDetail getUserDetailsByUserName(String username) {
|
||||
User user = userService.searchByUserName(username);
|
||||
return buildUserDetail(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建用户细节
|
||||
*
|
||||
* @param user 用户
|
||||
* @return {@link UserDetail }
|
||||
*/
|
||||
private UserDetail buildUserDetail(User user) {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
UserDetail userDetail = UserConvert.INSTANCE.entityToDetail(user);
|
||||
|
||||
Dept dept = deptService.getById(user.getDeptId());
|
||||
if (ObjectUtil.isNotNull(dept)) {
|
||||
userDetail.setDept(dept);
|
||||
}
|
||||
List<Role> roleList = userRoleService.selectRoleByUserId(user.getUserId());
|
||||
if (CollUtil.isNotEmpty(roleList)) {
|
||||
userDetail.setRoles(roleList);
|
||||
}
|
||||
return userDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表
|
||||
*
|
||||
* @param userQuery 用户查询
|
||||
* @return {@link List }<{@link UserVo }>
|
||||
*/
|
||||
public TableDataInfo<UserVo> searchList(UserQuery userQuery) {
|
||||
IPage<UserVo> page = userService.searchList(userQuery);
|
||||
return PageConditionUtil.convertDataTable(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索用户选择角色或部门
|
||||
*
|
||||
* @param type 类型
|
||||
* @param chooseId 选择id
|
||||
* @return {@link List }<{@link UserChooseVo }>
|
||||
*/
|
||||
public List<UserChooseVo> searchUserChooseRoleOrDept(Integer type, Long chooseId) {
|
||||
switch (type) {
|
||||
// 0代表角色
|
||||
case 0:
|
||||
return chooseRole(chooseId);
|
||||
// 1代表部门
|
||||
case 1:
|
||||
return chooseDept(chooseId);
|
||||
default:
|
||||
throw new CustomException("参数异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择角色
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return 选择成功的用户信息
|
||||
*/
|
||||
private List<UserChooseVo> chooseRole(Long roleId) {
|
||||
if (roleId.equals(0L)) {
|
||||
List<Role> roleList = roleService.list();
|
||||
return roleList.stream().map(UserChooseVo::toUserChooseByRole).collect(Collectors.toList());
|
||||
} else {
|
||||
List<UserVo> userList = userService.selectUserListByRoleId(roleId, null, null);
|
||||
return userList.stream().map(user ->
|
||||
UserChooseVo.toUserChooseByUser(user, roleId)
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择部门
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
private List<UserChooseVo> chooseDept(Long deptId) {
|
||||
List<Dept> deptList = deptService.selectListByDeptParentId(deptId);
|
||||
List<UserChooseVo> result = deptList.stream().map(dept -> UserChooseVo.toUserChooseByDept(dept, deptId)).collect(Collectors.toList());
|
||||
List<UserVo> userList = userService.selectByDeptIds(Collections.singletonList(deptId));
|
||||
userList.forEach(user -> result.add(UserChooseVo.toUserChooseByUser(user, deptId)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户id搜索详细信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return {@link UserDetailVo }
|
||||
*/
|
||||
public UserDetailVo searchDetailByUserId(Long userId) {
|
||||
User user = userService.getById(userId);
|
||||
UserDetail userDetail = buildUserDetail(user);
|
||||
UserDetailVo detailVo = new UserDetailVo();
|
||||
detailVo.setUser(userDetail);
|
||||
return detailVo;
|
||||
}
|
||||
}
|
||||
@@ -1,137 +1,25 @@
|
||||
package cn.fateverse.admin.mapper;
|
||||
|
||||
import cn.fateverse.admin.entity.Dept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2022/11/2
|
||||
*/
|
||||
public interface DeptMapper {
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门列表
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param state 部门状态
|
||||
* @return 部门集合
|
||||
*/
|
||||
List<Dept> selectList(@Param("deptName") String deptName, @Param("state") Integer state);
|
||||
|
||||
/**
|
||||
* 通过id查询部门信息
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 返回对象
|
||||
*/
|
||||
Dept selectById(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取排除自身的部门列表
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 部门集合
|
||||
*/
|
||||
List<Dept> selectExclude(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询所有的子节点
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 部门集合
|
||||
*/
|
||||
List<Dept> selectChildrenById(Long deptId);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param parentId 父部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
Dept selectByDeptNameAndParentId(@Param("deptName") String deptName, @Param("parentId") Long parentId);
|
||||
|
||||
/**
|
||||
* 根据父id查询部门信息
|
||||
*
|
||||
* @param parentId 父级部门id
|
||||
* @return 部门集合
|
||||
*/
|
||||
List<Dept> selectListByDeptParentId(Long parentId);
|
||||
|
||||
|
||||
/**
|
||||
* 通过parentId查询子列表
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 部门名称集合
|
||||
*/
|
||||
Set<String> selectDeptNameListByParentId(Long parentId);
|
||||
|
||||
/**
|
||||
* 查找是否存在子节点
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 数量
|
||||
*/
|
||||
int selectChildCountByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 数量
|
||||
*/
|
||||
int selectExistUserCount(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ids获取到部门
|
||||
*
|
||||
* @param deptIds 部门id列表
|
||||
* @return 部门集合对象
|
||||
*/
|
||||
List<Dept> selectByIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 影响条数
|
||||
*/
|
||||
int insert(Dept dept);
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 影响条数
|
||||
*/
|
||||
int update(Dept dept);
|
||||
|
||||
/**
|
||||
* 修改部门的状态;
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 影响条数
|
||||
*/
|
||||
int updateState(Dept dept);
|
||||
|
||||
/**
|
||||
* 批量修改子元素之前的关系
|
||||
*
|
||||
* @param depts 子元素
|
||||
* @return 结果
|
||||
*/
|
||||
int updateChildren(@Param("depts") List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 运行结构
|
||||
*/
|
||||
int delete(Long deptId);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.fateverse.admin.mapper;
|
||||
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,7 +11,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/11/4
|
||||
*/
|
||||
public interface RoleMapper {
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package cn.fateverse.admin.mapper;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.entity.UserBase;
|
||||
import cn.fateverse.admin.query.UserQuery;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,7 +14,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
public interface UserMapper {
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
@@ -32,10 +34,11 @@ public interface UserMapper {
|
||||
/**
|
||||
* 查询用户列表
|
||||
*
|
||||
* @param page 页面
|
||||
* @param query 用户查询信息
|
||||
* @return 用户信息
|
||||
*/
|
||||
List<UserVo> selectList(UserQuery query);
|
||||
IPage<UserVo> selectPage(@Param("page") IPage<User> page, @Param("query") UserQuery query);
|
||||
|
||||
/**
|
||||
* 排除角色id
|
||||
@@ -88,7 +91,7 @@ public interface UserMapper {
|
||||
* @param deptIds 部门id列表
|
||||
* @return 用户信息
|
||||
*/
|
||||
List<UserVo> selectUserByDeptIds(List<Long> deptIds);
|
||||
List<UserVo> selectByDeptIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 根据岗位id查询用户信息
|
||||
@@ -104,7 +107,7 @@ public interface UserMapper {
|
||||
* @param userId 用户id
|
||||
* @return 用户信息
|
||||
*/
|
||||
User selectUserByUserId(Long userId);
|
||||
UserDetail selectUserByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 校验用户是否唯一
|
||||
@@ -136,7 +139,7 @@ public interface UserMapper {
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(UserBase user);
|
||||
int insert(User user);
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
@@ -144,7 +147,7 @@ public interface UserMapper {
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
int update(UserBase user);
|
||||
int update(User user);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.fateverse.admin.mapper;
|
||||
|
||||
import cn.fateverse.admin.entity.UserPost;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -9,7 +10,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/11/26
|
||||
*/
|
||||
public interface UserPostMapper {
|
||||
public interface UserPostMapper extends BaseMapper<UserPost> {
|
||||
/**
|
||||
* 批量新增用户角色映射关系
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.fateverse.admin.mapper;
|
||||
|
||||
|
||||
import cn.fateverse.admin.entity.UserRole;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,7 +12,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/11/6
|
||||
*/
|
||||
public interface UserRoleMapper {
|
||||
public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||
|
||||
/**
|
||||
* 批量新增用户角色映射关系
|
||||
@@ -54,4 +56,11 @@ public interface UserRoleMapper {
|
||||
*/
|
||||
int bind(@Param("userIds") List<Long> userIds, @Param("roleId") Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户id选择角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return {@link List }<{@link Role }>
|
||||
*/
|
||||
List<Role> selectRoleByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.fateverse.admin.service;
|
||||
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import cn.fateverse.admin.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.OptionTree;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,24 +9,16 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/11/2
|
||||
*/
|
||||
public interface DeptService {
|
||||
public interface DeptService extends IService<Dept> {
|
||||
|
||||
/**
|
||||
* 查询部门树形结构数据
|
||||
*
|
||||
* @param deptName 部门名称
|
||||
* @param state 部门状态
|
||||
* @param state 部门状态
|
||||
* @return 部门集合
|
||||
*/
|
||||
List<DeptVo> searchTree(String deptName, Integer state);
|
||||
|
||||
/**
|
||||
* 部门id查询部门信息
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 返回对象
|
||||
*/
|
||||
DeptVo searchById(Long deptId);
|
||||
List<Dept> list(String deptName, Integer state);
|
||||
|
||||
/**
|
||||
* 获取排除自身的部门树形结构
|
||||
@@ -35,14 +26,7 @@ public interface DeptService {
|
||||
* @param deptId 部门id
|
||||
* @return 部门树形选择对象
|
||||
*/
|
||||
List<OptionTree> searchExcludeTree(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取部门选择的树形结构
|
||||
*
|
||||
* @return 部门树形选择对象
|
||||
*/
|
||||
List<OptionTree> searchTreeOption();
|
||||
List<Dept> searchExcludeTree(Long deptId);
|
||||
|
||||
/**
|
||||
* 通过ids获取到部门数据
|
||||
@@ -50,15 +34,14 @@ public interface DeptService {
|
||||
* @param deptIds 部门id列表
|
||||
* @return 部门集合对象
|
||||
*/
|
||||
List<DeptVo> searchByIds(List<Long> deptIds);
|
||||
List<Dept> searchByIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 校验部门名称是否唯一
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 结果
|
||||
*/
|
||||
String checkNameUnique(Dept dept);
|
||||
void checkNameUnique(Dept dept);
|
||||
|
||||
/**
|
||||
* 是否存在部门子节点
|
||||
@@ -69,34 +52,19 @@ public interface DeptService {
|
||||
boolean hasChildById(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询部门是否存在用户
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 结果 true 存在 false 不存在
|
||||
*/
|
||||
boolean checkExistUser(Long deptId);
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 影响条数
|
||||
*/
|
||||
int save(Dept dept);
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*
|
||||
* @param dept 部门对象
|
||||
* @return 影响条数
|
||||
*/
|
||||
int edit(Dept dept);
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* 按id选择子代
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return 影响条数
|
||||
* @return {@link List }<{@link Dept }>
|
||||
*/
|
||||
int remove(Long deptId);
|
||||
List<Dept> selectChildrenById(Long deptId);
|
||||
|
||||
/**
|
||||
* 按部门父级id选择列表
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return {@link List }<{@link Dept }>
|
||||
*/
|
||||
List<Dept> selectListByDeptParentId(Long deptId);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import cn.fateverse.admin.dto.RoleDto;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,7 +15,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/11/4
|
||||
*/
|
||||
public interface RoleService {
|
||||
public interface RoleService extends IService<Role> {
|
||||
|
||||
/**
|
||||
* 查询角色列表
|
||||
@@ -20,7 +23,7 @@ public interface RoleService {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<RoleVo> searchList(RoleQuery query);
|
||||
IPage<Role> searchList(RoleQuery query);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.fateverse.admin.service;
|
||||
|
||||
import cn.fateverse.admin.entity.UserPost;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface UserPostService extends IService<UserPost> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.fateverse.admin.service;
|
||||
|
||||
import cn.fateverse.admin.entity.UserRole;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRoleService extends IService<UserRole> {
|
||||
|
||||
List<Role> selectRoleByUserId(Long userId);
|
||||
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package cn.fateverse.admin.service;
|
||||
|
||||
import cn.fateverse.admin.dto.UserDto;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.query.UserQuery;
|
||||
import cn.fateverse.admin.vo.UserChooseVo;
|
||||
import cn.fateverse.admin.vo.UserDetailVo;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +17,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
public interface UserService {
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
@@ -31,7 +34,7 @@ public interface UserService {
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象
|
||||
*/
|
||||
User searchUserInfoByUserId(Long userId);
|
||||
UserDetail searchUserInfoByUserId(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,7 +43,7 @@ public interface UserService {
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
List<UserVo> searchList(UserQuery user);
|
||||
IPage<UserVo> searchList(UserQuery user);
|
||||
|
||||
/**
|
||||
* 根据角色或者是部门获取到用户信息
|
||||
@@ -91,14 +94,14 @@ public interface UserService {
|
||||
*
|
||||
* @param user@return
|
||||
*/
|
||||
boolean checkUserNameUnique(UserDto user);
|
||||
boolean checkUserNameUnique(User user);
|
||||
|
||||
/**
|
||||
* 校验手机号是否唯一
|
||||
*
|
||||
* @param user@return
|
||||
*/
|
||||
boolean checkPhoneNumberUnique(UserDto user);
|
||||
boolean checkPhoneNumberUnique(User user);
|
||||
|
||||
/**
|
||||
* 校验邮箱是否唯一
|
||||
@@ -263,4 +266,30 @@ public interface UserService {
|
||||
* @return
|
||||
*/
|
||||
List<Long> searchAllUserIds();
|
||||
|
||||
/**
|
||||
* 检查现有用户
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return boolean
|
||||
*/
|
||||
boolean checkExistUser(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据角色id选择用户列表
|
||||
*
|
||||
* @param roleId
|
||||
* @param userName 用户名
|
||||
* @param phoneNumber 电话号码
|
||||
* @return {@link List }<{@link UserVo }>
|
||||
*/
|
||||
List<UserVo> selectUserListByRoleId(Long roleId, String userName, String phoneNumber);
|
||||
|
||||
/**
|
||||
* 按部门id选择
|
||||
*
|
||||
* @param deptIds 部门id
|
||||
* @return {@link List }<{@link UserVo }>
|
||||
*/
|
||||
List<UserVo> selectByDeptIds(List<Long> deptIds);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.dto.ConfigDto;
|
||||
import cn.fateverse.admin.query.ConfigQuery;
|
||||
import cn.fateverse.admin.vo.ConfigVo;
|
||||
import cn.fateverse.admin.entity.Config;
|
||||
import cn.fateverse.admin.mapper.ConfigMapper;
|
||||
import cn.fateverse.admin.query.ConfigQuery;
|
||||
import cn.fateverse.admin.service.ConfigService;
|
||||
import cn.fateverse.admin.vo.ConfigVo;
|
||||
import cn.fateverse.common.core.entity.PageInfo;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.core.utils.TableSupport;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,7 +48,7 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
PageUtils.startPage();
|
||||
List<Config> list = configMapper.selectList(query);
|
||||
log.info("query time :{}", (System.currentTimeMillis() - startTime));
|
||||
return PageUtils.convertDataTable(list, ConfigVo::toConfigVo);
|
||||
return PageConditionUtil.convertDataTable(list, ConfigVo::toConfigVo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.vo.DeptVo;
|
||||
import cn.fateverse.admin.mapper.DeptMapper;
|
||||
import cn.fateverse.admin.service.DeptService;
|
||||
import cn.fateverse.common.core.constant.UserConstants;
|
||||
import cn.fateverse.admin.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.OptionTree;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import cn.fateverse.common.core.utils.AssertUtil;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.core.utils.convert.TreeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
@@ -25,157 +20,66 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept>
|
||||
implements DeptService {
|
||||
|
||||
|
||||
private final DeptMapper deptMapper;
|
||||
|
||||
public DeptServiceImpl(DeptMapper deptMapper) {
|
||||
this.deptMapper = deptMapper;
|
||||
@Override
|
||||
public List<Dept> list(String deptName, Integer state) {
|
||||
return this.lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(deptName), Dept::getDeptName, deptName)
|
||||
.like(ObjectUtil.isNotNull(state), Dept::getState, state)
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptVo> searchTree(String deptName, Integer state) {
|
||||
List<Dept> deptList = deptMapper.selectList(deptName, state);
|
||||
return TreeUtil.build(deptList, DeptVo.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setExclude("phone");
|
||||
});
|
||||
public List<Dept> searchExcludeTree(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.ne(Dept::getDeptId, deptId)
|
||||
.ne(Dept::getParentId, deptId)
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Dept> searchByIds(List<Long> deptIds) {
|
||||
return this.lambdaQuery()
|
||||
.in(Dept::getDeptId, deptIds)
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptVo searchById(Long deptId) {
|
||||
Dept dept = deptMapper.selectById(deptId);
|
||||
DeptVo deptVo = new DeptVo();
|
||||
BeanUtils.copyProperties(dept, deptVo);
|
||||
return deptVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionTree> searchExcludeTree(Long deptId) {
|
||||
Dept dept = deptMapper.selectById(deptId);
|
||||
if (0L == dept.getParentId()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Dept> deptList = deptMapper.selectExclude(deptId);
|
||||
return TreeUtil.build(deptList, OptionTree.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setOption("deptId", "deptName");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionTree> searchTreeOption() {
|
||||
List<Dept> deptList = deptMapper.selectList(null, null);
|
||||
return TreeUtil.build(deptList, OptionTree.class, (config) -> {
|
||||
config.setIdField("deptId");
|
||||
config.setOption("deptId", "deptName");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptVo> searchByIds(List<Long> deptIds) {
|
||||
List<Dept> deptList = deptMapper.selectByIds(deptIds);
|
||||
return deptList.stream().map(dept ->
|
||||
DeptVo.builder()
|
||||
.deptId(dept.getDeptId())
|
||||
.parentId(dept.getParentId())
|
||||
.deptName(dept.getDeptName())
|
||||
.email(dept.getEmail())
|
||||
.orderNum(dept.getOrderNum())
|
||||
.leader(dept.getLeader())
|
||||
.leaderId(dept.getLeaderId())
|
||||
.phone(dept.getPhone())
|
||||
.state(dept.getState())
|
||||
.createTime(dept.getCreateTime())
|
||||
.build()
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkNameUnique(Dept dept) {
|
||||
public void checkNameUnique(Dept dept) {
|
||||
Long deptId = LongUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||
Dept info = deptMapper.selectByDeptNameAndParentId(dept.getDeptName(), deptId);
|
||||
if (!ObjectUtils.isEmpty(info) && !info.getDeptId().equals(deptId)) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
Dept info = this.lambdaQuery()
|
||||
.eq(Dept::getDeptName, dept.getDeptName())
|
||||
.eq(Dept::getParentId, deptId)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
AssertUtil.isTrue(ObjectUtil.isNotNull(info) && !dept.getDeptId().equals(info.getDeptId()), "新增部门: {}'失败,部门名称以存在!", dept.getDeptName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildById(Long deptId) {
|
||||
return deptMapper.selectChildCountByDeptId(deptId) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkExistUser(Long deptId) {
|
||||
return deptMapper.selectExistUserCount(deptId) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int save(Dept dept) {
|
||||
Set<String> deptNameSet = deptMapper.selectDeptNameListByParentId(dept.getParentId());
|
||||
Dept info = deptMapper.selectById(dept.getParentId());
|
||||
if (deptNameSet.contains(dept.getDeptName())) {
|
||||
throw new CustomException(info.getDeptName() + "下已经存在" + dept.getDeptName() + "部门");
|
||||
}
|
||||
if (UserConstants.DEPT_DISABLE.equals(info.getState())) {
|
||||
throw new CustomException("上级部门停用,不允许添加");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + info.getDeptId());
|
||||
return deptMapper.insert(dept);
|
||||
return this.lambdaQuery()
|
||||
.eq(Dept::getParentId, deptId)
|
||||
.eq(Dept::getDelFlag, 0)
|
||||
.exists();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int edit(Dept dept) {
|
||||
Dept newParentDept = deptMapper.selectById(dept.getParentId());
|
||||
Dept oldDept = deptMapper.selectById(dept.getDeptId());
|
||||
if (null != newParentDept && null != oldDept) {
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
if (null != newParentDept && UserConstants.DEPT_DISABLE.equals(newParentDept.getState())) {
|
||||
updateParentDept(dept);
|
||||
}
|
||||
return deptMapper.update(dept);
|
||||
public List<Dept> selectChildrenById(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(Dept::getParentId, deptId)
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int remove(Long deptId) {
|
||||
return deptMapper.delete(deptId);
|
||||
public List<Dept> selectListByDeptParentId(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(Dept::getParentId, deptId)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新父级部门的状态
|
||||
*
|
||||
* @param dept
|
||||
*/
|
||||
public void updateParentDept(Dept dept) {
|
||||
dept = deptMapper.selectById(dept.getDeptId());
|
||||
deptMapper.updateState(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新字元素的ancestors
|
||||
*
|
||||
* @param deptId
|
||||
* @param newAncestors
|
||||
* @param odlAncestors
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String newAncestors, String odlAncestors) {
|
||||
List<Dept> children = deptMapper.selectChildrenById(deptId);
|
||||
List<Dept> newChildren = children.stream().peek(child -> {
|
||||
child.setAncestors(child.getAncestors().replace(odlAncestors, newAncestors));
|
||||
}).collect(Collectors.toList());
|
||||
if (newChildren.size() > 0) {
|
||||
deptMapper.updateChildren(newChildren);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
public List<RouterVo> searchRouterByUserId(Long userId) {
|
||||
List<Menu> menuList = null;
|
||||
if (User.isAdmin(userId)) {
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectRouterMenuList();
|
||||
} else {
|
||||
menuList = menuMapper.selectRouterMenuListByUserId(userId);
|
||||
@@ -78,11 +78,11 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
public List<MenuSimpVo> searchTree(String menuName, String state) {
|
||||
List<Menu> menuList = null;
|
||||
User user = Objects.requireNonNull(SecurityUtils.getLoginUser()).getUser();
|
||||
if (User.isAdmin(user.getUserId())) {
|
||||
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectList(menuName, state, null, false);
|
||||
} else {
|
||||
menuList = menuMapper.selectListByUserId(user.getUserId(), menuName, state, null, false);
|
||||
menuList = menuMapper.selectListByUserId(userId, menuName, state, null, false);
|
||||
}
|
||||
return TreeUtil.build(menuList, MenuSimpVo.class, (config) -> {
|
||||
config.setIdField("menuId");
|
||||
@@ -101,12 +101,12 @@ public class MenuServiceImpl implements MenuService {
|
||||
|
||||
@Override
|
||||
public List<OptionTree> searchTreeOption(Long excludeId) {
|
||||
User user = Objects.requireNonNull(SecurityUtils.getLoginUser()).getUser();
|
||||
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
|
||||
List<Menu> menuList = null;
|
||||
if (User.isAdmin(user.getUserId())) {
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectList(null, null, excludeId, true);
|
||||
} else {
|
||||
menuList = menuMapper.selectListByUserId(user.getUserId(), null, null, excludeId, true);
|
||||
menuList = menuMapper.selectListByUserId(userId, null, null, excludeId, true);
|
||||
}
|
||||
return TreeUtil.build(menuList, OptionTree.class, (config) -> {
|
||||
config.setIdField("menuId");
|
||||
@@ -121,12 +121,12 @@ public class MenuServiceImpl implements MenuService {
|
||||
if (null == roleId || roleId.equals(0L)) {
|
||||
checkedSet = menuMapper.selectCheckedMenuIdByRoleId(roleId);
|
||||
}
|
||||
User user = Objects.requireNonNull(SecurityUtils.getLoginUser()).getUser();
|
||||
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
|
||||
List<Menu> menuList = null;
|
||||
if (User.isAdmin(user.getUserId())) {
|
||||
if (SecurityUtils.isAdmin(userId)) {
|
||||
menuList = menuMapper.selectList(null, null, null, true);
|
||||
} else {
|
||||
menuList = menuMapper.selectListByUserId(user.getUserId(), null, null, null, true);
|
||||
menuList = menuMapper.selectListByUserId(userId, null, null, null, true);
|
||||
}
|
||||
return OptionMenuVo.builder()
|
||||
.checked(checkedSet)
|
||||
|
||||
@@ -8,7 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.admin.entity.OnlineUser;
|
||||
import cn.fateverse.admin.service.OnlineUserService;
|
||||
import cn.fateverse.common.core.constant.CacheConstants;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.dto.RoleDto;
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.admin.entity.RoleMenu;
|
||||
import cn.fateverse.admin.mapper.MenuMapper;
|
||||
import cn.fateverse.admin.mapper.RoleMapper;
|
||||
import cn.fateverse.admin.mapper.RoleMenuMapper;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.service.RoleService;
|
||||
import cn.fateverse.admin.vo.RoleVo;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.core.utils.StateUtils;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@@ -32,7 +34,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
|
||||
implements RoleService {
|
||||
|
||||
private final RoleMapper roleMapper;
|
||||
|
||||
@@ -47,25 +50,31 @@ public class RoleServiceImpl implements RoleService {
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo<RoleVo> searchList(RoleQuery query) {
|
||||
PageUtils.startPage();
|
||||
List<Role> list = roleMapper.selectList(query);
|
||||
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
|
||||
public IPage<Role> searchList(RoleQuery query) {
|
||||
IPage<Role> page = PageConditionUtil.getPage();
|
||||
return this.lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(query.getRoleName()), Role::getRoleName, query.getRoleName())
|
||||
.like(StrUtil.isNotBlank(query.getRoleKey()), Role::getRoleKey, query.getRoleKey())
|
||||
.eq(ObjectUtil.isNotNull(query.getState()), Role::getState, query.getState())
|
||||
.between(ObjectUtil.isNotNull(query.getStartTime()) && ObjectUtil.isNotNull(query.getEndTime()),
|
||||
Role::getCreateTime, query.getStartTime(), query.getEndTime())
|
||||
.page(page);
|
||||
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo<RoleVo> searchListByMenuId(Long menuId, String roleName, String roleKey) {
|
||||
PageUtils.startPage();
|
||||
PageConditionUtil.startPage();
|
||||
List<Role> list = roleMapper.selectListByMenuId(menuId, roleName, roleKey);
|
||||
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
|
||||
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<RoleVo> searchListExcludeMenuId(Long menuId, String roleName, String roleKey) {
|
||||
PageUtils.startPage();
|
||||
List<Role> list = roleMapper.searchListExcludeMenuId(menuId,roleName,roleKey);
|
||||
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
|
||||
PageConditionUtil.startPage();
|
||||
List<Role> list = roleMapper.searchListExcludeMenuId(menuId, roleName, roleKey);
|
||||
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +165,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
public int bindMenu(Long menuId, List<Long> roleIds) {
|
||||
List<RoleMenu> roleMenuList = roleIds.stream().filter(LongUtils::isNotNull).map(roleId -> RoleMenu.builder().roleId(roleId)
|
||||
.menuId(menuId).build()).collect(Collectors.toList());
|
||||
if (roleMenuList.isEmpty()){
|
||||
if (roleMenuList.isEmpty()) {
|
||||
throw new CustomException("角色id不能为空");
|
||||
}
|
||||
return roleMenuMapper.batch(roleMenuList);
|
||||
@@ -175,7 +184,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
}
|
||||
|
||||
public void checkRoleAllowed(Role role) {
|
||||
if (!ObjectUtils.isEmpty(role.getRoleId()) && role.isAdmin()) {
|
||||
if (!ObjectUtils.isEmpty(role.getRoleId()) && SecurityUtils.isAdmin(role.getRoleId())) {
|
||||
throw new CustomException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.entity.UserPost;
|
||||
import cn.fateverse.admin.mapper.UserPostMapper;
|
||||
import cn.fateverse.admin.service.UserPostService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserPostServiceImpl extends ServiceImpl<UserPostMapper, UserPost>
|
||||
implements UserPostService {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.entity.UserRole;
|
||||
import cn.fateverse.admin.mapper.UserRoleMapper;
|
||||
import cn.fateverse.admin.service.UserRoleService;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole>
|
||||
implements UserRoleService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Role> selectRoleByUserId(Long userId) {
|
||||
return baseMapper.selectRoleByUserId(userId);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,28 @@
|
||||
package cn.fateverse.admin.service.impl;
|
||||
|
||||
import cn.fateverse.admin.dto.UserDto;
|
||||
import cn.fateverse.admin.entity.*;
|
||||
import cn.fateverse.admin.entity.UserPost;
|
||||
import cn.fateverse.admin.entity.UserRole;
|
||||
import cn.fateverse.admin.mapper.*;
|
||||
import cn.fateverse.admin.query.RoleQuery;
|
||||
import cn.fateverse.admin.query.UserQuery;
|
||||
import cn.fateverse.admin.service.UserService;
|
||||
import cn.fateverse.admin.vo.UserChooseVo;
|
||||
import cn.fateverse.admin.vo.UserDetailVo;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.service.UserService;
|
||||
import cn.fateverse.common.core.entity.Dept;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -33,7 +39,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
implements UserService {
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
@@ -58,17 +65,21 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public User searchByUserName(String username) {
|
||||
return userMapper.selectByUserName(username);
|
||||
return this.lambdaQuery()
|
||||
.eq(User::getUserName, username)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public User searchUserInfoByUserId(Long userId) {
|
||||
public UserDetail searchUserInfoByUserId(Long userId) {
|
||||
return userMapper.selectUserByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVo> searchList(UserQuery user) {
|
||||
return userMapper.selectList(user);
|
||||
public IPage<UserVo> searchList(UserQuery user) {
|
||||
IPage<User> page = PageConditionUtil.getPage();
|
||||
return userMapper.selectPage(page, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,39 +113,45 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public List<UserVo> searchByDeptIds(List<Long> deptIds) {
|
||||
return userMapper.selectUserByDeptIds(deptIds);
|
||||
return userMapper.selectByDeptIds(deptIds);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetailVo searchByUserId(Long userId) {
|
||||
User user = userMapper.selectUserByUserId(userId);
|
||||
List<Long> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
user.setDept(null);
|
||||
user.setRoles(null);
|
||||
user.setPassword(null);
|
||||
UserDetail userDetail = userMapper.selectUserByUserId(userId);
|
||||
List<Long> roleIds = userDetail.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
|
||||
userDetail.setDept(null);
|
||||
userDetail.setRoles(null);
|
||||
userDetail.setPassword(null);
|
||||
List<Long> postIds = userPostMapper.selectPostIdListByUserId(userId);
|
||||
return UserDetailVo.builder()
|
||||
.user(user)
|
||||
.user(userDetail)
|
||||
.postIds(postIds)
|
||||
.roleIds(roleIds)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkUserNameUnique(UserDto user) {
|
||||
public boolean checkUserNameUnique(User user) {
|
||||
Long userId = getUserId(user);
|
||||
User info = userMapper.selectUserInfoByUserName(user.getUserName());
|
||||
User info = this.lambdaQuery()
|
||||
.eq(User::getUserName, user.getUserName())
|
||||
.last("limit 1")
|
||||
.one();
|
||||
return checkUser(info, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPhoneNumberUnique(UserDto user) {
|
||||
public boolean checkPhoneNumberUnique(User user) {
|
||||
if (StrUtil.isEmpty(user.getPhoneNumber())) {
|
||||
return false;
|
||||
}
|
||||
Long userId = getUserId(user);
|
||||
User info = userMapper.selectUserInfoByUserName(user.getPhoneNumber());
|
||||
User info = this.lambdaQuery()
|
||||
.eq(User::getPhoneNumber, user.getPhoneNumber())
|
||||
.last("limit 1")
|
||||
.one();
|
||||
return checkUser(info, userId);
|
||||
}
|
||||
|
||||
@@ -144,7 +161,7 @@ public class UserServiceImpl implements UserService {
|
||||
return false;
|
||||
}
|
||||
Long userId = getUserId(user);
|
||||
User info = userMapper.selectByEmail(user.getEmail());
|
||||
UserDetail info = userMapper.selectByEmail(user.getEmail());
|
||||
return checkUser(info, userId);
|
||||
}
|
||||
|
||||
@@ -155,14 +172,13 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public TableDataInfo<UserVo> searchUserListByExcludeRoleId(Long roleId, String userName, String phoneNumber) {
|
||||
PageUtils.startPage();
|
||||
PageConditionUtil.startPage();
|
||||
List<UserVo> list = userMapper.selectUserListByExcludeRoleId(roleId, userName, phoneNumber);
|
||||
Long total = PageUtils.getTotal(list);
|
||||
return PageUtils.convertDataTable(list, total);
|
||||
Long total = PageConditionUtil.getTotal(list);
|
||||
return PageConditionUtil.convertDataTable(list, total);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindRole(List<Long> userIds, Long roleId) {
|
||||
@@ -193,10 +209,10 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public TableDataInfo<UserVo> searchUserListByExcludePostId(Long postId, String userName, String phoneNumber) {
|
||||
PageUtils.startPage();
|
||||
PageConditionUtil.startPage();
|
||||
List<UserVo> list = userMapper.selectUserListByExcludePostId(postId, userName, phoneNumber);
|
||||
Long total = PageUtils.getTotal(list);
|
||||
return PageUtils.convertDataTable(list, total);
|
||||
Long total = PageConditionUtil.getTotal(list);
|
||||
return PageConditionUtil.convertDataTable(list, total);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +248,7 @@ public class UserServiceImpl implements UserService {
|
||||
private List<UserChooseVo> chooseDept(Long deptId) {
|
||||
List<Dept> deptList = deptMapper.selectListByDeptParentId(deptId);
|
||||
List<UserChooseVo> result = deptList.stream().map(dept -> UserChooseVo.toUserChooseByDept(dept, deptId)).collect(Collectors.toList());
|
||||
List<UserVo> userList = userMapper.selectUserByDeptIds(Collections.singletonList(deptId));
|
||||
List<UserVo> userList = userMapper.selectByDeptIds(Collections.singletonList(deptId));
|
||||
userList.forEach(user -> result.add(UserChooseVo.toUserChooseByUser(user, deptId)));
|
||||
return result;
|
||||
}
|
||||
@@ -262,15 +278,15 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public TableDataInfo<UserVo> searchUserListByExcludeDeptId(Long deptId, String userName, String phoneNumber) {
|
||||
PageUtils.startPage();
|
||||
PageConditionUtil.startPage();
|
||||
Dept dept = deptMapper.selectById(deptId);
|
||||
if (null == dept) {
|
||||
throw new CustomException("当前部门不存在");
|
||||
}
|
||||
// dept.getAncestors()
|
||||
List<UserVo> list = userMapper.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
|
||||
Long total = PageUtils.getTotal(list);
|
||||
return PageUtils.convertDataTable(list, total);
|
||||
Long total = PageConditionUtil.getTotal(list);
|
||||
return PageConditionUtil.convertDataTable(list, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,7 +304,7 @@ public class UserServiceImpl implements UserService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int save(UserDto dto) {
|
||||
checkUser(dto);
|
||||
UserBase user = insertInitUser(dto);
|
||||
User user = insertInitUser(dto);
|
||||
int result = userMapper.insert(user);
|
||||
dto.setUserId(user.getUserId());
|
||||
batchUserRole(dto, Boolean.FALSE);
|
||||
@@ -306,7 +322,7 @@ public class UserServiceImpl implements UserService {
|
||||
batchUserRole(dto, Boolean.TRUE);
|
||||
batchUserPost(dto, Boolean.TRUE);
|
||||
dto.setPassword(null);
|
||||
UserBase user = dto.toUser();
|
||||
User user = dto.toUser();
|
||||
return userMapper.update(user);
|
||||
}
|
||||
|
||||
@@ -322,14 +338,28 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> searchAllUserIds() {
|
||||
return userMapper.selectAllUserIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkExistUser(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(User::getDeptId, deptId)
|
||||
.exists();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserVo> selectUserListByRoleId(Long roleId, String userName, String phoneNumber) {
|
||||
return baseMapper.selectUserListByRoleId(roleId, userName, phoneNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVo> selectByDeptIds(List<Long> deptIds) {
|
||||
return baseMapper.selectByDeptIds(deptIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理用户与角色之间的对应关系
|
||||
@@ -374,8 +404,8 @@ public class UserServiceImpl implements UserService {
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
private UserBase insertInitUser(UserDto dto) {
|
||||
UserBase user = dto.toUser();
|
||||
private User insertInitUser(UserDto dto) {
|
||||
User user = dto.toUser();
|
||||
user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
|
||||
return user;
|
||||
}
|
||||
@@ -386,7 +416,7 @@ public class UserServiceImpl implements UserService {
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
private Long getUserId(UserDto user) {
|
||||
private Long getUserId(User user) {
|
||||
return LongUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,161 +23,10 @@
|
||||
from sys_dept
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
<if test="deptName != null and deptName != ''"> and dept_name like concat('%',#{deptName},'%')</if>
|
||||
<if test="state != null"> and `state` = #{state}</if>
|
||||
</where>
|
||||
order by parent_id, order_num
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="cn.fateverse.admin.entity.Dept">
|
||||
select d.dept_id,
|
||||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.leader_id,
|
||||
d.phone,
|
||||
d.email,
|
||||
d.state,
|
||||
d.del_flag,
|
||||
d.create_by,
|
||||
d.create_time,
|
||||
d.update_by,
|
||||
d.update_time
|
||||
from sys_dept d
|
||||
left join sys_dept p on p.dept_id = d.parent_id
|
||||
where d.dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="selectExclude" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
where dept_id != #{deptId} and parent_id != #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenById" parameterType="Long" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
where find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="selectByDeptNameAndParentId" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
where dept_name = #{deptName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectListByDeptParentId" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<select id="selectListByDeptParentId" resultType="cn.fateverse.common.core.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
where parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
<select id="selectChildCountByDeptId" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from sys_dept
|
||||
where parent_id = #{deptId}
|
||||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectExistUserCount" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from sys_user
|
||||
where dept_id = #{deptId}
|
||||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectDeptNameListByParentId" resultType="java.lang.String">
|
||||
select dept_name from sys_dept where parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="cn.fateverse.admin.entity.Dept">
|
||||
<include refid="selectSql"/>
|
||||
where dept_id in
|
||||
<foreach collection="list" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
insert into sys_dept
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name,</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||||
<if test="orderNum != null and orderNum != ''">order_num,</if>
|
||||
<if test="leader != null and leader != ''">leader,</if>
|
||||
<if test="leaderId != null ">leader_id,</if>
|
||||
<if test="phone != null and phone != ''">phone,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="state != null">state,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||||
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
|
||||
<if test="leader != null and leader != ''">#{leader},</if>
|
||||
<if test="leaderId != null ">#{leaderId},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="state != null">#{state},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update sys_dept
|
||||
<set>
|
||||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
||||
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="leader != null">leader = #{leader},</if>
|
||||
<if test="leaderId != null">leader_id = #{leaderId},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="state != null">state = #{state},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</set>
|
||||
where dept_id = #{deptId}
|
||||
</update>
|
||||
|
||||
<update id="updateChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.ancestors}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateState">
|
||||
update sys_dept
|
||||
<set>
|
||||
<if test="state != null and state != ''">state = #{state},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</set>
|
||||
where dept_id in (${ancestors})
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
delete
|
||||
from sys_dept
|
||||
where dept_id = #{deptId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
from sys_role
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectList" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
<if test="roleName != null and roleName != ''"> and role_name like concat('%',#{roleName} ,'%')</if>
|
||||
@@ -35,7 +35,7 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectById" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectById" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
where role_id = #{roleId}
|
||||
</select>
|
||||
@@ -46,16 +46,16 @@
|
||||
where r.role_id = #{roleId}
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectByRoleName" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectByRoleName" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
where role_name = #{roleName} limit 0,1
|
||||
</select>
|
||||
<select id="selectByRoleKey" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectByRoleKey" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
where role_key = #{roleKey} limit 0,1
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectByIds" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
where role_id in
|
||||
<foreach collection="list" open="(" separator="," close=")" item="roleId">
|
||||
@@ -63,7 +63,7 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectListByMenuId" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="selectListByMenuId" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
<if test="roleName != null and roleName != ''">and role_name like concat('%',#{roleName} ,'%')</if>
|
||||
@@ -72,7 +72,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="searchListExcludeMenuId" resultType="cn.fateverse.admin.entity.Role">
|
||||
<select id="searchListExcludeMenuId" resultType="cn.fateverse.common.core.entity.Role">
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
<if test="roleName != null and roleName != ''">and role_name like concat('%',#{roleName} ,'%')</if>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.fateverse.admin.mapper.UserMapper">
|
||||
|
||||
<resultMap type="cn.fateverse.admin.entity.User" id="UserResult">
|
||||
<resultMap type="cn.fateverse.common.core.entity.UserDetail" id="UserResult">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
@@ -26,11 +26,11 @@
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="openId" column="open_id"/>
|
||||
<result property="unionId" column="union_id"/>
|
||||
<association property="dept" column="dept_id" javaType="cn.fateverse.admin.entity.Dept" resultMap="deptResult"/>
|
||||
<association property="dept" column="dept_id" javaType="cn.fateverse.common.core.entity.Dept" resultMap="deptResult"/>
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="deptResult" type="cn.fateverse.admin.entity.Dept">
|
||||
<resultMap id="deptResult" type="cn.fateverse.common.core.entity.Dept">
|
||||
<id property="deptId" column="dept_id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
@@ -41,7 +41,7 @@
|
||||
<result property="state" column="dept_state"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RoleResult" type="cn.fateverse.admin.entity.Role">
|
||||
<resultMap id="RoleResult" type="cn.fateverse.common.core.entity.Role">
|
||||
<id property="roleId" column="role_id"/>
|
||||
<result property="roleName" column="role_name"/>
|
||||
<result property="roleKey" column="role_key"/>
|
||||
@@ -135,21 +135,21 @@
|
||||
where u.user_name = #{userName} limit 0,1
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultType="cn.fateverse.admin.vo.UserVo">
|
||||
<select id="selectPage" resultType="cn.fateverse.admin.vo.UserVo">
|
||||
<include refid="selectUserVo"/>
|
||||
<where>
|
||||
u.del_flag = '0'
|
||||
<if test="userName != null and userName != ''">and u.user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="phoneNumber != null and phoneNumber != ''">and u.phone_number like
|
||||
concat('%',#{phoneNumber},'%')
|
||||
<if test="query.userName != null and query.userName != ''">and u.user_name like concat('%', #{query.userName}, '%')</if>
|
||||
<if test="query.phoneNumber != null and query.phoneNumber != ''">and u.phone_number like
|
||||
concat('%',#{query.phoneNumber},'%')
|
||||
</if>
|
||||
<if test="state != null and state != ''">and u.state = #{state}</if>
|
||||
<if test="startTime != null and endTime != null">
|
||||
and u.create_time between #{startTime} and #{endTime}
|
||||
<if test="query.state != null">and u.state = #{query.state}</if>
|
||||
<if test="query.startTime != null and query.endTime != null">
|
||||
and u.create_time between #{query.startTime} and #{query.endTime}
|
||||
</if>
|
||||
<if test="deptId != null">
|
||||
and (u.dept_id = #{deptId} or u.dept_id in ( select t.dept_id from sys_dept t where
|
||||
find_in_set(#{deptId}, ancestors) ))
|
||||
<if test="query.deptId != null">
|
||||
and (u.dept_id = #{query.deptId} or u.dept_id in ( select t.dept_id from sys_dept t where
|
||||
find_in_set(#{query.deptId}, ancestors) ))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
@@ -218,17 +218,17 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectUserInfoByUserName" resultType="cn.fateverse.admin.entity.User">
|
||||
<select id="selectUserInfoByUserName" resultType="cn.fateverse.common.core.entity.UserDetail">
|
||||
<include refid="selectUser"/>
|
||||
where user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="selectByPhoneNum" resultType="cn.fateverse.admin.entity.User">
|
||||
<select id="selectByPhoneNum" resultType="cn.fateverse.common.core.entity.UserDetail">
|
||||
<include refid="selectUser"/>
|
||||
where phone_number = #{phoneNumber}
|
||||
</select>
|
||||
|
||||
<select id="selectByEmail" resultType="cn.fateverse.admin.entity.User">
|
||||
<select id="selectByEmail" resultType="cn.fateverse.common.core.entity.UserDetail">
|
||||
<include refid="selectUser"/>
|
||||
where email = #{email} limit 0,1
|
||||
</select>
|
||||
@@ -243,7 +243,7 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByDeptIds" resultType="cn.fateverse.admin.vo.UserVo">
|
||||
<select id="selectByDeptIds" resultType="cn.fateverse.admin.vo.UserVo">
|
||||
select distinct u.user_id,u.user_name,u.nick_name,u.phone_number,u.state,u.create_time,
|
||||
d.dept_name,u.user_type,u.sex,u.avatar,d.dept_id as leaderDeptId
|
||||
from sys_user u
|
||||
@@ -260,7 +260,7 @@
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insert" parameterType="cn.fateverse.admin.entity.UserBase" useGeneratedKeys="true" keyProperty="userId"
|
||||
<insert id="insert" parameterType="cn.fateverse.common.core.entity.User" useGeneratedKeys="true" keyProperty="userId"
|
||||
keyColumn="user_id">
|
||||
insert into sys_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
@@ -32,4 +32,22 @@
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectRoleByUserId" resultType="cn.fateverse.common.core.entity.Role">
|
||||
select r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.`state`,
|
||||
r.del_flag,
|
||||
r.create_by,
|
||||
r.create_time,
|
||||
r.update_by,
|
||||
r.update_time,
|
||||
r.remark,
|
||||
r.role_type
|
||||
from sys_role r
|
||||
left join sys_user_role ur on r.role_id = ur.role_id
|
||||
where ur.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -125,9 +125,9 @@ logging.resolver=${SW_LOGGING_RESOLVER:PATTERN}
|
||||
# * %level means log level.
|
||||
# * %timestamp means now of time with format yyyy-MM-dd HH:mm:ss:SSS.
|
||||
# * %thread means name of current thread.
|
||||
# * %msg means some message which user logged.
|
||||
# * %msg means some message which userDetail logged.
|
||||
# * %class means SimpleName of TargetClass.
|
||||
# * %throwable means a throwable which user called.
|
||||
# * %throwable means a throwable which userDetail called.
|
||||
# * %agent_name means agent.service_name. Only apply to the PatternLogger.
|
||||
logging.pattern=${SW_LOGGING_PATTERN:%level %timestamp %thread %class : %msg %throwable}
|
||||
# Logging max_file_size, default: 300 * 1024 * 1024 = 314572800
|
||||
@@ -155,7 +155,7 @@ jvm.buffer_size=${SW_JVM_BUFFER_SIZE:600}
|
||||
buffer.channel_size=${SW_BUFFER_CHANNEL_SIZE:5}
|
||||
# The buffer size.
|
||||
buffer.buffer_size=${SW_BUFFER_BUFFER_SIZE:300}
|
||||
# If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile.
|
||||
# If true, skywalking agent will enable profile when userDetail create a new profile task. Otherwise disable profile.
|
||||
profile.active=${SW_AGENT_PROFILE_ACTIVE:true}
|
||||
# Parallel monitor segment count
|
||||
profile.max_parallel=${SW_AGENT_PROFILE_MAX_PARALLEL:5}
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-file</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
package cn.fateverse.auth.service;
|
||||
|
||||
import cn.fateverse.admin.dubbo.DubboUserService;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.core.enums.UserState;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2022/10/27
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@DubboReference
|
||||
private DubboUserService userService;
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
//todo 编辑用户登录相关逻辑
|
||||
log.info("有用户登录:{}",username);
|
||||
User user = userService.getUserByUsername(username);
|
||||
log.info("有用户登录:{}", username);
|
||||
UserDetail user = userService.getUserDetailsByUserName(username);
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package cn.fateverse.auth.service.impl;
|
||||
|
||||
import cn.fateverse.auth.entity.UserInfo;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.fateverse.admin.dubbo.DubboMenuService;
|
||||
import cn.fateverse.admin.dubbo.DubboUserService;
|
||||
import cn.fateverse.admin.vo.RouterVo;
|
||||
import cn.fateverse.auth.entity.LoginBody;
|
||||
import cn.fateverse.auth.entity.UserInfo;
|
||||
import cn.fateverse.auth.event.LoginInfoEvent;
|
||||
import cn.fateverse.auth.service.LoginService;
|
||||
import cn.fateverse.admin.entity.Role;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.auth.utils.LoginInfoUtil;
|
||||
import cn.fateverse.common.core.constant.CacheConstants;
|
||||
import cn.fateverse.common.core.constant.DateConstants;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.Role;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.exception.UserPasswordNotMatchException;
|
||||
import cn.fateverse.common.core.utils.SpringContextHolder;
|
||||
import cn.fateverse.common.core.utils.uuid.IdUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.fateverse.auth.event.LoginInfoEvent;
|
||||
import cn.fateverse.auth.utils.LoginInfoUtil;
|
||||
import cn.fateverse.log.entity.LoginInfo;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.redisson.api.RLock;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package cn.fateverse.auth.service.impl;
|
||||
|
||||
import cn.fateverse.admin.dubbo.DubboMenuService;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.UserDetail;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -27,9 +28,9 @@ public class PermissionService {
|
||||
* @param loginUser 登录用户
|
||||
*/
|
||||
public void getMenuPermission(LoginUser loginUser) {
|
||||
User user = loginUser.getUser();
|
||||
UserDetail user = loginUser.getUser();
|
||||
Set<String> perms = new HashSet<>();
|
||||
if (user.isAdmin()) {
|
||||
if (SecurityUtils.isAdmin(user.getUserId())) {
|
||||
perms.add("*:*:*");
|
||||
} else {
|
||||
Set<String> menuSet = menuService.selectMenuPermsByUserId(user.getUserId());
|
||||
|
||||
@@ -10,7 +10,7 @@ import ${packageName}.service.${ClassName}Service;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
#end
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageUtils;
|
||||
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
@@ -44,7 +44,9 @@ public class ConsoleCapture {
|
||||
|
||||
|
||||
public interface Task {
|
||||
|
||||
Object execute() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ public class JavaCodeEngine {
|
||||
// 设置安全检查器
|
||||
System.setSecurityManager(securityManager);
|
||||
// 执行方法并返回结果
|
||||
return ConsoleCapture.capture(() -> method.invoke(null, args));
|
||||
return new EngineResult(method.invoke(null, args), null);
|
||||
// return ConsoleCapture.capture(() -> method.invoke(null, args));
|
||||
} catch (CustomException e) {
|
||||
EngineResult result = new EngineResult();
|
||||
result.setSuccess(Boolean.FALSE);
|
||||
@@ -279,7 +280,7 @@ public class JavaCodeEngine {
|
||||
}
|
||||
|
||||
|
||||
public void remove(){
|
||||
public void remove() {
|
||||
clazz = null;
|
||||
classLoader = null;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.fateverse.common.code.console.ConsoleCapture;
|
||||
import cn.fateverse.common.code.lock.SegmentLock;
|
||||
import cn.fateverse.common.code.model.EngineResult;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.graalvm.polyglot.Context;
|
||||
import org.graalvm.polyglot.Value;
|
||||
|
||||
|
||||
@@ -60,12 +60,22 @@
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.fateverse.common.core.bo;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public abstract class BaseQueryBO {
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private DateIntervalBO createTimeInterval;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private DateIntervalBO updateTimeInterval;
|
||||
|
||||
/**
|
||||
* 创建用户名称
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 更新用户名称
|
||||
*/
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 获取创建时间间隔
|
||||
*
|
||||
* @return 基准日期间隔
|
||||
*/
|
||||
public DateIntervalBO getCreateTimeInterval() {
|
||||
return Optional.ofNullable(createTimeInterval).orElse(new DateIntervalBO());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取更新时间间隔
|
||||
*
|
||||
* @return 基准日期间隔
|
||||
*/
|
||||
public DateIntervalBO getUpdateTimeInterval() {
|
||||
return Optional.ofNullable(updateTimeInterval).orElse(new DateIntervalBO());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间 区间非空校验
|
||||
*
|
||||
* @return boolean true = 起止非空
|
||||
*/
|
||||
public boolean createTimeBetweenIsNotEmpty() {
|
||||
return Optional.ofNullable(createTimeInterval).map(item -> ObjectUtil.isAllNotEmpty(item.getStartTime(), item.getEndTime())).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间 区间非空校验
|
||||
*
|
||||
* @return boolean true = 起止非空
|
||||
*/
|
||||
public boolean updateTimeBetweenIsNotEmpty() {
|
||||
return Optional.ofNullable(updateTimeInterval).map(item -> ObjectUtil.isAllNotEmpty(item.getStartTime(), item.getEndTime())).orElse(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.fateverse.common.core.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 基准日期间隔
|
||||
*
|
||||
* @author ZhangQiang
|
||||
* @date 2024/09/26
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DateIntervalBO {
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.fateverse.common.core.constant;
|
||||
|
||||
public interface BaseConstant {
|
||||
|
||||
Long ZERO = 0L;
|
||||
}
|
||||
@@ -5,24 +5,24 @@ package cn.fateverse.common.core.constant;
|
||||
* @author Clay
|
||||
* @date 2022/11/9
|
||||
*/
|
||||
public class CacheConstants {
|
||||
public interface CacheConstants {
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
/**
|
||||
* 路由缓存地址
|
||||
*/
|
||||
public static final String ROUTE_CACHE_KEY = "router:key:";
|
||||
String ROUTE_CACHE_KEY = "router:key:";
|
||||
/**
|
||||
* 登录用户 redis key
|
||||
*/
|
||||
public static final String LOGIN_TOKEN_KEY = "login_info:";
|
||||
String LOGIN_TOKEN_KEY = "login_info:";
|
||||
/**
|
||||
* 字典类型 redis key
|
||||
*/
|
||||
public static final String DICT_KEY = "dict:";
|
||||
String DICT_KEY = "dict:";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,34 +5,34 @@ package cn.fateverse.common.core.constant;
|
||||
*
|
||||
* @author Clay
|
||||
*/
|
||||
public class Constants {
|
||||
public interface Constants {
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer ";
|
||||
String TOKEN_PREFIX = "Bearer ";
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
String HTTPS = "https://";
|
||||
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
String LOGIN_USER_KEY = "login_user_key";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final long CAPTCHA_EXPIRATION = 2;
|
||||
long CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
|
||||
public static final String UTF8 = "UTF-8";
|
||||
String UTF8 = "UTF-8";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@ package cn.fateverse.common.core.constant;
|
||||
* @author Clay
|
||||
* @date 2023-05-25
|
||||
*/
|
||||
public class DateConstants {
|
||||
public interface DateConstants {
|
||||
|
||||
public static String YYYY = "yyyy";
|
||||
String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,44 +5,44 @@ package cn.fateverse.common.core.constant;
|
||||
*
|
||||
* @author Clay
|
||||
*/
|
||||
public class UserConstants {
|
||||
public interface UserConstants {
|
||||
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
String SYS_USER = "SYS_USER";
|
||||
|
||||
/**
|
||||
* 匿名用户
|
||||
*/
|
||||
public static final String ANONYMOUS_USER = "anonymousUser";
|
||||
String ANONYMOUS_USER = "anonymousUser";
|
||||
|
||||
/**
|
||||
* 正常状态
|
||||
*/
|
||||
public static final String NORMAL = "0";
|
||||
String NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 异常状态
|
||||
*/
|
||||
public static final String EXCEPTION = "1";
|
||||
String EXCEPTION = "1";
|
||||
|
||||
|
||||
/**
|
||||
* 部门停用状态
|
||||
*/
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
String DEPT_DISABLE = "1";
|
||||
|
||||
|
||||
/**
|
||||
* Layout组件标识
|
||||
*/
|
||||
public final static String LAYOUT = "Layout";
|
||||
String LAYOUT = "Layout";
|
||||
|
||||
/**
|
||||
* 校验返回结果码
|
||||
*/
|
||||
public final static String UNIQUE = "0";
|
||||
String UNIQUE = "0";
|
||||
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
String NOT_UNIQUE = "1";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.fateverse.common.core.convert;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 基本转换定义
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2024/09/29
|
||||
*/
|
||||
public interface BaseConvertDefine<DTO, Entity, VO> {
|
||||
|
||||
/**
|
||||
* 实体到视图对象
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return {@link VO}
|
||||
*/
|
||||
VO entityToVo(Entity entity);
|
||||
|
||||
/**
|
||||
* 业务对象到实体
|
||||
*
|
||||
* @param DTO 业务对象
|
||||
* @return {@link Entity}
|
||||
*/
|
||||
Entity dtoToEntity(DTO DTO);
|
||||
|
||||
/**
|
||||
* 从实体到视图对象
|
||||
*
|
||||
* @param list 列表
|
||||
* @return {@link List}<{@link VO}>
|
||||
*/
|
||||
default List<VO> entityToVOList(List<Entity> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return list.stream().map(this::entityToVo).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务对象到实体列表
|
||||
*
|
||||
* @param list 列表
|
||||
* @return {@link List}<{@link Entity}>
|
||||
*/
|
||||
default List<Entity> dtoToEntityList(List<DTO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return list.stream().map(this::dtoToEntity).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,15 +4,17 @@ import cn.fateverse.common.core.annotaion.AutoTime;
|
||||
import cn.fateverse.common.core.annotaion.AutoUser;
|
||||
import cn.fateverse.common.core.enums.MethodEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
public class BaseEntity implements Serializable {
|
||||
@Data
|
||||
public abstract class BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
@@ -25,7 +27,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@AutoTime(method = MethodEnum.INSERT)
|
||||
@JsonFormat(locale = "zh",timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
@@ -38,7 +40,7 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
@AutoTime(method = MethodEnum.UPDATE)
|
||||
@JsonFormat(locale = "zh",timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
private Date updateTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,44 +48,4 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
public Object getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(Object createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Object getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(Object updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package cn.fateverse.admin.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
@@ -16,13 +19,16 @@ import javax.validation.constraints.Pattern;
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_dept")
|
||||
@EnableAutoField
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Dept extends BaseEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
@@ -62,7 +68,7 @@ public class Dept extends BaseEntity {
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@Pattern(message = "手机号格式错误!",regexp = "^1[0-9]{10}$")
|
||||
@Pattern(message = "手机号格式错误!", regexp = "^1[0-9]{10}$")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
@@ -82,5 +88,4 @@ public class Dept extends BaseEntity {
|
||||
private String delFlag;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package cn.fateverse.common.security.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -17,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class LoginUser implements UserDetails {
|
||||
public class LoginUser implements org.springframework.security.core.userdetails.UserDetails {
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
@@ -29,7 +27,6 @@ public class LoginUser implements UserDetails {
|
||||
*/
|
||||
private Long loginTime;
|
||||
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
@@ -38,7 +35,7 @@ public class LoginUser implements UserDetails {
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private User user;
|
||||
private UserDetail user;
|
||||
|
||||
/**
|
||||
* 登录ip
|
||||
@@ -119,6 +116,7 @@ public class LoginUser implements UserDetails {
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可用 ,禁用的用户不能身份验证
|
||||
*
|
||||
@@ -1,29 +1,27 @@
|
||||
package cn.fateverse.admin.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Role extends BaseEntity {
|
||||
@TableName("sys_role")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Role extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
@@ -1,12 +1,11 @@
|
||||
package cn.fateverse.admin.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -15,15 +14,15 @@ import java.util.Date;
|
||||
* @date 2022/11/7
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserBase extends BaseEntity {
|
||||
@TableName("sys_user")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class User extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
@@ -1,7 +1,8 @@
|
||||
package cn.fateverse.admin.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,7 +11,8 @@ import java.util.List;
|
||||
* @date 2022/10/27
|
||||
*/
|
||||
@Data
|
||||
public class User extends UserBase {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserDetail extends User {
|
||||
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.fateverse.common.core.utils;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class AssertUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 断定为 true. 非 true 时抛出异常.
|
||||
*
|
||||
* @param condition 条件
|
||||
* @param message 异常枚举
|
||||
* @param args 需要 format 的参数
|
||||
*/
|
||||
public static void isTrue(boolean condition, String message, Object... args) {
|
||||
if (!condition) {
|
||||
throw new CustomException(StrUtil.format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 断定为 false. 非 false 时抛出异常.
|
||||
*
|
||||
* @param condition 条件
|
||||
* @param message 异常枚举
|
||||
* @param args arg游戏
|
||||
*/
|
||||
public static void isFalse(boolean condition, String message, Object... args) {
|
||||
if (condition) {
|
||||
throw new CustomException(StrUtil.format(message, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
<artifactId>common-mybatis-puls</artifactId>
|
||||
|
||||
<properties>
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -6,29 +6,36 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-05-25
|
||||
*/
|
||||
@MapperScan("${mybatis.mapperPackage}")
|
||||
public class MybatisPlusAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(MybatisPlusInterceptor.class)
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 分页插件
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||
// 配置分页拦截器
|
||||
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
|
||||
paginationInnerInterceptor.setOptimizeJoin(false);
|
||||
paginationInnerInterceptor.setMaxLimit(500L);
|
||||
paginationInnerInterceptor.setOverflow(false);
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor);
|
||||
// 乐观锁插件
|
||||
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
|
||||
// 添加防止全表更新与删除插件
|
||||
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页插件,自动识别数据库类型
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.fateverse.common.mybatisplus.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public interface BaseEnum<T extends Enum<T>> extends IEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 获取编码
|
||||
*
|
||||
* @return {@link Integer}
|
||||
*/
|
||||
Integer getCode();
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return {@link String}
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* 获取value值
|
||||
*
|
||||
* @return {@link Integer}
|
||||
*/
|
||||
@Override
|
||||
default Integer getValue() {
|
||||
return getCode();
|
||||
}
|
||||
/**
|
||||
* 解析通过编码
|
||||
*
|
||||
* @param enumClass 枚举班
|
||||
* @param code 编码
|
||||
* @return {@link E}
|
||||
*/
|
||||
static <E extends Enum<E> & BaseEnum<E>> E parseByCode(Class<E> enumClass, Integer code) {
|
||||
return Arrays.stream(enumClass.getEnumConstants())
|
||||
.filter(e -> e.getCode().equals(code))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按名称解析
|
||||
*
|
||||
* @param enumClass 枚举班
|
||||
* @param name 名称
|
||||
* @return {@link E}
|
||||
*/
|
||||
static <E extends Enum<E> & BaseEnum<E>> E parseByName(Class<E> enumClass, String name) {
|
||||
return Arrays.stream(enumClass.getEnumConstants())
|
||||
.filter(e -> e.getName().equals(name))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -27,6 +28,9 @@ public class AutoSetMetaObjectHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
autoSetValue(metaObject, MethodEnum.UPDATE);
|
||||
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
|
||||
this.strictUpdateFill(metaObject, "updateBy", Long.class, SecurityUtils.getUserId());
|
||||
this.strictUpdateFill(metaObject, "updateUserName", String.class, SecurityUtils.getUsername());
|
||||
}
|
||||
|
||||
private void autoSetValue(MetaObject metaObject, MethodEnum method) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.fateverse.common.mybatisplus.utils;
|
||||
import cn.fateverse.common.core.entity.PageInfo;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.TableSupport;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -14,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
* @author Clay
|
||||
* @date 2023-05-25
|
||||
*/
|
||||
public class PageUtils {
|
||||
public class PageConditionUtil {
|
||||
|
||||
|
||||
/**
|
||||
@@ -26,11 +27,21 @@ public class PageUtils {
|
||||
* @param <R> 需要转换的对象类型
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
public static <T, R> TableDataInfo<T> convertDataTable(Page<R> page, Function<R, T> map) {
|
||||
public static <T, R> TableDataInfo<T> convertDataTable(IPage<R> page, Function<R, T> map) {
|
||||
List<T> convertList = page.getRecords().stream().map(map).collect(Collectors.toList());
|
||||
return convertDataTable(convertList, page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为TableDataInfo对象
|
||||
*
|
||||
* @param page 源对象
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
public static <T> TableDataInfo<T> convertDataTable(IPage<T> page) {
|
||||
return convertDataTable(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为TableDataInfo对象
|
||||
@@ -50,7 +61,7 @@ public class PageUtils {
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
public static <T> Page<T> getPage(){
|
||||
public static <T> IPage<T> getPage() {
|
||||
PageInfo pageInfo = TableSupport.getPageInfo();
|
||||
return new Page<>(pageInfo.getPageNum(), pageInfo.getPageSize());
|
||||
}
|
||||
@@ -48,9 +48,5 @@
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.fateverse.common.security.filter;
|
||||
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
||||
@@ -6,12 +6,11 @@ import cn.fateverse.common.core.constant.Constants;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.utils.HttpServletUtils;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
@@ -2,7 +2,7 @@ package cn.fateverse.common.security.utils;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.utils.HttpServletUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<bitwalker.version>1.19</bitwalker.version>
|
||||
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
|
||||
<pagehelper.boot.version>1.4.5</pagehelper.boot.version>
|
||||
<mapstruct.version>1.6.2</mapstruct.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@@ -81,6 +82,11 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.fateverse.query.entity;
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
@@ -61,8 +61,8 @@ public class JavaEngineExecuteHandler implements EngineExecuteHandler {
|
||||
String modifiedCode = modifiedCode(dataAdapter.getCode());
|
||||
String replacedCode = replacedClass(modifiedCode, getClassName(dataAdapter));
|
||||
String IMPORT_CODE = "import java.util.*;\n" +
|
||||
"import java.util.stream.*;\n" +
|
||||
"import com.alibaba.fastjson2.*;";
|
||||
"import java.util.stream.*;\n" ;
|
||||
// "import com.alibaba.fastjson2.*;";
|
||||
dataAdapter.setExecuteCode(IMPORT_CODE + replacedCode);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Spring
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 162.14.111.170:8848
|
||||
namespace: clay
|
||||
dubbo:
|
||||
registry:
|
||||
parameters:
|
||||
namespace: dubbo-clay
|
||||
code:
|
||||
java:
|
||||
class-path: E:\home\clay\code\
|
||||
seata:
|
||||
service:
|
||||
grouplist:
|
||||
seata-server: 192.168.31.102:8091
|
||||
registry:
|
||||
nacos:
|
||||
namespace: clay
|
||||
config:
|
||||
apollo:
|
||||
namespace: clay
|
||||
|
||||
@@ -9,7 +9,7 @@ import cn.fateverse.log.vo.LoginInfoVo;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -56,6 +56,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-reactor-netty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -8,14 +8,13 @@ import cn.fateverse.notice.entity.DelayedTask;
|
||||
import cn.fateverse.notice.entity.SocketAuth;
|
||||
import cn.fateverse.notice.entity.UserInfo;
|
||||
import cn.fateverse.notice.mq.RabbitConfig;
|
||||
import cn.fateverse.common.security.entity.LoginUser;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -45,6 +45,7 @@
|
||||
<spring-cloud.version>2021.0.3</spring-cloud.version>
|
||||
<swagger.annotations.version>1.6.8</swagger.annotations.version>
|
||||
<spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version>
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ CREATE TABLE `sys_menu` (
|
||||
INSERT INTO `sys_menu` VALUES (1, '系统管理', 0, 'D', 1, 'system', NULL, ' ', '0', 0, 1, 1, '0', '1', '', 'setting', '1', '2018-03-16 11:33:00', 'admin', '2023-10-23 20:48:54', '系统管理目录');
|
||||
INSERT INTO `sys_menu` VALUES (2, '系统监控', 0, 'D', 2, 'monitor', NULL, NULL, '0', 0, 1, 1, '0', '1', '', 'data_board', '0', '2018-03-16 11:33:00', 'admin', '2023-10-23 21:00:29', '系统监控目录');
|
||||
INSERT INTO `sys_menu` VALUES (3, '系统工具', 0, 'D', 3, 'tool', NULL, NULL, '0', 0, 1, 1, '0', '1', '', 'mokuaiguanli', '0', '2018-03-16 11:33:00', 'admin', '2023-10-23 21:00:54', '系统工具目录');
|
||||
INSERT INTO `sys_menu` VALUES (100, '用户管理', 1, 'M', 1, 'user', '{\"userId\": \"123\"}', 'system/user/index', '0', 0, 0, 1, '0', '1', 'system:user:list', 'User', '0', '2018-03-16 11:33:00', 'admin', '2023-08-23 14:39:12', '用户管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (100, '用户管理', 1, 'M', 1, 'userDetail', '{\"userId\": \"123\"}', 'system/userDetail/index', '0', 0, 0, 1, '0', '1', 'system:userDetail:list', 'User', '0', '2018-03-16 11:33:00', 'admin', '2023-08-23 14:39:12', '用户管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (101, '角色管理', 1, 'M', 2, 'role', NULL, 'system/role/index', '0', 0, 0, 1, '0', '1', 'system:role:list', 'Avatar', '0', '2018-03-16 11:33:00', 'admin', '2023-06-02 15:30:09', '角色管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (102, '菜单管理', 1, 'M', 3, 'menu', NULL, 'system/menu/index', '0', 0, 0, 1, '0', '1', 'system:menu:list', 'Menu', '0', '2018-03-16 11:33:00', 'admin', '2023-05-21 20:21:57', '菜单管理菜单');
|
||||
INSERT INTO `sys_menu` VALUES (103, '部门管理', 1, 'M', 4, 'dept', NULL, 'system/dept/index', '0', 0, 0, 1, '0', '1', 'system:dept:list', 'bumenguanli', '0', '2018-03-16 11:33:00', 'admin', '2023-07-19 17:04:53', '部门管理菜单');
|
||||
@@ -292,13 +292,13 @@ INSERT INTO `sys_menu` VALUES (109, '在线用户', 2, 'M', 1, 'online', NULL, '
|
||||
INSERT INTO `sys_menu` VALUES (114, '代码生成', 1151, 'M', 2, 'gen', NULL, 'rapid/gen/index', '0', 0, 0, 1, '0', '1', 'rapid:gen:list', 'daimashengcheng', '0', '2018-03-16 11:33:00', 'admin', '2023-07-19 17:23:31', '代码生成菜单');
|
||||
INSERT INTO `sys_menu` VALUES (500, '操作日志', 108, 'M', 1, 'operlog', NULL, 'monitor/operlog/index', '0', 0, 0, 1, '0', '1', 'monitor:operlog:list', 'caozuorizhi', '0', '2018-03-16 11:33:00', 'admin', '2023-07-19 17:13:51', '操作日志菜单');
|
||||
INSERT INTO `sys_menu` VALUES (501, '登录日志', 108, 'M', 2, 'logininfor', NULL, 'monitor/logininfor/index', '0', 0, 0, 1, '0', '1', 'monitor:logininfor:list', 'guanlidenglurizhi', '0', '2018-03-16 11:33:00', 'admin', '2023-07-19 17:14:26', '登录日志菜单');
|
||||
INSERT INTO `sys_menu` VALUES (1001, '用户查询', 100, 'B', 1, '', NULL, '', '0', 0, 1, 1, '0', '1', 'admin:user:list', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1002, '用户新增', 100, 'B', 2, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:add', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1003, '用户修改', 100, 'B', 3, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:edit', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1004, '用户删除', 100, 'B', 4, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:remove', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1005, '用户导出', 100, 'B', 5, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:export', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1006, '用户导入', 100, 'B', 6, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:import', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1007, '重置密码', 100, 'B', 7, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:user:resetPwd', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1001, '用户查询', 100, 'B', 1, '', NULL, '', '0', 0, 1, 1, '0', '1', 'admin:userDetail:list', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1002, '用户新增', 100, 'B', 2, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:add', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1003, '用户修改', 100, 'B', 3, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:edit', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1004, '用户删除', 100, 'B', 4, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:remove', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1005, '用户导出', 100, 'B', 5, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:export', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1006, '用户导入', 100, 'B', 6, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:import', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1007, '重置密码', 100, 'B', 7, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:userDetail:resetPwd', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1008, '角色查询', 101, 'B', 1, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:role:query', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1009, '角色新增', 101, 'B', 2, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:role:add', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
INSERT INTO `sys_menu` VALUES (1010, '角色修改', 101, 'B', 3, '', NULL, '', '0', 0, 1, 1, '0', '1', 'system:role:edit', '', '0', '2018-03-16 11:33:00', '0', '2018-03-16 11:33:00', '');
|
||||
|
||||
@@ -256,7 +256,7 @@ jobconf_trigger_type_api=Api trigger
|
||||
jobconf_trigger_type_retry=Fail retry trigger
|
||||
jobconf_trigger_type_misfire=Misfire compensation trigger
|
||||
|
||||
## user
|
||||
## userDetail
|
||||
user_manage=User Manage
|
||||
user_username=Username
|
||||
user_password=Password
|
||||
|
||||
@@ -256,7 +256,7 @@ jobconf_trigger_type_api=API触发
|
||||
jobconf_trigger_type_retry=失败重试触发
|
||||
jobconf_trigger_type_misfire=调度过期补偿
|
||||
|
||||
## user
|
||||
## userDetail
|
||||
user_manage=用户管理
|
||||
user_username=账号
|
||||
user_password=密码
|
||||
|
||||
@@ -256,7 +256,7 @@ jobconf_trigger_type_api=API觸發
|
||||
jobconf_trigger_type_retry=失敗重試觸發
|
||||
jobconf_trigger_type_misfire=調度過期補償
|
||||
|
||||
## user
|
||||
## userDetail
|
||||
user_manage=用户管理
|
||||
user_username=帳號
|
||||
user_password=密碼
|
||||
|
||||
@@ -70,7 +70,7 @@ l502 -73q56 -9 56 -46z" />
|
||||
<glyph glyph-name="star_empty" unicode="" horiz-adv-x="1664"
|
||||
d="M1137 532l306 297l-422 62l-189 382l-189 -382l-422 -62l306 -297l-73 -421l378 199l377 -199zM1664 889q0 -22 -26 -48l-363 -354l86 -500q1 -7 1 -20q0 -50 -41 -50q-19 0 -40 12l-449 236l-449 -236q-22 -12 -40 -12q-21 0 -31.5 14.5t-10.5 35.5q0 6 2 20l86 500
|
||||
l-364 354q-25 27 -25 48q0 37 56 46l502 73l225 455q19 41 49 41t49 -41l225 -455l502 -73q56 -9 56 -46z" />
|
||||
<glyph glyph-name="user" unicode="" horiz-adv-x="1280"
|
||||
<glyph glyph-name="userDetail" unicode="" horiz-adv-x="1280"
|
||||
d="M1280 137q0 -109 -62.5 -187t-150.5 -78h-854q-88 0 -150.5 78t-62.5 187q0 85 8.5 160.5t31.5 152t58.5 131t94 89t134.5 34.5q131 -128 313 -128t313 128q76 0 134.5 -34.5t94 -89t58.5 -131t31.5 -152t8.5 -160.5zM1024 1024q0 -159 -112.5 -271.5t-271.5 -112.5
|
||||
t-271.5 112.5t-112.5 271.5t112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5z" />
|
||||
<glyph glyph-name="film" unicode="" horiz-adv-x="1920"
|
||||
|
||||
|
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 434 KiB |
@@ -6,7 +6,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, userDetail-scalable=no" name="viewport">
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/bower_components/bootstrap/css/bootstrap.min.css">
|
||||
<!-- Font Awesome -->
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<#-- login user -->
|
||||
<#-- login userDetail -->
|
||||
<li class="dropdown">
|
||||
<a href="javascript:" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
${I18n.system_welcome} ${Request["XXL_JOB_LOGIN_IDENTITY"].username}
|
||||
@@ -139,7 +139,7 @@
|
||||
<li class="nav-click <#if pageName == "joblog">active</#if>" ><a href="${request.contextPath}/joblog"><i class="fa fa-circle-o text-green"></i><span>${I18n.joblog_name}</span></a></li>
|
||||
<#if Request["XXL_JOB_LOGIN_IDENTITY"].role == 1>
|
||||
<li class="nav-click <#if pageName == "jobgroup">active</#if>" ><a href="${request.contextPath}/jobgroup"><i class="fa fa-circle-o text-red"></i><span>${I18n.jobgroup_name}</span></a></li>
|
||||
<li class="nav-click <#if pageName == "user">active</#if>" ><a href="${request.contextPath}/user"><i class="fa fa-circle-o text-purple"></i><span>${I18n.user_manage}</span></a></li>
|
||||
<li class="nav-click <#if pageName == "userDetail">active</#if>" ><a href="${request.contextPath}/userDetail"><i class="fa fa-circle-o text-purple"></i><span>${I18n.user_manage}</span></a></li>
|
||||
</#if>
|
||||
<li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li>
|
||||
</ul>
|
||||
@@ -173,7 +173,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript::;">
|
||||
<i class="menu-icon fa fa-user bg-yellow"></i>
|
||||
<i class="menu-icon fa fa-userDetail bg-yellow"></i>
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Frodo 更新了资料</h4>
|
||||
<p>更新手机号码 +1(800)555-1234</p>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<br>
|
||||
<p>
|
||||
<a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a>
|
||||
<iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe>
|
||||
<iframe src="https://ghbtns.com/github-btn.html?userDetail=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe>
|
||||
<br><br>
|
||||
<a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>
|
||||
<br><br>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- header -->
|
||||
<@netCommon.commonHeader />
|
||||
<!-- left -->
|
||||
<@netCommon.commonLeft "user" />
|
||||
<@netCommon.commonLeft "userDetail" />
|
||||
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
@@ -183,6 +183,6 @@
|
||||
<!-- DataTables -->
|
||||
<script src="${request.contextPath}/static/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
|
||||
<script src="${request.contextPath}/static/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
|
||||
<script src="${request.contextPath}/static/js/user.index.1.js"></script>
|
||||
<script src="${request.contextPath}/static/js/userDetail.index.1.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -120,6 +120,10 @@
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.fateverse.workflow.entity.bpmn;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
import cn.fateverse.common.core.entity.LoginUser;
|
||||
import cn.fateverse.workflow.enums.OperationStateEnums;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -47,6 +48,7 @@ public class UserInfo {
|
||||
public static UserInfo toUserInfo(User user){
|
||||
return toUserInfo(user, OperationStateEnums.RUNNING);
|
||||
}
|
||||
|
||||
public static UserInfo toUserInfo(User user, OperationStateEnums state){
|
||||
return UserInfo.builder()
|
||||
.id(user.getUserId().toString())
|
||||
@@ -57,6 +59,16 @@ public class UserInfo {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static UserInfo toUserInfo(LoginUser user, OperationStateEnums state){
|
||||
return UserInfo.builder()
|
||||
.id(user.getUserId().toString())
|
||||
.avatar(user.getAvatar())
|
||||
.name(user.getNickName())
|
||||
.state(state)
|
||||
.sex(user.getSex())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static UserInfo toUserInfo(UserVo user, OperationStateEnums state){
|
||||
return UserInfo.builder()
|
||||
.id(user.getUserId().toString())
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<if test="state != null">state,</if>
|
||||
<if test="startTime != null ">start_time,</if>
|
||||
<if test="finishTime != null ">finish_time,</if>
|
||||
<if test="userInfo != null and userInfo != ''">user_info,</if>
|
||||
<if test="userDetail != null and userDetail != ''">user_info,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="taskId != null and taskId != ''">#{taskId},</if>
|
||||
@@ -105,7 +105,7 @@
|
||||
<if test="state != null">#{state},</if>
|
||||
<if test="startTime != null ">#{startTime},</if>
|
||||
<if test="finishTime != null ">#{finishTime},</if>
|
||||
<if test="userInfo != null and userInfo != ''">#{userInfo},</if>
|
||||
<if test="userDetail != null and userDetail != ''">#{userDetail},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<set>
|
||||
<if test="finishTime != null ">finish_time = #{finishTime},</if>
|
||||
<if test="state != null">state = #{state},</if>
|
||||
<if test="userInfo != null and userInfo != ''">user_info = #{userInfo},</if>
|
||||
<if test="userDetail != null and userDetail != ''">user_info = #{userDetail},</if>
|
||||
<if test="message != null and message != ''">message = #{message},</if>
|
||||
</set>
|
||||
where process_instance_id = #{processInstanceId} and node_id = #{nodeId}
|
||||
@@ -145,9 +145,9 @@
|
||||
</trim>
|
||||
<trim prefix="user_info = case" suffix="end,">
|
||||
<foreach collection="list" separator=" " item="item">
|
||||
<if test="item.userInfo != null and item.userInfo != ''">
|
||||
<if test="item.userDetail != null and item.userDetail != ''">
|
||||
</if>
|
||||
when task_id = #{item.taskId} then #{item.userInfo}
|
||||
when task_id = #{item.taskId} then #{item.userDetail}
|
||||
</foreach>
|
||||
</trim>
|
||||
<trim prefix="message = case" suffix="end,">
|
||||
|
||||
Reference in New Issue
Block a user