mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-22 21:36:39 +08:00
commit
835076c301
29
.gitignore
vendored
29
.gitignore
vendored
@ -1,6 +1,31 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
**/target/
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
**/node_modules/
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
@ -85,6 +85,10 @@ public class ResponseDTO<T> {
|
||||
return new ResponseDTO<T>(codeConst, msg);
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> wrapMsg(ResponseCodeConst codeConst, String msg) {
|
||||
return new ResponseDTO<T>(codeConst, msg);
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.lab1024.smartadmin.common.domain.BaseEnum;
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 枚举类校验器
|
||||
@ -15,9 +17,9 @@ import java.util.List;
|
||||
public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||
|
||||
/**
|
||||
* 枚举类的类对象
|
||||
* 枚举类实例集合
|
||||
*/
|
||||
private Class<? extends BaseEnum> enumClass;
|
||||
private List<Object> enumValList;
|
||||
|
||||
/**
|
||||
* 是否必须
|
||||
@ -27,8 +29,9 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||
@Override
|
||||
public void initialize(CheckEnum constraintAnnotation) {
|
||||
// 获取注解传入的枚举类对象
|
||||
enumClass = constraintAnnotation.enumClazz();
|
||||
required = constraintAnnotation.required();
|
||||
Class<? extends BaseEnum> enumClass = constraintAnnotation.enumClazz();
|
||||
enumValList = Stream.of(enumClass.getEnumConstants()).map(BaseEnum::getValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,7 +47,7 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||
}
|
||||
|
||||
// 校验是否为合法的枚举值
|
||||
return this.hasEnum(value);
|
||||
return enumValList.contains(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,23 +61,11 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||
// 必须的情况下 list 不能为空
|
||||
return false;
|
||||
}
|
||||
for (Object obj : list) {
|
||||
boolean hasEnum = this.hasEnum(obj);
|
||||
if (!hasEnum) {
|
||||
// 校验是否重复
|
||||
long count = list.stream().distinct().count();
|
||||
if (count != list.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasEnum(Object value) {
|
||||
// 校验是否为合法的枚举值
|
||||
BaseEnum[] enums = enumClass.getEnumConstants();
|
||||
for (BaseEnum baseEnum : enums) {
|
||||
if (baseEnum.getValue().equals(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return enumValList.containsAll(list);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.lab1024.smartadmin.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
@ -9,6 +8,8 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.interceptor.SmartAuthenticationInterceptor;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
@ -23,8 +24,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.RequestHandler;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
@ -89,9 +92,9 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
|
||||
private String groupName = "default";
|
||||
|
||||
private List<String> groupList = Lists.newArrayList();
|
||||
private final List<String> groupList = Lists.newArrayList();
|
||||
|
||||
private Map<String, List<String>> groupMap = Maps.newHashMap();
|
||||
private final Map<String, List<String>> groupMap = Maps.newHashMap();
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
@ -108,7 +111,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
this.groupBuild();
|
||||
for (Map.Entry<String, List<String>> entry : groupMap.entrySet()) {
|
||||
String group = entry.getKey();
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this :: baseDocket);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this::baseDocket);
|
||||
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
|
||||
registry.registerBeanDefinition(group + "Api", beanDefinition);
|
||||
}
|
||||
@ -137,6 +140,16 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
}
|
||||
|
||||
private Docket baseDocket() {
|
||||
// 配置全局参数 token
|
||||
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||
Parameter parameter = tokenPar.name(SmartAuthenticationInterceptor.TOKEN_NAME)
|
||||
.description("token")
|
||||
.modelRef(new ModelRef("string"))
|
||||
.parameterType("header")
|
||||
.defaultValue("")
|
||||
.required(false)
|
||||
.build();
|
||||
|
||||
// 请求类型过滤规则
|
||||
Predicate<RequestHandler> controllerPredicate = getControllerPredicate();
|
||||
// controller 包路径
|
||||
@ -151,17 +164,18 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
.build()
|
||||
.apiInfo(this.serviceApiInfo())
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
.securityContexts(securityContexts())
|
||||
.globalOperationParameters(Lists.newArrayList(parameter));
|
||||
}
|
||||
|
||||
private List<ApiKey> securitySchemes() {
|
||||
List<ApiKey> apiKeyList= new ArrayList<>();
|
||||
List<ApiKey> apiKeyList = new ArrayList<>();
|
||||
apiKeyList.add(new ApiKey("x-access-token", "x-access-token", "header"));
|
||||
return apiKeyList;
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts=new ArrayList<>();
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
@ -174,7 +188,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
List<SecurityReference> securityReferences=new ArrayList<>();
|
||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||
securityReferences.add(new SecurityReference("x-access-token", authorizationScopes));
|
||||
return securityReferences;
|
||||
}
|
||||
@ -196,9 +210,9 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
};
|
||||
groupIndex++;
|
||||
return Predicates.or(
|
||||
Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class),methodPredicate),
|
||||
Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class), methodPredicate),
|
||||
Predicates.and(
|
||||
RequestHandlerSelectors.withMethodAnnotation(ResponseBody.class),methodPredicate)
|
||||
RequestHandlerSelectors.withMethodAnnotation(ResponseBody.class), methodPredicate)
|
||||
);
|
||||
}
|
||||
|
||||
@ -219,6 +233,4 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import java.util.List;
|
||||
@Component
|
||||
public class SmartAuthenticationInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private static final String TOKEN_NAME = "x-access-token";
|
||||
public static final String TOKEN_NAME = "x-access-token";
|
||||
|
||||
@Value("${access-control-allow-origin}")
|
||||
private String accessControlAllowOrigin;
|
||||
|
@ -59,15 +59,15 @@ public class DepartmentController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除部门", notes = "删除部门")
|
||||
@PostMapping("/department/delete/{departmentId}")
|
||||
public ResponseDTO<String> delDepartment(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.delDepartment(departmentId);
|
||||
@PostMapping("/department/delete/{deptId}")
|
||||
public ResponseDTO<String> delDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.delDepartment(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取部门信息", notes = "获取部门")
|
||||
@GetMapping("/department/query/{departmentId}")
|
||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.getDepartmentById(departmentId);
|
||||
@GetMapping("/department/query/{deptId}")
|
||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.getDepartmentById(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询部门列表", notes = "查询部门列表")
|
||||
@ -78,21 +78,21 @@ public class DepartmentController {
|
||||
|
||||
|
||||
@ApiOperation(value = "上下移动")
|
||||
@GetMapping("/department/upOrDown/{departmentId}/{swapId}")
|
||||
public ResponseDTO<String> upOrDown(@PathVariable("departmentId") Long departmentId,@PathVariable("swapId") Long swapId) {
|
||||
return departmentService.upOrDown(departmentId,swapId);
|
||||
@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/{departmentId}")
|
||||
public ResponseDTO<String> upgrade(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.upgrade(departmentId);
|
||||
@GetMapping("/department/upgrade/{deptId}")
|
||||
public ResponseDTO<String> upgrade(@PathVariable Long deptId) {
|
||||
return departmentService.upgrade(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "降级")
|
||||
@GetMapping("/department/downgrade/{departmentId}/{preId}")
|
||||
public ResponseDTO<String> downgrade(@PathVariable("departmentId") Long departmentId,@PathVariable("preId") Long preId) {
|
||||
return departmentService.downgrade(departmentId,preId);
|
||||
@GetMapping("/department/downgrade/{deptId}/{preId}")
|
||||
public ResponseDTO<String> downgrade(@PathVariable Long deptId, @PathVariable Long preId) {
|
||||
return departmentService.downgrade(deptId, preId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,14 +19,13 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门id,查询此部门子部门的数量
|
||||
* 根据部门id,查询此部门直接子部门的数量
|
||||
*
|
||||
* @param departmentId
|
||||
* @param deptId
|
||||
* @return int 子部门的数量
|
||||
*/
|
||||
Integer countSubDepartment(@Param("departmentId") Long departmentId);
|
||||
Integer countSubDepartment(@Param("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 获取全部部门列表
|
||||
|
@ -14,7 +14,7 @@ public class DepartmentResponseCodeConst extends ResponseCodeConst {
|
||||
/**
|
||||
* 部门不存在 1001
|
||||
*/
|
||||
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在!");
|
||||
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在");
|
||||
|
||||
/**
|
||||
* 当前部门有子级部门 不能删除 10003
|
||||
|
@ -64,7 +64,7 @@ public class DepartmentService {
|
||||
departmentVOList = filterDepartment(departmentVOList, departmentName);
|
||||
}
|
||||
|
||||
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO :: getId, Function.identity()));
|
||||
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO::getId, Function.identity()));
|
||||
// 获取全部员工列表
|
||||
List<EmployeeDTO> employeeList = employeeDao.listAll();
|
||||
employeeList.forEach(employeeDTO -> {
|
||||
@ -103,7 +103,7 @@ public class DepartmentService {
|
||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
||||
for (DepartmentVO dto : filterResult) {
|
||||
if (! departmentMap.containsKey(dto.getId())) {
|
||||
if (!departmentMap.containsKey(dto.getId())) {
|
||||
departmentMap.put(dto.getId(), dto);
|
||||
}
|
||||
}
|
||||
@ -165,23 +165,27 @@ public class DepartmentService {
|
||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||
*
|
||||
* @param departmentId
|
||||
* @return AjaxResult<String>
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseDTO<String> delDepartment(Long departmentId) {
|
||||
public ResponseDTO<String> delDepartment(Long deptId) {
|
||||
DepartmentEntity departmentEntity = departmentDao.selectById(deptId);
|
||||
if (null == departmentEntity) {
|
||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.DEPT_NOT_EXISTS);
|
||||
}
|
||||
// 是否有子级部门
|
||||
int subDepartmentNum = departmentDao.countSubDepartment(departmentId);
|
||||
int subDepartmentNum = departmentDao.countSubDepartment(deptId);
|
||||
if (subDepartmentNum > 0) {
|
||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_CHILD);
|
||||
}
|
||||
|
||||
// 是否有员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(departmentId);
|
||||
// 是否有未删除员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(deptId, false);
|
||||
if (employeeNum > 0) {
|
||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_EMPLOYEE);
|
||||
}
|
||||
departmentDao.deleteById(departmentId);
|
||||
departmentDao.deleteById(deptId);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@ -278,5 +282,4 @@ public class DepartmentService {
|
||||
departmentDao.updateById(departmentEntity);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
|
||||
/**
|
||||
* 不带分页查询员工列表
|
||||
*
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
@ -84,10 +85,11 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
/**
|
||||
* 获取某个部门员工数
|
||||
*
|
||||
* @param departmentId
|
||||
* @param depId
|
||||
* @param deleteFlag 可以null
|
||||
* @return
|
||||
*/
|
||||
Integer countByDepartmentId(@Param("departmentId") Long departmentId);
|
||||
Integer countByDepartmentId(@Param("depId") Long depId, @Param("deleteFlag") Boolean deleteFlag);
|
||||
|
||||
/**
|
||||
* 获取一批员工
|
||||
@ -99,6 +101,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
|
||||
|
||||
EmployeeDTO getEmployeeById(@Param("id") Long employeeId);
|
||||
|
||||
/**
|
||||
* 获取某个部门的员工
|
||||
*
|
||||
@ -128,6 +131,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
|
||||
/**
|
||||
* 查询所有员工
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeVO> selectAll();
|
||||
|
@ -42,7 +42,6 @@ public class LoginController {
|
||||
return loginService.login(loginForm, request);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/session/get")
|
||||
@ApiOperation(value = "获取session", notes = "获取session")
|
||||
@NoValidPrivilege
|
||||
|
@ -1,4 +1,5 @@
|
||||
package net.lab1024.smartadmin.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
@ -34,12 +35,15 @@ public class SmartBigDecimalUtil {
|
||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.add(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.divide(num2, RoundingMode.HALF_UP), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
@ -53,12 +57,15 @@ public class SmartBigDecimalUtil {
|
||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.add(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.divide(num2, PRICE_DECIMAL_POINT, RoundingMode.HALF_UP);
|
||||
}
|
||||
@ -72,12 +79,15 @@ public class SmartBigDecimalUtil {
|
||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.add(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.divide(num2, WEIGHT_DECIMAL_POINT, RoundingMode.HALF_UP);
|
||||
}
|
||||
@ -176,7 +186,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isLessThan(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.compareTo(num2) == - 1;
|
||||
return num1.compareTo(num2) == -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +237,7 @@ public class SmartBigDecimalUtil {
|
||||
if (num1 == null || num2 == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (num2.equals(Integer.valueOf(0))) {
|
||||
if (num2.equals(0)) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal bigDecimalNum1 = new BigDecimal(num1);
|
||||
@ -272,7 +282,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static Boolean isNotEmpty(BigDecimal num) {
|
||||
return ! isEmpty(num);
|
||||
return !isEmpty(num);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,8 +293,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal convertTenThousand(BigDecimal num, int point) {
|
||||
BigDecimal decimal = num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
||||
return decimal;
|
||||
return num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -300,4 +309,25 @@ public class SmartBigDecimalUtil {
|
||||
return BigDecimal.ZERO.subtract(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较 num1,num2 返回最大的值
|
||||
*
|
||||
* @param num1
|
||||
* @param num2
|
||||
* @return BigDecimal
|
||||
*/
|
||||
public static BigDecimal max(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.compareTo(num2) > 0 ? num1 : num2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较 num1,num2 返回最小的值
|
||||
*
|
||||
* @param num1
|
||||
* @param num2
|
||||
* @return BigDecimal
|
||||
*/
|
||||
public static BigDecimal min(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.compareTo(num2) < 0 ? num1 : num2;
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,6 @@
|
||||
d.create_time
|
||||
</sql>
|
||||
|
||||
<select id="countSubDepartment" resultType="integer">
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
t_department
|
||||
WHERE
|
||||
parent_id = #{departmentId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="DepartmentVO">
|
||||
SELECT
|
||||
<include refid="baseSql"></include>,
|
||||
@ -50,5 +41,14 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="countSubDepartment" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
t_department
|
||||
WHERE
|
||||
parent_id = #{deptId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -124,7 +124,10 @@
|
||||
FROM
|
||||
t_employee e
|
||||
WHERE
|
||||
e.department_id = #{departmentId}
|
||||
e.department_id = #{depId}
|
||||
<if test="deleteFlag != null">
|
||||
AND e.is_delete = #{deleteFlag}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS `t_department` (
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `parent_id` (`parent_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='部门表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='部门表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_department 的数据:~4 rows (大约)
|
||||
DELETE FROM `t_department`;
|
||||
@ -154,7 +154,7 @@ CREATE TABLE IF NOT EXISTS `t_employee` (
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`is_delete` int NOT NULL DEFAULT '0' COMMENT '是否删除0否 1是',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='员工表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='员工表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_employee 的数据:~28 rows (大约)
|
||||
DELETE FROM `t_employee`;
|
||||
@ -207,7 +207,7 @@ CREATE TABLE IF NOT EXISTS `t_file` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `module_id_module_type` (`module_id`,`module_type`) USING BTREE,
|
||||
KEY `module_type` (`module_type`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_file 的数据:~23 rows (大约)
|
||||
DELETE FROM `t_file`;
|
||||
@ -248,7 +248,7 @@ CREATE TABLE IF NOT EXISTS `t_heart_beat_record` (
|
||||
`process_start_time` datetime DEFAULT NULL COMMENT '进程开启时间',
|
||||
`heart_beat_time` datetime DEFAULT NULL COMMENT '心跳时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_heart_beat_record 的数据:~2 rows (大约)
|
||||
DELETE FROM `t_heart_beat_record`;
|
||||
@ -274,7 +274,7 @@ CREATE TABLE IF NOT EXISTS `t_id_generator` (
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
`create_time` datetime NOT NULL,
|
||||
UNIQUE KEY `key_name` (`key_name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='id生成器定义表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='id生成器定义表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_id_generator 的数据:~2 rows (大约)
|
||||
DELETE FROM `t_id_generator`;
|
||||
@ -293,7 +293,7 @@ CREATE TABLE IF NOT EXISTS `t_id_generator_record` (
|
||||
`day` int NOT NULL,
|
||||
`last_number` int NOT NULL,
|
||||
PRIMARY KEY (`generator_id`,`year`,`month`,`day`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='id_generator记录表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='id_generator记录表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_id_generator_record 的数据:~5 rows (大约)
|
||||
DELETE FROM `t_id_generator_record`;
|
||||
@ -400,7 +400,7 @@ CREATE TABLE IF NOT EXISTS `t_order_operate_log` (
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `order_id_order_type` (`order_id`,`order_type`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='各种单据操作记录\r\n';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='各种单据操作记录\r\n';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_order_operate_log 的数据:~0 rows (大约)
|
||||
DELETE FROM `t_order_operate_log`;
|
||||
@ -720,7 +720,7 @@ CREATE TABLE IF NOT EXISTS `t_reload_item` (
|
||||
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`tag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_reload_item 的数据:~0 rows (大约)
|
||||
DELETE FROM `t_reload_item`;
|
||||
@ -738,7 +738,7 @@ CREATE TABLE IF NOT EXISTS `t_reload_result` (
|
||||
`result` tinyint unsigned NOT NULL COMMENT '是否成功 ',
|
||||
`exception` text,
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_reload_result 的数据:~127 rows (大约)
|
||||
DELETE FROM `t_reload_result`;
|
||||
@ -938,7 +938,7 @@ CREATE TABLE IF NOT EXISTS `t_role_employee` (
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=214 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色员工功能表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=214 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色员工功能表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_role_employee 的数据:~25 rows (大约)
|
||||
DELETE FROM `t_role_employee`;
|
||||
@ -980,7 +980,7 @@ CREATE TABLE IF NOT EXISTS `t_role_privilege` (
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10835 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色权限功能表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10835 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色权限功能表';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_role_privilege 的数据:~322 rows (大约)
|
||||
DELETE FROM `t_role_privilege`;
|
||||
@ -1322,7 +1322,7 @@ CREATE TABLE IF NOT EXISTS `t_system_config` (
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '上次修改时间',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_system_config 的数据:~8 rows (大约)
|
||||
DELETE FROM `t_system_config`;
|
||||
@ -1354,7 +1354,7 @@ CREATE TABLE IF NOT EXISTS `t_user_login_log` (
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `customer_id` (`user_id`) USING BTREE,
|
||||
KEY `auditor_id` (`remote_browser`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1743 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户登录日志';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1743 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户登录日志';
|
||||
|
||||
-- 正在导出表 smart-admin-dev.t_user_login_log 的数据:~122 rows (大约)
|
||||
DELETE FROM `t_user_login_log`;
|
||||
|
Loading…
Reference in New Issue
Block a user