新增部门信息,雪花算法生成id设置

master
shijie 4 years ago
parent 070e8aaa60
commit 6bf797ee13
  1. 28
      dq-financial-api/dq-financial-api.iml
  2. 4
      dq-financial-api/pom.xml
  3. 5
      dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java
  4. 6
      dq-financial-hrms/pom.xml
  5. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java
  6. 43
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java
  7. 3
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java
  8. 64
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java
  9. 14
      dq-framework-common/src/main/java/com/daqing/framework/exception/CustomException.java
  10. 6
      dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCast.java
  11. 19
      dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCatch.java
  12. 19
      dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java
  13. 12
      dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java
  14. 37
      dq-framework-common/src/main/java/com/daqing/framework/model/response/ResultCode.java
  15. 4
      dq-framework-common/src/main/java/com/daqing/framework/xss/SQLFilter.java
  16. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CompanyCustomerEntity.java
  17. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CustomerEntity.java
  18. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/PersonalCustomerEntity.java
  19. 5
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DeptEntity.java
  20. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeDeptEntity.java
  21. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java
  22. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeePositionEntity.java
  23. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeRoleEntity.java
  24. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PermissionEntity.java
  25. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java
  26. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RoleEntity.java
  27. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RolePermissionEntity.java
  28. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java
  29. 32
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/DeptAddRequest.java
  30. 51
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/DeptCode.java
  31. 38
      dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java

@ -128,21 +128,23 @@
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.9.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" /> <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" /> <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.5" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.5" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" /> <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" level="project" /> <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.8.RELEASE" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.8.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.8.RELEASE" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.8.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.8.RELEASE" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.8.RELEASE" level="project" />

@ -33,12 +33,12 @@
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version> <version>2.7.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version> <version>2.7.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -1,11 +1,10 @@
package com.daqing.financial.hrms; package com.daqing.financial.hrms;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.Map;
/** /**
* @Author: gongsj. * @Author: gongsj.
* @Description: 部门管理controllerApi定义 * @Description: 部门管理controllerApi定义
@ -19,5 +18,5 @@ public interface DeptControllerApi {
* 新增一条部门信息 * 新增一条部门信息
*/ */
@ApiOperation(value = "新增一条部门信息", notes = "新增一条部门信息") @ApiOperation(value = "新增一条部门信息", notes = "新增一条部门信息")
ResponseResult save(); ResponseResult save(DeptAddRequest deptAddRequest);
} }

@ -35,6 +35,12 @@
<artifactId>dq-framework-utils</artifactId> <artifactId>dq-framework-utils</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

@ -4,10 +4,12 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
@EnableFeignClients(basePackages = "com.daqing.financial.hrms.feign") @EnableFeignClients(basePackages = "com.daqing.financial.hrms.feign")
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = "com.daqing.financial")
public class DqFinancialHrmsApplication { public class DqFinancialHrmsApplication {
public static void main(String[] args) { public static void main(String[] args) {

@ -1,17 +1,18 @@
package com.daqing.financial.hrms.controller; package com.daqing.financial.hrms.controller;
import java.util.Arrays; import com.daqing.financial.hrms.DeptControllerApi;
import java.util.HashMap;
import java.util.Map;
import com.daqing.financial.hrms.feign.CrmsFeignService; import com.daqing.financial.hrms.feign.CrmsFeignService;
import com.daqing.financial.hrms.service.DeptService;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.daqing.framework.domain.hrms.DeptEntity; import java.util.Arrays;
import com.daqing.financial.hrms.service.DeptService; import java.util.HashMap;
import com.daqing.framework.utils.PageUtils; import java.util.Map;
/** /**
* 记录部门信息 * 记录部门信息
@ -22,7 +23,7 @@ import com.daqing.framework.utils.PageUtils;
*/ */
@RestController @RestController
@RequestMapping("hrms/dept") @RequestMapping("hrms/dept")
public class DeptController { public class DeptController implements DeptControllerApi {
@Autowired @Autowired
private DeptService deptService; private DeptService deptService;
@ -30,6 +31,20 @@ public class DeptController {
@Autowired @Autowired
private CrmsFeignService crmsFeignService; private CrmsFeignService crmsFeignService;
/**
* 保存一条部门信息
*
* @param deptAddRequest 新增部门请求体对象
* @return 统一响应对象
*/
@Override
@PostMapping("/save")
public ResponseResult save(@RequestBody DeptAddRequest deptAddRequest) {
boolean result = deptService.saveDept(deptAddRequest);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/** /**
* 测试远程调用 * 测试远程调用
*/ */
@ -62,17 +77,6 @@ public class DeptController {
return ResponseResult.SUCCESS(); return ResponseResult.SUCCESS();
} }
/**
* 保存
*/
@PostMapping("/save")
//@RequiresPermissions("hrms:dept:save")
public ResponseResult save(@RequestBody DeptEntity dept){
deptService.save(dept);
return ResponseResult.SUCCESS();
}
/** /**
* 修改 * 修改
*/ */
@ -94,5 +98,4 @@ public class DeptController {
return ResponseResult.SUCCESS(); return ResponseResult.SUCCESS();
} }
} }

@ -1,6 +1,7 @@
package com.daqing.financial.hrms.service; package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
@ -16,5 +17,7 @@ import java.util.Map;
public interface DeptService extends IService<DeptEntity> { public interface DeptService extends IService<DeptEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
boolean saveDept(DeptAddRequest deptAddRequest);
} }

@ -6,10 +6,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrms.dao.DeptDao; import com.daqing.financial.hrms.dao.DeptDao;
import com.daqing.financial.hrms.service.DeptService; import com.daqing.financial.hrms.service.DeptService;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.domain.hrms.response.DeptCode;
import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.utils.Query; import com.daqing.framework.utils.Query;
import com.daqing.framework.utils.SnowflakeIdUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map; import java.util.Map;
@ -26,4 +33,61 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
return new PageUtils(page); return new PageUtils(page);
} }
/**
* 保存一条部门信息
*
* @param deptAddRequest 新增部门请求体对象
* @return 保存成功或失败
*/
@Override
public boolean saveDept(DeptAddRequest deptAddRequest) {
//1、校验部门名称是否合法(为空与是否已存在)
String deptName = deptAddRequest.getName();
if (StringUtils.isEmpty(deptName)) {
//抛出部门名称非法异常
ExceptionCast.cast(DeptCode.DEPT_NAME_ILLEGAL);
}
//根据name查询数据条数,如果条数大于0,说明数据库中已经存在此部门名称
int countByName = this.count(new QueryWrapper<DeptEntity>().eq("name", deptName));
if (countByName > 0) {
//抛出部门名称非法异常
ExceptionCast.cast(DeptCode.DEPT_NAME_ILLEGAL);
}
//实体类
DeptEntity deptEntity = new DeptEntity();
//设置id
deptEntity.setId(SnowflakeIdUtils.getRandomid());
//属性拷贝,将上级部门id(如果有)、部门名称、排序(如果有)设置到实体类
BeanUtils.copyProperties(deptAddRequest, deptEntity);
//2、判断部门上级id是否为空,为空则此部门是一级部门,否则查询并计算部门层级,并判断部门层级是否大于5级或小于1级
//得到上级部门id
Long parentId = deptAddRequest.getParentId();
if (parentId == null) {
//说明是添加一级部门
//设置层级为1
deptEntity.setLevel(1);
//设置上级部门id为0
deptEntity.setParentId(0L);
} else {
//添加非一级部门
//根据上级部门id查询上级部门信息
DeptEntity byId = this.getById(parentId);
if (byId == null) {
//抛出部门id不存在异常
ExceptionCast.cast(DeptCode.DEPT_ID_NOT_EXSIT);
}
//根据上级部门层级计算当前部门层级
int level = byId.getLevel() + 1;
if (level > 5 || level < 1) {
ExceptionCast.cast(DeptCode.DEPT_LEVEL_ILLEGAL);
}
deptEntity.setLevel(level);
}
//设置创建时间和修改时间
deptEntity.setCreateTime(new Date());
deptEntity.setMotifyTime(new Date());
//3、保存部门信息到数据库
return this.save(deptEntity);
}
} }

@ -1,6 +1,6 @@
package com.daqing.framework.exception; package com.daqing.framework.exception;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResultCode;
/** /**
* @Author: gongsj. * @Author: gongsj.
@ -9,15 +9,15 @@ import com.daqing.framework.model.response.ResponseResult;
* @Modified By: * @Modified By:
*/ */
public class CustomException extends RuntimeException { public class CustomException extends RuntimeException {
private ResponseResult responseResult; private ResultCode resultCode;
public CustomException(ResponseResult responseResult) { public CustomException(ResultCode resultCode) {
//异常信息为错误码+异常信息 //异常信息为错误码+异常信息
super("错误码:" + responseResult.getCode() + "错误信息:" + responseResult.getMessage()); super("错误码:" + resultCode.code() + "错误信息:" + resultCode.message());
this.responseResult = responseResult; this.resultCode = resultCode;
} }
public ResponseResult getResultCode() { public ResultCode getResultCode() {
return this.responseResult; return this.resultCode;
} }
} }

@ -1,6 +1,6 @@
package com.daqing.framework.exception; package com.daqing.framework.exception;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResultCode;
/** /**
* @Author: gongsj. * @Author: gongsj.
@ -10,7 +10,7 @@ import com.daqing.framework.model.response.ResponseResult;
*/ */
public class ExceptionCast { public class ExceptionCast {
//使用此静态方法抛出自定义异常 //使用此静态方法抛出自定义异常
public static void cast(ResponseResult responseResult) { public static void cast(ResultCode resultCode) {
throw new CustomException(responseResult); throw new CustomException(resultCode);
} }
} }

@ -2,6 +2,7 @@ package com.daqing.framework.exception;
import com.daqing.framework.model.response.CommonCode; import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.model.response.ResultCode;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -22,13 +23,12 @@ public class ExceptionCatch {
private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.class); private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.class);
//定义Map,配置异常类型所对应的错误代码,使用 ImmutableMap 一旦写入数据,就无法更改,只读并且线程安全 //定义Map,配置异常类型所对应的错误代码,使用 ImmutableMap 一旦写入数据,就无法更改,只读并且线程安全
private static ImmutableMap<Class<? extends Throwable>, ResponseResult> EXCEPTIONS; private static ImmutableMap<Class<? extends Throwable>, ResultCode> EXCEPTIONS;
//定义map的builder对象,去构建ImmutableMap //定义map的builder对象,去构建ImmutableMap
protected static ImmutableMap.Builder<Class<? extends Throwable>, ResponseResult> builder = ImmutableMap.builder(); protected static ImmutableMap.Builder<Class<? extends Throwable>, ResultCode> builder = ImmutableMap.builder();
@ResponseBody
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseBody
public ResponseResult exception(Exception exception) { public ResponseResult exception(Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
//记录日志 //记录日志
@ -37,9 +37,9 @@ public class ExceptionCatch {
EXCEPTIONS = builder.build();//EXCEPTION构建成功 EXCEPTIONS = builder.build();//EXCEPTION构建成功
} }
//从EXCEPTIONS中找到异常类型所对应的错误代码,如果找到了,将错误代码相应给用户,如果找不到则给用户相应99999 //从EXCEPTIONS中找到异常类型所对应的错误代码,如果找到了,将错误代码相应给用户,如果找不到则给用户相应99999
ResponseResult responseResult = EXCEPTIONS.get(exception.getClass()); ResultCode resultCode = EXCEPTIONS.get(exception.getClass());
if (responseResult != null) { if (resultCode != null) {
return responseResult; return new ResponseResult(resultCode);
} }
//返回99999异常 //返回99999异常
return new ResponseResult(CommonCode.SERVER_ERROR); return new ResponseResult(CommonCode.SERVER_ERROR);
@ -47,7 +47,7 @@ public class ExceptionCatch {
static { static {
//定义异常类型所对应的错误代码 //定义异常类型所对应的错误代码
builder.put(HttpMessageNotReadableException.class, new ResponseResult(CommonCode.INVALID_PARAM)); builder.put(HttpMessageNotReadableException.class, CommonCode.INVALID_PARAM);
} }
@ExceptionHandler(CustomException.class)//捕获CustomException类型异常 @ExceptionHandler(CustomException.class)//捕获CustomException类型异常
@ -57,6 +57,7 @@ public class ExceptionCatch {
//记录日志 //记录日志
LOGGER.error("catch exception:{}", customException.getMessage()); LOGGER.error("catch exception:{}", customException.getMessage());
return customException.getResultCode(); ResultCode resultCode = customException.getResultCode();
return new ResponseResult(resultCode);
} }
} }

@ -2,6 +2,7 @@ package com.daqing.framework.model.response;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
/** /**
* @Author: gongsj. * @Author: gongsj.
@ -9,8 +10,9 @@ import lombok.Getter;
* @Date:Created in 2020/09/07 11:35. * @Date:Created in 2020/09/07 11:35.
* @Modified By: * @Modified By:
*/ */
@ToString
@AllArgsConstructor @AllArgsConstructor
public enum CommonCode { public enum CommonCode implements ResultCode {
SUCCESS(true, 10000, "操作成功!"), SUCCESS(true, 10000, "操作成功!"),
FAIL(false, 11111, "操作失败!"), FAIL(false, 11111, "操作失败!"),
@ -36,4 +38,19 @@ public enum CommonCode {
*/ */
@Getter @Getter
private String message; private String message;
@Override
public boolean success() {
return this.success;
}
@Override
public int code() {
return this.code;
}
@Override
public String message() {
return this.message;
}
} }

@ -42,10 +42,10 @@ public class ResponseResult<T> {
this.message = message; this.message = message;
} }
public ResponseResult(CommonCode commonCode) { public ResponseResult(ResultCode resultCode) {
this.success = commonCode.isSuccess(); this.success = resultCode.success();
this.code = commonCode.getCode(); this.code = resultCode.code();
this.message = commonCode.getMessage(); this.message = resultCode.message();
} }
public static ResponseResult SUCCESS() { public static ResponseResult SUCCESS() {
@ -55,8 +55,4 @@ public class ResponseResult<T> {
public static ResponseResult FAIL() { public static ResponseResult FAIL() {
return new ResponseResult(CommonCode.FAIL); return new ResponseResult(CommonCode.FAIL);
} }
public static ResponseResult FAIL(String message) {
return new ResponseResult(false, 500, message);
}
} }

@ -0,0 +1,37 @@
package com.daqing.framework.model.response;
/**
* @Author: gongsj.
* @Description: 系统操作状态集接口
* @Date:Created in 2020/09/09 15:35.
* @Modified By:
* 10000-- 通用错误码
* 22000-- 人资管理系统错误码
* 23000-- 人资管理系统认证系统错误码
* 24000-- 客户管理系统错误码
* 25000-- 客户管理系统认证系统错误码
* 26000-- 工作流程管理系统错误码
* 27000-- 担保业务系统错误码
*/
public interface ResultCode {
/**
* 操作是否成功
*
* @return true为成功false操作失败
*/
boolean success();
/**
* 操作码
*
* @return 操作码
*/
int code();
/**
* 提示信息
*
* @return 提示信息
*/
String message();
}

@ -9,7 +9,7 @@
package com.daqing.framework.xss; package com.daqing.framework.xss;
import com.daqing.framework.exception.ExceptionCast; import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.CommonCode;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
/** /**
@ -44,7 +44,7 @@ public class SQLFilter {
for (String keyword : keywords) { for (String keyword : keywords) {
//if (str.indexOf(keyword) != -1) //if (str.indexOf(keyword) != -1)
if (str.contains(keyword)) { if (str.contains(keyword)) {
ExceptionCast.cast(ResponseResult.FAIL("包含非法字符")); ExceptionCast.cast(CommonCode.INVALID_PARAM);
} }
} }
return str; return str;

@ -1,5 +1,6 @@
package com.daqing.framework.domain.crms; package com.daqing.framework.domain.crms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class CompanyCustomerEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 注册资金 * 注册资金

@ -1,5 +1,6 @@
package com.daqing.framework.domain.crms; package com.daqing.framework.domain.crms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class CustomerEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 客户编号 * 客户编号

@ -1,5 +1,6 @@
package com.daqing.framework.domain.crms; package com.daqing.framework.domain.crms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class PersonalCustomerEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 客户基本信息表id * 客户基本信息表id

@ -1,11 +1,12 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import lombok.Data;
/** /**
* 记录部门信息 * 记录部门信息
@ -22,7 +23,7 @@ public class DeptEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 部门名称 * 部门名称

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class EmployeeDeptEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 员工id * 员工id

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class EmployeeEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 姓名 * 姓名

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class EmployeePositionEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 员工id * 员工id

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class EmployeeRoleEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 用户id * 用户id

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class PermissionEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 权限标识符 * 权限标识符

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class PositionEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 部门id * 部门id

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class RoleEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 角色名称 * 角色名称

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class RolePermissionEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 角色id * 角色id

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms; package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class UserEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId @TableId(value = "id", type = IdType.INPUT)
private Long id; private Long id;
/** /**
* 用于登录的账号必填 * 用于登录的账号必填

@ -0,0 +1,32 @@
package com.daqing.framework.domain.hrms.request;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 新增部门请求体对象
*
* @author gongsj
* @email gongsj@gmail.com
* @date 2020-09-07 17:12:14
*/
@Data
public class DeptAddRequest implements Serializable {
/**
* 部门名称
*/
private String name;
/**
* 上级部门id
*/
private Long parentId;
/**
* 排序
*/
private Integer sort;
}

@ -0,0 +1,51 @@
package com.daqing.framework.domain.hrms.response;
import com.daqing.framework.model.response.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
/**
* @Author: gongsj.
* @Description: 部门相关操作状态集
* @Date:Created in 2020/09/09 15:35.
* @Modified By:
*/
@ToString
@AllArgsConstructor
public enum DeptCode implements ResultCode {
DEPT_NAME_ILLEGAL(false, 22001, "部门名称为空或已存在!"),
DEPT_ID_NOT_EXSIT(false, 22002, "部门id不存在!"),
DEPT_LEVEL_ILLEGAL(false, 22003, "部门层级不可超出5级!");
/**
* 操作是否成功
*/
@Getter
private boolean success;
/**
* 状态码
*/
@Getter
private int code;
/**
* 提示信息
*/
@Getter
private String message;
public boolean success() {
return this.success;
}
public int code() {
return this.code;
}
public String message() {
return this.message;
}
}

@ -1,8 +1,5 @@
package com.daqing.framework.utils; package com.daqing.framework.utils;
import java.util.HashSet;
import java.util.Set;
/** /**
* @Author JCccc * @Author JCccc
* @Description 雪花算法生成id工具类 * @Description 雪花算法生成id工具类
@ -175,27 +172,28 @@ public class SnowflakeIdUtils {
return SnowflakeIdUtils.getInstance().nextId(); return SnowflakeIdUtils.getInstance().nextId();
} }
// public static void main(String[] args) { public static void main(String[] args) {
//
// SnowflakeIdUtils snowflakeIdUtils = SnowflakeIdUtils.getInstance(); SnowflakeIdUtils snowflakeIdUtils = SnowflakeIdUtils.getInstance();
// for (int i = 0; i < 20; i++) {
// System.out.println(snowflakeIdUtils.nextId());
// }
// System.out.println("-+-+-+-+-+-+-+-+-+-+-+-+-+-");
// for (int i = 0; i < 20; i++) {
// System.out.println(SnowflakeIdUtils.getInstance().nextId());
// }
// Set<Long> set2 = new HashSet<>();
// for (int i = 0; i < 1000000; i++) {
// set2.add(snowflakeIdUtils.nextId());
// }
// System.out.println(set2.size());
// //
//// for (int i = 0; i < 20; i++) {
//// System.out.println(snowflakeIdUtils.nextId());
//// }
//// System.out.println("-+-+-+-+-+-+-+-+-+-+-+-+-+-");
//// for (int i = 0; i < 20; i++) {
//// System.out.println(SnowflakeIdUtils.getInstance().nextId());
//// }
//// Set<Long> set2 = new HashSet<>();
//// for (int i = 0; i < 1000000; i++) {
//// set2.add(snowflakeIdUtils.nextId());
//// }
//// System.out.println(set2.size());
////
// Set<Long> set = new HashSet<>(); // Set<Long> set = new HashSet<>();
// for (int i = 0; i < 1000000; i++) { // for (int i = 0; i < 1000000; i++) {
// set.add(SnowflakeIdUtils.getRandomid()); // set.add(SnowflakeIdUtils.getRandomid());
// } // }
// System.out.println(set.size()); // System.out.println(set.size());
// } System.out.println((SnowflakeIdUtils.getRandomid() + "").length());
}
} }
Loading…
Cancel
Save