feat : 部门重构完成
This commit is contained in:
@@ -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.UserBase;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.fateverse.admin.dubbo;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import cn.fateverse.common.core.entity.User;
|
||||
import cn.fateverse.admin.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -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,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不能为空!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ 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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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,9 +1,9 @@
|
||||
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.UserBase;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
public interface UserMapper {
|
||||
public interface UserMapper extends BaseMapper<UserBase> {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
|
||||
@@ -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,11 @@ 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
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.result.page.TableDataInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
* @author Clay
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
public interface UserService {
|
||||
public interface UserService extends IService<User> {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
@@ -263,4 +264,12 @@ public interface UserService {
|
||||
* @return
|
||||
*/
|
||||
List<Long> searchAllUserIds();
|
||||
|
||||
/**
|
||||
* 检查现有用户
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return boolean
|
||||
*/
|
||||
boolean checkExistUser(Long deptId);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
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.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 +19,58 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int remove(Long deptId) {
|
||||
return deptMapper.delete(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新父级部门的状态
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
public List<Dept> selectChildrenById(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(Dept::getParentId, deptId)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 (User.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 (User.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 (User.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,22 +1,26 @@
|
||||
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.User;
|
||||
import cn.fateverse.common.core.entity.UserBase;
|
||||
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.PageUtils;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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 +37,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
|
||||
implements UserService {
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
@@ -162,7 +167,6 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindRole(List<Long> userIds, Long roleId) {
|
||||
@@ -322,14 +326,17 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> searchAllUserIds() {
|
||||
return userMapper.selectAllUserIds();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkExistUser(Long deptId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(UserBase::getDeptId, deptId)
|
||||
.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理用户与角色之间的对应关系
|
||||
|
||||
@@ -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.User" 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"/>
|
||||
@@ -218,17 +218,17 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectUserInfoByUserName" resultType="cn.fateverse.admin.entity.User">
|
||||
<select id="selectUserInfoByUserName" resultType="cn.fateverse.common.core.entity.User">
|
||||
<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.User">
|
||||
<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.User">
|
||||
<include refid="selectUser"/>
|
||||
where email = #{email} limit 0,1
|
||||
</select>
|
||||
@@ -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.UserBase" useGeneratedKeys="true" keyProperty="userId"
|
||||
keyColumn="user_id">
|
||||
insert into sys_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
@@ -4,7 +4,7 @@ import cn.fateverse.admin.dubbo.DubboUserService;
|
||||
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.common.core.entity.LoginUser;
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
||||
@@ -15,7 +15,7 @@ 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.core.entity.LoginUser;
|
||||
import cn.fateverse.common.security.service.TokenService;
|
||||
import cn.fateverse.common.security.utils.SecurityUtils;
|
||||
import cn.fateverse.auth.event.LoginInfoEvent;
|
||||
|
||||
@@ -2,7 +2,7 @@ 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 org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -66,6 +66,10 @@
|
||||
<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,8 @@
|
||||
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 lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
@@ -16,6 +16,7 @@ import javax.validation.constraints.Pattern;
|
||||
* @date 2022/10/30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EnableAutoField
|
||||
public class Dept extends BaseEntity {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.fateverse.common.security.entity;
|
||||
package cn.fateverse.common.core.entity;
|
||||
|
||||
import cn.fateverse.admin.entity.User;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -29,7 +29,6 @@ public class LoginUser implements UserDetails {
|
||||
*/
|
||||
private Long loginTime;
|
||||
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
@@ -119,6 +118,7 @@ public class LoginUser implements UserDetails {
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可用 ,禁用的用户不能身份验证
|
||||
*
|
||||
@@ -1,7 +1,6 @@
|
||||
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.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -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,6 +11,7 @@ import java.util.List;
|
||||
* @date 2022/10/27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class User extends UserBase {
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
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.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -19,6 +15,7 @@ import java.util.Date;
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserBase extends BaseEntity {
|
||||
|
||||
/**
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-05-25
|
||||
*/
|
||||
public class PageConditionUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 转换为TableDataInfo对象
|
||||
*
|
||||
* @param page 源对象
|
||||
* @param map 转换方法
|
||||
* @param <T> 转换后的对象类型
|
||||
* @param <R> 需要转换的对象类型
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
public static <T, R> TableDataInfo<T> convertDataTable(Page<R> page, Function<R, T> map) {
|
||||
List<T> convertList = page.getRecords().stream().map(map).collect(Collectors.toList());
|
||||
return convertDataTable(convertList, page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为TableDataInfo对象
|
||||
*
|
||||
* @param list
|
||||
* @param count
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> TableDataInfo<T> convertDataTable(List<T> list, Long count) {
|
||||
if (null == list) {
|
||||
return new TableDataInfo<>(new ArrayList<>(), 0);
|
||||
}
|
||||
TableDataInfo<T> tableDataInfo = new TableDataInfo<>();
|
||||
tableDataInfo.setRows(list);
|
||||
tableDataInfo.setTotal(count);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
public static <T> Page<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>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user