mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-08 21:26:40 +08:00
提交跑步起来的一大波....
This commit is contained in:
parent
db4b844146
commit
4734d3c408
@ -26,12 +26,7 @@ public enum UserErrorCode implements ErrorCode {
|
||||
|
||||
LOGIN_STATE_INVALID(30007, "您还未登录或登录失效,请重新登录!"),
|
||||
|
||||
LOGIN_OTHER_DEVICE(30008, "您的账号已在其他设备登录,请重新登录"),
|
||||
|
||||
USER_STATUS_ERROR(30009, "用户状态异常"),
|
||||
|
||||
LOGIN_FAILED(30010, "用户名或密码错误!"),
|
||||
|
||||
USER_STATUS_ERROR(30008, "用户状态异常"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
@ -0,0 +1,22 @@
|
||||
package net.lab1024.smartadmin.service.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class CaptchaVO {
|
||||
|
||||
/**
|
||||
* 验证码UUID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* base64 验证码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||
* @Date Created in 2017/10/28 16:19
|
||||
*/
|
||||
@Data
|
||||
public class PageParamForm {
|
||||
public class PageParam {
|
||||
|
||||
@ApiModelProperty(value = "页码(不能为空)", required = true, example = "1")
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@ -35,13 +35,13 @@ public class PageParamForm {
|
||||
@ApiModelProperty("排序字段集合")
|
||||
@Size(max = 10, message = "排序字段最多10")
|
||||
@Valid
|
||||
private List<SortItemDTO> sortItemList;
|
||||
private List<SortItem> sortItemList;
|
||||
|
||||
/**
|
||||
* 排序DTO类
|
||||
*/
|
||||
@Data
|
||||
public static class SortItemDTO {
|
||||
public static class SortItem {
|
||||
|
||||
@ApiModelProperty("true正序|false倒序")
|
||||
@NotNull(message = "排序规则不能为空")
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
* @Date Created in 2017/10/31 15:05
|
||||
*/
|
||||
@Data
|
||||
public class PageResultDTO<T> {
|
||||
public class PageResult<T> {
|
||||
|
||||
/**
|
||||
* 当前页
|
@ -0,0 +1,24 @@
|
||||
package net.lab1024.smartadmin.service.common.domain;
|
||||
|
||||
/**
|
||||
* @author zhuoda
|
||||
* @Date 2021-11-01
|
||||
*/
|
||||
public interface RequestUser {
|
||||
|
||||
/**
|
||||
* 请求用户id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Long requestUserId();
|
||||
|
||||
|
||||
/**
|
||||
* 请求用户名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String requestUserName();
|
||||
|
||||
}
|
@ -2,8 +2,8 @@ package net.lab1024.smartadmin.service.common.util;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,10 +23,10 @@ public class SmartPageUtil {
|
||||
* @param baseDTO
|
||||
* @return
|
||||
*/
|
||||
public static Page<?> convert2PageQuery(PageParamForm baseDTO) {
|
||||
public static Page<?> convert2PageQuery(PageParam baseDTO) {
|
||||
Page<?> page = new Page<>(baseDTO.getPageNum(), baseDTO.getPageSize());
|
||||
// 设置排序字段
|
||||
List<PageParamForm.SortItemDTO> sortItemList = baseDTO.getSortItemList();
|
||||
List<PageParam.SortItem> sortItemList = baseDTO.getSortItemList();
|
||||
if (CollectionUtils.isNotEmpty(sortItemList)) {
|
||||
List<OrderItem> orderItemList = sortItemList.stream().map(e -> new OrderItem(e.getColumn(), e.getIsAsc())).collect(Collectors.toList());
|
||||
page.setOrders(orderItemList);
|
||||
@ -42,7 +42,7 @@ public class SmartPageUtil {
|
||||
* @param targetClazz 目标类
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> PageResultDTO<T> convert2PageResult(Page<?> page, List<E> sourceList, Class<T> targetClazz) {
|
||||
public static <T, E> PageResult<T> convert2PageResult(Page<?> page, List<E> sourceList, Class<T> targetClazz) {
|
||||
return convert2PageResult(page, SmartBeanUtil.copyList(sourceList, targetClazz));
|
||||
}
|
||||
|
||||
@ -53,32 +53,32 @@ public class SmartPageUtil {
|
||||
* @param sourceList list
|
||||
* @return
|
||||
*/
|
||||
public static <E> PageResultDTO<E> convert2PageResult(Page<?> page, List<E> sourceList) {
|
||||
PageResultDTO<E> pageResultDTO = new PageResultDTO<>();
|
||||
pageResultDTO.setPageNum(page.getCurrent());
|
||||
pageResultDTO.setPageSize(page.getSize());
|
||||
pageResultDTO.setTotal(page.getTotal());
|
||||
pageResultDTO.setPages(page.getPages());
|
||||
pageResultDTO.setList(sourceList);
|
||||
pageResultDTO.setEmptyFlag(CollectionUtils.isEmpty(sourceList));
|
||||
return pageResultDTO;
|
||||
public static <E> PageResult<E> convert2PageResult(Page<?> page, List<E> sourceList) {
|
||||
PageResult<E> pageResult = new PageResult<>();
|
||||
pageResult.setPageNum(page.getCurrent());
|
||||
pageResult.setPageSize(page.getSize());
|
||||
pageResult.setTotal(page.getTotal());
|
||||
pageResult.setPages(page.getPages());
|
||||
pageResult.setList(sourceList);
|
||||
pageResult.setEmptyFlag(CollectionUtils.isEmpty(sourceList));
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换分页结果对象
|
||||
*
|
||||
* @param pageResultDTO
|
||||
* @param pageResult
|
||||
* @param targetClazz
|
||||
* @return
|
||||
*/
|
||||
public static <E, T> PageResultDTO<T> convert2PageResult(PageResultDTO<E> pageResultDTO, Class<T> targetClazz) {
|
||||
PageResultDTO<T> newPageResultDTO = new PageResultDTO<>();
|
||||
newPageResultDTO.setPageNum(pageResultDTO.getPageNum());
|
||||
newPageResultDTO.setPageSize(pageResultDTO.getPageSize());
|
||||
newPageResultDTO.setTotal(pageResultDTO.getTotal());
|
||||
newPageResultDTO.setPages(pageResultDTO.getPages());
|
||||
newPageResultDTO.setEmptyFlag(pageResultDTO.getEmptyFlag());
|
||||
newPageResultDTO.setList(SmartBeanUtil.copyList(pageResultDTO.getList(), targetClazz));
|
||||
return newPageResultDTO;
|
||||
public static <E, T> PageResult<T> convert2PageResult(PageResult<E> pageResult, Class<T> targetClazz) {
|
||||
PageResult<T> newPageResult = new PageResult<>();
|
||||
newPageResult.setPageNum(pageResult.getPageNum());
|
||||
newPageResult.setPageSize(pageResult.getPageSize());
|
||||
newPageResult.setTotal(pageResult.getTotal());
|
||||
newPageResult.setPages(pageResult.getPages());
|
||||
newPageResult.setEmptyFlag(pageResult.getEmptyFlag());
|
||||
newPageResult.setList(SmartBeanUtil.copyList(pageResult.getList(), targetClazz));
|
||||
return newPageResult;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.lab1024.smartadmin.service.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
@ -9,16 +9,16 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Slf4j
|
||||
public class SmartEmployeeTokenUtil {
|
||||
public class SmartRequestUtil {
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EmployeeLoginInfoDTO getRequestEmployee() {
|
||||
public static RequestEmployee getRequestEmployee() {
|
||||
try {
|
||||
return (EmployeeLoginInfoDTO) getAuthentication().getPrincipal();
|
||||
return (RequestEmployee) getAuthentication().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户信息异常:{}", e);
|
||||
}
|
||||
@ -40,7 +40,7 @@ public class SmartEmployeeTokenUtil {
|
||||
* @return
|
||||
*/
|
||||
public static Long getRequestEmployeeId() {
|
||||
EmployeeLoginInfoDTO requestUser = getRequestEmployee();
|
||||
RequestEmployee requestUser = getRequestEmployee();
|
||||
if (null == requestUser) {
|
||||
return null;
|
||||
}
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.MyBatisPlugin;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.MyBatisPlugin;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
|
@ -19,8 +19,7 @@ import java.time.format.DateTimeParseException;
|
||||
/**
|
||||
* java8 localDate 时间类格式化配置
|
||||
*
|
||||
* @author listen
|
||||
* @date 2019年10月18日 19:02:55
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Configuration
|
||||
public class DateConfig {
|
||||
@ -35,14 +34,14 @@ public class DateConfig {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* string 转为 LocalDate 配置类
|
||||
* string 转为 LocalDateTime 配置类
|
||||
*
|
||||
* @author Turbolisten
|
||||
* @date 2020/3/6 14:34
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Configuration
|
||||
public static class SmartConverterStringToLocalDateTime implements Converter<String, LocalDateTime> {
|
||||
public static class StringToLocalDateTime implements Converter<String, LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public LocalDateTime convert(String str) {
|
||||
@ -61,14 +60,14 @@ public class DateConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* string 转为 LocalDate 配置类
|
||||
*
|
||||
* @author Turbolisten
|
||||
* @date 2020/3/6 14:34
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Configuration
|
||||
public static class SmartConverterStringToLocalDate implements Converter<String, LocalDate> {
|
||||
public static class StringToLocalDate implements Converter<String, LocalDate> {
|
||||
|
||||
@Override
|
||||
public LocalDate convert(String str) {
|
||||
|
@ -9,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @Author zhuoda
|
||||
*/
|
||||
@Configuration
|
||||
public class AdminWebAppConfig implements WebMvcConfigurer {
|
||||
public class MvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
@ -1,6 +1,6 @@
|
||||
package net.lab1024.smartadmin.service.config;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.util.SmartEmployeeTokenUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||
import net.lab1024.smartadmin.service.module.support.repeatsubmit.RepeatSubmitAspect;
|
||||
import net.lab1024.smartadmin.service.module.support.repeatsubmit.RepeatSubmitCaffeineTicket;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -38,7 +38,7 @@ public class RepeatSubmitConfig {
|
||||
* @return
|
||||
*/
|
||||
private String ticket(String servletPath) {
|
||||
Long employeeId = SmartEmployeeTokenUtil.getRequestEmployeeId();
|
||||
Long employeeId = SmartRequestUtil.getRequestEmployeeId();
|
||||
if (employeeId == null) {
|
||||
return "";
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package net.lab1024.smartadmin.service.config;
|
||||
import net.lab1024.smartadmin.service.common.security.SecurityUrlMatchers;
|
||||
import net.lab1024.smartadmin.service.filter.SecurityTokenFilter;
|
||||
import net.lab1024.smartadmin.service.common.security.SecurityAuthenticationFailHandler;
|
||||
import net.lab1024.smartadmin.service.module.system.login.EmployeeLoginTokenService;
|
||||
import net.lab1024.smartadmin.service.module.system.login.service.JwtService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -41,7 +41,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
* 获取TOKEN 解析类
|
||||
*/
|
||||
@Autowired
|
||||
private EmployeeLoginTokenService loginTokenService;
|
||||
private JwtService loginTokenService;
|
||||
|
||||
/**
|
||||
* 跨域配置
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.common.constant;
|
||||
package net.lab1024.smartadmin.service.constant;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
@ -25,6 +25,10 @@ public class CacheModuleConst {
|
||||
|
||||
public static class Department {
|
||||
|
||||
/**
|
||||
* 部门树
|
||||
*/
|
||||
public static final String DEPARTMENT_CACHE = "department_cache";
|
||||
|
||||
/**
|
||||
* 部门树
|
||||
@ -34,7 +38,11 @@ public class CacheModuleConst {
|
||||
/**
|
||||
* 某个部门以及下级的id列表
|
||||
*/
|
||||
public static final String DEPARTMENT_SELF_CHILDREN_ID_CACHE = "department_self_children_id_cache";
|
||||
public static final String DEPARTMENT_SELF_CHILDREN_CACHE = "department_self_children_cache";
|
||||
|
||||
public static final String DEPARTMENT_SCHOOL_CACHE = "department_school_cache";
|
||||
|
||||
public static final String DEPARTMENT_ROUTE_CACHE = "department_route_cache";
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package net.lab1024.smartadmin.service.common.constant;
|
||||
package net.lab1024.smartadmin.service.constant;
|
||||
|
||||
/**
|
||||
* redis key 常量类
|
||||
*
|
||||
* @author listen
|
||||
* @date 2019/09/23 20:48
|
||||
* @author zhuoda
|
||||
*/
|
||||
public class RedisKeyConst {
|
||||
|
||||
public static final String PROJECT = "smart:";
|
||||
public static final String PROJECT = "sa:";
|
||||
|
||||
public class Support {
|
||||
|
||||
@ -20,6 +19,7 @@ public class RedisKeyConst {
|
||||
|
||||
public static final String ID_GENERATOR = LOCK + "id-generator:";
|
||||
|
||||
// 验证码
|
||||
public static final String CAPTCHA = PROJECT + "captcha:";
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package net.lab1024.smartadmin.service.constant;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @date
|
||||
*/
|
||||
public class SwaggerTagConst {
|
||||
|
||||
public static class Business {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class System {
|
||||
|
||||
public static final String MANAGER_HOME = "管理端-首页";
|
||||
|
||||
public static final String MANAGER_SYSTEM_CONFIG = "管理端-系统配置";
|
||||
|
||||
public static final String MANAGER_EMPLOYEE_LOGIN = "管理端-员工登录";
|
||||
|
||||
public static final String EMPLOYEE = "系统-员工管理";
|
||||
|
||||
public static final String DEPARTMENT = "系统-部门管理";
|
||||
|
||||
public static final String MANAGER_ROLE = "管理端-角色";
|
||||
|
||||
public static final String MANAGER_MENU = "管理端-菜单";
|
||||
|
||||
public static final String MANAGER_ROLE_MENU = "管理端-角色-菜单";
|
||||
|
||||
public static final String MANAGER_ROLE_USER = "管理端-角色用户";
|
||||
|
||||
public static final String MANAGER_ROLE_PRIVILEGE = "管理端-角色权限";
|
||||
|
||||
public static final String MANAGER_BUSINESS_OPERATE_LOG = "管理端-操作日志";
|
||||
|
||||
public static final String MANAGER_DATA_SCOPE = "管理端-数据范围";
|
||||
|
||||
public static final String MANAGER_JOB = "管理端-岗位";
|
||||
|
||||
public static final String MANAGER_NOTICE = "管理端-系统通知";
|
||||
|
||||
public static final String MANAGER_PRIVILEGE = "通用-权限";
|
||||
|
||||
public static final String MANAGER_PIC = "管理端-轮播图";
|
||||
|
||||
public static final String CATEGORY = "管理端-类目业务";
|
||||
|
||||
public static final String GOODS = "管理端-商品业务";
|
||||
|
||||
public static final String ORDER = "管理端-订单业务";
|
||||
|
||||
public static final String RECEIVE_ACCOUNT = "管理端-收款账号";
|
||||
|
||||
public static final String TABLE_COLUMN = "管理端-表格列自定义";
|
||||
|
||||
public static final String MANAGER_CLUE = "管理端-线索";
|
||||
|
||||
public static final String MANAGER_CONTRACT = "管理端-合同";
|
||||
|
||||
public static final String MANAGER_DEPARTMENT_BUSINESS = "管理端-部门业务";
|
||||
|
||||
public static final String MANAGER_EMPLOYEE_BUSINESS = "管理端-员工业务";
|
||||
|
||||
public static final String MANAGER_DATA_TRACER = "管理端-数据变动记录";
|
||||
|
||||
public static final String MANAGER_FLOW = "管理端-审批流";
|
||||
|
||||
public static final String SPEAK_SCRIPT = "管理端-话术";
|
||||
|
||||
public static final String SPEAK_SCRIPT_CATEGORY = "管理端-话术分类";
|
||||
|
||||
public static final String TAG = "管理端-标签管理";
|
||||
|
||||
public static final String SEAL = "管理端-印章管理";
|
||||
}
|
||||
|
||||
public static class Support {
|
||||
|
||||
public static final String AREA = "基础-地区服务";
|
||||
|
||||
public static final String FILE = "基础-文件服务";
|
||||
|
||||
public static final String CACHE = "基础-缓存";
|
||||
|
||||
public static final String SYSTEM_CONFIG = "基础-系统参数";
|
||||
|
||||
public static final String WX = "基础-微信业务";
|
||||
|
||||
public static final String SMART_RELOAD = "基础-Reload";
|
||||
|
||||
public static final String HEART_BEAT = "基础-心跳";
|
||||
|
||||
public static final String USER_OPERATE_LOG = "基础-用户操作日志";
|
||||
|
||||
public static final String PAY = "基础-支付业务";
|
||||
|
||||
public static final String SMS = "基础-短信业务";
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package net.lab1024.smartadmin.service.filter;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.constant.RequestHeaderConst;
|
||||
import net.lab1024.smartadmin.service.module.system.login.EmployeeLoginTokenService;
|
||||
import net.lab1024.smartadmin.service.module.system.login.service.JwtService;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginBO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
@ -26,9 +26,9 @@ import java.io.IOException;
|
||||
|
||||
public class SecurityTokenFilter extends OncePerRequestFilter {
|
||||
|
||||
private EmployeeLoginTokenService loginTokenService;
|
||||
private JwtService loginTokenService;
|
||||
|
||||
public SecurityTokenFilter(EmployeeLoginTokenService loginTokenService) {
|
||||
public SecurityTokenFilter(JwtService loginTokenService) {
|
||||
this.loginTokenService = loginTokenService;
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,11 @@ public class SmartAdminStartupRunner implements CommandLineRunner {
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
|
||||
log.info("###################### init start ######################");
|
||||
log.info("###################### SmartAdmin v2.x init start ######################");
|
||||
|
||||
// 初始化状态码
|
||||
ErrorCodeRegister.init();
|
||||
|
||||
log.info("###################### init complete ######################");
|
||||
log.info("###################### SmartAdmin v2.x init complete ######################");
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.business.category;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.constant.CacheModuleConst;
|
||||
import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
||||
import net.lab1024.smartadmin.service.common.constant.StringConst;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.module.business.category.domain.CategoryEntity;
|
||||
|
@ -3,12 +3,12 @@ package net.lab1024.smartadmin.service.module.business.goods;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.business.goods.domain.*;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartEmployeeTokenUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -32,7 +32,7 @@ public class GoodsController extends SystemBaseController {
|
||||
@ApiOperation("添加商品 by listen")
|
||||
@PostMapping("/goods/add")
|
||||
public ResponseDTO<String> add(@RequestBody @Valid GoodsAddForm addForm) {
|
||||
EmployeeLoginInfoDTO employee = SmartEmployeeTokenUtil.getRequestEmployee();
|
||||
EmployeeLoginInfoDTO employee = SmartRequestUtil.getRequestEmployee();
|
||||
addForm.setUpdateId(employee.getEmployeeId());
|
||||
addForm.setUpdateName(employee.getActualName());
|
||||
return goodsService.add(addForm);
|
||||
@ -41,7 +41,7 @@ public class GoodsController extends SystemBaseController {
|
||||
@ApiOperation("更新商品 by listen")
|
||||
@PostMapping("/goods/update")
|
||||
public ResponseDTO<String> update(@RequestBody @Valid GoodsUpdateForm updateForm) {
|
||||
EmployeeLoginInfoDTO employee = SmartEmployeeTokenUtil.getRequestEmployee();
|
||||
EmployeeLoginInfoDTO employee = SmartRequestUtil.getRequestEmployee();
|
||||
updateForm.setUpdateId(employee.getEmployeeId());
|
||||
updateForm.setUpdateName(employee.getActualName());
|
||||
return goodsService.update(updateForm);
|
||||
@ -50,7 +50,7 @@ public class GoodsController extends SystemBaseController {
|
||||
@ApiOperation("删除 by listen")
|
||||
@PostMapping("/goods/del")
|
||||
public ResponseDTO<String> del(@RequestBody @Valid GoodsDelForm delForm) {
|
||||
EmployeeLoginInfoDTO employee = SmartEmployeeTokenUtil.getRequestEmployee();
|
||||
EmployeeLoginInfoDTO employee = SmartRequestUtil.getRequestEmployee();
|
||||
delForm.setUpdateId(employee.getEmployeeId());
|
||||
delForm.setUpdateName(employee.getActualName());
|
||||
return goodsService.del(delForm);
|
||||
@ -58,7 +58,7 @@ public class GoodsController extends SystemBaseController {
|
||||
|
||||
@ApiOperation("分页查询 by listen")
|
||||
@PostMapping("/goods/query")
|
||||
public ResponseDTO<PageResultDTO<GoodsAdminVO>> query(@RequestBody @Valid GoodsQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<GoodsAdminVO>> query(@RequestBody @Valid GoodsQuery queryForm) {
|
||||
return goodsService.query(queryForm);
|
||||
}
|
||||
}
|
||||
|
@ -34,5 +34,5 @@ public interface GoodsDao extends BaseMapper<GoodsEntity> {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<GoodsAdminVO> query(Page page, @Param("query") GoodsQueryForm query);
|
||||
List<GoodsAdminVO> query(Page page, @Param("query") GoodsQuery query);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.business.goods;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||
@ -136,11 +136,11 @@ public class GoodsService {
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<GoodsAdminVO>> query(GoodsQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<GoodsAdminVO>> query(GoodsQuery queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<GoodsAdminVO> list = goodsDao.query(page, queryForm);
|
||||
PageResultDTO<GoodsAdminVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
PageResult<GoodsAdminVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.business.goods.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||
import net.lab1024.smartadmin.service.module.business.goods.constant.GoodsTypeEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -14,7 +14,7 @@ import org.hibernate.validator.constraints.Length;
|
||||
* @date 2021/8/5 14:42
|
||||
*/
|
||||
@Data
|
||||
public class GoodsQueryForm extends PageParamForm {
|
||||
public class GoodsQuery extends PageParam {
|
||||
|
||||
@ApiModelPropertyEnum(desc = "商品类型|可选", value = GoodsTypeEnum.class)
|
||||
private Integer goodsType;
|
@ -4,13 +4,13 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.*;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.vo.NoticeDetailVO;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.vo.NoticeVO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartEmployeeTokenUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -31,27 +31,27 @@ public class NoticeController extends SystemBaseController {
|
||||
|
||||
@ApiOperation(value = "分页查询全部消息", notes = "@author 罗伊")
|
||||
@PostMapping("/notice/page/query")
|
||||
public ResponseDTO<PageResultDTO<NoticeVO>> queryByPage(@RequestBody NoticeQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<NoticeVO>> queryByPage(@RequestBody NoticeQuery queryForm) {
|
||||
return noticeService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取已收取的所有消息", notes = "@author 罗伊")
|
||||
@PostMapping("/notice/receive/page/query")
|
||||
public ResponseDTO<PageResultDTO<NoticeReceiveForm>> queryReceiveByPage(@RequestBody NoticeReceiveQueryForm queryForm) {
|
||||
queryForm.setEmployeeId(SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
public ResponseDTO<PageResult<NoticeReceiveForm>> queryReceiveByPage(@RequestBody NoticeReceiveQuery queryForm) {
|
||||
queryForm.setEmployeeId(SmartRequestUtil.getRequestEmployeeId());
|
||||
return noticeService.queryReceiveByPage(queryForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询未读消息", notes = "@author 罗伊")
|
||||
@PostMapping("/notice/unread/page/query")
|
||||
public ResponseDTO<PageResultDTO<NoticeVO>> queryUnreadByPage(@RequestBody PageParamForm queryForm) {
|
||||
return noticeService.queryUnreadByPage(queryForm, SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
public ResponseDTO<PageResult<NoticeVO>> queryUnreadByPage(@RequestBody PageParam queryForm) {
|
||||
return noticeService.queryUnreadByPage(queryForm, SmartRequestUtil.getRequestEmployeeId());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加", notes = "@author 罗伊")
|
||||
@PostMapping("/notice/add")
|
||||
public ResponseDTO<String> add(@RequestBody @Valid NoticeAddForm addForm) {
|
||||
addForm.setCreateId(SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
addForm.setCreateId(SmartRequestUtil.getRequestEmployeeId());
|
||||
return noticeService.add(addForm);
|
||||
}
|
||||
|
||||
@ -76,12 +76,12 @@ public class NoticeController extends SystemBaseController {
|
||||
@ApiOperation(value = "发送", notes = "@author 罗伊")
|
||||
@GetMapping("/notice/send/{id}")
|
||||
public ResponseDTO<NoticeDetailVO> send(@PathVariable("id") Long id) {
|
||||
return noticeService.send(id, SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
return noticeService.send(id, SmartRequestUtil.getRequestEmployeeId());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "读取消息", notes = "@author 罗伊")
|
||||
@GetMapping("/notice/read/{id}")
|
||||
public ResponseDTO<NoticeDetailVO> read(@PathVariable("id") Long id) {
|
||||
return noticeService.read(id, SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
return noticeService.read(id, SmartRequestUtil.getRequestEmployeeId());
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package net.lab1024.smartadmin.service.module.business.notice;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.dao.NoticeDao;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.dao.NoticeReceiveRecordDao;
|
||||
@ -42,12 +42,12 @@ public class NoticeService {
|
||||
* @description 分页查询
|
||||
* @date 2019-07-11 16:19:48
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<NoticeVO>> queryByPage(NoticeQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<NoticeVO>> queryByPage(NoticeQuery queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<NoticeVO> dtoList = noticeDao.queryByPage(page, queryForm);
|
||||
PageResultDTO<NoticeVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<NoticeVO> pageResult = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ public class NoticeService {
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<NoticeReceiveForm>> queryReceiveByPage(NoticeReceiveQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<NoticeReceiveForm>> queryReceiveByPage(NoticeReceiveQuery queryForm) {
|
||||
queryForm.setSendStatus(true);
|
||||
Page page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<NoticeReceiveForm> dtoList = noticeDao.queryReceiveByPage(page, queryForm);
|
||||
@ -64,8 +64,8 @@ public class NoticeService {
|
||||
dtoList.forEach(e -> {
|
||||
e.setReadStatus(e.getReceiveTime() != null);
|
||||
});
|
||||
PageResultDTO<NoticeReceiveForm> pageResultDTO = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<NoticeReceiveForm> pageResult = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,11 +74,11 @@ public class NoticeService {
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<NoticeVO>> queryUnreadByPage(PageParamForm queryForm, Long employeeId) {
|
||||
public ResponseDTO<PageResult<NoticeVO>> queryUnreadByPage(PageParam queryForm, Long employeeId) {
|
||||
Page page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<NoticeVO> dtoList = noticeDao.queryUnreadByPage(page, employeeId, true);
|
||||
PageResultDTO<NoticeVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<NoticeVO> pageResult = SmartPageUtil.convert2PageResult(page, dtoList);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,16 +2,16 @@ package net.lab1024.smartadmin.service.module.business.notice.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeQuery;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeReadCountDTO;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeReceiveForm;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeReceiveQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.dto.NoticeReceiveQuery;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.entity.NoticeEntity;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.vo.NoticeDetailVO;
|
||||
import net.lab1024.smartadmin.service.module.business.notice.domain.vo.NoticeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.anno.DataScope;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.DataScope;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -34,7 +34,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
* @return NoticeEntity
|
||||
*/
|
||||
@DataScope(dataScopeType = DataScopeTypeEnum.NOTICE, joinSql = "n.create_user in (#employeeIds)", whereInType = DataScopeWhereInTypeEnum.EMPLOYEE)
|
||||
List<NoticeVO> queryByPage(Page page, @Param("query") NoticeQueryForm query);
|
||||
List<NoticeVO> queryByPage(Page page, @Param("query") NoticeQuery query);
|
||||
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<NoticeReceiveForm> queryReceiveByPage(Page page, @Param("query") NoticeReceiveQueryForm query);
|
||||
List<NoticeReceiveForm> queryReceiveByPage(Page page, @Param("query") NoticeReceiveQuery query);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.business.notice.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
@ -10,7 +10,7 @@ import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class NoticeQueryForm extends PageParamForm {
|
||||
public class NoticeQuery extends PageParam {
|
||||
|
||||
|
||||
@ApiModelProperty("开始日期")
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class NoticeReceiveQueryForm extends NoticeQueryForm {
|
||||
public class NoticeReceiveQuery extends NoticeQuery {
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long employeeId;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.systemcache;
|
||||
package net.lab1024.smartadmin.service.module.support.cache;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -19,10 +19,10 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_SYSTEM_CACHE})
|
||||
public class SystemCacheController {
|
||||
public class CacheController {
|
||||
|
||||
@Autowired
|
||||
private SystemCacheService systemCacheService;
|
||||
private CacheService systemCacheService;
|
||||
|
||||
@ApiOperation(value = "获取所有缓存", notes = "@author 罗伊")
|
||||
@GetMapping("/cache/names")
|
@ -1,8 +1,7 @@
|
||||
package net.lab1024.smartadmin.service.module.system.systemcache;
|
||||
package net.lab1024.smartadmin.service.module.support.cache;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.caffeine.CaffeineCache;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -19,7 +18,7 @@ import java.util.stream.Collectors;
|
||||
* @date 2021/10/11 20:07
|
||||
*/
|
||||
@Service
|
||||
public class SystemCacheService {
|
||||
public class CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
@ -5,7 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.code.SystemErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.constant.StringConst;
|
||||
import net.lab1024.smartadmin.service.common.constant.RedisKeyConst;
|
||||
import net.lab1024.smartadmin.service.constant.RedisKeyConst;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.captcha.domain.CaptchaVO;
|
||||
import net.lab1024.smartadmin.service.third.SmartRedisService;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.anno;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.strategy.DataScopePowerStrategy;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.strategy.DataScopePowerStrategy;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -13,7 +13,12 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* [ 数据范围 ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
||||
* @date
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
@ -0,0 +1,40 @@
|
||||
package net.lab1024.smartadmin.service.module.support.datascope;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeAndViewTypeVO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.service.DataScopeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/27 0027 下午 15:12
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Api(tags = {SwaggerTagConst.System.MANAGER_ROLE})
|
||||
@RestController
|
||||
public class DataScopeController extends SupportBaseController {
|
||||
|
||||
@Autowired
|
||||
private DataScopeService dataScopeService;
|
||||
|
||||
@ApiOperation(value = "获取当前系统所配置的所有数据范围")
|
||||
@GetMapping("/dataScope/list")
|
||||
public ResponseDTO<List<DataScopeAndViewTypeVO>> dataScopeList() {
|
||||
return dataScopeService.dataScopeList();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.service.DataScopeSqlConfigService;
|
||||
import net.lab1024.smartadmin.service.third.SmartApplicationContext;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartStringUtil;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.service.DataScopeSqlConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.mapping.*;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,12 +20,20 @@ import java.util.Properties;
|
||||
/**
|
||||
* [ mybaits sql 拦截 ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
||||
* @date
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Intercepts({@Signature(type = org.apache.ibatis.executor.Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
|
||||
@Component
|
||||
public class MyBatisPlugin implements Interceptor {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
|
||||
@ -110,7 +119,7 @@ public class MyBatisPlugin implements Interceptor {
|
||||
}
|
||||
|
||||
public DataScopeSqlConfigService dataScopeSqlConfigService() {
|
||||
return (DataScopeSqlConfigService) SmartApplicationContext.getBean("dataScopeSqlConfigService");
|
||||
return (DataScopeSqlConfigService) applicationContext.getBean("dataScopeSqlConfigService");
|
||||
}
|
||||
|
||||
public class BoundSqlSqlSource implements SqlSource {
|
@ -0,0 +1,68 @@
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.constant;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/28 0028 下午 15:37
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeTypeEnum implements BaseEnum {
|
||||
|
||||
CLUE_USER(1, 1, "线索", "线索数据范围"),
|
||||
CLUE_USER_TRACK(2, 2, "线索跟进", "线索跟进记录"),
|
||||
CLUE_PUBLIC_USER(3, 3, "公海线索", "公海线索数据范围"),
|
||||
CLUE_INVALID_USER(4, 4, "无效线索", "无效线索数据范围"),
|
||||
|
||||
CONTRACT(11, 5, "合同", "合同数据范围"),
|
||||
|
||||
ORDER(21, 10, "订单", "订单数据范围"),
|
||||
RECEIVE_ORDER(22, 11, "收款单", "收款单数据范围"),
|
||||
REFUND_ORDER(23, 12, "退款单", "退款单数据范围"),
|
||||
|
||||
EMPLOYEE_SALES_RANK(31, 15, "员工业绩排行", "员工业绩排行数据范围"),
|
||||
|
||||
NOTICE(41, 20, "系统通知", "系统通知数据范围"),
|
||||
;
|
||||
|
||||
private Integer value;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String name;
|
||||
|
||||
private String desc;
|
||||
|
||||
DataScopeTypeEnum(Integer value, Integer sort, String name, String desc) {
|
||||
this.value = value;
|
||||
this.sort = sort;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.constant;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/28 0028 下午 15:37
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeViewTypeEnum implements BaseEnum {
|
||||
|
||||
ME(0, 0, "本人"),
|
||||
|
||||
DEPARTMENT(1, 5, "本部门"),
|
||||
|
||||
DEPARTMENT_AND_SUB(2, 10, "本部门及下属子部门"),
|
||||
|
||||
SCHOOL(3, 15, "本校区"),
|
||||
|
||||
ALL(10, 100, "全部");
|
||||
|
||||
|
||||
|
||||
private Integer value;
|
||||
private Integer level;
|
||||
private String desc;
|
||||
|
||||
DataScopeViewTypeEnum(Integer value, Integer level, String desc) {
|
||||
this.value = value;
|
||||
this.level = level;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.constant;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/5/8 0008 下午 16:00
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeWhereInTypeEnum implements BaseEnum {
|
||||
|
||||
EMPLOYEE(0, "以员工IN"),
|
||||
|
||||
DEPARTMENT(1, "以部门IN"),
|
||||
|
||||
CUSTOM_STRATEGY(2, "自定义策略");
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
||||
DataScopeWhereInTypeEnum(Integer value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -8,7 +8,12 @@ import java.util.List;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/27 0027 下午 16:37
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
public class DataScopeAndViewTypeVO {
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
@ -7,7 +7,12 @@ import lombok.Data;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/27 0027 下午 16:37
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
@ -1,13 +1,18 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/28 0028 下午 17:21
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
public class DataScopeSqlConfigDTO {
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
@ -7,7 +7,12 @@ import lombok.Data;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/28 0028 下午 15:41
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.entity;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -10,7 +10,12 @@ import java.time.LocalDateTime;
|
||||
/**
|
||||
* [ 数据范围与角色关系 ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/27 0027 下午 14:43
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_role_data_scope")
|
||||
@ -20,19 +25,16 @@ public class DataScopeRoleEntity {
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据范围id
|
||||
* {@link net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum}
|
||||
* {@link net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum}
|
||||
*/
|
||||
private Integer dataScopeType;
|
||||
|
||||
/**
|
||||
* 数据范围类型
|
||||
* {@link net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeViewTypeEnum}
|
||||
* {@link net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeViewTypeEnum}
|
||||
*/
|
||||
private Integer viewType;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
@ -0,0 +1,76 @@
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeAndViewTypeVO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeViewTypeVO;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/27 0027 下午 14:52
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Service
|
||||
public class DataScopeService {
|
||||
|
||||
/**
|
||||
* 获取所有可以进行数据范围配置的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DataScopeAndViewTypeVO>> dataScopeList() {
|
||||
List<DataScopeDTO> dataScopeList = this.getDataScopeType();
|
||||
List<DataScopeAndViewTypeVO> dataScopeAndTypeList = SmartBeanUtil.copyList(dataScopeList, DataScopeAndViewTypeVO.class);
|
||||
List<DataScopeViewTypeVO> typeList = this.getViewType();
|
||||
dataScopeAndTypeList.forEach(e -> {
|
||||
e.setViewTypeList(typeList);
|
||||
});
|
||||
return ResponseDTO.ok(dataScopeAndTypeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前系统存在的数据可见范围
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<DataScopeViewTypeVO> getViewType() {
|
||||
List<DataScopeViewTypeVO> viewTypeList = Lists.newArrayList();
|
||||
DataScopeViewTypeEnum[] enums = DataScopeViewTypeEnum.class.getEnumConstants();
|
||||
DataScopeViewTypeVO dataScopeViewTypeDTO;
|
||||
for (DataScopeViewTypeEnum viewTypeEnum : enums) {
|
||||
dataScopeViewTypeDTO = DataScopeViewTypeVO.builder().viewType(viewTypeEnum.getValue()).viewTypeLevel(viewTypeEnum.getLevel()).viewTypeName(viewTypeEnum.getDesc()).build();
|
||||
viewTypeList.add(dataScopeViewTypeDTO);
|
||||
}
|
||||
Comparator<DataScopeViewTypeVO> comparator = (h1, h2) -> h1.getViewTypeLevel().compareTo(h2.getViewTypeLevel());
|
||||
viewTypeList.sort(comparator);
|
||||
return viewTypeList;
|
||||
}
|
||||
|
||||
public List<DataScopeDTO> getDataScopeType() {
|
||||
List<DataScopeDTO> dataScopeTypeList = Lists.newArrayList();
|
||||
DataScopeTypeEnum[] enums = DataScopeTypeEnum.class.getEnumConstants();
|
||||
DataScopeDTO dataScopeDTO;
|
||||
for (DataScopeTypeEnum typeEnum : enums) {
|
||||
dataScopeDTO =
|
||||
DataScopeDTO.builder().dataScopeType(typeEnum.getValue()).dataScopeTypeDesc(typeEnum.getDesc()).dataScopeTypeName(typeEnum.getName()).dataScopeTypeSort(typeEnum.getSort()).build();
|
||||
dataScopeTypeList.add(dataScopeDTO);
|
||||
}
|
||||
Comparator<DataScopeDTO> comparator = (h1, h2) -> h1.getDataScopeTypeSort().compareTo(h2.getDataScopeTypeSort());
|
||||
dataScopeTypeList.sort(comparator);
|
||||
return dataScopeTypeList;
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,7 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.service;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.anno.DataScope;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.strategy.DataScopePowerStrategy;
|
||||
import net.lab1024.smartadmin.service.third.SmartApplicationContext;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartEmployeeTokenUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.reflections.Reflections;
|
||||
@ -17,7 +10,14 @@ import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.DataScope;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.strategy.DataScopePowerStrategy;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,20 +29,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/29 0029 上午 10:12
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataScopeSqlConfigService {
|
||||
|
||||
private ConcurrentHashMap<String, DataScopeSqlConfigDTO> dataScopeMethodMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
private DataScopeViewService dataScopeViewService;
|
||||
|
||||
@Value("${project.module}")
|
||||
private String scanPackage;
|
||||
|
||||
/**
|
||||
* 注解joinsql 参数
|
||||
*/
|
||||
@ -50,6 +47,18 @@ public class DataScopeSqlConfigService {
|
||||
|
||||
private static final String DEPARTMENT_PARAM = "#departmentIds";
|
||||
|
||||
private ConcurrentHashMap<String, DataScopeSqlConfigDTO> dataScopeMethodMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
private DataScopeViewService dataScopeViewService;
|
||||
|
||||
@Value("${swagger.packAge}")
|
||||
private String scanPackage;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void initDataScopeMethodMap() {
|
||||
this.refreshDataScopeMethodMap();
|
||||
@ -99,7 +108,7 @@ public class DataScopeSqlConfigService {
|
||||
public String getJoinSql(Map<String, Object> paramMap, DataScopeSqlConfigDTO sqlConfigDTO) {
|
||||
DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
|
||||
String joinSql = sqlConfigDTO.getJoinSql();
|
||||
Long employeeId = SmartEmployeeTokenUtil.getRequestEmployeeId();
|
||||
Long employeeId = SmartRequestUtil.getRequestEmployeeId();
|
||||
if (employeeId == null) {
|
||||
return "";
|
||||
}
|
||||
@ -109,7 +118,7 @@ public class DataScopeSqlConfigService {
|
||||
log.warn("data scope custom strategy class is null");
|
||||
return "";
|
||||
}
|
||||
DataScopePowerStrategy powerStrategy = (DataScopePowerStrategy) SmartApplicationContext.getBean(sqlConfigDTO.getJoinSqlImplClazz());
|
||||
DataScopePowerStrategy powerStrategy = (DataScopePowerStrategy) applicationContext.getBean(sqlConfigDTO.getJoinSqlImplClazz());
|
||||
if (powerStrategy == null) {
|
||||
log.warn("data scope custom strategy class:{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
|
||||
return "";
|
@ -1,18 +1,18 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.service;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.DataScopeRoleDao;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.entity.DataScopeRoleEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.department.DepartmentService;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.entity.DataScopeRoleEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.department.service.DepartmentService;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.menu.MenuEmployeeService;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.RoleEmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.menu.service.MenuEmployeeService;
|
||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDataScopeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBaseEnumUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -23,7 +23,12 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2019/4/28 0028 下午 15:56
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Service
|
||||
public class DataScopeViewService {
|
||||
@ -32,7 +37,7 @@ public class DataScopeViewService {
|
||||
private RoleEmployeeDao roleEmployeeDao;
|
||||
|
||||
@Autowired
|
||||
private DataScopeRoleDao dataScopeRoleDao;
|
||||
private RoleDataScopeDao roleDataScopeDao;
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
@ -42,6 +47,7 @@ public class DataScopeViewService {
|
||||
|
||||
@Autowired
|
||||
private MenuEmployeeService menuEmployeeService;
|
||||
|
||||
/**
|
||||
* 获取某人可以查看的所有人员信息
|
||||
*
|
||||
@ -60,6 +66,9 @@ public class DataScopeViewService {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.SCHOOL == viewType) {
|
||||
return this.getSchoolEmployeeIdList(employeeId);
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
@ -81,15 +90,18 @@ public class DataScopeViewService {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubIdList(employeeId);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.SCHOOL == viewType) {
|
||||
return this.getSchoolDepartmentIdList(employeeId);
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
private List<Long> getMeDepartmentIdList(Long employeeId) {
|
||||
public List<Long> getMeDepartmentIdList(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
return Lists.newArrayList(employeeEntity.getDepartmentId());
|
||||
}
|
||||
|
||||
private List<Long> getDepartmentAndSubIdList(Long employeeId) {
|
||||
public List<Long> getDepartmentAndSubIdList(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
List<Long> allDepartmentIds = departmentService.selfAndChildrenIdList(employeeEntity.getDepartmentId());
|
||||
return allDepartmentIds;
|
||||
@ -115,12 +127,15 @@ public class DataScopeViewService {
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
//未设置角色数据范围 默认本人
|
||||
List<DataScopeRoleEntity> dataScopeRoleList = dataScopeRoleDao.listByRoleIdList(roleIdList);
|
||||
List<DataScopeRoleEntity> dataScopeRoleList = roleDataScopeDao.listByRoleIdList(roleIdList);
|
||||
if (CollectionUtils.isEmpty(dataScopeRoleList)) {
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
Map<Integer, List<DataScopeRoleEntity>> listMap = dataScopeRoleList.stream().collect(Collectors.groupingBy(DataScopeRoleEntity::getDataScopeType));
|
||||
List<DataScopeRoleEntity> viewLevelList = listMap.get(dataScopeTypeEnum.getValue());
|
||||
List<DataScopeRoleEntity> viewLevelList = listMap.getOrDefault(dataScopeTypeEnum.getValue(), Lists.newArrayList());
|
||||
if (CollectionUtils.isEmpty(viewLevelList)) {
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
DataScopeRoleEntity maxLevel = viewLevelList.stream().max(Comparator.comparing(e -> SmartBaseEnumUtil.getEnumByValue(e.getViewType(), DataScopeViewTypeEnum.class).getLevel())).get();
|
||||
return SmartBaseEnumUtil.getEnumByValue(maxLevel.getViewType(), DataScopeViewTypeEnum.class);
|
||||
}
|
||||
@ -143,7 +158,7 @@ public class DataScopeViewService {
|
||||
*/
|
||||
private List<Long> getDepartmentEmployeeIdList(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
List<Long> employeeIdList = employeeDao.getEmployeeIdByDepartmentId(employeeEntity.getDepartmentId(),false,false);
|
||||
List<Long> employeeIdList = employeeDao.getEmployeeIdByDepartmentId(employeeEntity.getDepartmentId(), null, null, false);
|
||||
return employeeIdList;
|
||||
}
|
||||
|
||||
@ -155,8 +170,39 @@ public class DataScopeViewService {
|
||||
*/
|
||||
private List<Long> getDepartmentAndSubEmployeeIdList(Long employeeId) {
|
||||
List<Long> allDepartmentIds = getDepartmentAndSubIdList(employeeId);
|
||||
List<Long> employeeIdList = employeeDao.getEmployeeIdByDepartmentIdList(allDepartmentIds,false,false);
|
||||
List<Long> employeeIdList = employeeDao.getEmployeeIdByDepartmentIdList(allDepartmentIds, null, null, false);
|
||||
return employeeIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认所属分校的所有员工id
|
||||
*
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
private List<Long> getSchoolEmployeeIdList(Long employeeId) {
|
||||
Long schoolDepartmentId = departmentService.getSchoolIdByEmployeeId(employeeId);
|
||||
if (schoolDepartmentId == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<Long> allDepartmentIds = departmentService.selfAndChildrenIdList(schoolDepartmentId);
|
||||
List<Long> employeeIdList = employeeDao.getEmployeeIdByDepartmentIdList(allDepartmentIds, null, null, false);
|
||||
return employeeIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认所属分校的所有部门id
|
||||
*
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
private List<Long> getSchoolDepartmentIdList(Long employeeId) {
|
||||
Long schoolDepartmentId = departmentService.getSchoolIdByEmployeeId(employeeId);
|
||||
if (schoolDepartmentId == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<Long> allDepartmentIds = departmentService.selfAndChildrenIdList(schoolDepartmentId);
|
||||
return allDepartmentIds;
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,19 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.strategy;
|
||||
package net.lab1024.smartadmin.service.module.support.datascope.strategy;
|
||||
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* [ 数据范围策略 ,使用DataScopeWhereInTypeEnum.CUSTOM_STRATEGY类型,DataScope注解的joinSql属性无用]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||
* @date 2020/11/28 0008 下午 16:00
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public abstract class DataScopePowerStrategy {
|
||||
|
@ -4,9 +4,9 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -31,7 +31,7 @@ public class DataTracerController extends SystemBaseController {
|
||||
|
||||
@ApiOperation("分页查询业务操作日志 - by listen")
|
||||
@PostMapping("/data/tracer/log/query")
|
||||
public ResponseDTO<PageResultDTO<DataTracerVO>> query(@Valid @RequestBody DataTracerQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<DataTracerVO>> query(@Valid @RequestBody DataTracerQuery queryForm) {
|
||||
return dataTracerService.query(queryForm);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package net.lab1024.smartadmin.service.module.support.datatracer;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -33,5 +33,5 @@ public interface DataTracerDao extends BaseMapper<DataTracerEntity> {
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
List<DataTracerVO> query(Page page, @Param("query") DataTracerQueryForm queryForm);
|
||||
List<DataTracerVO> query(Page page, @Param("query") DataTracerQuery queryForm);
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.constant.DataTracerBusinessTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.domain.DataTracerVO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -107,10 +107,10 @@ public class DataTracerService {
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<DataTracerVO>> query(DataTracerQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<DataTracerVO>> query(DataTracerQuery queryForm) {
|
||||
Page page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DataTracerVO> list = dataTracerDao.query(page, queryForm);
|
||||
PageResultDTO<DataTracerVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
PageResult<DataTracerVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.support.datatracer.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.datatracer.constant.DataTracerBusinessTypeEnum;
|
||||
|
||||
@ -15,7 +15,7 @@ import javax.validation.constraints.NotNull;
|
||||
* @date 2021/8/17 8:47
|
||||
*/
|
||||
@Data
|
||||
public class DataTracerQueryForm extends PageParamForm {
|
||||
public class DataTracerQuery extends PageParam {
|
||||
|
||||
@ApiModelPropertyEnum(DataTracerBusinessTypeEnum.class)
|
||||
private Integer businessType;
|
@ -3,11 +3,11 @@ package net.lab1024.smartadmin.service.module.support.file;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileUrlUploadForm;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileUploadVO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileVO;
|
||||
@ -52,7 +52,7 @@ public class FileController extends SupportBaseController {
|
||||
|
||||
@ApiOperation(value = "文件分页查询 by listen")
|
||||
@PostMapping("/file/query")
|
||||
public ResponseDTO<PageResultDTO<FileVO>> queryListByPage(@RequestBody @Valid FileQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<FileVO>> queryListByPage(@RequestBody @Valid FileQuery queryForm) {
|
||||
return fileService.queryListByPage(queryForm);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package net.lab1024.smartadmin.service.module.support.file;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -34,6 +34,6 @@ public interface FileDao extends BaseMapper<FileEntity> {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<FileVO> queryListByPage(Page page, @Param("query") FileQueryForm query);
|
||||
List<FileVO> queryListByPage(Page page, @Param("query") FileQuery query);
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.support.file.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||
import net.lab1024.smartadmin.service.common.validator.enumeration.CheckEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
||||
@ -15,7 +15,7 @@ import org.hibernate.validator.constraints.Length;
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class FileQueryForm extends PageParamForm {
|
||||
public class FileQuery extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "文件名称")
|
||||
@Length(max = 50, message = "文件名称搜索最多50字符")
|
@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.code.SystemErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.constant.RedisKeyConst;
|
||||
import net.lab1024.smartadmin.service.constant.RedisKeyConst;
|
||||
import net.lab1024.smartadmin.service.common.constant.StringConst;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBaseEnumUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
@ -18,7 +18,7 @@ import net.lab1024.smartadmin.service.module.support.file.domain.FileEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileDownloadDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileMetadataDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileQuery;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileUrlUploadForm;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileUploadVO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileVO;
|
||||
@ -205,7 +205,7 @@ public class FileService {
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<FileVO>> queryListByPage(FileQueryForm queryDTO) {
|
||||
public ResponseDTO<PageResult<FileVO>> queryListByPage(FileQuery queryDTO) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryDTO);
|
||||
List<FileVO> fileList = fileDao.queryListByPage(page, queryDTO);
|
||||
if (CollectionUtils.isNotEmpty(fileList)) {
|
||||
@ -214,8 +214,8 @@ public class FileService {
|
||||
e.setFileUrl(fileStorageService.getFileUrl(e.getFileKey()).getData());
|
||||
});
|
||||
}
|
||||
PageResultDTO<FileVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, fileList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<FileVO> pageResult = SmartPageUtil.convert2PageResult(page, fileList);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,8 +3,8 @@ package net.lab1024.smartadmin.service.module.support.heartbeat;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,8 +24,8 @@ public class HeartBeatController extends SupportBaseController {
|
||||
|
||||
@PostMapping("/heartBeat/query")
|
||||
@ApiOperation("查询心跳记录 @author 卓大")
|
||||
public ResponseDTO<PageResultDTO<HeartBeatRecordVO>> query(@RequestBody @Valid PageParamForm pageParamForm) {
|
||||
return heartBeatService.pageQuery(pageParamForm);
|
||||
public ResponseDTO<PageResult<HeartBeatRecordVO>> query(@RequestBody @Valid PageParam pageParam) {
|
||||
return heartBeatService.pageQuery(pageParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package net.lab1024.smartadmin.service.module.support.heartbeat;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,10 +24,10 @@ public class HeartBeatService {
|
||||
private HeartBeatRecordDao heartBeatRecordDao;
|
||||
|
||||
|
||||
public ResponseDTO<PageResultDTO<HeartBeatRecordVO>> pageQuery(PageParamForm pageParamForm) {
|
||||
Page pageQueryInfo = SmartPageUtil.convert2PageQuery(pageParamForm);
|
||||
public ResponseDTO<PageResult<HeartBeatRecordVO>> pageQuery(PageParam pageParam) {
|
||||
Page pageQueryInfo = SmartPageUtil.convert2PageQuery(pageParam);
|
||||
List<HeartBeatRecordVO> recordVOList = heartBeatRecordDao.pageQuery(pageQueryInfo);
|
||||
PageResultDTO<HeartBeatRecordVO> pageResultDTO = SmartPageUtil.convert2PageResult(pageQueryInfo, recordVOList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<HeartBeatRecordVO> pageResult = SmartPageUtil.convert2PageResult(pageQueryInfo, recordVOList);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package net.lab1024.smartadmin.service.module.support.operatelog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -27,7 +27,7 @@ public class OperateLogController extends SupportBaseController {
|
||||
|
||||
@ApiOperation(value = "分页查询 @author 罗伊")
|
||||
@PostMapping("/userOperateLog/page/query")
|
||||
public ResponseDTO<PageResultDTO<OperateLogDTO>> queryByPage(@RequestBody OperateLogQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<OperateLogDTO>> queryByPage(@RequestBody OperateLogQuery queryForm) {
|
||||
return operateLogService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package net.lab1024.smartadmin.service.module.support.operatelog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.OperateLogEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQuery;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -25,7 +25,7 @@ public interface OperateLogDao extends BaseMapper<OperateLogEntity> {
|
||||
* @param queryForm
|
||||
* @return UserOperateLogEntity
|
||||
*/
|
||||
List<OperateLogEntity> queryByPage(Page page, @Param("query") OperateLogQueryForm queryForm);
|
||||
List<OperateLogEntity> queryByPage(Page page, @Param("query") OperateLogQuery queryForm);
|
||||
|
||||
/**
|
||||
* 根据id删除
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.lab1024.smartadmin.service.module.support.operatelog;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.OperateLogEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.support.operatelog.domain.dto.OperateLogQuery;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -29,11 +29,11 @@ public class OperateLogService {
|
||||
* @description 分页查询
|
||||
* @date 2019-05-15 11:32:14
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<OperateLogDTO>> queryByPage(OperateLogQueryForm queryForm) {
|
||||
public ResponseDTO<PageResult<OperateLogDTO>> queryByPage(OperateLogQuery queryForm) {
|
||||
Page page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<OperateLogEntity> logEntityList = operateLogDao.queryByPage(page, queryForm);
|
||||
PageResultDTO<OperateLogDTO> pageResultDTO = SmartPageUtil.convert2PageResult(page, logEntityList, OperateLogDTO.class);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<OperateLogDTO> pageResult = SmartPageUtil.convert2PageResult(page, logEntityList, OperateLogDTO.class);
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.lab1024.smartadmin.service.module.support.operatelog.domain.dto;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -10,7 +10,7 @@ import lombok.Data;
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class OperateLogQueryForm extends PageParamForm {
|
||||
public class OperateLogQuery extends PageParam {
|
||||
|
||||
|
||||
@ApiModelProperty("开始日期")
|
@ -1,49 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeAndViewTypeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeBatchSetRoleDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.DataScopeSelectVO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.service.DataScopeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_ROLE})
|
||||
@RestController
|
||||
public class DataScopeController extends SystemBaseController {
|
||||
|
||||
@Autowired
|
||||
private DataScopeService dataScopeService;
|
||||
|
||||
@ApiOperation(value = "获取当前系统所配置的所有数据范围")
|
||||
@GetMapping("/dataScope/list")
|
||||
public ResponseDTO<List<DataScopeAndViewTypeVO>> dataScopeList() {
|
||||
return dataScopeService.dataScopeList();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取某角色所设置的数据范围")
|
||||
@GetMapping("/dataScope/listByRole/{roleId}")
|
||||
public ResponseDTO<List<DataScopeSelectVO>> dataScopeListByRole(@PathVariable Long roleId) {
|
||||
return dataScopeService.dataScopeListByRole(roleId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量设置某角色数据范围")
|
||||
@PostMapping("/dataScope/batchSet")
|
||||
public ResponseDTO<String> dataScopeBatchSet(@RequestBody @Valid DataScopeBatchSetRoleDTO batchSetRoleDTO) {
|
||||
return dataScopeService.dataScopeBatchSet(batchSetRoleDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.constant;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DataScopeTypeEnum implements BaseEnum {
|
||||
|
||||
NOTICE(7, 7, "系统通知", "系统通知数据范围"),
|
||||
;
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final Integer sort;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String desc;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.constant;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DataScopeViewTypeEnum implements BaseEnum {
|
||||
|
||||
ME(0, 0, "本人"),
|
||||
|
||||
DEPARTMENT(1, 5, "本部门"),
|
||||
|
||||
DEPARTMENT_AND_SUB(2, 10, "本部门及下属子部门"),
|
||||
|
||||
ALL(3, 15, "全部");
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final Integer level;
|
||||
|
||||
private final String desc;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.constant;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DataScopeWhereInTypeEnum implements BaseEnum {
|
||||
|
||||
EMPLOYEE(0, "以员工IN"),
|
||||
|
||||
DEPARTMENT(1, "以部门IN"),
|
||||
|
||||
CUSTOM_STRATEGY(2, "自定义策略");
|
||||
|
||||
private final Integer value;
|
||||
|
||||
private final String desc;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class DataScopeBatchSetDTO {
|
||||
|
||||
@ApiModelProperty("数据范围类型")
|
||||
@NotNull(message = "数据范围类型不能为空")
|
||||
private Integer dataScopeType;
|
||||
|
||||
@ApiModelProperty("可见范围")
|
||||
@NotNull(message = "可见范围不能为空")
|
||||
private Integer viewType;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class DataScopeBatchSetRoleDTO {
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
@NotNull(message = "角色id不能为空")
|
||||
private Long roleId;
|
||||
|
||||
@ApiModelProperty("设置信息")
|
||||
@Valid
|
||||
private List<DataScopeBatchSetDTO> batchSetList;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Data
|
||||
public class DataScopeSelectVO {
|
||||
|
||||
@ApiModelProperty("数据范围id")
|
||||
private Integer dataScopeType;
|
||||
|
||||
@ApiModelProperty("可见范围")
|
||||
private Integer viewType;
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.datascope.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.DataScopeRoleDao;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.dto.*;
|
||||
import net.lab1024.smartadmin.service.module.system.datascope.domain.entity.DataScopeRoleEntity;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*/
|
||||
@Service
|
||||
public class DataScopeService {
|
||||
|
||||
@Autowired
|
||||
private DataScopeRoleDao dataScopeRoleDao;
|
||||
|
||||
/**
|
||||
* 获取所有可以进行数据范围配置的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DataScopeAndViewTypeVO>> dataScopeList() {
|
||||
List<DataScopeDTO> dataScopeList = this.getDataScopeType();
|
||||
List<DataScopeAndViewTypeVO> dataScopeAndTypeList = SmartBeanUtil.copyList(dataScopeList, DataScopeAndViewTypeVO.class);
|
||||
List<DataScopeViewTypeVO> typeList = this.getViewType();
|
||||
dataScopeAndTypeList.forEach(e -> {
|
||||
e.setViewTypeList(typeList);
|
||||
});
|
||||
return ResponseDTO.ok(dataScopeAndTypeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前系统存在的数据可见范围
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<DataScopeViewTypeVO> getViewType() {
|
||||
List<DataScopeViewTypeVO> viewTypeList = Lists.newArrayList();
|
||||
DataScopeViewTypeEnum[] enums = DataScopeViewTypeEnum.class.getEnumConstants();
|
||||
DataScopeViewTypeVO dataScopeViewTypeDTO;
|
||||
for (DataScopeViewTypeEnum viewTypeEnum : enums) {
|
||||
dataScopeViewTypeDTO = DataScopeViewTypeVO.builder().viewType(viewTypeEnum.getValue()).viewTypeLevel(viewTypeEnum.getLevel()).viewTypeName(viewTypeEnum.getDesc()).build();
|
||||
viewTypeList.add(dataScopeViewTypeDTO);
|
||||
}
|
||||
Comparator<DataScopeViewTypeVO> comparator = Comparator.comparing(DataScopeViewTypeVO::getViewTypeLevel);
|
||||
viewTypeList.sort(comparator);
|
||||
return viewTypeList;
|
||||
}
|
||||
|
||||
public List<DataScopeDTO> getDataScopeType() {
|
||||
List<DataScopeDTO> dataScopeTypeList = Lists.newArrayList();
|
||||
DataScopeTypeEnum[] enums = DataScopeTypeEnum.class.getEnumConstants();
|
||||
DataScopeDTO dataScopeDTO;
|
||||
for (DataScopeTypeEnum typeEnum : enums) {
|
||||
dataScopeDTO =
|
||||
DataScopeDTO.builder().dataScopeType(typeEnum.getValue()).dataScopeTypeDesc(typeEnum.getDesc()).dataScopeTypeName(typeEnum.getName()).dataScopeTypeSort(typeEnum.getSort()).build();
|
||||
dataScopeTypeList.add(dataScopeDTO);
|
||||
}
|
||||
Comparator<DataScopeDTO> comparator = Comparator.comparing(DataScopeDTO::getDataScopeTypeSort);
|
||||
dataScopeTypeList.sort(comparator);
|
||||
return dataScopeTypeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个角色的数据范围设置信息
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DataScopeSelectVO>> dataScopeListByRole(Long roleId) {
|
||||
|
||||
List<DataScopeRoleEntity> dataScopeRoleEntityList = dataScopeRoleDao.listByRoleId(roleId);
|
||||
if (CollectionUtils.isEmpty(dataScopeRoleEntityList)) {
|
||||
return ResponseDTO.ok(Lists.newArrayList());
|
||||
}
|
||||
List<DataScopeSelectVO> dataScopeSelects = SmartBeanUtil.copyList(dataScopeRoleEntityList, DataScopeSelectVO.class);
|
||||
return ResponseDTO.ok(dataScopeSelects);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置某个角色的数据范围设置信息
|
||||
*
|
||||
* @param batchSetRoleDTO
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseDTO<String> dataScopeBatchSet(DataScopeBatchSetRoleDTO batchSetRoleDTO) {
|
||||
List<DataScopeBatchSetDTO> batchSetList = batchSetRoleDTO.getBatchSetList();
|
||||
if (CollectionUtils.isEmpty(batchSetList)) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "缺少配置信息");
|
||||
}
|
||||
List<DataScopeRoleEntity> dataScopeRoleEntityList = SmartBeanUtil.copyList(batchSetList, DataScopeRoleEntity.class);
|
||||
dataScopeRoleEntityList.forEach(e -> e.setRoleId(batchSetRoleDTO.getRoleId()));
|
||||
dataScopeRoleDao.deleteByRoleId(batchSetRoleDTO.getRoleId());
|
||||
dataScopeRoleDao.batchInsert(dataScopeRoleEntityList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.constant.CacheModuleConst;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @date 2021-01-31 0:48
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DepartmentCacheManager {
|
||||
|
||||
@Autowired
|
||||
private DepartmentDao departmentDao;
|
||||
|
||||
@Autowired
|
||||
private DepartmentTreeService departmentTreeService;
|
||||
|
||||
|
||||
/**
|
||||
* 清除自身以及下级的id列表缓存
|
||||
*/
|
||||
@CacheEvict(CacheModuleConst.Department.DEPARTMENT_SELF_CHILDREN_ID_CACHE)
|
||||
public void clearSelfAndChildrenIdCache() {
|
||||
log.info("clear DEPARTMENT_SELF_CHILDREN_ID_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除树结构缓存
|
||||
*/
|
||||
@CacheEvict(CacheModuleConst.Department.DEPARTMENT_TREE_CACHE)
|
||||
public void clearTreeCache() {
|
||||
log.info("clear DEPARTMENT_TREE_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存部门树结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_TREE_CACHE)
|
||||
public List<DepartmentTreeVO> departmentTreeCache() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
List<DepartmentTreeVO> treeList = departmentTreeService.buildTree(departmentVOList);
|
||||
return treeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存某个部门的下级id列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_SELF_CHILDREN_ID_CACHE)
|
||||
public List<Long> departmentSelfAndChildrenIdCache(Long departmentId) {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
List<Long> idList = departmentTreeService.selfAndChildrenIdList(departmentId, departmentVOList);
|
||||
return idList;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
|
||||
class DepartmentConst {
|
||||
|
||||
/**
|
||||
* 默认的顶级部门的parent id
|
||||
*/
|
||||
|
||||
static final long DEFAULT_PARENT_ID = 0;
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.dto.DepartmentCreateDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.dto.DepartmentUpdateDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentEmployeeTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理路由器
|
||||
*
|
||||
* @author listen
|
||||
* @date 2017/12/19 14:29
|
||||
*/
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_DEPARTMENT})
|
||||
@RestController
|
||||
public class DepartmentController extends SystemBaseController {
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@ApiOperation(value = "查询部门树形列表")
|
||||
@GetMapping("/department/treeList")
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTree() {
|
||||
return departmentService.departmentTree();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询部门及员工树列表")
|
||||
@GetMapping("/department/departmentEmployeeTree")
|
||||
public ResponseDTO<List<DepartmentEmployeeTreeVO>> departmentEmployeeTree() {
|
||||
return departmentService.departmentEmployeeTree();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据部门名称查询部门树列表")
|
||||
@GetMapping("/department/departmentTreeByName")
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTreeByName(String departmentName) {
|
||||
return departmentService.departmentTreeByName(departmentName);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加部门")
|
||||
@PostMapping("/department/add")
|
||||
public ResponseDTO<String> addDepartment(@Valid @RequestBody DepartmentCreateDTO createDTO) {
|
||||
return departmentService.addDepartment(createDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新部门信息")
|
||||
@PostMapping("/department/update")
|
||||
public ResponseDTO<String> updateDepartment(@Valid @RequestBody DepartmentUpdateDTO updateDTO) {
|
||||
return departmentService.updateDepartment(updateDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除部门")
|
||||
@GetMapping("/department/delete/{deptId}")
|
||||
public ResponseDTO<String> delDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.delDepartment(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取部门信息")
|
||||
@GetMapping("/department/query/{deptId}")
|
||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.getDepartmentById(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询部门列表")
|
||||
@GetMapping("/department/listAll")
|
||||
public ResponseDTO<List<DepartmentVO>> listAll() {
|
||||
return departmentService.listAll();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "上下移动")
|
||||
@GetMapping("/department/upOrDown/{deptId}/{swapId}")
|
||||
public ResponseDTO<String> upOrDown(@PathVariable Long deptId, @PathVariable Long swapId) {
|
||||
return departmentService.upOrDown(deptId, swapId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "升级")
|
||||
@GetMapping("/department/upgrade/{deptId}")
|
||||
public ResponseDTO<String> upgrade(@PathVariable Long deptId) {
|
||||
return departmentService.upgrade(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "降级")
|
||||
@GetMapping("/department/downgrade/{deptId}/{preId}")
|
||||
public ResponseDTO<String> downgrade(@PathVariable Long deptId, @PathVariable Long preId) {
|
||||
return departmentService.downgrade(deptId, preId);
|
||||
}
|
||||
|
||||
@ApiOperation("获取校区列表 by 善逸")
|
||||
@GetMapping("/department/querySchoolList")
|
||||
public ResponseDTO<List<DepartmentVO>> querySchoolList() {
|
||||
return departmentService.querySchoolList();
|
||||
}
|
||||
|
||||
}
|
@ -1,399 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.dto.DepartmentCreateDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.dto.DepartmentUpdateDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentEmployeeTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.EmployeeDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理业务类
|
||||
*
|
||||
* @author listen
|
||||
* @date 2017/12/19 14:25
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentService {
|
||||
|
||||
@Autowired
|
||||
private DepartmentDao departmentDao;
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
@Autowired
|
||||
private DepartmentTreeService departmentTreeService;
|
||||
|
||||
@Autowired
|
||||
protected DepartmentCacheManager departmentCacheManager;
|
||||
|
||||
/**
|
||||
* 获取部门树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTree() {
|
||||
List<DepartmentTreeVO> treeVOList = departmentCacheManager.departmentTreeCache();
|
||||
return ResponseDTO.ok(treeVOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自身以及所有下级的部门id列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public List<Long> selfAndChildrenIdList(Long departmentId) {
|
||||
return departmentCacheManager.departmentSelfAndChildrenIdCache(departmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门员工树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentEmployeeTreeVO>> departmentEmployeeTree() {
|
||||
List<DepartmentTreeVO> treeVOList = departmentCacheManager.departmentTreeCache();
|
||||
if (CollectionUtils.isEmpty(treeVOList)) {
|
||||
return ResponseDTO.ok(Lists.newArrayList());
|
||||
}
|
||||
// 获取全部员工列表
|
||||
List<EmployeeDTO> employeeList = employeeDao.listAll();
|
||||
if (CollectionUtils.isEmpty(employeeList)) {
|
||||
return ResponseDTO.ok(SmartBeanUtil.copyList(treeVOList, DepartmentEmployeeTreeVO.class));
|
||||
}
|
||||
Map<Long, List<EmployeeDTO>> employeeMap = employeeList.stream().collect(Collectors.groupingBy(EmployeeDTO::getDepartmentId));
|
||||
//构建各部门的员工信息
|
||||
List<DepartmentEmployeeTreeVO> departmentEmployeeTreeVOList = this.buildTreeEmployee(treeVOList, employeeMap);
|
||||
|
||||
return ResponseDTO.ok(departmentEmployeeTreeVOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建每部门的员工信息
|
||||
*
|
||||
* @param treeVOList
|
||||
* @param employeeMap
|
||||
* @return
|
||||
*/
|
||||
private List<DepartmentEmployeeTreeVO> buildTreeEmployee(List<DepartmentTreeVO> treeVOList, Map<Long, List<EmployeeDTO>> employeeMap) {
|
||||
List<DepartmentEmployeeTreeVO> departmentEmployeeTreeVOList = Lists.newArrayList();
|
||||
for (DepartmentTreeVO departmentTreeVO : treeVOList) {
|
||||
DepartmentEmployeeTreeVO departmentEmployeeTreeVO = SmartBeanUtil.copy(departmentTreeVO, DepartmentEmployeeTreeVO.class);
|
||||
departmentEmployeeTreeVO.setEmployees(employeeMap.getOrDefault(departmentEmployeeTreeVO.getId(), Lists.newArrayList()));
|
||||
List<DepartmentTreeVO> children = departmentTreeVO.getChildren();
|
||||
if (CollectionUtils.isEmpty(children)) {
|
||||
continue;
|
||||
}
|
||||
List<DepartmentEmployeeTreeVO> childrenList = this.buildTreeEmployee(children, employeeMap);
|
||||
departmentEmployeeTreeVO.setChildren(childrenList);
|
||||
departmentEmployeeTreeVOList.add(departmentEmployeeTreeVO);
|
||||
}
|
||||
return departmentEmployeeTreeVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有部门和员工信息
|
||||
*
|
||||
* @param departmentName
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTreeByName(String departmentName) {
|
||||
// 获取全部部门列表
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
if (StringUtils.isNotBlank(departmentName)) {
|
||||
// 检索条件不为空的时候 过滤部门列表
|
||||
departmentVOList = this.filterDepartment(departmentVOList, departmentName);
|
||||
}
|
||||
List<DepartmentTreeVO> result = departmentTreeService.buildTree(departmentVOList);
|
||||
return ResponseDTO.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤部门名称,获取过滤后的结果
|
||||
*
|
||||
* @author 开云
|
||||
* @date 2019/4/28 20:17
|
||||
*/
|
||||
private List<DepartmentVO> filterDepartment(List<DepartmentVO> departmentVOList, String departmentName) {
|
||||
Map<Long, DepartmentVO> departmentMap = new HashMap<>(departmentVOList.size());
|
||||
departmentVOList.forEach(item -> {
|
||||
if (!item.getName().contains(departmentName)) {
|
||||
return;
|
||||
}
|
||||
// 当前部门包含关键字
|
||||
departmentMap.put(item.getId(), item);
|
||||
Long parentId = item.getParentId();
|
||||
if (null != parentId) {
|
||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
||||
for (DepartmentVO dto : filterResult) {
|
||||
if (!departmentMap.containsKey(dto.getId())) {
|
||||
departmentMap.put(dto.getId(), dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ArrayList<>(departmentMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取部门的所有上级元素
|
||||
*
|
||||
* @param departmentVOList
|
||||
* @param parentId
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private List<DepartmentVO> getParentDepartment(List<DepartmentVO> departmentVOList, Long parentId, List<DepartmentVO> result) {
|
||||
List<DepartmentVO> deptList = departmentVOList.stream().filter(e -> e.getId().equals(parentId)).collect(Collectors.toList());
|
||||
for (DepartmentVO item : deptList) {
|
||||
result.add(item);
|
||||
if (item.getParentId() != DepartmentConst.DEFAULT_PARENT_ID && item.getParentId() != null) {
|
||||
result.addAll(getParentDepartment(departmentVOList, item.getParentId(), result));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增添加部门
|
||||
*
|
||||
* @param departmentCreateDTO
|
||||
* @return AjaxResult
|
||||
*/
|
||||
|
||||
public ResponseDTO<String> addDepartment(DepartmentCreateDTO departmentCreateDTO) {
|
||||
DepartmentEntity departmentEntity = SmartBeanUtil.copy(departmentCreateDTO, DepartmentEntity.class);
|
||||
departmentEntity.setSort(0L);
|
||||
DepartmentService departmentService = (DepartmentService) AopContext.currentProxy();
|
||||
departmentService.addDepartmentHandle(departmentEntity);
|
||||
departmentCacheManager.clearTreeCache();
|
||||
departmentCacheManager.clearSelfAndChildrenIdCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门数据处理
|
||||
*
|
||||
* @param departmentEntity
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addDepartmentHandle(DepartmentEntity departmentEntity) {
|
||||
departmentDao.insert(departmentEntity);
|
||||
DepartmentEntity updateSortEntity = new DepartmentEntity();
|
||||
updateSortEntity.setId(departmentEntity.getId());
|
||||
updateSortEntity.setSort(departmentEntity.getId());
|
||||
departmentDao.updateById(updateSortEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*
|
||||
* @param updateDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateDepartment(DepartmentUpdateDTO updateDTO) {
|
||||
if (updateDTO.getParentId() == null) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "父级部门id不能为空");
|
||||
}
|
||||
DepartmentEntity entity = departmentDao.selectById(updateDTO.getId());
|
||||
if (entity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity departmentEntity = SmartBeanUtil.copy(updateDTO, DepartmentEntity.class);
|
||||
departmentEntity.setSort(entity.getSort());
|
||||
departmentDao.updateById(departmentEntity);
|
||||
departmentCacheManager.clearTreeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除部门
|
||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> delDepartment(Long deptId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(deptId);
|
||||
if (null == departmentEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
// 是否有子级部门
|
||||
int subDepartmentNum = departmentDao.countSubDepartment(deptId);
|
||||
if (subDepartmentNum > 0) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "请先删除子级部门");
|
||||
}
|
||||
|
||||
// 是否有未删除员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(deptId, false);
|
||||
if (employeeNum > 0) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "请先删除部门员工");
|
||||
}
|
||||
departmentDao.deleteById(deptId);
|
||||
// 清除缓存
|
||||
departmentCacheManager.clearTreeCache();
|
||||
departmentCacheManager.clearSelfAndChildrenIdCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取部门信息
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<DepartmentVO> getDepartmentById(Long departmentId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (departmentEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentVO departmentVO = SmartBeanUtil.copy(departmentEntity, DepartmentVO.class);
|
||||
return ResponseDTO.ok(departmentVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentVO>> listAll() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
return ResponseDTO.ok(departmentVOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下移动
|
||||
*
|
||||
* @param departmentId
|
||||
* @param swapId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> upOrDown(Long departmentId, Long swapId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (departmentEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity swapEntity = departmentDao.selectById(swapId);
|
||||
if (swapEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity updateEntity = new DepartmentEntity();
|
||||
updateEntity.setId(departmentId);
|
||||
updateEntity.setSort(swapEntity.getSort());
|
||||
|
||||
DepartmentEntity swapUpdateEntity = new DepartmentEntity();
|
||||
swapUpdateEntity.setId(swapEntity.getId());
|
||||
swapUpdateEntity.setSort(departmentEntity.getSort());
|
||||
DepartmentService departmentService = (DepartmentService) AopContext.currentProxy();
|
||||
departmentService.upOrDownUpdate(updateEntity, swapEntity);
|
||||
//清除缓存
|
||||
departmentCacheManager.clearTreeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下移动数据库处理
|
||||
*
|
||||
* @param departmentEntity
|
||||
* @param swapEntity
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upOrDownUpdate(DepartmentEntity departmentEntity, DepartmentEntity swapEntity) {
|
||||
departmentDao.updateById(departmentEntity);
|
||||
departmentDao.updateById(swapEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门升级
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> upgrade(Long departmentId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (departmentEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
if (departmentEntity.getParentId() == null || departmentEntity.getParentId().equals(DepartmentConst.DEFAULT_PARENT_ID)) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "此部门已经是根节点无法移动");
|
||||
}
|
||||
DepartmentEntity parentEntity = departmentDao.selectById(departmentEntity.getParentId());
|
||||
|
||||
DepartmentEntity updateEntity = new DepartmentEntity();
|
||||
updateEntity.setId(departmentId);
|
||||
updateEntity.setParentId(parentEntity.getParentId());
|
||||
departmentDao.updateById(updateEntity);
|
||||
//清除缓存
|
||||
departmentCacheManager.clearTreeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门降级
|
||||
*
|
||||
* @param departmentId
|
||||
* @param preId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> downgrade(Long departmentId, Long preId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (departmentEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity preEntity = departmentDao.selectById(preId);
|
||||
if (preEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity updateEntity = new DepartmentEntity();
|
||||
updateEntity.setId(departmentId);
|
||||
updateEntity.setParentId(preEntity.getId());
|
||||
departmentDao.updateById(updateEntity);
|
||||
//清除缓存
|
||||
departmentCacheManager.clearTreeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取校区列表 即第二级部门列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentVO>> querySchoolList() {
|
||||
ResponseDTO<List<DepartmentTreeVO>> res = departmentTree();
|
||||
if (!res.getOk()) {
|
||||
return ResponseDTO.error(res);
|
||||
}
|
||||
List<DepartmentTreeVO> data = res.getData();
|
||||
// 拿到第二级部门列表
|
||||
List<DepartmentVO> resList = Lists.newArrayList();
|
||||
for (DepartmentTreeVO tree : data) {
|
||||
List<DepartmentTreeVO> children = tree.getChildren();
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
resList.addAll(SmartBeanUtil.copyList(children, DepartmentVO.class));
|
||||
}
|
||||
}
|
||||
return ResponseDTO.ok(resList);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentAddForm;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentUpdateForm;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.service.DepartmentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Api(tags = {SwaggerTagConst.System.DEPARTMENT})
|
||||
@RestController
|
||||
public class DepartmentController extends SystemBaseController {
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@ApiOperation(value = "查询部门树形列表 @author zhuoda")
|
||||
@GetMapping("/department/treeList")
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTree() {
|
||||
return departmentService.departmentTree();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "添加部门 @author zhuoda")
|
||||
@PostMapping("/department/add")
|
||||
public ResponseDTO<String> addDepartment(@Valid @RequestBody DepartmentAddForm createDTO) {
|
||||
return departmentService.addDepartment(createDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新部门 @author zhuoda")
|
||||
@PostMapping("/department/update")
|
||||
public ResponseDTO<String> updateDepartment(@Valid @RequestBody DepartmentUpdateForm updateDTO) {
|
||||
return departmentService.updateDepartment(updateDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除部门 @author zhuoda")
|
||||
@GetMapping("/department/delete/{departmentId}")
|
||||
public ResponseDTO<String> deleteDepartment(@PathVariable Long departmentId) {
|
||||
return departmentService.deleteDepartment(departmentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询部门列表 @author zhuoda")
|
||||
@GetMapping("/department/listAll")
|
||||
public ResponseDTO<List<DepartmentVO>> listAll() {
|
||||
return departmentService.listAll();
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,15 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
package net.lab1024.smartadmin.service.module.system.department.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* t_department dao接口
|
||||
*
|
||||
* @author listen
|
||||
* @date 2017/12/19 10:58
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
@ -22,23 +18,15 @@ public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
/**
|
||||
* 根据部门id,查询此部门直接子部门的数量
|
||||
*
|
||||
* @param deptId
|
||||
* @param departmentId
|
||||
* @return int 子部门的数量
|
||||
*/
|
||||
Integer countSubDepartment(@Param("deptId") Long deptId);
|
||||
Integer countSubDepartment(@Param("departmentId") Long departmentId);
|
||||
|
||||
/**
|
||||
* 获取全部部门列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentVO> listAll();
|
||||
|
||||
/**
|
||||
* 获取根据父级ID查询部门列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentVO> queryByParentId(@Param("parentId") Long parentId);
|
||||
|
||||
}
|
@ -29,11 +29,6 @@ public class DepartmentEntity {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 部门简称
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 负责人员工 id
|
||||
*/
|
||||
@ -47,7 +42,7 @@ public class DepartmentEntity {
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Long sort;
|
||||
private Integer sort;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,33 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 部门实体类
|
||||
* t_department 数据表
|
||||
*
|
||||
* @author listen
|
||||
* @date 2017/12/19 10:45
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "t_department_third")
|
||||
public class DepartmentThirdEntity {
|
||||
|
||||
private Long departmentId;
|
||||
/**
|
||||
* {@link net.lab1024.smartadmin.mq.constant.XmfCrmPlatformEnum}
|
||||
*/
|
||||
private Integer platformType;
|
||||
/**
|
||||
* 第三方平台部门id
|
||||
*/
|
||||
private Long thirdDepartmentId;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.department.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -9,19 +9,25 @@ import javax.validation.constraints.NotNull;
|
||||
/**
|
||||
*
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*
|
||||
* @version 1.0
|
||||
* @since JDK1.8
|
||||
* @author yandanyang
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
||||
* @date
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentCreateDTO {
|
||||
public class DepartmentAddForm {
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
@Length(min = 1, max = 50, message = "请输入正确的部门名称(1-50个字符)")
|
||||
@NotNull(message = "请输入正确的部门名称(1-50个字符)")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("部门简称")
|
||||
private String shortName;
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = "排序值")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("部门负责人id")
|
||||
private Long managerId;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.department.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -8,10 +8,15 @@ import javax.validation.constraints.NotNull;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
||||
* @date
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentUpdateDTO extends DepartmentCreateDTO {
|
||||
public class DepartmentUpdateForm extends DepartmentAddForm {
|
||||
|
||||
@ApiModelProperty("部门id")
|
||||
@NotNull(message = "部门id不能为空")
|
@ -2,19 +2,19 @@ package net.lab1024.smartadmin.service.module.system.department.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.EmployeeDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @date 2021-01-30 23:57
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentEmployeeTreeVO extends DepartmentVO {
|
||||
|
||||
@ApiModelProperty("部门员工列表")
|
||||
private List<EmployeeDTO> employees;
|
||||
private List<EmployeeVO> employees;
|
||||
|
||||
@ApiModelProperty("子部门")
|
||||
private List<DepartmentEmployeeTreeVO> children;
|
||||
|
@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @date 2021-01-30 23:57
|
||||
*/
|
||||
@Data
|
||||
|
@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @date 2021-01-30 23:57
|
||||
*/
|
||||
@Data
|
||||
@ -35,7 +35,7 @@ public class DepartmentVO {
|
||||
private Long nextId;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Long sort;
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("父级部门名称")
|
||||
private String parentName;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
package net.lab1024.smartadmin.service.module.system.department.manager;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
@ -10,7 +12,7 @@ import java.util.List;
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @author 善逸
|
||||
* @author lihaifan
|
||||
* @date 2021/8/31 17:19
|
||||
*/
|
||||
@Service
|
||||
@ -25,7 +27,11 @@ public class DepartmentManager extends ServiceImpl<DepartmentDao, DepartmentEnti
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchInsertUpdate(List<DepartmentEntity> insertDepartmentList, List<DepartmentEntity> updateDepartmentList) {
|
||||
saveBatch(insertDepartmentList);
|
||||
updateBatchById(updateDepartmentList);
|
||||
if(!CollectionUtils.isEmpty(insertDepartmentList)){
|
||||
saveBatch(insertDepartmentList);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(updateDepartmentList)){
|
||||
updateBatchById(updateDepartmentList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.service;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @date 2021-01-31 0:48
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DepartmentCacheService {
|
||||
|
||||
@Autowired
|
||||
private DepartmentDao departmentDao;
|
||||
|
||||
@Autowired
|
||||
private DepartmentTreeService departmentTreeService;
|
||||
|
||||
/**
|
||||
* 清除自身以及下级的id列表缓存
|
||||
*/
|
||||
@CacheEvict(value = CacheModuleConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE, allEntries = true)
|
||||
public void clearSelfAndChildrenIdCache() {
|
||||
log.info("clear DEPARTMENT_SELF_CHILDREN_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除树结构缓存
|
||||
*/
|
||||
@CacheEvict(value = CacheModuleConst.Department.DEPARTMENT_TREE_CACHE, allEntries = true)
|
||||
public void clearTreeCache() {
|
||||
log.info("clear DEPARTMENT_TREE_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有缓存
|
||||
*/
|
||||
@CacheEvict(value = CacheModuleConst.Department.DEPARTMENT_CACHE, allEntries = true)
|
||||
public void clearDepartmentCache() {
|
||||
log.info("clear DEPARTMENT_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有缓存
|
||||
*/
|
||||
@CacheEvict(value = CacheModuleConst.Department.DEPARTMENT_SCHOOL_CACHE, allEntries = true)
|
||||
public void clearDepartmentSchoolCache() {
|
||||
log.info("clear DEPARTMENT_SCHOOL_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有缓存
|
||||
*/
|
||||
@CacheEvict(value = CacheModuleConst.Department.DEPARTMENT_ROUTE_CACHE, allEntries = true)
|
||||
public void clearDepartmentRouteCache() {
|
||||
log.info("clear DEPARTMENT_ROUTE_CACHE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存部门结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_CACHE)
|
||||
public List<DepartmentVO> departmentCache() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
return departmentVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存部门树结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_TREE_CACHE)
|
||||
public List<DepartmentTreeVO> departmentTreeCache() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
List<DepartmentTreeVO> treeList = departmentTreeService.buildTree(departmentVOList);
|
||||
return treeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存某个部门的下级id列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_SELF_CHILDREN_CACHE)
|
||||
public List<Long> departmentSelfChildrenCache(Long departmentId) {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
List<Long> idList = departmentTreeService.selfAndChildrenIdList(departmentId, departmentVOList);
|
||||
return idList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个部门所属的分校信息
|
||||
*
|
||||
* @param departmentId
|
||||
* @param schoolParentDepartmentId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_SCHOOL_CACHE)
|
||||
public DepartmentVO departmentSchoolCache(Long departmentId, Long schoolParentDepartmentId) {
|
||||
List<DepartmentVO> departmentList = departmentDao.listAll();
|
||||
// 递归寻找校区(第二级)
|
||||
return this.findSchoolDepartmentId(departmentList, departmentId, schoolParentDepartmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 寻找校区ID
|
||||
*
|
||||
* @param departmentList
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
private DepartmentVO findSchoolDepartmentId(List<DepartmentVO> departmentList, Long departmentId, Long schoolParentDepartmentId) {
|
||||
Optional<DepartmentVO> findRes = departmentList.stream().filter(e -> e.getId().equals(departmentId)).findFirst();
|
||||
// 如果查询不到 或者自己本身为最顶级 返回null
|
||||
if (!findRes.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
DepartmentVO departmentVO = findRes.get();
|
||||
if (departmentVO.getParentId().equals(schoolParentDepartmentId)) {
|
||||
return departmentVO;
|
||||
}
|
||||
// 若父级不为最顶级 进入递归
|
||||
return this.findSchoolDepartmentId(departmentList, departmentVO.getParentId(), schoolParentDepartmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门的路径名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_ROUTE_CACHE)
|
||||
public Map<Long, String> departmentRouteCache() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO::getId, Function.identity()));
|
||||
|
||||
Map<Long, String> routeNameMap = Maps.newHashMap();
|
||||
for (DepartmentVO departmentVO : departmentVOList) {
|
||||
String routeName = this.buildRoutePath(departmentVO, departmentMap);
|
||||
routeNameMap.put(departmentVO.getId(), routeName);
|
||||
}
|
||||
|
||||
return routeNameMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建父级考点路径
|
||||
*
|
||||
* @param departmentVO
|
||||
* @param departmentMap
|
||||
*/
|
||||
private String buildRoutePath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
||||
if (departmentVO.getParentId() == DepartmentService.DEFAULT_PARENT_ID) {
|
||||
return departmentVO.getName();
|
||||
}
|
||||
//父节点
|
||||
DepartmentVO parentDepartment = departmentMap.get(departmentVO.getParentId());
|
||||
if (parentDepartment == null) {
|
||||
return departmentVO.getName();
|
||||
}
|
||||
String parentRouteName = buildRoutePath(parentDepartment, departmentMap);
|
||||
return parentRouteName + "/" + departmentVO.getName();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentAddForm;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentUpdateForm;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentEmployeeTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentService {
|
||||
|
||||
static final long DEFAULT_PARENT_ID = 0L;
|
||||
|
||||
@Autowired
|
||||
private DepartmentDao departmentDao;
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
@Autowired
|
||||
private DepartmentCacheService departmentCacheService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取部门树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentTreeVO>> departmentTree() {
|
||||
List<DepartmentTreeVO> treeVOList = departmentCacheService.departmentTreeCache();
|
||||
return ResponseDTO.ok(treeVOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自身以及所有下级的部门id列表
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public List<Long> selfAndChildrenIdList(Long departmentId) {
|
||||
return departmentCacheService.departmentSelfChildrenCache(departmentId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归构建每部门的员工信息
|
||||
*
|
||||
* @param treeVOList
|
||||
* @param employeeMap
|
||||
* @return
|
||||
*/
|
||||
private List<DepartmentEmployeeTreeVO> buildTreeEmployee(List<DepartmentTreeVO> treeVOList, Map<Long, List<EmployeeVO>> employeeMap) {
|
||||
List<DepartmentEmployeeTreeVO> departmentEmployeeTreeVOList = Lists.newArrayList();
|
||||
for (DepartmentTreeVO departmentTreeVO : treeVOList) {
|
||||
DepartmentEmployeeTreeVO departmentEmployeeTreeVO = SmartBeanUtil.copy(departmentTreeVO, DepartmentEmployeeTreeVO.class);
|
||||
departmentEmployeeTreeVO.setEmployees(employeeMap.getOrDefault(departmentEmployeeTreeVO.getId(), Lists.newArrayList()));
|
||||
List<DepartmentTreeVO> children = departmentTreeVO.getChildren();
|
||||
if (CollectionUtils.isEmpty(children)) {
|
||||
continue;
|
||||
}
|
||||
List<DepartmentEmployeeTreeVO> childrenList = this.buildTreeEmployee(children, employeeMap);
|
||||
departmentEmployeeTreeVO.setChildren(childrenList);
|
||||
departmentEmployeeTreeVOList.add(departmentEmployeeTreeVO);
|
||||
}
|
||||
return departmentEmployeeTreeVOList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过滤部门名称,获取过滤后的结果
|
||||
*
|
||||
* @author lidoudou
|
||||
* @date 2019/4/28 20:17
|
||||
*/
|
||||
private List<DepartmentVO> filterDepartment(List<DepartmentVO> departmentVOList, String departmentName) {
|
||||
Map<Long, DepartmentVO> departmentMap = new HashMap<>(departmentVOList.size());
|
||||
departmentVOList.forEach(item -> {
|
||||
if (!item.getName().contains(departmentName)) {
|
||||
return;
|
||||
}
|
||||
// 当前部门包含关键字
|
||||
departmentMap.put(item.getId(), item);
|
||||
Long parentId = item.getParentId();
|
||||
if (null != parentId) {
|
||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
||||
for (DepartmentVO dto : filterResult) {
|
||||
if (!departmentMap.containsKey(dto.getId())) {
|
||||
departmentMap.put(dto.getId(), dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ArrayList<>(departmentMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取部门的所有上级元素
|
||||
*
|
||||
* @param departmentVOList
|
||||
* @param parentId
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private List<DepartmentVO> getParentDepartment(List<DepartmentVO> departmentVOList, Long parentId, List<DepartmentVO> result) {
|
||||
List<DepartmentVO> deptList = departmentVOList.stream().filter(e -> e.getId().equals(parentId)).collect(Collectors.toList());
|
||||
for (DepartmentVO item : deptList) {
|
||||
result.add(item);
|
||||
if (item.getParentId() != DEFAULT_PARENT_ID && item.getParentId() != null) {
|
||||
result.addAll(getParentDepartment(departmentVOList, item.getParentId(), result));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增添加部门
|
||||
*
|
||||
* @param departmentAddForm
|
||||
* @return AjaxResult
|
||||
*/
|
||||
|
||||
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
||||
DepartmentEntity departmentEntity = SmartBeanUtil.copy(departmentAddForm, DepartmentEntity.class);
|
||||
DepartmentService departmentService = (DepartmentService) AopContext.currentProxy();
|
||||
departmentDao.insert(departmentEntity);
|
||||
this.clearCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*
|
||||
* @param updateDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateDepartment(DepartmentUpdateForm updateDTO) {
|
||||
if (updateDTO.getParentId() == null) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "父级部门id不能为空");
|
||||
}
|
||||
DepartmentEntity entity = departmentDao.selectById(updateDTO.getId());
|
||||
if (entity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
DepartmentEntity departmentEntity = SmartBeanUtil.copy(updateDTO, DepartmentEntity.class);
|
||||
departmentEntity.setSort(updateDTO.getSort());
|
||||
departmentDao.updateById(departmentEntity);
|
||||
this.clearCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除部门
|
||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> deleteDepartment(Long departmentId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (null == departmentEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
// 是否有子级部门
|
||||
int subDepartmentNum = departmentDao.countSubDepartment(departmentId);
|
||||
if (subDepartmentNum > 0) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "请先删除子级部门");
|
||||
}
|
||||
|
||||
// 是否有未删除员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(departmentId, false);
|
||||
if (employeeNum > 0) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "请先删除部门员工");
|
||||
}
|
||||
departmentDao.deleteById(departmentId);
|
||||
// 清除缓存
|
||||
this.clearCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<DepartmentVO>> listAll() {
|
||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||
return ResponseDTO.ok(departmentVOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清除自身以及下级的id列表缓存
|
||||
*/
|
||||
private void clearCache() {
|
||||
departmentCacheService.clearDepartmentCache();
|
||||
departmentCacheService.clearSelfAndChildrenIdCache();
|
||||
departmentCacheService.clearTreeCache();
|
||||
departmentCacheService.clearDepartmentSchoolCache();
|
||||
departmentCacheService.clearDepartmentRouteCache();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,20 +1,18 @@
|
||||
package net.lab1024.smartadmin.service.module.system.department;
|
||||
package net.lab1024.smartadmin.service.module.system.department.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.constant.StringConst;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentTreeService {
|
||||
@ -29,7 +27,7 @@ public class DepartmentTreeService {
|
||||
if (CollectionUtils.isEmpty(voList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<DepartmentVO> rootList = voList.stream().filter(e -> e.getParentId() == null || e.getParentId() == DepartmentConst.DEFAULT_PARENT_ID).collect(Collectors.toList());
|
||||
List<DepartmentVO> rootList = voList.stream().filter(e -> e.getParentId() == null || Objects.equals(e.getParentId(), DepartmentService.DEFAULT_PARENT_ID)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(rootList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.constant.CacheModuleConst;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.RoleEmployeeDao;
|
||||
import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @date 2021-01-30 23:57
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EmployeeCacheManager {
|
||||
public class EmployeeCacheService {
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
@Autowired
|
||||
private RoleEmployeeDao roleEmployeeDao;
|
||||
|
||||
@ -34,23 +34,30 @@ public class EmployeeCacheManager {
|
||||
*/
|
||||
@CacheEvict({CacheModuleConst.Employee.SINGLE_EMPLOYEE_CACHE, CacheModuleConst.Employee.SINGLE_EMPLOYEE_ROLE_CACHE})
|
||||
public void clearCacheByEmployeeId(Long employeeId) {
|
||||
log.info("clear SINGLE_EMPLOYEE_CACHE and SINGLE_EMPLOYEE_ROLE_CACHE {}",employeeId);
|
||||
log.info("clear SINGLE_EMPLOYEE_CACHE and SINGLE_EMPLOYEE_ROLE_CACHE {}", employeeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除businessId为部门id的缓存信息
|
||||
*
|
||||
* @param departmentId
|
||||
*/
|
||||
@CacheEvict({CacheModuleConst.Employee.DEPARTMENT_EMPLOYEE_CACHE})
|
||||
public void clearCacheByDepartmentId(Long departmentId) {
|
||||
log.info("clear DEPARTMENT_EMPLOYEE_CACHE {}",departmentId);
|
||||
log.info("clear DEPARTMENT_EMPLOYEE_CACHE {}", departmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存某个部门下的员工
|
||||
* cacheKey = CacheKeyConst.Employee
|
||||
* businessId = departmentId
|
||||
*
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(CacheModuleConst.Employee.DEPARTMENT_EMPLOYEE_CACHE)
|
||||
public List<EmployeeEntity> departmentEmployeeCache(Long departmentId) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, false, false);
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, null, null, false);
|
||||
return employeeEntityList;
|
||||
}
|
||||
|
||||
@ -73,7 +80,7 @@ public class EmployeeCacheManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个员工的角色缓存
|
||||
* 单个员工的缓存
|
||||
*
|
||||
* @param employeeId
|
||||
* @return
|
@ -1,15 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee;
|
||||
|
||||
/**
|
||||
* @author 罗伊
|
||||
* @date 2021-01-31 0:00
|
||||
*/
|
||||
class EmployeeConst {
|
||||
|
||||
static final class Password {
|
||||
|
||||
static final String DEFAULT = "123456";
|
||||
|
||||
static final String SALT_FORMAT = "smartAdmin_%s";
|
||||
}
|
||||
}
|
@ -2,15 +2,16 @@ package net.lab1024.smartadmin.service.module.system.employee;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.service.common.swagger.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.*;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartEmployeeTokenUtil;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import net.lab1024.smartadmin.service.common.annoation.NoValidPrivilege;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.form.*;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
@ -18,96 +19,79 @@ import java.util.List;
|
||||
/**
|
||||
* 员工管理
|
||||
*
|
||||
* @author 开云
|
||||
* @date 2017年12月19日上午11:34:52
|
||||
* @author zhuoda
|
||||
* @date 2021年09月19日上午21:34:52
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_EMPLOYEE})
|
||||
@Api(tags = {SwaggerTagConst.System.EMPLOYEE})
|
||||
public class EmployeeController extends SystemBaseController {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@PostMapping("/employee/query")
|
||||
@ApiOperation(value = "员工管理查询", notes = "员工管理查询 @author 开云")
|
||||
public ResponseDTO<PageResultDTO<EmployeeVO>> query(@Valid @RequestBody EmployeeQueryForm query) {
|
||||
return employeeService.queryEmployeeList(query);
|
||||
@ApiOperation(value = "员工管理查询 @author zhuoda")
|
||||
public ResponseDTO<PageResult<EmployeeVO>> query(@Valid @RequestBody EmployeeQueryForm query) {
|
||||
return employeeService.queryEmployee(query);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加员工", notes = "@author 罗伊")
|
||||
@ApiOperation(value = "添加员工 @author zhuoda")
|
||||
@PostMapping("/employee/add")
|
||||
public ResponseDTO<String> addEmployee(@Valid @RequestBody EmployeeAddDTO addDTO) {
|
||||
addDTO.setUpdateId(SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
return employeeService.addEmployee(addDTO);
|
||||
public ResponseDTO<String> addEmployee(@Valid @RequestBody EmployeeAddForm employeeAddForm) {
|
||||
employeeAddForm.setUpdateId(SmartRequestUtil.getRequestEmployeeId());
|
||||
return employeeService.addEmployee(employeeAddForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新员工禁用状态", notes = "@author 罗伊")
|
||||
@ApiOperation(value = "更新员工 @author zhuoda")
|
||||
@PostMapping("/employee/update")
|
||||
public ResponseDTO<String> updateEmployee(@Valid @RequestBody EmployeeUpdateForm employeeUpdateForm) {
|
||||
employeeUpdateForm.setUpdateId(SmartRequestUtil.getRequestEmployeeId());
|
||||
return employeeService.updateEmployee(employeeUpdateForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新员工禁用/启用状态 @author zhuoda")
|
||||
@GetMapping("/employee/update/disabled/{employeeId}")
|
||||
public ResponseDTO<String> updateDisableFlag(@PathVariable Long employeeId) {
|
||||
return employeeService.updateDisableFlag(employeeId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量更新员工禁用状态", notes = "@author 罗伊")
|
||||
@PostMapping("/employee/update/batch/disabled")
|
||||
public ResponseDTO<String> batchUpdateDisableFlag(@Valid @RequestBody EmployeeDisabledUpdateDTO updateDTO) {
|
||||
return employeeService.batchUpdateDisableFlag(updateDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新员工信息", notes = "@author 罗伊")
|
||||
@PostMapping("/employee/update")
|
||||
public ResponseDTO<String> updateEmployee(@Valid @RequestBody EmployeeUpdateDTO updateDTO) {
|
||||
updateDTO.setUpdateId(SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
return employeeService.updateEmployee(updateDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除员工", notes = "@author 罗伊")
|
||||
@GetMapping("/employee/delete/{employeeId}")
|
||||
public ResponseDTO<String> deleteEmployeeById(@PathVariable Long employeeId) {
|
||||
return employeeService.deleteEmployeeById(employeeId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除员工", notes = "@author 善逸")
|
||||
@ApiOperation(value = "批量删除员工 @author zhuoda")
|
||||
@GetMapping("/employee/update/batch/delete")
|
||||
public ResponseDTO<String> batchUpdateDeleteFlag(@RequestParam("employeeIdList")List<Long> employeeIdList) {
|
||||
public ResponseDTO<String> batchUpdateDeleteFlag(@RequestParam("employeeIdList") List<Long> employeeIdList) {
|
||||
return employeeService.batchUpdateDeleteFlag(employeeIdList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量调整员工部门", notes = "@author 善逸")
|
||||
@ApiOperation(value = "批量调整员工部门 @author zhuoda")
|
||||
@PostMapping("/employee/update/batch/department")
|
||||
public ResponseDTO<String> batchUpdateDepartment(@Valid @RequestBody EmployeeDepartmentUpdateDTO updateDto) {
|
||||
return employeeService.batchUpdateDepartment(updateDto);
|
||||
public ResponseDTO<String> batchUpdateDepartment(@Valid @RequestBody EmployeeBatchUpdateDepartmentForm batchUpdateDepartmentForm) {
|
||||
return employeeService.batchUpdateDepartment(batchUpdateDepartmentForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "单个员工角色授权", notes = "@author 罗伊")
|
||||
@PostMapping("/employee/update/roles")
|
||||
public ResponseDTO<String> updateRoles(@Valid @RequestBody EmployeeRoleUpdateDTO updateRolesDTO) {
|
||||
return employeeService.updateRole(updateRolesDTO);
|
||||
@ApiOperation(value = "修改密码 @author zhuoda")
|
||||
@PostMapping("/employee/update/password")
|
||||
@NoValidPrivilege
|
||||
public ResponseDTO<String> updatePassword(@Valid @RequestBody EmployeeUpdatePasswordForm updatePasswordForm) {
|
||||
updatePasswordForm.setEmployeeId(SmartRequestUtil.getRequestEmployeeId());
|
||||
return employeeService.updatePassword(updatePasswordForm);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码", notes = "@author 罗伊")
|
||||
@PostMapping("/employee/update/pwd")
|
||||
public ResponseDTO<String> updatePwd(@Valid @RequestBody EmployeeUpdatePwdDTO updatePwdDTO) {
|
||||
updatePwdDTO.setEmployeeId(SmartEmployeeTokenUtil.getRequestEmployeeId());
|
||||
return employeeService.updatePwd(updatePwdDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询员工-根据部门id", notes = "@author 罗伊")
|
||||
@GetMapping("/employee/query/dept/{deptId}")
|
||||
public ResponseDTO<List<EmployeeVO>> listByDepartmentId(@PathVariable Long deptId) {
|
||||
return employeeService.getEmployeeByDeptId(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有员工 by 善逸")
|
||||
@GetMapping("/employee/queryAll")
|
||||
public ResponseDTO<List<EmployeeVO>> queryAllEmploy(@RequestParam(value = "disabledFlag", required = false) Boolean disabledFlag) {
|
||||
return employeeService.queryAllEmploy(disabledFlag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "重置员工密码", notes = "@author 罗伊")
|
||||
@GetMapping("/employee/update/pwd/reset/{employeeId}")
|
||||
@ApiOperation(value = "重置员工密码 @author zhuoda")
|
||||
@GetMapping("/employee/update/password/reset/{employeeId}")
|
||||
public ResponseDTO<String> resetPassword(@PathVariable Integer employeeId) {
|
||||
return employeeService.resetPassword(employeeId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询员工-根据部门id @author zhuoda")
|
||||
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
|
||||
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE);
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有员工 @author zhuoda")
|
||||
@GetMapping("/employee/queryAll")
|
||||
public ResponseDTO<List<EmployeeVO>> queryAllEmployee(@RequestParam(value = "disabledFlag", required = false) Boolean disabledFlag) {
|
||||
return employeeService.queryAllEmployee(disabledFlag, SmartRequestUtil.getRequestEmployee());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,12 @@ package net.lab1024.smartadmin.service.module.system.employee;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.form.EmployeeQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.EmployeeDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.EmployeeQueryForm;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -16,7 +15,7 @@ import java.util.List;
|
||||
/**
|
||||
* 员工dao接口
|
||||
*
|
||||
* @author 开云
|
||||
* @author lidoudou
|
||||
* @date 2017年12月19日下午1:36:30
|
||||
*/
|
||||
@Mapper
|
||||
@ -26,27 +25,19 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* 查询员工列表
|
||||
*
|
||||
* @param page
|
||||
* @param queryDTO
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeVO> queryEmployee(Page page, @Param("queryDTO") EmployeeQueryForm queryDTO);
|
||||
List<EmployeeVO> queryEmployee(Page page, @Param("queryForm") EmployeeQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 查询员工列表
|
||||
* 查询员工
|
||||
*
|
||||
* @param queryDTO
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeVO> queryEmployee(@Param("queryDTO") EmployeeQueryForm queryDTO);
|
||||
List<EmployeeVO> queryEmployee(@Param("queryForm") EmployeeQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 批量更新禁用状态
|
||||
*
|
||||
* @param employeeIdList
|
||||
* @param disabledFlag
|
||||
*/
|
||||
void batchUpdateDisableFlag(@Param("employeeIdList") List<Long> employeeIdList,
|
||||
@Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 更新单个
|
||||
@ -56,17 +47,6 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
*/
|
||||
void updateDisableFlag(@Param("id") Long id, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 根据 账号 密码 查询
|
||||
*
|
||||
* @param loginName
|
||||
* @param loginPwd
|
||||
* @param deletedFlag
|
||||
* @return
|
||||
*/
|
||||
EmployeeEntity selectByLoginNameAndPwd(@Param("loginName") String loginName,
|
||||
@Param("loginPwd") String loginPwd,
|
||||
@Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 通过登录名查询
|
||||
@ -75,9 +55,20 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* @param disabledFlag
|
||||
* @return
|
||||
*/
|
||||
EmployeeDTO getByLoginName(@Param("loginName") String loginName,
|
||||
@Param("disabledFlag") Boolean disabledFlag,
|
||||
@Param("deletedFlag") Boolean deletedFlag);
|
||||
EmployeeEntity getByLoginName(@Param("loginName") String loginName,
|
||||
@Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
|
||||
/**
|
||||
* 通过姓名查询
|
||||
*
|
||||
* @param actualName
|
||||
* @param disabledFlag
|
||||
* @return
|
||||
*/
|
||||
EmployeeEntity getByActualName(@Param("actualName") String actualName,
|
||||
@Param("disabledFlag") Boolean disabledFlag
|
||||
);
|
||||
|
||||
/**
|
||||
* 通过手机号查询
|
||||
@ -86,23 +77,22 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* @param disabledFlag
|
||||
* @return
|
||||
*/
|
||||
EmployeeDTO getByPhone(@Param("phone") String phone, @Param("disabledFlag") Boolean disabledFlag);
|
||||
EmployeeEntity getByPhone(@Param("phone") String phone, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 获取所有员工
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeDTO> listAll();
|
||||
List<EmployeeVO> listAll();
|
||||
|
||||
/**
|
||||
* 获取某个部门员工数
|
||||
*
|
||||
* @param departmentId
|
||||
* @param deletedFlag 可以null
|
||||
* @return
|
||||
*/
|
||||
Integer countByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
|
||||
Integer countByDepartmentId(@Param("departmentId") Long departmentId);
|
||||
|
||||
/**
|
||||
* 获取一批员工
|
||||
@ -110,7 +100,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* @param employeeIds
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeDTO> getEmployeeByIds(@Param("ids") Collection<Long> employeeIds);
|
||||
List<EmployeeVO> getEmployeeByIds(@Param("ids") Collection<Long> employeeIds);
|
||||
|
||||
|
||||
/**
|
||||
@ -119,7 +109,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
EmployeeDTO getEmployeeById(@Param("id") Long employeeId);
|
||||
EmployeeVO getEmployeeById(@Param("id") Long employeeId);
|
||||
|
||||
|
||||
/**
|
||||
@ -127,10 +117,21 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
*
|
||||
* @param departmentId
|
||||
* @param disabledFlag
|
||||
* @param deletedFlag
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
|
||||
/**
|
||||
* 查询某些部门下用户名是xxx的员工
|
||||
*
|
||||
* @param departmentIdList
|
||||
* @param actualName
|
||||
* @param disabledFlag
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeEntity> selectByActualName(@Param("departmentIdList") List<Long> departmentIdList, @Param("actualName") String actualName, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
|
||||
/**
|
||||
* 获取某批部门的员工Id
|
||||
@ -138,24 +139,25 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
* @param departmentIds
|
||||
* @return
|
||||
*/
|
||||
List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 获取所有
|
||||
*
|
||||
* @param leaveFlag
|
||||
* @param disabledFlag
|
||||
* @param deletedFlag
|
||||
* @return
|
||||
*/
|
||||
List<Long> getEmployeeId( @Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
List<Long> getEmployeeId(@Param("leaveFlag") Boolean leaveFlag, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 获取某个部门的员工Id
|
||||
*
|
||||
* @param departmentId
|
||||
* @param disabledFlag
|
||||
* @param deletedFlag
|
||||
* @return
|
||||
*/
|
||||
List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
/**
|
||||
* 员工重置密码
|
||||
|
@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.RoleEmployeeManager;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.domain.RoleEmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleEmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.role.manager.RoleEmployeeManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -16,7 +16,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 员工 manager
|
||||
*
|
||||
* @author 胡克
|
||||
* @author Turbolisten
|
||||
* @date 2021/7/28 19:15
|
||||
*/
|
||||
@Service
|
||||
|
@ -3,41 +3,43 @@ package net.lab1024.smartadmin.service.module.system.employee;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||
import net.lab1024.smartadmin.service.module.system.department.DepartmentDao;
|
||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.dto.*;
|
||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||
import net.lab1024.smartadmin.service.module.system.department.service.DepartmentCacheService;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.form.*;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginBO;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.menu.MenuEmployeeService;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.RoleEmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.role.roleemployee.domain.RoleEmployeeEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.LoginUserDetail;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
||||
import net.lab1024.smartadmin.service.module.system.menu.service.MenuEmployeeService;
|
||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
||||
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleEmployeeVO;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工管理
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @date 2021年01月21日上午11:54:52
|
||||
*/
|
||||
@Service
|
||||
public class EmployeeService {
|
||||
|
||||
private static final String DEFAULT_PASSWORD = "123456";
|
||||
|
||||
private static final String PASSWORD_SALT_FORMAT = "smart_%_admin_$%^&*";
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
@ -54,7 +56,9 @@ public class EmployeeService {
|
||||
private RoleEmployeeDao roleEmployeeDao;
|
||||
|
||||
@Autowired
|
||||
private EmployeeCacheManager employeeCacheManager;
|
||||
private EmployeeCacheService employeeCacheService;
|
||||
@Autowired
|
||||
private DepartmentCacheService departmentCacheService;
|
||||
|
||||
/**
|
||||
* 获取员工登录信息
|
||||
@ -62,12 +66,13 @@ public class EmployeeService {
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
public EmployeeLoginInfoDTO getById(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeCacheManager.singleEmployeeCache(employeeId);
|
||||
List<Long> roleIdList = employeeCacheManager.singleEmployeeRoleCache(employeeId);
|
||||
public RequestEmployee getById(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeCacheService.singleEmployeeCache(employeeId);
|
||||
//获取员工角色缓存
|
||||
List<Long> roleIdList = employeeCacheService.singleEmployeeRoleCache(employeeId);
|
||||
if (employeeEntity != null) {
|
||||
Boolean isSuperman = menuEmployeeService.isSuperman(employeeId);
|
||||
EmployeeLoginInfoDTO loginDTO = SmartBeanUtil.copy(employeeEntity, EmployeeLoginInfoDTO.class);
|
||||
RequestEmployee loginDTO = SmartBeanUtil.copy(employeeEntity, RequestEmployee.class);
|
||||
loginDTO.setEmployeeId(employeeId);
|
||||
loginDTO.setIsSuperMan(isSuperman);
|
||||
loginDTO.setRoleList(roleIdList);
|
||||
@ -82,78 +87,88 @@ public class EmployeeService {
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
public EmployeeLoginBO getBoById(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeCacheManager.singleEmployeeCache(employeeId);
|
||||
List<Long> roleIdList = employeeCacheManager.singleEmployeeRoleCache(employeeId);
|
||||
if (employeeEntity != null) {
|
||||
Boolean isSuperman = menuEmployeeService.isSuperman(employeeId);
|
||||
EmployeeLoginBO loginDTO = SmartBeanUtil.copy(employeeEntity, EmployeeLoginBO.class);
|
||||
loginDTO.setEmployeeId(employeeId);
|
||||
loginDTO.setIsSuperMan(isSuperman);
|
||||
loginDTO.setRoleList(roleIdList);
|
||||
return loginDTO;
|
||||
public LoginUserDetail getBoById(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeCacheService.singleEmployeeCache(employeeId);
|
||||
//获取员工角色缓存
|
||||
List<Long> roleIdList = employeeCacheService.singleEmployeeRoleCache(employeeId);
|
||||
if (employeeEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
Boolean isSuperman = menuEmployeeService.isSuperman(employeeId);
|
||||
LoginUserDetail loginDTO = SmartBeanUtil.copy(employeeEntity, LoginUserDetail.class);
|
||||
loginDTO.setEmployeeId(employeeId);
|
||||
loginDTO.setIsSuperMan(isSuperman);
|
||||
loginDTO.setRoleList(roleIdList);
|
||||
return loginDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询员工列表
|
||||
*
|
||||
* @param queryDTO
|
||||
* @param employeeQueryForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<PageResultDTO<EmployeeVO>> queryEmployeeList(EmployeeQueryForm queryDTO) {
|
||||
queryDTO.setDeletedFlag(false);
|
||||
Page pageParam = SmartPageUtil.convert2PageQuery(queryDTO);
|
||||
List<EmployeeVO> employeeList = employeeDao.queryEmployee(pageParam, queryDTO);
|
||||
public ResponseDTO<PageResult<EmployeeVO>> queryEmployee(EmployeeQueryForm employeeQueryForm) {
|
||||
Page pageParam = SmartPageUtil.convert2PageQuery(employeeQueryForm);
|
||||
List<EmployeeVO> employeeList = employeeDao.queryEmployee(pageParam, employeeQueryForm);
|
||||
if (CollectionUtils.isEmpty(employeeList)) {
|
||||
PageResultDTO<EmployeeVO> pageResultDTO = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<EmployeeVO> PageResult = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
||||
return ResponseDTO.ok(PageResult);
|
||||
}
|
||||
// 查询员工角色
|
||||
|
||||
List<Long> employeeIdList = employeeList.stream().map(EmployeeVO::getId).collect(Collectors.toList());
|
||||
List<RoleEmployeeEntity> roleEmployeeEntityList = roleEmployeeDao.selectRoleIdByEmployeeIdList(employeeIdList);
|
||||
Map<Long, List<Long>> employeeRoleIdListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeEntity::getEmployeeId, Collectors.mapping(RoleEmployeeEntity::getRoleId, Collectors.toList())));
|
||||
// 写入角色ID
|
||||
// 查询员工角色
|
||||
List<RoleEmployeeVO> roleEmployeeEntityList = roleEmployeeDao.selectRoleByEmployeeIdList(employeeIdList);
|
||||
Map<Long, List<Long>> employeeRoleIdListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleId, Collectors.toList())));
|
||||
Map<Long, List<String>> employeeRoleNameListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleName, Collectors.toList())));
|
||||
// 查询员工部门
|
||||
Map<Long, String> departmentNameMap = departmentCacheService.departmentRouteCache();
|
||||
|
||||
employeeList.forEach(e -> {
|
||||
e.setRoleIdList(employeeRoleIdListMap.getOrDefault(e.getId(), Lists.newArrayList()));
|
||||
e.setRoleNameList(employeeRoleNameListMap.getOrDefault(e.getId(), Lists.newArrayList()));
|
||||
e.setDepartmentName(departmentNameMap.getOrDefault(e.getDepartmentId(), ""));
|
||||
});
|
||||
PageResultDTO<EmployeeVO> pageResultDTO = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
||||
return ResponseDTO.ok(pageResultDTO);
|
||||
PageResult<EmployeeVO> PageResult = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
||||
return ResponseDTO.ok(PageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增员工
|
||||
*
|
||||
* @param addDTO
|
||||
* @param employeeAddForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> addEmployee(EmployeeAddDTO addDTO) {
|
||||
public synchronized ResponseDTO<String> addEmployee(EmployeeAddForm employeeAddForm) {
|
||||
// 校验名称是否重复
|
||||
EmployeeDTO employeeDTO = employeeDao.getByLoginName(addDTO.getLoginName(), false, false);
|
||||
if (null != employeeDTO) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "员工名称重复");
|
||||
EmployeeEntity employeeEntity = employeeDao.getByLoginName(employeeAddForm.getLoginName(), false);
|
||||
if (null != employeeEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "登录名重复");
|
||||
}
|
||||
// 校验姓名是否重复
|
||||
employeeEntity = employeeDao.getByActualName(employeeAddForm.getActualName(), false);
|
||||
if (null != employeeEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "姓名重复");
|
||||
}
|
||||
// 校验电话是否存在
|
||||
employeeDTO = employeeDao.getByPhone(addDTO.getPhone(), false);
|
||||
if (null != employeeDTO) {
|
||||
employeeEntity = employeeDao.getByPhone(employeeAddForm.getPhone(), false);
|
||||
if (null != employeeEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "手机号已存在");
|
||||
}
|
||||
// 部门是否存在
|
||||
Long departmentId = addDTO.getDepartmentId();
|
||||
Long departmentId = employeeAddForm.getDepartmentId();
|
||||
DepartmentEntity department = departmentDao.selectById(departmentId);
|
||||
if (department == null) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "部门不存在");
|
||||
}
|
||||
|
||||
EmployeeEntity entity = SmartBeanUtil.copy(addDTO, EmployeeEntity.class);
|
||||
EmployeeEntity entity = SmartBeanUtil.copy(employeeAddForm, EmployeeEntity.class);
|
||||
// 设置密码 默认密码
|
||||
entity.setLoginPwd(getEncryptPwd(null));
|
||||
entity.setLoginPwd(getEncryptPwd(DEFAULT_PASSWORD));
|
||||
|
||||
// 保存数据
|
||||
employeeManager.saveEmployee(entity, addDTO.getRoleIdList());
|
||||
|
||||
employeeCacheManager.clearCacheByDepartmentId(departmentId);
|
||||
employeeManager.saveEmployee(entity, employeeAddForm.getRoleIdList());
|
||||
employeeCacheService.clearCacheByDepartmentId(departmentId);
|
||||
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
@ -161,45 +176,56 @@ public class EmployeeService {
|
||||
/**
|
||||
* 更新员工
|
||||
*
|
||||
* @param updateDTO
|
||||
* @param employeeUpdateForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateEmployee(EmployeeUpdateDTO updateDTO) {
|
||||
Long employeeId = updateDTO.getId();
|
||||
public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employeeUpdateForm) {
|
||||
|
||||
Long employeeId = employeeUpdateForm.getId();
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
if (null == employeeEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
Long departmentId = updateDTO.getDepartmentId();
|
||||
|
||||
// 部门是否存在
|
||||
Long departmentId = employeeUpdateForm.getDepartmentId();
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);
|
||||
if (departmentEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "部门不存在");
|
||||
}
|
||||
EmployeeDTO employeeDTO = employeeDao.getByLoginName(updateDTO.getLoginName(), false, false);
|
||||
if (null != employeeDTO && !Objects.equals(employeeDTO.getId(), employeeId)) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
|
||||
|
||||
EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), false);
|
||||
if (null != existEntity && !Objects.equals(existEntity.getId(), employeeId)) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "登录名重复");
|
||||
}
|
||||
employeeDTO = employeeDao.getByPhone(updateDTO.getLoginName(), false);
|
||||
if (null != employeeDTO && !Objects.equals(employeeDTO.getId(), employeeId)) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
|
||||
existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), false);
|
||||
if (null != existEntity && !Objects.equals(existEntity.getId(), employeeId)) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "手机号已存在");
|
||||
}
|
||||
|
||||
existEntity = employeeDao.getByActualName(employeeUpdateForm.getActualName(), false);
|
||||
if (null != existEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "姓名重复");
|
||||
}
|
||||
|
||||
// 不更新密码
|
||||
EmployeeEntity entity = SmartBeanUtil.copy(updateDTO, EmployeeEntity.class);
|
||||
EmployeeEntity entity = SmartBeanUtil.copy(employeeUpdateForm, EmployeeEntity.class);
|
||||
entity.setLoginPwd(null);
|
||||
|
||||
// 更新数据
|
||||
employeeManager.updateEmployee(entity, updateDTO.getRoleIdList());
|
||||
employeeManager.updateEmployee(entity, employeeUpdateForm.getRoleIdList());
|
||||
|
||||
// 清除缓存
|
||||
employeeCacheManager.clearCacheByEmployeeId(employeeId);
|
||||
employeeCacheManager.clearCacheByDepartmentId(departmentId);
|
||||
employeeCacheService.clearCacheByEmployeeId(employeeId);
|
||||
employeeCacheService.clearCacheByDepartmentId(departmentId);
|
||||
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新禁用状态
|
||||
* 更新禁用/启用状态
|
||||
*
|
||||
* @param employeeId
|
||||
* @return
|
||||
@ -215,33 +241,11 @@ public class EmployeeService {
|
||||
|
||||
employeeDao.updateDisableFlag(employeeId, !employeeEntity.getDisabledFlag());
|
||||
|
||||
employeeCacheManager.clearCacheByEmployeeId(employeeId);
|
||||
employeeCacheManager.clearCacheByDepartmentId(employeeEntity.getDepartmentId());
|
||||
employeeCacheService.clearCacheByEmployeeId(employeeId);
|
||||
employeeCacheService.clearCacheByDepartmentId(employeeEntity.getDepartmentId());
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新员工状态
|
||||
*
|
||||
* @param batchUpdateStatusDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> batchUpdateDisableFlag(EmployeeDisabledUpdateDTO batchUpdateStatusDTO) {
|
||||
List<Long> employeeIdList = batchUpdateStatusDTO.getEmployeeIdList();
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectBatchIds(employeeIdList);
|
||||
if (employeeIdList.size() != employeeEntityList.size()) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
|
||||
employeeDao.batchUpdateDisableFlag(employeeIdList, batchUpdateStatusDTO.getDisabledFlag());
|
||||
|
||||
// 清除缓存
|
||||
employeeEntityList.forEach(e -> {
|
||||
employeeCacheManager.clearCacheByEmployeeId(e.getId());
|
||||
employeeCacheManager.clearCacheByDepartmentId(e.getDepartmentId());
|
||||
});
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除员工
|
||||
@ -257,8 +261,9 @@ public class EmployeeService {
|
||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
// 更新删除
|
||||
List<EmployeeEntity> deleteList = employeeIdList.stream().map(e -> {
|
||||
// 更新删除
|
||||
EmployeeEntity updateEmployee = new EmployeeEntity();
|
||||
updateEmployee.setId(e);
|
||||
updateEmployee.setDeletedFlag(true);
|
||||
@ -268,42 +273,21 @@ public class EmployeeService {
|
||||
|
||||
// 清除缓存
|
||||
employeeEntityList.forEach(e -> {
|
||||
employeeCacheManager.clearCacheByEmployeeId(e.getId());
|
||||
employeeCacheManager.clearCacheByDepartmentId(e.getDepartmentId());
|
||||
employeeCacheService.clearCacheByEmployeeId(e.getId());
|
||||
employeeCacheService.clearCacheByDepartmentId(e.getDepartmentId());
|
||||
});
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工
|
||||
*
|
||||
* @param employeeId 员工ID
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> deleteEmployeeById(Long employeeId) {
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
if (null == employeeEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
// 更新删除
|
||||
EmployeeEntity updateEmployee = new EmployeeEntity();
|
||||
updateEmployee.setId(employeeId);
|
||||
updateEmployee.setDeletedFlag(true);
|
||||
employeeDao.updateById(updateEmployee);
|
||||
|
||||
employeeCacheManager.clearCacheByEmployeeId(employeeId);
|
||||
employeeCacheManager.clearCacheByDepartmentId(employeeEntity.getDepartmentId());
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新部门
|
||||
*
|
||||
* @param updateDto
|
||||
* @param batchUpdateDepartmentForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> batchUpdateDepartment(EmployeeDepartmentUpdateDTO updateDto) {
|
||||
List<Long> employeeIdList = updateDto.getEmployeeIdList();
|
||||
public ResponseDTO<String> batchUpdateDepartment(EmployeeBatchUpdateDepartmentForm batchUpdateDepartmentForm) {
|
||||
List<Long> employeeIdList = batchUpdateDepartmentForm.getEmployeeIdList();
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectBatchIds(employeeIdList);
|
||||
if (employeeIdList.size() != employeeEntityList.size()) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
@ -313,70 +297,49 @@ public class EmployeeService {
|
||||
// 更新删除
|
||||
EmployeeEntity updateEmployee = new EmployeeEntity();
|
||||
updateEmployee.setId(e);
|
||||
updateEmployee.setDepartmentId(updateDto.getDepartmentId());
|
||||
updateEmployee.setDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
||||
return updateEmployee;
|
||||
}).collect(Collectors.toList());
|
||||
employeeManager.updateBatchById(updateList);
|
||||
|
||||
// 清除缓存
|
||||
employeeEntityList.forEach(e -> {
|
||||
employeeCacheManager.clearCacheByEmployeeId(e.getId());
|
||||
employeeCacheManager.clearCacheByDepartmentId(e.getDepartmentId());
|
||||
employeeCacheService.clearCacheByEmployeeId(e.getId());
|
||||
employeeCacheService.clearCacheByDepartmentId(e.getDepartmentId());
|
||||
});
|
||||
employeeCacheService.clearCacheByDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户角色
|
||||
*
|
||||
* @param updateDTO
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updateRole(EmployeeRoleUpdateDTO updateDTO) {
|
||||
Long employeeId = updateDTO.getEmployeeId();
|
||||
List<Long> roleIdList = updateDTO.getRoleIdList();
|
||||
|
||||
// 保存新的角色信息
|
||||
List<RoleEmployeeEntity> roleEmployeeList = null;
|
||||
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
||||
roleEmployeeList = roleIdList.stream()
|
||||
.map(roleId -> new RoleEmployeeEntity(roleId, employeeId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
employeeManager.updateEmployeeRole(employeeId, roleEmployeeList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新密码
|
||||
*
|
||||
* @param updatePwdDTO
|
||||
* @param updatePasswordForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> updatePwd(EmployeeUpdatePwdDTO updatePwdDTO) {
|
||||
Long employeeId = updatePwdDTO.getEmployeeId();
|
||||
public ResponseDTO<String> updatePassword(EmployeeUpdatePasswordForm updatePasswordForm) {
|
||||
Long employeeId = updatePasswordForm.getEmployeeId();
|
||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||
if (employeeEntity == null) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
// 校验原始密码
|
||||
String encryptPwd = getEncryptPwd(updatePwdDTO.getOldPwd());
|
||||
String encryptPwd = getEncryptPwd(updatePasswordForm.getOldPassword());
|
||||
if (!Objects.equals(encryptPwd, employeeEntity.getLoginPwd())) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "原密码有误,请重新输入");
|
||||
}
|
||||
|
||||
// 新旧密码相同
|
||||
String newPwd = updatePwdDTO.getPwd();
|
||||
if (Objects.equals(updatePwdDTO.getOldPwd(), newPwd)) {
|
||||
String newPassword = updatePasswordForm.getNewPassword();
|
||||
if (Objects.equals(updatePasswordForm.getOldPassword(), newPassword)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
// 更新密码
|
||||
EmployeeEntity updateEntity = new EmployeeEntity();
|
||||
updateEntity.setId(employeeId);
|
||||
updateEntity.setLoginPwd(getEncryptPwd(newPwd));
|
||||
updateEntity.setLoginPwd(getEncryptPwd(newPassword));
|
||||
employeeDao.updateById(updateEntity);
|
||||
|
||||
return ResponseDTO.ok();
|
||||
@ -388,12 +351,24 @@ public class EmployeeService {
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<EmployeeVO>> getEmployeeByDeptId(Long departmentId) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeCacheManager.departmentEmployeeCache(departmentId);
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean leaveFlag) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeCacheService.departmentEmployeeCache(departmentId);
|
||||
if (leaveFlag != null) {
|
||||
employeeEntityList = employeeEntityList.stream().filter(e -> e.getLeaveFlag().equals(leaveFlag)).collect(Collectors.toList());
|
||||
}
|
||||
// 获取部门
|
||||
List<DepartmentVO> departmentList = departmentCacheService.departmentCache();
|
||||
Optional<DepartmentVO> departmentVO = departmentList.stream().filter(e -> e.getId().equals(departmentId)).findFirst();
|
||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||
return ResponseDTO.ok(Collections.emptyList());
|
||||
}
|
||||
List<EmployeeVO> voList = SmartBeanUtil.copyList(employeeEntityList, EmployeeVO.class);
|
||||
List<EmployeeVO> voList = employeeEntityList.stream().map(e -> {
|
||||
EmployeeVO employeeVO = SmartBeanUtil.copy(e, EmployeeVO.class);
|
||||
if (departmentVO.isPresent()) {
|
||||
employeeVO.setDepartmentName(departmentVO.get().getName());
|
||||
}
|
||||
return employeeVO;
|
||||
}).collect(Collectors.toList());
|
||||
return ResponseDTO.ok(voList);
|
||||
}
|
||||
|
||||
@ -405,25 +380,19 @@ public class EmployeeService {
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> resetPassword(Integer employeeId) {
|
||||
String md5Password = getEncryptPwd(null);
|
||||
employeeDao.updatePassword(employeeId, md5Password);
|
||||
return ResponseDTO.ok();
|
||||
employeeDao.updatePassword(employeeId, getEncryptPwd(DEFAULT_PASSWORD));
|
||||
return ResponseDTO.okMsg("重置密码为:" + DEFAULT_PASSWORD);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 加密后 的密码
|
||||
*
|
||||
* @param pwd 密码为空 将使用原始密码
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static String getEncryptPwd(String pwd) {
|
||||
pwd = StringUtils.isBlank(pwd) ? EmployeeConst.Password.DEFAULT : pwd;
|
||||
return DigestUtils.md5Hex(String.format(EmployeeConst.Password.SALT_FORMAT, pwd));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getEncryptPwd("123456"));
|
||||
|
||||
public static String getEncryptPwd(String password) {
|
||||
return DigestUtils.md5Hex(String.format(PASSWORD_SALT_FORMAT, password));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,13 +400,10 @@ public class EmployeeService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<List<EmployeeVO>> queryAllEmploy(Boolean disabledFlag) {
|
||||
EmployeeQueryForm queryDTO = new EmployeeQueryForm();
|
||||
queryDTO.setDeletedFlag(Boolean.FALSE);
|
||||
if (disabledFlag != null) {
|
||||
queryDTO.setDisabledFlag(disabledFlag);
|
||||
}
|
||||
List<EmployeeVO> employeeList = employeeDao.queryEmployee(queryDTO);
|
||||
public ResponseDTO<List<EmployeeVO>> queryAllEmployee(Boolean disabledFlag, RequestEmployee requestEmployee) {
|
||||
EmployeeQueryForm employeeQueryForm = new EmployeeQueryForm();
|
||||
employeeQueryForm.setDisabledFlag(disabledFlag);
|
||||
List<EmployeeVO> employeeList = employeeDao.queryEmployee(employeeQueryForm);
|
||||
return ResponseDTO.ok(employeeList);
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 员工列表DTO
|
||||
*
|
||||
* @author 开云
|
||||
* @date 2017年12月21日上午09:09:31
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeDTO {
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("登录账号")
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty("员工名称")
|
||||
private String actualName;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("部门id")
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty("是否被禁用")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@ApiModelProperty("是否删除")
|
||||
private Boolean deletedFlag;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String departmentName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工禁用状态更新 DTO
|
||||
*
|
||||
* @author listen
|
||||
* @date 2021年07月29日 20:00
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeDisabledUpdateDTO {
|
||||
|
||||
@ApiModelProperty("员工id")
|
||||
@NotEmpty(message = "员工id不能为空")
|
||||
@Size(max = 99, message = "一次最多更新99次")
|
||||
private List<Long> employeeIdList;
|
||||
|
||||
@ApiModelProperty("禁用状态")
|
||||
@NotNull(message = "禁用状态不能为空")
|
||||
private Boolean disabledFlag;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 1024lab
|
||||
* 不带分页的查询条件
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeQueryExportDTO {
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String actualName;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@ApiModelProperty(value = "删除状态", hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
|
||||
@ApiModelProperty(value = "员工ID集合", hidden = true)
|
||||
private List<Long> employeeIds;
|
||||
|
||||
}
|
@ -4,14 +4,13 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.enumeration.GenderEnum;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 员工实体类
|
||||
*
|
||||
* @author 开云
|
||||
* @author lidoudou
|
||||
* @date 2017年12月19日下午1:34:48
|
||||
*/
|
||||
@Data
|
||||
@ -39,7 +38,7 @@ public class EmployeeEntity {
|
||||
/**
|
||||
* 性别
|
||||
*
|
||||
* @see GenderEnum
|
||||
* @see net.lab1024.smartadmin.service.common.constant.GenderEnum
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
@ -63,6 +62,11 @@ public class EmployeeEntity {
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
|
||||
/**
|
||||
* 是否离职
|
||||
*/
|
||||
private Boolean leaveFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ -72,4 +76,9 @@ public class EmployeeEntity {
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 是否校盈易导入数据
|
||||
*/
|
||||
private Boolean importFlag;
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.enumeration.GenderEnum;
|
||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartVerificationUtil;
|
||||
import net.lab1024.smartadmin.service.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import net.lab1024.smartadmin.service.common.util.SmartVerificationUtil;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
@ -14,11 +15,11 @@ import java.util.List;
|
||||
/**
|
||||
* 添加员工
|
||||
*
|
||||
* @author 开云
|
||||
* @author lidoudou
|
||||
* @date 2017年12月19日下午2:06:31
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeAddDTO {
|
||||
public class EmployeeAddForm {
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
@NotNull(message = "姓名不能为空")
|
||||
@ -31,6 +32,7 @@ public class EmployeeAddDTO {
|
||||
private String loginName;
|
||||
|
||||
@ApiModelPropertyEnum(GenderEnum.class)
|
||||
@CheckEnum(value = GenderEnum.class, message = "性别错误")
|
||||
private Integer gender;
|
||||
|
||||
@ApiModelProperty("部门id")
|
||||
@ -41,6 +43,10 @@ public class EmployeeAddDTO {
|
||||
@NotNull(message = "是否被禁用不能为空")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@ApiModelProperty("是否离职")
|
||||
@NotNull(message = "是否离职不能为空")
|
||||
private Boolean leaveFlag;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
@NotNull(message = "手机号不能为空")
|
||||
@Pattern(regexp = SmartVerificationUtil.PHONE_REGEXP, message = "手机号格式不正确")
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -11,11 +11,11 @@ import java.util.List;
|
||||
/**
|
||||
* 员工更新部门 DTO
|
||||
*
|
||||
* @author 善逸
|
||||
* @author lihaifan
|
||||
* @date 2021年07月29日 20:00
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeDepartmentUpdateDTO {
|
||||
public class EmployeeBatchUpdateDepartmentForm {
|
||||
|
||||
@ApiModelProperty("员工id")
|
||||
@NotEmpty(message = "员工id不能为空")
|
@ -1,8 +1,8 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParamForm;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageParam;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
@ -11,11 +11,11 @@ import java.util.List;
|
||||
/**
|
||||
* 员工列表DTO
|
||||
*
|
||||
* @author 开云
|
||||
* @author lidoudou
|
||||
* @date 2017年12月21日上午09:09:31
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeQueryForm extends PageParamForm {
|
||||
public class EmployeeQueryForm extends PageParam {
|
||||
|
||||
@ApiModelProperty("搜索词")
|
||||
@Length(max = 20, message = "搜索词最多20字符")
|
||||
@ -31,6 +31,4 @@ public class EmployeeQueryForm extends PageParamForm {
|
||||
@Size(max = 99, message = "最多查询99个员工")
|
||||
private List<Long> employeeIdList;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.domain.form.EmployeeAddForm;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 更新员工
|
||||
*
|
||||
* @author 开云
|
||||
* @author lidoudou
|
||||
* @date 2017年12月19日下午2:06:31
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeUpdateDTO extends EmployeeAddDTO {
|
||||
public class EmployeeUpdateForm extends EmployeeAddForm {
|
||||
|
||||
@ApiModelProperty("员工id")
|
||||
@NotNull(message = "员工id不能为空")
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -14,7 +14,7 @@ import javax.validation.constraints.Pattern;
|
||||
* @date 2018-02-23 下午 4:53
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeUpdatePwdDTO {
|
||||
public class EmployeeUpdatePasswordForm {
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long employeeId;
|
||||
@ -22,10 +22,10 @@ public class EmployeeUpdatePwdDTO {
|
||||
@ApiModelProperty("原密码")
|
||||
@NotBlank(message = "原密码不能为空哦")
|
||||
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "原密码请输入6-15位(数字|大小写字母|小数点)")
|
||||
private String oldPwd;
|
||||
private String oldPassword;
|
||||
|
||||
@ApiModelProperty("新密码")
|
||||
@NotBlank(message = "新密码不能为空哦")
|
||||
@Pattern(regexp = SmartVerificationUtil.PWD_REGEXP, message = "新密码请输入6-15位(数字|大小写字母|小数点)")
|
||||
private String pwd;
|
||||
private String newPassword;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.dto;
|
||||
package net.lab1024.smartadmin.service.module.system.employee.domain.form;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -10,10 +10,15 @@ import java.util.List;
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @author yandanyang
|
||||
* @version 1.0
|
||||
* @company 1024lab.net
|
||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
||||
* @date
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Data
|
||||
public class EmployeeRoleUpdateDTO {
|
||||
public class EmployeeUpdateRoleForm {
|
||||
|
||||
@ApiModelProperty("员工id")
|
||||
@NotNull(message = "员工id不能为空")
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user