From 6bf797ee137f3d239c4f1d9476f855c93b3bc0d8 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 9 Sep 2020 17:07:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E9=97=A8=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95=E7=94=9F?= =?UTF-8?q?=E6=88=90id=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dq-financial-api/dq-financial-api.iml | 28 ++++---- dq-financial-api/pom.xml | 4 +- .../financial/hrms/DeptControllerApi.java | 5 +- dq-financial-hrms/pom.xml | 6 ++ .../hrms/DqFinancialHrmsApplication.java | 2 + .../hrms/controller/DeptController.java | 43 +++++++------ .../financial/hrms/service/DeptService.java | 3 + .../hrms/service/impl/DeptServiceImpl.java | 64 +++++++++++++++++++ .../framework/exception/CustomException.java | 14 ++-- .../framework/exception/ExceptionCast.java | 6 +- .../framework/exception/ExceptionCatch.java | 21 +++--- .../framework/model/response/CommonCode.java | 19 +++++- .../model/response/ResponseResult.java | 12 ++-- .../framework/model/response/ResultCode.java | 37 +++++++++++ .../com/daqing/framework/xss/SQLFilter.java | 4 +- .../domain/crms/CompanyCustomerEntity.java | 3 +- .../framework/domain/crms/CustomerEntity.java | 3 +- .../domain/crms/PersonalCustomerEntity.java | 3 +- .../framework/domain/hrms/DeptEntity.java | 5 +- .../domain/hrms/EmployeeDeptEntity.java | 3 +- .../framework/domain/hrms/EmployeeEntity.java | 3 +- .../domain/hrms/EmployeePositionEntity.java | 3 +- .../domain/hrms/EmployeeRoleEntity.java | 3 +- .../domain/hrms/PermissionEntity.java | 3 +- .../framework/domain/hrms/PositionEntity.java | 3 +- .../framework/domain/hrms/RoleEntity.java | 3 +- .../domain/hrms/RolePermissionEntity.java | 3 +- .../framework/domain/hrms/UserEntity.java | 3 +- .../domain/hrms/request/DeptAddRequest.java | 32 ++++++++++ .../domain/hrms/response/DeptCode.java | 51 +++++++++++++++ .../framework/utils/SnowflakeIdUtils.java | 38 ++++++----- 31 files changed, 327 insertions(+), 103 deletions(-) create mode 100644 dq-framework-common/src/main/java/com/daqing/framework/model/response/ResultCode.java create mode 100644 dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/DeptAddRequest.java create mode 100644 dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/DeptCode.java diff --git a/dq-financial-api/dq-financial-api.iml b/dq-financial-api/dq-financial-api.iml index 6f583860..ee26d26e 100644 --- a/dq-financial-api/dq-financial-api.iml +++ b/dq-financial-api/dq-financial-api.iml @@ -128,21 +128,23 @@ - - - - - - - - - - - + + + + + + + + + + + + + - - + + diff --git a/dq-financial-api/pom.xml b/dq-financial-api/pom.xml index 846f0a4a..fc4b6c1d 100644 --- a/dq-financial-api/pom.xml +++ b/dq-financial-api/pom.xml @@ -33,12 +33,12 @@ io.springfox springfox-swagger2 - 2.9.2 + 2.7.0 io.springfox springfox-swagger-ui - 2.9.2 + 2.7.0 org.springframework.boot diff --git a/dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java b/dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java index 7de96c2e..06518136 100644 --- a/dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java +++ b/dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java @@ -1,11 +1,10 @@ package com.daqing.financial.hrms; +import com.daqing.framework.domain.hrms.request.DeptAddRequest; import com.daqing.framework.model.response.ResponseResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.Map; - /** * @Author: gongsj. * @Description: 部门管理controllerApi定义 @@ -19,5 +18,5 @@ public interface DeptControllerApi { * 新增一条部门信息 */ @ApiOperation(value = "新增一条部门信息", notes = "新增一条部门信息") - ResponseResult save(); + ResponseResult save(DeptAddRequest deptAddRequest); } diff --git a/dq-financial-hrms/pom.xml b/dq-financial-hrms/pom.xml index d0edb1f3..13f8b1c2 100644 --- a/dq-financial-hrms/pom.xml +++ b/dq-financial-hrms/pom.xml @@ -35,6 +35,12 @@ dq-framework-utils 0.0.1-SNAPSHOT + + com.daqing.financial + dq-financial-api + 0.0.1-SNAPSHOT + compile + org.springframework.boot spring-boot-starter-web diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java index aab52da0..285e9a6d 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java @@ -4,10 +4,12 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; @EnableFeignClients(basePackages = "com.daqing.financial.hrms.feign") @EnableDiscoveryClient @SpringBootApplication +@ComponentScan(basePackages = "com.daqing.financial") public class DqFinancialHrmsApplication { public static void main(String[] args) { diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java index fc4eb2f4..bb6582b2 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java @@ -1,17 +1,18 @@ package com.daqing.financial.hrms.controller; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - +import com.daqing.financial.hrms.DeptControllerApi; 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.utils.PageUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import com.daqing.framework.domain.hrms.DeptEntity; -import com.daqing.financial.hrms.service.DeptService; -import com.daqing.framework.utils.PageUtils; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; /** * 记录部门信息 @@ -22,7 +23,7 @@ import com.daqing.framework.utils.PageUtils; */ @RestController @RequestMapping("hrms/dept") -public class DeptController { +public class DeptController implements DeptControllerApi { @Autowired private DeptService deptService; @@ -30,6 +31,20 @@ public class DeptController { @Autowired 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(); } - /** - * 保存 - */ - @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(); } - } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java index 1952732c..49ea4034 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java @@ -1,6 +1,7 @@ package com.daqing.financial.hrms.service; 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.domain.hrms.DeptEntity; @@ -16,5 +17,7 @@ import java.util.Map; public interface DeptService extends IService { PageUtils queryPage(Map params); + + boolean saveDept(DeptAddRequest deptAddRequest); } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java index 6d2673d2..c75ad899 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java @@ -6,10 +6,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.daqing.financial.hrms.dao.DeptDao; 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.domain.hrms.response.DeptCode; +import com.daqing.framework.exception.ExceptionCast; import com.daqing.framework.utils.PageUtils; 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 java.util.Date; import java.util.Map; @@ -26,4 +33,61 @@ public class DeptServiceImpl extends ServiceImpl implements 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().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); + } + } \ No newline at end of file diff --git a/dq-framework-common/src/main/java/com/daqing/framework/exception/CustomException.java b/dq-framework-common/src/main/java/com/daqing/framework/exception/CustomException.java index 5457a5a3..90710156 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/exception/CustomException.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/exception/CustomException.java @@ -1,6 +1,6 @@ package com.daqing.framework.exception; -import com.daqing.framework.model.response.ResponseResult; +import com.daqing.framework.model.response.ResultCode; /** * @Author: gongsj. @@ -9,15 +9,15 @@ import com.daqing.framework.model.response.ResponseResult; * @Modified By: */ public class CustomException extends RuntimeException { - private ResponseResult responseResult; + private ResultCode resultCode; - public CustomException(ResponseResult responseResult) { + public CustomException(ResultCode resultCode) { //异常信息为错误码+异常信息 - super("错误码:" + responseResult.getCode() + "错误信息:" + responseResult.getMessage()); - this.responseResult = responseResult; + super("错误码:" + resultCode.code() + "错误信息:" + resultCode.message()); + this.resultCode = resultCode; } - public ResponseResult getResultCode() { - return this.responseResult; + public ResultCode getResultCode() { + return this.resultCode; } } diff --git a/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCast.java b/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCast.java index 6e2697b2..657bfeae 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCast.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCast.java @@ -1,6 +1,6 @@ package com.daqing.framework.exception; -import com.daqing.framework.model.response.ResponseResult; +import com.daqing.framework.model.response.ResultCode; /** * @Author: gongsj. @@ -10,7 +10,7 @@ import com.daqing.framework.model.response.ResponseResult; */ public class ExceptionCast { //使用此静态方法抛出自定义异常 - public static void cast(ResponseResult responseResult) { - throw new CustomException(responseResult); + public static void cast(ResultCode resultCode) { + throw new CustomException(resultCode); } } diff --git a/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCatch.java b/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCatch.java index d2d11bcd..d339522f 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCatch.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/exception/ExceptionCatch.java @@ -2,6 +2,7 @@ package com.daqing.framework.exception; import com.daqing.framework.model.response.CommonCode; import com.daqing.framework.model.response.ResponseResult; +import com.daqing.framework.model.response.ResultCode; import com.google.common.collect.ImmutableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,13 +23,12 @@ public class ExceptionCatch { private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.class); //定义Map,配置异常类型所对应的错误代码,使用 ImmutableMap 一旦写入数据,就无法更改,只读并且线程安全 - private static ImmutableMap, ResponseResult> EXCEPTIONS; - + private static ImmutableMap, ResultCode> EXCEPTIONS; //定义map的builder对象,去构建ImmutableMap - protected static ImmutableMap.Builder, ResponseResult> builder = ImmutableMap.builder(); + protected static ImmutableMap.Builder, ResultCode> builder = ImmutableMap.builder(); - @ResponseBody @ExceptionHandler(Exception.class) + @ResponseBody public ResponseResult exception(Exception exception) { exception.printStackTrace(); //记录日志 @@ -37,9 +37,9 @@ public class ExceptionCatch { EXCEPTIONS = builder.build();//EXCEPTION构建成功 } //从EXCEPTIONS中找到异常类型所对应的错误代码,如果找到了,将错误代码相应给用户,如果找不到则给用户相应99999 - ResponseResult responseResult = EXCEPTIONS.get(exception.getClass()); - if (responseResult != null) { - return responseResult; + ResultCode resultCode = EXCEPTIONS.get(exception.getClass()); + if (resultCode != null) { + return new ResponseResult(resultCode); } //返回99999异常 return new ResponseResult(CommonCode.SERVER_ERROR); @@ -47,7 +47,7 @@ public class ExceptionCatch { static { //定义异常类型所对应的错误代码 - builder.put(HttpMessageNotReadableException.class, new ResponseResult(CommonCode.INVALID_PARAM)); + builder.put(HttpMessageNotReadableException.class, CommonCode.INVALID_PARAM); } @ExceptionHandler(CustomException.class)//捕获CustomException类型异常 @@ -57,6 +57,7 @@ public class ExceptionCatch { //记录日志 LOGGER.error("catch exception:{}", customException.getMessage()); - return customException.getResultCode(); + ResultCode resultCode = customException.getResultCode(); + return new ResponseResult(resultCode); } -} +} \ No newline at end of file diff --git a/dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java b/dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java index 61e02eb7..259467a7 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java @@ -2,6 +2,7 @@ package com.daqing.framework.model.response; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.ToString; /** * @Author: gongsj. @@ -9,8 +10,9 @@ import lombok.Getter; * @Date:Created in 2020/09/07 11:35. * @Modified By: */ +@ToString @AllArgsConstructor -public enum CommonCode { +public enum CommonCode implements ResultCode { SUCCESS(true, 10000, "操作成功!"), FAIL(false, 11111, "操作失败!"), @@ -36,4 +38,19 @@ public enum CommonCode { */ @Getter private String message; + + @Override + public boolean success() { + return this.success; + } + + @Override + public int code() { + return this.code; + } + + @Override + public String message() { + return this.message; + } } diff --git a/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java index 84c39ced..2f37e4a9 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java @@ -42,10 +42,10 @@ public class ResponseResult { this.message = message; } - public ResponseResult(CommonCode commonCode) { - this.success = commonCode.isSuccess(); - this.code = commonCode.getCode(); - this.message = commonCode.getMessage(); + public ResponseResult(ResultCode resultCode) { + this.success = resultCode.success(); + this.code = resultCode.code(); + this.message = resultCode.message(); } public static ResponseResult SUCCESS() { @@ -55,8 +55,4 @@ public class ResponseResult { public static ResponseResult FAIL() { return new ResponseResult(CommonCode.FAIL); } - - public static ResponseResult FAIL(String message) { - return new ResponseResult(false, 500, message); - } } diff --git a/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResultCode.java b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResultCode.java new file mode 100644 index 00000000..a3e24511 --- /dev/null +++ b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResultCode.java @@ -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(); +} diff --git a/dq-framework-common/src/main/java/com/daqing/framework/xss/SQLFilter.java b/dq-framework-common/src/main/java/com/daqing/framework/xss/SQLFilter.java index 25c1f6de..e0a11856 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/xss/SQLFilter.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/xss/SQLFilter.java @@ -9,7 +9,7 @@ package com.daqing.framework.xss; 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; /** @@ -44,7 +44,7 @@ public class SQLFilter { for (String keyword : keywords) { //if (str.indexOf(keyword) != -1) if (str.contains(keyword)) { - ExceptionCast.cast(ResponseResult.FAIL("包含非法字符")); + ExceptionCast.cast(CommonCode.INVALID_PARAM); } } return str; diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CompanyCustomerEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CompanyCustomerEntity.java index 28fca9cd..6a85275b 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CompanyCustomerEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CompanyCustomerEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.crms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 注册资金 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CustomerEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CustomerEntity.java index 86210c84..e3c41162 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CustomerEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/CustomerEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.crms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 客户编号 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/PersonalCustomerEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/PersonalCustomerEntity.java index 665b9e23..4a1aea87 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/PersonalCustomerEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/PersonalCustomerEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.crms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 客户基本信息表id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DeptEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DeptEntity.java index 1b0bb4ad..628b3bf5 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DeptEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DeptEntity.java @@ -1,11 +1,12 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; import java.io.Serializable; 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; /** * 部门名称 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeDeptEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeDeptEntity.java index 8f1717e3..5a5e963a 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeDeptEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeDeptEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 员工id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java index 049a5dd8..5d5f4d65 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 姓名 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeePositionEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeePositionEntity.java index e1857107..eb193156 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeePositionEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeePositionEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 员工id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeRoleEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeRoleEntity.java index 296aae58..19b17eb4 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeRoleEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeRoleEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 用户id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PermissionEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PermissionEntity.java index 3b614ca4..c053d233 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PermissionEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PermissionEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 权限标识符 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java index a0e8c90e..4ced00de 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 部门id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RoleEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RoleEntity.java index f466e2be..a05469c1 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RoleEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RoleEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 角色名称 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RolePermissionEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RolePermissionEntity.java index 9775b6b3..0b07244c 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RolePermissionEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/RolePermissionEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 角色id diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java index 8644942a..29a4d79d 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java @@ -1,5 +1,6 @@ package com.daqing.framework.domain.hrms; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; 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; /** * 用于登录的账号,必填 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/DeptAddRequest.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/DeptAddRequest.java new file mode 100644 index 00000000..121775f0 --- /dev/null +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/DeptAddRequest.java @@ -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; +} diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/DeptCode.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/DeptCode.java new file mode 100644 index 00000000..115886a3 --- /dev/null +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/DeptCode.java @@ -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; + } +} diff --git a/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java b/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java index 8b0fe802..c50f35cc 100644 --- a/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java +++ b/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java @@ -1,8 +1,5 @@ package com.daqing.framework.utils; -import java.util.HashSet; -import java.util.Set; - /** * @Author: JCccc * @Description: 雪花算法生成id工具类 @@ -175,27 +172,28 @@ public class SnowflakeIdUtils { return SnowflakeIdUtils.getInstance().nextId(); } -// public static void main(String[] args) { -// -// SnowflakeIdUtils snowflakeIdUtils = SnowflakeIdUtils.getInstance(); + public static void main(String[] args) { + + 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 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 set2 = new HashSet<>(); -//// for (int i = 0; i < 1000000; i++) { -//// set2.add(snowflakeIdUtils.nextId()); -//// } -//// System.out.println(set2.size()); -//// // Set set = new HashSet<>(); // for (int i = 0; i < 1000000; i++) { // set.add(SnowflakeIdUtils.getRandomid()); // } // System.out.println(set.size()); -// } + System.out.println((SnowflakeIdUtils.getRandomid() + "").length()); + } } \ No newline at end of file