Merge remote-tracking branch 'origin/master'

# Conflicts:
#	dq-financial-crms-auth/src/main/resources/bootstrap.properties
#	dq-financial-hrms/src/main/resources/bootstrap.properties
#	dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java
#	dq-govern-gateway/src/main/resources/bootstrap.properties
master
邱飞云 4 years ago
commit 1b1e23e82c
  1. 25
      dq-financial-api/src/main/java/com/daqing/financial/crms/CustomerControllerApi.java
  2. 25
      dq-financial-api/src/main/java/com/daqing/financial/hrauth/SystemLogControllerApi.java
  3. 3
      dq-financial-api/src/main/java/com/daqing/financial/hrauth/UserLoginControllerApi.java
  4. 13
      dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java
  5. 3
      dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java
  6. BIN
      dq-financial-api/target/classes/com/daqing/financial/DqFinancialApiApplication.class
  7. BIN
      dq-financial-api/target/classes/com/daqing/financial/crms/CustomerControllerApi.class
  8. BIN
      dq-financial-api/target/classes/com/daqing/financial/hrauth/UserLoginControllerApi.class
  9. BIN
      dq-financial-api/target/classes/com/daqing/financial/hrms/DeptControllerApi.class
  10. BIN
      dq-financial-api/target/classes/com/daqing/financial/hrms/EmployeeControllerApi.class
  11. 2
      dq-financial-crms-auth/src/main/java/com/daqing/financial/crauth/service/impl/CustomerLoginServiceImpl.java
  12. 4
      dq-financial-crms-auth/src/main/resources/bootstrap.properties
  13. 2
      dq-financial-crms-auth/src/main/resources/mapper/crmsauth/CustomerLoginMapper.xml
  14. 19
      dq-financial-crms-auth/target/classes/bootstrap.properties
  15. 47
      dq-financial-crms-auth/target/classes/logback-spring.xml
  16. 10
      dq-financial-crms-auth/target/classes/mapper/crmsauth/CustomerLoginMapper.xml
  17. BIN
      dq-financial-crms-auth/target/test-classes/com/daqing/financial/crauth/DqFinancialCrmsAuthApplicationTests.class
  18. 50
      dq-financial-crms/src/main/java/com/daqing/financial/crms/config/CorsConfig.java
  19. 61
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java
  20. 2
      dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java
  21. 18
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerService.java
  22. 321
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  23. 4
      dq-financial-crms/src/main/resources/mapper/crms/CompanyCustomerDao.xml
  24. 6
      dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml
  25. 4
      dq-financial-crms/src/main/resources/mapper/crms/PersonalCustomerDao.xml
  26. BIN
      dq-financial-crms/target/classes/META-INF/dq-financial-crms.kotlin_module
  27. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/DqFinancialCrmsApplication.class
  28. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/config/CorsConfig.class
  29. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/config/IPageConfig.class
  30. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/controller/CustomerController.class
  31. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/dao/CompanyCustomerDao.class
  32. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/dao/CustomerDao.class
  33. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/dao/PersonalCustomerDao.class
  34. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/feign/HrmsFeignService.class
  35. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/service/CustomerService.class
  36. BIN
      dq-financial-crms/target/classes/com/daqing/financial/crms/service/impl/CustomerServiceImpl.class
  37. 4
      dq-financial-crms/target/classes/mapper/crms/CompanyCustomerDao.xml
  38. 6
      dq-financial-crms/target/classes/mapper/crms/CustomerDao.xml
  39. 4
      dq-financial-crms/target/classes/mapper/crms/PersonalCustomerDao.xml
  40. 42
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/annotation/Log.java
  41. 129
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/aspect/Operation.java
  42. 179
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/aspect/SysLogAspect.java
  43. 56
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/SystemLogController.java
  44. 11
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java
  45. 6
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/LoginLogMapper.java
  46. 20
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/SystemLogMapper.java
  47. 66
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/enums/BusinessType.java
  48. 52
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/enums/OperationType.java
  49. 37
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/enums/OperationUnit.java
  50. 4
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/LoginLogService.java
  51. 11
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/SystemLogService.java
  52. 3
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java
  53. 19
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/LoginLogServiceImpl.java
  54. 32
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/SystemLogServiceImpl.java
  55. 63
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  56. 67
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/IpUtils.java
  57. 39
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/LoginLogMapper.xml
  58. 16
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/SystemLogMapper.xml
  59. 2
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml
  60. 29
      dq-financial-hrms-auth/target/classes/bootstrap.properties
  61. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/DqFinancialHrmsAuthApplication.class
  62. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/annotation/Log.class
  63. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/aspect/Operation.class
  64. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/aspect/SysLogAspect.class
  65. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/controller/UserLoginController.class
  66. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/dao/LoginLogMapper.class
  67. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/dao/SystemLogMapper.class
  68. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/dao/TokenMapper.class
  69. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/dao/UserLoginDao.class
  70. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/enums/BusinessType$1.class
  71. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/enums/BusinessType.class
  72. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/enums/OperationType$1.class
  73. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/enums/OperationType.class
  74. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/enums/OperationUnit.class
  75. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/LoginLogService.class
  76. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/TokenService.class
  77. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/UserLoginService.class
  78. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/impl/LoginLogServiceImpl.class
  79. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/impl/TokenServiceImpl.class
  80. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.class
  81. BIN
      dq-financial-hrms-auth/target/classes/com/daqing/financial/hrauth/util/IpUtils.class
  82. 47
      dq-financial-hrms-auth/target/classes/logback-spring.xml
  83. 41
      dq-financial-hrms-auth/target/classes/mapper/hrmsauth/UserLoginMapper.xml
  84. 8
      dq-financial-hrms/pom.xml
  85. 33
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/config/CorsConfig.java
  86. 11
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java
  87. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java
  88. 7
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/UserController.java
  89. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/DeptDao.java
  90. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java
  91. 25
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java
  92. 1
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java
  93. 12
      dq-financial-hrms/src/main/resources/application.yml
  94. 11
      dq-financial-hrms/src/main/resources/bootstrap.properties
  95. 5
      dq-financial-hrms/src/main/resources/mapper/hrms/DeptDao.xml
  96. 26
      dq-financial-hrms/src/main/resources/mapper/hrms/EmployeeDao.xml
  97. 2
      dq-financial-hrms/src/main/resources/mapper/hrms/PositionDao.xml
  98. 12
      dq-financial-hrms/target/classes/application.yml
  99. 12
      dq-financial-hrms/target/classes/bootstrap.properties
  100. BIN
      dq-financial-hrms/target/classes/com/daqing/financial/hrms/config/CorsConfig.class
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,8 +1,7 @@
package com.daqing.financial.crms; package com.daqing.financial.crms;
import com.daqing.framework.domain.crms.ext.CustomerCompanyTO; import com.daqing.framework.domain.crms.ext.*;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTO;
import com.daqing.framework.domain.crms.request.CustomerRequest; import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -10,8 +9,6 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/** /**
* @Author: gongsj. * @Author: gongsj.
@ -25,7 +22,7 @@ public interface CustomerControllerApi {
/** /**
* 列表展示 * 列表展示
*/ */
@ApiOperation(value = "客户信息列表展示", notes = "客户信息列表展示") @ApiOperation(value = "客户信息列表展示", notes = "客户信息列表展示",response = CustomerTO.class)
ResponseResult queryList(Integer page, Integer size, CustomerRequest customerRequest); ResponseResult queryList(Integer page, Integer size, CustomerRequest customerRequest);
/** /**
@ -41,34 +38,34 @@ public interface CustomerControllerApi {
ResponseResult deleteCustomer(Long[] ids); ResponseResult deleteCustomer(Long[] ids);
/** /**
* 插入个人类型客户信息 * 新增个人类型客户信息
*/ */
@ApiOperation(value = "插入个人类型客户信息", notes = "插入个人类型客户信息") @ApiOperation(value = "新增个人类型客户信息", notes = "新增个人类型客户信息")
ResponseResult savePersonal(CustomerPersonalTO customerPersonalTO); ResponseResult savePersonal(CustomerPersonalTOI customerPersonalTOI);
/** /**
* 插入企业类型客户信息 * 新增企业类型客户信息
*/ */
@ApiOperation(value = "插入企业类型客户信息", notes = "插入企业类型客户信息") @ApiOperation(value = "新增企业类型客户信息", notes = "新增企业类型客户信息")
ResponseResult saveCompany(CustomerCompanyTO customerCompanyTO); ResponseResult saveCompany(CustomerCompanyTOI customerCompanyTOI);
/** /**
* 更新个人类型客户信息 * 更新个人类型客户信息
*/ */
@ApiOperation(value = "更新个人类型客户信息", notes = "更新个人类型客户信息") @ApiOperation(value = "更新个人类型客户信息", notes = "更新个人类型客户信息")
ResponseResult updatePersonal(CustomerPersonalTO customerPersonalTO); ResponseResult updatePersonal(CustomerPersonalTOU customerPersonalTOU);
/** /**
* 更新企业类型客户信息 * 更新企业类型客户信息
*/ */
@ApiOperation(value = "更新企业类型客户信息", notes = "更新企业类型客户信息") @ApiOperation(value = "更新企业类型客户信息", notes = "更新企业类型客户信息")
ResponseResult updateCompany(CustomerCompanyTO customerCompanyTO); ResponseResult updateCompany(CustomerCompanyTOU customerCompanyTOU);
/** /**
* 导入excel数据 * 导入excel数据
*/ */
@ApiOperation(value = "导入excel数据", notes = "导入excel数据") @ApiOperation(value = "导入excel数据", notes = "导入excel数据")
void excelImportCustomer(MultipartFile file); ResponseResult excelImportCustomer(MultipartFile file);
/** /**
* 导出数据到excel * 导出数据到excel

@ -0,0 +1,25 @@
package com.daqing.financial.hrauth;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UserLoginLogRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @Author: gongsj.
* @Description: 登录controllerApi定义
* @Date:Created in 2020/09/07 11:33.
* @Modified By:
*/
@Api(value = "系统日志相关操作", tags = "提供系统日志相关操作")
public interface SystemLogControllerApi {
@ApiOperation(value = "系统日志列表")
ResponseResult list(Integer page, Integer size);
@ApiOperation(value = "登录日志列表")
ResponseResult loginLogList(Integer page, Integer size, UserLoginLogRequest userLoginLogRequest);
}

@ -1,6 +1,7 @@
package com.daqing.financial.hrauth; package com.daqing.financial.hrauth;
import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest; import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -26,5 +27,7 @@ public interface UserLoginControllerApi {
@ApiOperation(value = "登录") @ApiOperation(value = "登录")
ResponseResult login(LoginRequest loginRequest); ResponseResult login(LoginRequest loginRequest);
@ApiOperation(value = "修改超管员密码")
ResponseResult updatePwd(UpdatePwdRequest user);
} }

@ -1,5 +1,6 @@
package com.daqing.financial.hrms; package com.daqing.financial.hrms;
import com.daqing.framework.domain.crms.ext.CustomerCompanyVO;
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.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
@ -42,7 +43,7 @@ public interface DeptControllerApi {
/** /**
* 根据id修改部门信息 * 根据id修改部门信息
*/ */
@ApiOperation(value = "根据id修改部门信息", notes = "根据id修改部门信息") @ApiOperation(value = "根据id修改部门信息", notes = "根据id修改部门信息", response = CustomerCompanyVO.class)
ResponseResult update(DeptEntity dept); ResponseResult update(DeptEntity dept);
/** /**
@ -54,6 +55,12 @@ public interface DeptControllerApi {
/** /**
* 查询所有部门及部门下的员工信息 * 查询所有部门及部门下的员工信息
*/ */
@ApiOperation(value = "查询所有部门及部门下的员工信息", notes = "查询所有部门及部门下的员工信息") /*@ApiOperation(value = "查询所有部门及部门下的员工信息", notes = "查询所有部门及部门下的员工信息")
ResponseResult trees(); ResponseResult trees();*/
/**
* 查询该部门下所有子部门及部门下的的员工
*/
@ApiOperation(value = "查询该部门下所有子部门及部门下的的员工", notes = "查询该部门下所有子部门及部门下的的员工")
ResponseResult children(Long id);
} }

@ -26,4 +26,7 @@ public interface EmployeeControllerApi {
@ApiOperation(value = "根据id删除员工信息", notes = "根据id删除员工信息") @ApiOperation(value = "根据id删除员工信息", notes = "根据id删除员工信息")
ResponseResult delete(Long[] ids); ResponseResult delete(Long[] ids);
@ApiOperation(value = "查询所有员工id和姓名",notes = "查询所有员工id和姓名")
ResponseResult listEmployeeName();
} }

@ -32,7 +32,7 @@ public class CustomerLoginServiceImpl implements CustomerLoginService, UserDetai
List<SimpleGrantedAuthority> authorities = new ArrayList<>(); List<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("ROLE_ADMIN")); authorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
System.out.println(customer); System.out.println(customer);
UserDetails userDetails = new User(customer.getCode(),new BCryptPasswordEncoder().encode(customer.getPassword()),authorities); UserDetails userDetails = new User(customer.getPhone(),new BCryptPasswordEncoder().encode(customer.getPassword()),authorities);
return userDetails; return userDetails;
} }

@ -1,5 +1,7 @@
# 开发和测试环境(dev)
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
spring.application.name=dq-financial-crms spring.application.name=dq-financial-crms
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
spring.cloud.nacos.config.server-addr=192.168.31.142:8848 spring.cloud.nacos.config.server-addr=192.168.31.142:8848
spring.cloud.nacos.config.namespace=37d72d30-3178-4173-8b5e-269a23355ed9 spring.cloud.nacos.config.namespace=37d72d30-3178-4173-8b5e-269a23355ed9
#spring.cloud.nacos.config.group=prod #spring.cloud.nacos.config.group=prod

@ -4,7 +4,7 @@
<mapper namespace="com.daqing.financial.crauth.dao.CustomerLoginDao"> <mapper namespace="com.daqing.financial.crauth.dao.CustomerLoginDao">
<select id="getCustomer" parameterType="string" resultType="com.daqing.framework.domain.crms.CustomerEntity"> <select id="getCustomer" parameterType="string" resultType="com.daqing.framework.domain.crms.CustomerEntity">
SELECT code,password FROM crms_customer WHERE code = #{code} SELECT phone,password FROM crms_customer WHERE phone = #{phone}
</select> </select>
</mapper> </mapper>

@ -0,0 +1,19 @@
#·þÎñÃû³Æ
spring.application.name=dq-financial-crms
#ÅäÖÃÖÐÐĵØÖ·
spring.cloud.nacos.config.server-addr=192.168.31.142:8848
spring.cloud.nacos.config.namespace=37d72d30-3178-4173-8b5e-269a23355ed9
#spring.cloud.nacos.config.group=prod
spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml
spring.cloud.nacos.config.ext-config[0].group=dev
spring.cloud.nacos.config.ext-config[0].refresh=true
spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml
spring.cloud.nacos.config.ext-config[1].group=dev
spring.cloud.nacos.config.ext-config[1].refresh=true
spring.cloud.nacos.config.ext-config[2].data-id=other.yml
spring.cloud.nacos.config.ext-config[2].group=dev
spring.cloud.nacos.config.ext-config[2].refresh=true

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--定义日志文件的存储地址,使用绝对路径-->
<property name="LOG_HOME" value="d:/logs/daqing/crms_auth"/>
<!-- Console 输出设置 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<fileNamePattern>${LOG_HOME}/crms_auth.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- 异步输出 -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="FILE"/>
</appender>
<logger name="org.apache.ibatis.cache.decorators.LoggingCache" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.boot" level="DEBUG"/>
<root level="info">
<!--<appender-ref ref="ASYNC"/>-->
<appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/>
</root>
</configuration>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.crauth.dao.CustomerLoginDao">
<select id="getCustomer" parameterType="string" resultType="com.daqing.framework.domain.crms.CustomerEntity">
SELECT phone,password FROM crms_customer WHERE phone = #{phone}
</select>
</mapper>

@ -0,0 +1,50 @@
//package com.daqing.financial.crms.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 实现基本的跨域请求
// *
// * @auther River
// * @date 2020/9/25 15:09
// */
//@Configuration
//public class CorsConfig extends WebMvcConfigurerAdapter {
//
//
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(new HandlerInterceptor() {
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
// throws Exception {
// // boolean isTrue = envConfig.getIsDev();//判断是测试服才需要解决跨域问题
// //if (isTrue) {
// response.addHeader("Access-Control-Allow-Origin", "*");
// response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
// response.addHeader("Access-Control-Allow-Headers",
// "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,token");
// // }
// return true;
// }
//
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// ModelAndView modelAndView) throws Exception {
//
// }
//
// @Override
// public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
// Exception ex) throws Exception {
// }
// });
// }
//}

@ -2,17 +2,23 @@ package com.daqing.financial.crms.controller;
import com.daqing.financial.crms.CustomerControllerApi; import com.daqing.financial.crms.CustomerControllerApi;
import com.daqing.financial.crms.service.CustomerService; import com.daqing.financial.crms.service.CustomerService;
import com.daqing.framework.domain.crms.ext.CustomerCompanyTO; import com.daqing.framework.domain.crms.ext.CustomerCompanyTOI;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTO; import com.daqing.framework.domain.crms.ext.CustomerCompanyTOU;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOU;
import com.daqing.framework.domain.crms.request.CustomerRequest; import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.PromptSuccess;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import javax.validation.Valid;
import java.util.*;
/** /**
@ -63,57 +69,60 @@ public class CustomerController implements CustomerControllerApi {
/** /**
* 根据客户id删除所选客户 * 根据客户id删除所选客户
*/ */
@Override
@DeleteMapping("/deleteCustomer") @DeleteMapping("/deleteCustomer")
public ResponseResult deleteCustomer(@RequestBody Long[] ids){ public ResponseResult deleteCustomer(@RequestBody Long[] ids){
List<String> list = customerService.updateCustomerById(ids);
return new ResponseResult<List<String>>().SUCCESS(customerService.updateCustomerById(ids)); if (list == null){
return new ResponseResult(CommonCode.INVALID_PARAM);
}else if (Objects.equals(list.get(0),PromptSuccess.DELETE_SUCCESS)){
return ResponseResult.SUCCESS();
}else if (Objects.equals(list.get(0),PromptSuccess.DELETE_FAIL)){
return new ResponseResult(CommonCode.DELETE_FAIL);
}
else {
return new ResponseResult<List<String>>().SUCCESS_DATA(list);
}
} }
/** /**
* 保存个人类型客户信息 * 保存个人类型客户信息
*/ */
@PostMapping("/savePersonal") @PostMapping("/savePersonal")
@Override public ResponseResult savePersonal(@RequestBody @Valid CustomerPersonalTOI customerPersonalTOI) {
public ResponseResult savePersonal(@RequestBody CustomerPersonalTO customerPersonalTO) { boolean result = customerService.saveCustomerPersonal(customerPersonalTOI);
boolean result = customerService.saveCustomerPersonal(customerPersonalTO.getCustomerEntity(), customerPersonalTO.getPersonalCustomerEntity()); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.SAVE_FAIL);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
* 保存企业类型客户信息 * 保存企业类型客户信息
*/ */
@PostMapping("/saveCompany") @PostMapping("/saveCompany")
@Override public ResponseResult saveCompany(@RequestBody @Valid CustomerCompanyTOI customerCompanyTOI) {
public ResponseResult saveCompany(@RequestBody CustomerCompanyTO customerCompanyTO) { boolean result = customerService.saveCustomerCompany(customerCompanyTOI);
boolean result = customerService.saveCustomerCompany(customerCompanyTO.getCustomerEntity(), customerCompanyTO.getCompanyCustomerEntity()); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.SAVE_FAIL);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
* 更新个人类型客户信息 * 更新个人类型客户信息
*/ */
@PostMapping("/updatePersonal") @PostMapping("/updatePersonal")
@Override public ResponseResult updatePersonal(@RequestBody @Valid CustomerPersonalTOU customerPersonalTOU) {
public ResponseResult updatePersonal(@RequestBody CustomerPersonalTO customerPersonalTO) { boolean result = customerService.updateCustomerPersonal(customerPersonalTOU);
boolean result = customerService.updateCustomerPersonal(customerPersonalTO.getCustomerEntity(), customerPersonalTO.getPersonalCustomerEntity()); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
* 更新企业类型客户信息 * 更新企业类型客户信息
*/ */
@PostMapping("/updateCompany") @PostMapping("/updateCompany")
@Override public ResponseResult updateCompany(@RequestBody @Valid CustomerCompanyTOU customerCompanyTOU) {
public ResponseResult updateCompany(@RequestBody CustomerCompanyTO customerCompanyTO) { boolean result = customerService.updateCustomerCompany(customerCompanyTOU);
boolean result = customerService.updateCustomerCompany(customerCompanyTO.getCustomerEntity(), customerCompanyTO.getCompanyCustomerEntity()); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
* 导出数据到excel * 导出数据到excel
*/ */
@Override
@GetMapping("/excelExport") @GetMapping("/excelExport")
public void excelExportCustomer(HttpServletResponse response){ public void excelExportCustomer(HttpServletResponse response){
@ -123,7 +132,6 @@ public class CustomerController implements CustomerControllerApi {
/** /**
* 导出excel模板 * 导出excel模板
*/ */
@Override
@GetMapping("/excelTemplate") @GetMapping("/excelTemplate")
public void excelTemplate(HttpServletResponse response){ public void excelTemplate(HttpServletResponse response){
@ -134,9 +142,8 @@ public class CustomerController implements CustomerControllerApi {
* 导入excel数据 * 导入excel数据
*/ */
@PostMapping("/excelImport") @PostMapping("/excelImport")
@Override public ResponseResult excelImportCustomer(MultipartFile file){
public void excelImportCustomer(MultipartFile file){
customerService.excelImportCustomer(file); return customerService.excelImportCustomer(file);
} }
} }

@ -25,7 +25,7 @@ public interface CustomerDao extends BaseMapper<CustomerEntity> {
CustomerEntity queryCustomerById(Long id); CustomerEntity queryCustomerById(Long id);
void updateCustomerById(@Param("ids") List<Long> ids); boolean updateCustomerById(@Param("ids") List<Long> ids);
List<String> queryCustomerNameById(@Param("ids") List<Long> ids); List<String> queryCustomerNameById(@Param("ids") List<Long> ids);

@ -1,8 +1,10 @@
package com.daqing.financial.crms.service; package com.daqing.financial.crms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.crms.CompanyCustomerEntity; import com.daqing.framework.domain.crms.ext.CustomerCompanyTOI;
import com.daqing.framework.domain.crms.PersonalCustomerEntity; import com.daqing.framework.domain.crms.ext.CustomerCompanyTOU;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTOU;
import com.daqing.framework.domain.crms.request.CustomerRequest; import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
@ -10,9 +12,7 @@ import com.daqing.framework.domain.crms.CustomerEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 记录客户基本信息 * 记录客户基本信息
@ -29,17 +29,17 @@ public interface CustomerService extends IService<CustomerEntity> {
List<String> updateCustomerById(Long[] ids); List<String> updateCustomerById(Long[] ids);
boolean saveCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity); boolean saveCustomerPersonal(CustomerPersonalTOI customerPersonalTOI);
boolean saveCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity); boolean saveCustomerCompany(CustomerCompanyTOI customerCompanyTOI);
boolean updateCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity); boolean updateCustomerPersonal(CustomerPersonalTOU customerPersonalTOU);
boolean updateCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity); boolean updateCustomerCompany(CustomerCompanyTOU customerCompanyTOU);
void excelExportCustomer(HttpServletResponse response); void excelExportCustomer(HttpServletResponse response);
void excelImportCustomer(MultipartFile excel); ResponseResult excelImportCustomer(MultipartFile excel);
void excelTemplate(HttpServletResponse response); void excelTemplate(HttpServletResponse response);
} }

@ -2,6 +2,7 @@ package com.daqing.financial.crms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.crms.dao.CompanyCustomerDao; import com.daqing.financial.crms.dao.CompanyCustomerDao;
@ -15,13 +16,14 @@ import com.daqing.framework.domain.crms.PersonalCustomerEntity;
import com.daqing.framework.domain.crms.ext.*; import com.daqing.framework.domain.crms.ext.*;
import com.daqing.framework.domain.crms.request.CustomerRequest; import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.domain.crms.response.CrmsCode; import com.daqing.framework.domain.crms.response.CrmsCode;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeTO; import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.domain.hrms.ext.EmployeeVO; import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.exception.ExceptionCast; import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.PromptSuccess;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.utils.SnowflakeIdUtils;
import com.daqing.framework.utils.excel.ExcelUtil; import com.daqing.framework.utils.excel.ExcelUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -62,30 +65,30 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
// 时间参数校验 // 时间参数校验
this.timeCheckout(customerRequest.getCreateTime(), customerRequest.getStartTime(), customerRequest.getEndTime(), customerRequest); this.timeCheckout(customerRequest.getCreateTime(), customerRequest.getStartTime(), customerRequest.getEndTime(), customerRequest);
// 分页参数校验 // 分页参数校验
Page<Object> pages = this.pageCheckout(page, size); Page<Object> pages = this.pageCheckout(page, size);
// 查询所有客户的基本信息 // 查询所有客户的基本信息
IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest); IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest);
// 获取所有的客户基本信息 // 获取所有的客户基本信息
List<CustomerEntity> customers = customerEntityIPage.getRecords(); List<CustomerEntity> customers = customerEntityIPage.getRecords();
// 获取所有的客户经理id // 获取所有的客户经理id
Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new); Long[] ids = customers.stream().map(CustomerEntity::getManager).toArray(Long[]::new);
if (ids != null && ids.length != 0) { if (ids != null && ids.length != 0) {
//TODO 远程调用查询客户经理信息的接口 //TODO 远程调用查询客户经理信息的接口
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids);
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData();
if (employeeTO != null){
// 将客户信息和客户经理及部门信息拼装起来 // 将客户信息和客户经理及部门信息拼装起来
List<CustomerTO> customerTOS = this.jointCustomerEmployee(customers, employeeTO); List<CustomerTO> customerTOS = this.jointCustomerEmployee(customers, employeeTO);
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils IPage<CustomerTO> iPage = new Page<>();
IPage<CustomerTO> iPage = new Page<>(); BeanUtils.copyProperties(customerEntityIPage, iPage);
BeanUtils.copyProperties(customerEntityIPage, iPage); iPage.setRecords(customerTOS);
iPage.setRecords(customerTOS); return new PageUtils(iPage);
return new PageUtils(iPage); }else {
return new PageUtils(customerEntityIPage);
}
} else { } else {
return new PageUtils(customerEntityIPage); return new PageUtils(customerEntityIPage);
} }
@ -100,24 +103,64 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
@Override @Override
public ResponseResult queryCustomerById(Long id) { public ResponseResult queryCustomerById(Long id) {
if (id == null){
return new ResponseResult(CommonCode.INVALID_PARAM);
}
// 员工基本信息 // 员工基本信息
CustomerEntity customer = customerDao.queryCustomerById(id); CustomerEntity customer = customerDao.queryCustomerById(id);
if (customer == null) { if (customer == null) {
return new ResponseResult<CustomerEntity>().SUCCESS(null); return new ResponseResult(CommonCode.INEXISTENCE);
} }
// 客户经理姓名
String name = hrmsFeignService.getEmployeeById(customer.getManager()).getData().getName();
// 判断该客户的类型 // 判断该客户的类型
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) { if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) {
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id); PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id);
//封装个人类型客户信息 // 封装个人类型客户信息
CustomerPersonalDTO customerPersonalDTO = this.setPersonal(customer,personalCustomerEntity);
return new ResponseResult<CustomerPersonalDTO>().SUCCESS(customerPersonalDTO);
} else if (Objects.equals(customer.getType(),CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())){
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id);
// 封装企业类型客户信息
CustomerCompanyDTO customerCompanyDTO = this.setCompany(customer, companyCustomerEntity);
return new ResponseResult<CustomerCompanyDTO>().SUCCESS(customerCompanyDTO);
}else {
return new ResponseResult(CommonCode.INEXISTENCE);
}
}
/**
* 根据id查询客户的信息(导入到excel中)
*/
public ResponseResult getCustomerById(Long id) {
if (id == null){
return new ResponseResult(CommonCode.INVALID_PARAM);
}
// 员工基本信息
CustomerEntity customer = customerDao.queryCustomerById(id);
if (customer == null) {
return new ResponseResult(CommonCode.INEXISTENCE);
}
String name = PromptSuccess.NOT_BEING;
if (customer.getManager() != null){
ResponseResult<EmployeeEntity> employee = hrmsFeignService.getEmployeeById(customer.getManager());
if (employee.getData() != null){
// 客户经理姓名
name = hrmsFeignService.getEmployeeById(customer.getManager()).getData().getName();
}
}
// 判断该客户的类型
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) {
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id);
// 封装个人类型客户信息
CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity); CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity);
return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO); return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO);
} else { } else if (Objects.equals(customer.getType(),CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())){
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id); CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id);
//封装企业类型客户信息 // 封装企业类型客户信息
CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity); CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity);
return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO); return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO);
}else {
return new ResponseResult(CommonCode.INEXISTENCE);
} }
} }
@ -129,12 +172,18 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
*/ */
@Override @Override
public List<String> updateCustomerById(Long[] ids) { public List<String> updateCustomerById(Long[] ids) {
if (ids == null || ids.length == 0){
return null;
}
//TODO 远程调用审批模块判断所选客户是否在审批,返回正在审批的客户的id集合Long[] idArray //TODO 远程调用审批模块判断所选客户是否在审批,返回正在审批的客户的id集合Long[] idArray
List<Long> idArray = new ArrayList<>();// 假设为返回的正在审批的客户id集合 List<Long> idArray = new ArrayList<>();// 假设为返回的正在审批的客户id集合
if (idArray.size() == 0 || idArray == null) { if (idArray.size() == 0 || idArray == null) {
customerDao.updateCustomerById(Arrays.asList(ids)); boolean customer = customerDao.updateCustomerById(Arrays.asList(ids));
return new ArrayList<>(); List<String> success = new ArrayList<>();
success.add(PromptSuccess.DELETE_SUCCESS);
List<String> fail = new ArrayList<>();
fail.add(PromptSuccess.DELETE_FAIL);
return customer ? success : fail;
} else { } else {
return customerDao.queryCustomerNameById(idArray); return customerDao.queryCustomerNameById(idArray);
} }
@ -142,68 +191,79 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
/** /**
* 插入个人类型客户信息 * 插入个人类型客户信息
* @param customerEntity 客户基本信息
* @param personalCustomerEntity 个人类型信息
* @return
*/ */
@Transactional @Transactional
@Override @Override
public boolean saveCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) { public boolean saveCustomerPersonal(CustomerPersonalTOI customerPersonalTOI) {
customerEntity.setId(SnowflakeIdUtils.getRandomid()); CustomerEntity customerEntity = new CustomerEntity();
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity();
BeanUtils.copyProperties(customerPersonalTOI,customerEntity);
BeanUtils.copyProperties(customerPersonalTOI,personalCustomerEntity);
//TODO 设置客户编号 //TODO 设置客户编号
customerEntity.setCode(((int)(Math.random()*100+1))+""); customerEntity.setCode(((int)(Math.random()*100+1))+"");
customerEntity.setCreateTime(new Date()); customerEntity.setCreateTime(new Date());
customerEntity.setMotifyTime(new Date()); customerEntity.setMotifyTime(new Date());
personalCustomerEntity.setId(SnowflakeIdUtils.getRandomid()); boolean customer = customerDao.saveCustomer(customerEntity);
personalCustomerEntity.setCustomerId(customerEntity.getId()); personalCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.saveCustomer(customerEntity) && personalCustomerDao.savePersonalCustomer(personalCustomerEntity); boolean personal = personalCustomerDao.savePersonalCustomer(personalCustomerEntity);
return customer && personal;
} }
/** /**
* 插入企业类型客户信息 * 插入企业类型客户信息
* @param customerEntity 客户基本信息
* @param companyCustomerEntity 企业类型信息
* @return
*/ */
@Transactional @Transactional
@Override @Override
public boolean saveCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity) { public boolean saveCustomerCompany(CustomerCompanyTOI customerCompanyTOI) {
customerEntity.setId(SnowflakeIdUtils.getRandomid()); CustomerEntity customerEntity = new CustomerEntity();
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity();
BeanUtils.copyProperties(customerCompanyTOI,customerEntity);
BeanUtils.copyProperties(customerCompanyTOI,companyCustomerEntity);
//TODO 设置客户编号 //TODO 设置客户编号
customerEntity.setCode(((int)(Math.random()*100+1))+""); customerEntity.setCode(((int)(Math.random()*100+1))+"");
customerEntity.setCreateTime(new Date()); customerEntity.setCreateTime(new Date());
customerEntity.setMotifyTime(new Date()); customerEntity.setMotifyTime(new Date());
companyCustomerEntity.setId(SnowflakeIdUtils.getRandomid()); boolean customer = customerDao.saveCustomer(customerEntity);
companyCustomerEntity.setCustomerId(customerEntity.getId()); companyCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.saveCustomer(customerEntity) && companyCustomerDao.saveCompanyCustomer(companyCustomerEntity); boolean company = companyCustomerDao.saveCompanyCustomer(companyCustomerEntity);
return customer && company;
} }
/** /**
* 更新个人类型客户信息 * 更新个人类型客户信息
* @param customerEntity 客户基本信息
* @param personalCustomerEntity 企业类型信息
* @return
*/ */
@Transactional @Transactional
@Override @Override
public boolean updateCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) { public boolean updateCustomerPersonal(CustomerPersonalTOU customerPersonalTOU) {
CustomerEntity customerEntity = new CustomerEntity();
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity();
BeanUtils.copyProperties(customerPersonalTOU,customerEntity);
BeanUtils.copyProperties(customerPersonalTOU,personalCustomerEntity);
if (customerEntity.getId() == null){
return false;
}
customerEntity.setMotifyTime(new Date()); customerEntity.setMotifyTime(new Date());
boolean customer = customerDao.updateCustomer(customerEntity);
personalCustomerEntity.setCustomerId(customerEntity.getId()); personalCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.updateCustomer(customerEntity) && personalCustomerDao.updatePersonalCustomer(personalCustomerEntity); boolean personal = personalCustomerDao.updatePersonalCustomer(personalCustomerEntity);
return customer && personal;
} }
/** /**
* 更新企业类型客户信息 * 更新企业类型客户信息
* @param customerEntity 客户基本信息
* @param companyCustomerEntity 企业类型信息
* @return
*/ */
@Transactional @Transactional
@Override @Override
public boolean updateCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity) { public boolean updateCustomerCompany(CustomerCompanyTOU customerCompanyTOU) {
CustomerEntity customerEntity = new CustomerEntity();
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity();
BeanUtils.copyProperties(customerCompanyTOU,customerEntity);
BeanUtils.copyProperties(customerCompanyTOU,companyCustomerEntity);
customerEntity.setMotifyTime(new Date()); customerEntity.setMotifyTime(new Date());
boolean customer = customerDao.updateCustomer(customerEntity);
companyCustomerEntity.setCustomerId(customerEntity.getId()); companyCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.updateCustomer(customerEntity) && companyCustomerDao.updateCompanyCustomer(companyCustomerEntity); boolean company = companyCustomerDao.updateCompanyCustomer(companyCustomerEntity);
return customer && company;
} }
/** /**
@ -218,12 +278,14 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
List<CustomerCompanyVO> companyList = new ArrayList<>(); List<CustomerCompanyVO> companyList = new ArrayList<>();
List<CustomerPersonalVO> personalList = new ArrayList<>(); List<CustomerPersonalVO> personalList = new ArrayList<>();
List<Long> longList = customerDao.listCustomerId(); List<Long> longList = customerDao.listCustomerId();
for (Long id : longList) { if (longList != null){
ResponseResult responseResult = this.queryCustomerById(id); for (Long id : longList) {
if ((responseResult.getData()).getClass() == CustomerCompanyVO.class){ ResponseResult responseResult = this.getCustomerById(id);
companyList.add((CustomerCompanyVO) responseResult.getData()); if ((responseResult.getData()).getClass() == CustomerCompanyVO.class){
}else { companyList.add((CustomerCompanyVO) responseResult.getData());
personalList.add((CustomerPersonalVO) responseResult.getData()); }else {
personalList.add((CustomerPersonalVO) responseResult.getData());
}
} }
} }
ExcelUtil.writeExcelWithSheets(response,personalList,"客户资源信息一览表","个人类型",new CustomerPersonalVO()) ExcelUtil.writeExcelWithSheets(response,personalList,"客户资源信息一览表","个人类型",new CustomerPersonalVO())
@ -240,10 +302,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
@Override @Override
public void excelTemplate(HttpServletResponse response) { public void excelTemplate(HttpServletResponse response) {
try { try {
List<CustomerCompanyVO> companyList = new ArrayList<>(); List<CompanyTemplate> companyTemplates = new ArrayList<>();
List<CustomerPersonalVO> personalList = new ArrayList<>(); List<PersonalTemplate> personalTemplates = new ArrayList<>();
ExcelUtil.writeExcelWithSheets(response,personalList,"客户资源信息表模板","个人类型",new CustomerPersonalVO()) ExcelUtil.writeExcelWithSheets(response,personalTemplates,"客户资源信息表模板","个人类型",new PersonalTemplate())
.write(companyList,"企业类型",new CustomerCompanyVO()) .write(companyTemplates,"企业类型",new CompanyTemplate())
.finish(); .finish();
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORTTEMPLATE_EXSIT); ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORTTEMPLATE_EXSIT);
@ -256,50 +318,60 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
*/ */
@Transactional @Transactional
@Override @Override
public void excelImportCustomer(MultipartFile excel) { public ResponseResult excelImportCustomer(MultipartFile excel) {
//TODO 导入excel数据到数据库,思路耗时太长,有待优化 //TODO 导入excel数据到数据库,思路耗时太长,有待优化
if (excel == null){
ExceptionCast.cast(CrmsCode.NOT_NULL);
}
try { try {
List<Object> personalList = ExcelUtil.readExcel(excel, new CustomerPersonalVO(), 1); List<Object> personalList = ExcelUtil.readExcel(excel,new PersonalTemplate(), 1);
List<Object> companyList = ExcelUtil.readExcel(excel, new CustomerCompanyVO(), 2); List<Object> companyList = ExcelUtil.readExcel(excel, new CompanyTemplate(), 2);
List<EmployeeVO> nameList = hrmsFeignService.listEmployeeName().getData(); List<EmployeeVO> nameList = hrmsFeignService.listEmployeeName().getData();
CustomerEntity customer; // 客户基本信息 CustomerPersonalTOI customerPersonalTOI;
PersonalCustomerEntity pc; // 个人类型信息
CompanyCustomerEntity cc; // 企业类型信息
ManagerName manager; // 客户名称 ManagerName manager; // 客户名称
// 个人类型 // 个人类型
for (Object personal : personalList) { for (Object personal : personalList) {
customer = new CustomerEntity(); customerPersonalTOI = new CustomerPersonalTOI();
customerPersonalTOI.setType(0);
BeanUtils.copyProperties(personal,customerPersonalTOI);
manager = new ManagerName(); manager = new ManagerName();
pc = new PersonalCustomerEntity();
BeanUtils.copyProperties(personal,customer);
BeanUtils.copyProperties(personal,pc);
BeanUtils.copyProperties(personal,manager); BeanUtils.copyProperties(personal,manager);
// 根据客户经理名称找到对应的员工id // 根据客户经理名称找到对应的员工id
for (EmployeeVO employeeVO : nameList){ if (nameList != null && manager.getManager() != null){
if (Objects.equals(manager.getManager(),employeeVO.getName())){ for (EmployeeVO employeeVO : nameList){
customer.setManager(employeeVO.getId()); if (Objects.equals(manager.getManager(),employeeVO.getName())){
customerPersonalTOI.setManager(employeeVO.getId());
}
}
if (customerPersonalTOI.getManager() == null){
ExceptionCast.cast(CrmsCode.CUSTOMER_IS_NULL);
} }
} }
this.saveCustomerPersonal(customer,pc); this.saveCustomerPersonal(customerPersonalTOI);
} }
// 企业类型 // 企业类型
for (Object company : companyList){ for (Object company : companyList){
customer = new CustomerEntity(); CustomerCompanyTOI customerCompanyTOI = new CustomerCompanyTOI();
manager = new ManagerName(); manager = new ManagerName();
cc = new CompanyCustomerEntity(); customerCompanyTOI.setType(1);
BeanUtils.copyProperties(company,customer); BeanUtils.copyProperties(company,customerCompanyTOI);
BeanUtils.copyProperties(company,cc);
BeanUtils.copyProperties(company,manager); BeanUtils.copyProperties(company,manager);
// 根据客户经理名称找到对应的员工id // 根据客户经理名称找到对应的员工id
for (EmployeeVO employeeVO : nameList){ if (nameList != null && manager.getManager() != null){
if (Objects.equals(manager.getManager(),employeeVO.getName())){ for (EmployeeVO employeeVO : nameList){
customer.setManager(employeeVO.getId()); if (Objects.equals(manager.getManager(),employeeVO.getName())){
customerCompanyTOI.setManager(employeeVO.getId());
}
}
if (customerCompanyTOI.getManager() == null){
return new ResponseResult<String>().SUCCESS("导入数据失败,"+manager.getManager()+"员工不存在");
} }
} }
this.saveCustomerCompany(customer,cc); this.saveCustomerCompany(customerCompanyTOI);
} }
return ResponseResult.SUCCESS();
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CrmsCode.CUSTOMER_IMPORT_EXSIT); return new ResponseResult<String>().SUCCESS("导入数据失败,请检查文件和数据格式或稍后再试");
} }
} }
@ -312,7 +384,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
*/ */
private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerRequest customerRequest) { private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerRequest customerRequest) {
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间 // 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间
if (startTime == null && endTime == null && createTime != null) { if ((startTime == null || startTime.length() == 0) && (endTime == null || endTime.length() == 0) && createTime != null) {
if (createTime == 3 || createTime == 6 || createTime == 9 || createTime == 12) { if (createTime == 3 || createTime == 6 || createTime == 9 || createTime == 12) {
String pastTime = this.pastTime(createTime); String pastTime = this.pastTime(createTime);
customerRequest.setStartTime(pastTime); customerRequest.setStartTime(pastTime);
@ -348,7 +420,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
* @param size 每页条数 * @param size 每页条数
*/ */
private Page<Object> pageCheckout(Integer page, Integer size) { private Page<Object> pageCheckout(Integer page, Integer size) {
Integer count = this.count(new QueryWrapper<CustomerEntity>().eq("del_or_not", CrmsConstant.NOT_DELETE));//查询客户有效总条数 // 查询客户有效总条数
Integer count = this.count(new QueryWrapper<CustomerEntity>().eq("del_or_not", CrmsConstant.NOT_DELETE));
if (size == null || size < 1) { if (size == null || size < 1) {
size = 10; size = 10;
} }
@ -373,95 +446,77 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
private List<CustomerTO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO) { private List<CustomerTO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO) {
List<CustomerTO> customerTOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合 List<CustomerTO> customerTOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
CustomerTO customerTO; CustomerTO customerTO;
// 将客户信息和客户经理及部门信息拼装起来 // 将客户信息和客户经理及部门信息拼装起来
for (CustomerEntity customer : customers) { for (CustomerEntity customer : customers) {
// 每一个客户对应一个不同的对象 // 每一个客户对应一个不同的对象
customerTO = new CustomerTO(); customerTO = new CustomerTO();
for (EmployeeTO anEmployeeTO : employeeTO) { for (EmployeeTO anEmployeeTO : employeeTO) {
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) { if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) {
customerTO.setId(customer.getId()); BeanUtils.copyProperties(customer,customerTO);
customerTO.setCode(customer.getCode());
customerTO.setName(customer.getName());
customerTO.setPhone(customer.getPhone());
customerTO.setType(customer.getType());
customerTO.setManager(anEmployeeTO.getEmpName()); customerTO.setManager(anEmployeeTO.getEmpName());
customerTO.setDepartments(anEmployeeTO.getDeptNames()); customerTO.setDepartments(anEmployeeTO.getDeptNames());
customerTOS.add(customerTO); customerTOS.add(customerTO);
} }
} }
if (!Objects.equals(customerTO.getId(), customer.getId())) { if (!Objects.equals(customerTO.getId(), customer.getId())) {
customerTO.setId(customer.getId()); BeanUtils.copyProperties(customer,customerTO);
customerTO.setCode(customer.getCode());
customerTO.setName(customer.getName());
customerTO.setPhone(customer.getPhone());
customerTO.setType(customer.getType());
customerTOS.add(customerTO); customerTOS.add(customerTO);
} }
} }
return customerTOS; return customerTOS;
} }
/** /**
* 封装个人类型的客户信息 * 封装个人类型的客户信息
* *
* @param customer 客户基本信息 * @param customer 客户基本信息
* @param name 客户经理姓名
* @param personal 个人类型信息 * @param personal 个人类型信息
* @return * @return
*/ */
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { private CustomerPersonalDTO setPersonal(CustomerEntity customer, PersonalCustomerEntity personal) {
//BeanUtils能批量封装相同字段名称和类型的属性的值 //BeanUtils能批量封装相同字段名称和类型的属性的值
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO(); CustomerPersonalDTO personalDTO = new CustomerPersonalDTO();
customerPersonalVO.setCode(customer.getCode()); BeanUtils.copyProperties(customer,personalDTO);
customerPersonalVO.setType(customer.getType()); BeanUtils.copyProperties(personal,personalDTO);
customerPersonalVO.setManager(name); return personalDTO;
customerPersonalVO.setName(customer.getName());
customerPersonalVO.setAddr(customer.getAddr());
customerPersonalVO.setPhone(customer.getPhone());
customerPersonalVO.setIdCard(personal.getIdCard());
customerPersonalVO.setAge(personal.getAge());
customerPersonalVO.setGender(personal.getGender());
customerPersonalVO.setMaritalStatus(personal.getMaritalStatus());
customerPersonalVO.setEducation(personal.getEducation());
customerPersonalVO.setEmployer(personal.getEmployer());
customerPersonalVO.setPosition(personal.getPosition());
customerPersonalVO.setWorkingYears(personal.getWorkingYears());
customerPersonalVO.setSocialSecurityNum(personal.getSocialSecurityNum());
customerPersonalVO.setLivingSituation(personal.getLivingSituation());
customerPersonalVO.setResidenceAddr(personal.getResidenceAddr());
customerPersonalVO.setBusinessSource(personal.getBusinessSource());
customerPersonalVO.setEmergencyLinkman(personal.getEmergencyLinkman());
customerPersonalVO.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship());
customerPersonalVO.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone());
return customerPersonalVO;
} }
/** /**
* 封装企业类型的客户信息 * 封装企业类型的客户信息
* *
* @param customer 客户基本信息 * @param customer 客户基本信息
* @param name 客户经理姓名
* @param company 企业类型信息 * @param company 企业类型信息
* @return * @return
*/ */
private CustomerCompanyDTO setCompany(CustomerEntity customer, CompanyCustomerEntity company) {
CustomerCompanyDTO companyDTO = new CustomerCompanyDTO();
BeanUtils.copyProperties(customer,companyDTO);
BeanUtils.copyProperties(company,companyDTO);
return companyDTO;
}
/**
* 封装企业类型的客户信息(excel)
*/
private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) {
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO(); CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO();
customerCompanyVO.setCode(customer.getCode()); BeanUtils.copyProperties(customer,customerCompanyVO);
customerCompanyVO.setType(customer.getType()); BeanUtils.copyProperties(company,customerCompanyVO);
customerCompanyVO.setManager(name); customerCompanyVO.setManager(name);
customerCompanyVO.setName(customer.getName());
customerCompanyVO.setAddr(customer.getAddr());
customerCompanyVO.setPhone(customer.getPhone());
customerCompanyVO.setRegisteredCapital(company.getRegisteredCapital());
customerCompanyVO.setIndustry(company.getIndustry());
customerCompanyVO.setYears(company.getYears());
customerCompanyVO.setRegion(company.getRegion());
customerCompanyVO.setShareholder(company.getShareholder());
customerCompanyVO.setAffiliatedCompany(company.getAffiliatedCompany());
customerCompanyVO.setEmployeeNumber(company.getEmpNum());
customerCompanyVO.setLinkman(company.getLinkman());
customerCompanyVO.setBusinessSource(company.getBusinessSource());
return customerCompanyVO; return customerCompanyVO;
} }
/**
* 封装个人类型的客户信息(excel)
*/
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) {
//BeanUtils能批量封装相同字段名称和类型的属性的值
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO();
BeanUtils.copyProperties(customer,customerPersonalVO);
BeanUtils.copyProperties(personal,customerPersonalVO);
customerPersonalVO.setManager(name);
return customerPersonalVO;
}
} }

@ -28,8 +28,8 @@
<!-- 插入企业类型客户信息 --> <!-- 插入企业类型客户信息 -->
<insert id="saveCompanyCustomer" parameterType="com.daqing.framework.domain.crms.CompanyCustomerEntity"> <insert id="saveCompanyCustomer" parameterType="com.daqing.framework.domain.crms.CompanyCustomerEntity">
INSERT INTO crms_company_customer INSERT INTO crms_company_customer
(id,registered_capital,industry,years,region,shareholder,affiliated_company,emp_num,linkman,business_source,customer_id) (registered_capital,industry,years,region,shareholder,affiliated_company,emp_num,linkman,business_source,customer_id)
values (#{id},#{registeredCapital},#{industry},#{years},#{region},#{shareholder},#{affiliatedCompany},#{empNum},#{linkman}, values (#{registeredCapital},#{industry},#{years},#{region},#{shareholder},#{affiliatedCompany},#{empNum},#{linkman},
#{businessSource},#{customerId}); #{businessSource},#{customerId});
</insert> </insert>

@ -70,10 +70,10 @@
</select> </select>
<!-- 插入客户基本信息 --> <!-- 插入客户基本信息 -->
<insert id="saveCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity"> <insert id="saveCustomer" keyProperty="id" useGeneratedKeys="true" parameterType="com.daqing.framework.domain.crms.CustomerEntity">
INSERT INTO crms_customer INSERT INTO crms_customer
(id,code,type,manager,name,addr,phone,del_or_not,status,create_time,motify_time) (code,type,manager,name,addr,phone,del_or_not,status,create_time,motify_time)
VALUES (#{id},#{code},#{type},#{manager},#{name},#{addr},#{phone},0,0,#{createTime},#{motifyTime}) VALUES (#{code},#{type},#{manager},#{name},#{addr},#{phone},0,0,#{createTime},#{motifyTime})
</insert> </insert>
<!-- 更新客户基本信息 --> <!-- 更新客户基本信息 -->

@ -36,9 +36,9 @@
<!-- 插入个人类型的客户信息 --> <!-- 插入个人类型的客户信息 -->
<insert id="savePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity"> <insert id="savePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity">
INSERT INTO crms_personal_customer INSERT INTO crms_personal_customer
(id,customer_id,id_card,age,gender,marital_status,education,employer,position,working_years,social_security_num,living_situation (customer_id,id_card,age,gender,marital_status,education,employer,position,working_years,social_security_num,living_situation
,residence_addr,business_source,emergency_linkman,emergency_linkman_relationship,emergency_linkman_phone) ,residence_addr,business_source,emergency_linkman,emergency_linkman_relationship,emergency_linkman_phone)
VALUES (#{id},#{customerId},#{idCard},#{age},#{gender},#{maritalStatus},#{education},#{employer},#{position},#{workingYears}, VALUES (#{customerId},#{idCard},#{age},#{gender},#{maritalStatus},#{education},#{employer},#{position},#{workingYears},
#{socialSecurityNum},#{livingSituation},#{residenceAddr},#{businessSource},#{emergencyLinkman},#{emergencyLinkmanRelationship}, #{socialSecurityNum},#{livingSituation},#{residenceAddr},#{businessSource},#{emergencyLinkman},#{emergencyLinkmanRelationship},
#{emergencyLinkmanPhone}); #{emergencyLinkmanPhone});
</insert> </insert>

@ -28,8 +28,8 @@
<!-- 插入企业类型客户信息 --> <!-- 插入企业类型客户信息 -->
<insert id="saveCompanyCustomer" parameterType="com.daqing.framework.domain.crms.CompanyCustomerEntity"> <insert id="saveCompanyCustomer" parameterType="com.daqing.framework.domain.crms.CompanyCustomerEntity">
INSERT INTO crms_company_customer INSERT INTO crms_company_customer
(id,registered_capital,industry,years,region,shareholder,affiliated_company,emp_num,linkman,business_source,customer_id) (registered_capital,industry,years,region,shareholder,affiliated_company,emp_num,linkman,business_source,customer_id)
values (#{id},#{registeredCapital},#{industry},#{years},#{region},#{shareholder},#{affiliatedCompany},#{empNum},#{linkman}, values (#{registeredCapital},#{industry},#{years},#{region},#{shareholder},#{affiliatedCompany},#{empNum},#{linkman},
#{businessSource},#{customerId}); #{businessSource},#{customerId});
</insert> </insert>

@ -70,10 +70,10 @@
</select> </select>
<!-- 插入客户基本信息 --> <!-- 插入客户基本信息 -->
<insert id="saveCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity"> <insert id="saveCustomer" keyProperty="id" useGeneratedKeys="true" parameterType="com.daqing.framework.domain.crms.CustomerEntity">
INSERT INTO crms_customer INSERT INTO crms_customer
(id,code,type,manager,name,addr,phone,del_or_not,status,create_time,motify_time) (code,type,manager,name,addr,phone,del_or_not,status,create_time,motify_time)
VALUES (#{id},#{code},#{type},#{manager},#{name},#{addr},#{phone},0,0,#{createTime},#{motifyTime}) VALUES (#{code},#{type},#{manager},#{name},#{addr},#{phone},0,0,#{createTime},#{motifyTime})
</insert> </insert>
<!-- 更新客户基本信息 --> <!-- 更新客户基本信息 -->

@ -36,9 +36,9 @@
<!-- 插入个人类型的客户信息 --> <!-- 插入个人类型的客户信息 -->
<insert id="savePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity"> <insert id="savePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity">
INSERT INTO crms_personal_customer INSERT INTO crms_personal_customer
(id,customer_id,id_card,age,gender,marital_status,education,employer,position,working_years,social_security_num,living_situation (customer_id,id_card,age,gender,marital_status,education,employer,position,working_years,social_security_num,living_situation
,residence_addr,business_source,emergency_linkman,emergency_linkman_relationship,emergency_linkman_phone) ,residence_addr,business_source,emergency_linkman,emergency_linkman_relationship,emergency_linkman_phone)
VALUES (#{id},#{customerId},#{idCard},#{age},#{gender},#{maritalStatus},#{education},#{employer},#{position},#{workingYears}, VALUES (#{customerId},#{idCard},#{age},#{gender},#{maritalStatus},#{education},#{employer},#{position},#{workingYears},
#{socialSecurityNum},#{livingSituation},#{residenceAddr},#{businessSource},#{emergencyLinkman},#{emergencyLinkmanRelationship}, #{socialSecurityNum},#{livingSituation},#{residenceAddr},#{businessSource},#{emergencyLinkman},#{emergencyLinkmanRelationship},
#{emergencyLinkmanPhone}); #{emergencyLinkmanPhone});
</insert> </insert>

@ -0,0 +1,42 @@
package com.daqing.financial.hrauth.annotation;
import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit;
import java.lang.annotation.*;
/**
* @author Rogers
* 操作日志注解
* @create 2020-07-03
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Log {
/**
* 方法描述,可使用占位符获取参数:{{tel}}
*/
String detail() default "";
/**
* 日志等级:自己定此处分为1-9
*/
int level() default 0;
/**
* 操作类型(enum):主要是select,insert,update,delete
*/
OperationType operationType() default OperationType.UNKNOWN;
/**
* 被操作的对象(此处使用enum):可以是任何对象如表名(user)或者是工具(redis)
*/
OperationUnit operationUnit() default OperationUnit.UNKNOWN;
}

@ -0,0 +1,129 @@
package com.daqing.financial.hrauth.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.dao.SystemLogMapper;
import com.daqing.financial.hrauth.service.TokenService;
import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.financial.hrauth.util.IpUtils;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.Token;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @ClassName Operation
* @Description 操作日志类
* @Date 2020/9/29 10:06
* @Version 1.0
*/
@Slf4j
@Component
public class Operation {
@Resource
private SystemLogMapper systemLogMapper;
@Autowired
private TokenService tokenService;
@Autowired
private UserLoginService userLoginService;
@Async
public void addOperationLog(JoinPoint joinPoint, Object res, long time, UserEntity systemUser) {
// synchronized (SysLogAspect.class) {//获得登录用户信息
// User systemUser = (User) SecurityUtils.getSubject().getPrincipal();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
SystemLog operationLog = new SystemLog();
//获取内网地址IpUtils.intranetIp()
//获取外网地址IpUtils.internetIp()
// operationLog.setIpAddressLan("");
// operationLog.setIpAddressWan("");
operationLog.setIpAddressLan(IpUtils.intranetIp());
//获取不到外网IP设置内网IP
if (StringUtils.isBlank(IpUtils.internetIp())) {
operationLog.setIpAddressWan(IpUtils.intranetIp());
} else {
operationLog.setIpAddressWan(IpUtils.internetIp());
}
// operationLog.setRunTime(time);
//operationLog.setRunTime(0L);
operationLog.setReturnValue(JSONObject.toJSONString(res));
operationLog.setId(UUID.randomUUID().toString());
operationLog.setArgs(JSONObject.toJSONString(joinPoint.getArgs()));
operationLog.setCreateTime(new Date());
operationLog.setMethod(signature.getDeclaringTypeName() + "." + signature.getName());
operationLog.setUserId(systemUser.getId() + "");
operationLog.setUserName(systemUser.getAccount());
Log annotation = signature.getMethod().getAnnotation(Log.class);
if (annotation != null) {
operationLog.setLogLevel(annotation.level());
operationLog.setLogDescribe(getDetail(((MethodSignature) joinPoint.getSignature()).getParameterNames(), joinPoint.getArgs(), annotation));
operationLog.setOperationType(annotation.operationType().getValue());
operationLog.setOperationUnit(annotation.operationUnit().getValue());
}
//这里保存日志
// log.info("######记录日志:{}######", operationLog.toString());
int b = systemLogMapper.insert(operationLog);
log.info("######记录日志:{}######", operationLog.toString());
if (b<= 0) {
log.error("#####新增###记录日志失败:{}####", operationLog);
}
// }
}
/**
* 对当前登录用户和占位符处理
*
* @param argNames 方法参数名称数组
* @param args 方法参数数组
* @param annotation 注解信息
* @return 返回处理后的描述
*/
private String getDetail(String[] argNames, Object[] args, Log annotation) {
//获得登录用户信息
//User systemUser = (User) SecurityUtils.getSubject().getPrincipal();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);
String userEntityStr = RedisUtil.get("dq:userId:"+userId);
UserEntity systemUser = JSON.parseObject(userEntityStr,UserEntity.class);
//Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("token", token));
//UserEntity systemUser = userLoginService.getOne(new QueryWrapper<UserEntity>().eq("id",userToken.getUserId()));
Map<Object, Object> map = new HashMap<>(4);
for (int i = 0; i < argNames.length; i++) {
map.put(argNames[i], args[i]);
}
String detail = annotation.detail();
try {
detail = "'" + systemUser.getAccount() + "'=》" + annotation.detail();
for (Map.Entry<Object, Object> entry : map.entrySet()) {
Object k = entry.getKey();
Object v = entry.getValue();
detail = detail.replace("{{" + k + "}}", JSONObject.toJSONString(v));
}
} catch (Exception e) {
e.printStackTrace();
}
return detail;
}
}

@ -0,0 +1,179 @@
package com.daqing.financial.hrauth.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.service.TokenService;
import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.Token;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName SysLogAspect
* @Description 操作日志切面
* @Date 2020/9/30
* @Version 1.0
*/
@Slf4j
@Aspect
@Component
public class SysLogAspect {
@Resource
private Operation operation;
@Autowired
private TokenService tokenService;
@Autowired
private UserLoginService userLoginService;
/**
* 此处的切点是注解的方式也可以用包名的方式达到相同的效果
* '@Pointcut("execution(* com.wwj.springboot.service.impl.*.*(..))")'
*/
@Pointcut("@annotation(com.daqing.financial.hrauth.annotation.Log)")
public void operationLog() {
}
/**
* 环绕增强相当于MethodInterceptor
*/
@Around("operationLog()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object res = null;
long time = System.currentTimeMillis();
try {
res = joinPoint.proceed();
time = System.currentTimeMillis() - time;
return res;
} finally {
try {
//User systemUser = (User) SecurityUtils.getSubject().getPrincipal();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);
String userEntityStr = RedisUtil.get("dq:userId:"+userId);
UserEntity systemUser = JSON.parseObject(userEntityStr,UserEntity.class);
//Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("token", token));
//UserEntity systemUser = userLoginService.getOne(new QueryWrapper<UserEntity>().eq("id",userId));
operation.addOperationLog(joinPoint,res,time,systemUser);
//方法执行完成后增加日志
// addOperationLog(joinPoint, res, time);
} catch (Exception e) {
log.error("LogAspect 操作失败:" + e.getMessage());
e.printStackTrace();
}
}
}
/**
* 对当前登录用户和占位符处理
*
* @param argNames 方法参数名称数组
* @param args 方法参数数组
* @param annotation 注解信息
* @return 返回处理后的描述
*/
private String getDetail(String[] argNames, Object[] args, Log annotation) {
//获得登录用户信息
//User systemUser = (User) SecurityUtils.getSubject().getPrincipal();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
UserEntity systemUser = (UserEntity) request.getUserPrincipal();
Map<Object, Object> map = new HashMap<>(4);
for (int i = 0; i < argNames.length; i++) {
map.put(argNames[i], args[i]);
}
String detail = annotation.detail();
try {
detail = "'" + systemUser.getAccount() + "'=》" + annotation.detail();
for (Map.Entry<Object, Object> entry : map.entrySet()) {
Object k = entry.getKey();
Object v = entry.getValue();
detail = detail.replace("{{" + k + "}}", JSONObject.toJSONString(v));
}
} catch (Exception e) {
e.printStackTrace();
}
return detail;
}
@Before("operationLog()")
public void doBeforeAdvice(JoinPoint joinPoint) {
// System.out.println("进入方法前执行.....");
}
/**
* 处理完请求返回内容
*
* @param ret
*/
@AfterReturning(returning = "ret", pointcut = "operationLog()")
public void doAfterReturning(Object ret) {
// System.out.println("方法的返回值 : " + ret);
}
/**
* 后置异常通知
*/
@AfterThrowing("operationLog()")
public void throwss(JoinPoint jp) {
// System.out.println("方法异常时执行.....");
}
/**
* 后置最终通知,final增强不管是抛出异常或者正常退出都会执行
*/
@After("operationLog()")
public void after(JoinPoint jp) {
// System.out.println("方法最后执行.....");
}
/**
* 获取客户端ip地址
*
* @param request
* @return
*/
public static String getClientIp(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.trim() == "" || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.trim() == "" || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.trim() == "" || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
// 多个路由时,取第一个非unknown的ip
final String[] arr = ip.split(",");
for (final String str : arr) {
if (!"unknown".equalsIgnoreCase(str)) {
ip = str;
break;
}
}
return ip;
}
}

@ -0,0 +1,56 @@
package com.daqing.financial.hrauth.controller;
import com.daqing.financial.hrauth.SystemLogControllerApi;
import com.daqing.financial.hrauth.UserLoginControllerApi;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit;
import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.financial.hrauth.service.SystemLogService;
import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UserLoginLogRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @auther River
* @date 2020/9/22 15:27
*/
@RestController
@RequestMapping("/hrms/auth/systemLog")
@Api(tags = {"日志管理"})
public class SystemLogController implements SystemLogControllerApi {
@Autowired
private SystemLogService systemLogService;
@Autowired
private LoginLogService loginLogService;
@GetMapping("/list")
@Log(detail = "系统日志列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.SELECT)
public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size) {
PageUtils data = systemLogService.queryPage(page, size);
return new ResponseResult<PageUtils>().SUCCESS(data);
}
@GetMapping("/loginLogList")
@Log(detail = "登录日志列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.SELECT)
public ResponseResult loginLogList(@RequestParam("page") Integer page,
@RequestParam("size") Integer size, UserLoginLogRequest userLoginLogRequest) {
PageUtils data = loginLogService.queryPage(page, size,userLoginLogRequest);
return new ResponseResult<PageUtils>().SUCCESS(data);
}
}

@ -3,6 +3,7 @@ package com.daqing.financial.hrauth.controller;
import com.daqing.financial.hrauth.UserLoginControllerApi; import com.daqing.financial.hrauth.UserLoginControllerApi;
import com.daqing.financial.hrauth.service.UserLoginService; import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest; import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -14,7 +15,7 @@ import javax.validation.Valid;
/** /**
* @auther River * @auther River
* @date 2020/9/22 15:27 * @date 2020/9/22 15:27
*/ */
@RestController @RestController
@ -53,6 +54,7 @@ public class UserLoginController implements UserLoginControllerApi {
@PostMapping(value = "/login") @PostMapping(value = "/login")
@ApiOperation(value = "用户登录") @ApiOperation(value = "用户登录")
/*@SysLog(MODULE = "登录日志", REMARK = "登录日志")*/
public ResponseResult login( public ResponseResult login(
@RequestBody LoginRequest loginRequest @RequestBody LoginRequest loginRequest
/* @RequestParam("password") String password, @RequestParam("phone") String phone, /* @RequestParam("password") String password, @RequestParam("phone") String phone,
@ -67,4 +69,11 @@ public class UserLoginController implements UserLoginControllerApi {
loginRequest.setPhone(phone);*/ loginRequest.setPhone(phone);*/
return userLoginService.login(loginRequest); return userLoginService.login(loginRequest);
} }
@PostMapping("/updatePwd")
@ApiOperation(value = "修改平台超管员密码")
public ResponseResult updatePwd(@RequestBody @Valid UpdatePwdRequest user){
boolean result = userLoginService.updatePwd(user);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
} }

@ -1,9 +1,15 @@
package com.daqing.financial.hrauth.dao; package com.daqing.financial.hrauth.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.request.UserLoginLogRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface LoginLogMapper extends BaseMapper<LoginLog> { public interface LoginLogMapper extends BaseMapper<LoginLog> {
IPage<LoginLog> pageByCondition(Page page,@Param("loginLog") UserLoginLogRequest userLoginLogRequest);
} }

@ -0,0 +1,20 @@
package com.daqing.financial.hrauth.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.SystemLog;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName SystemLogMapper
* @Description 用户动作记录
* @Date 2020/9/30
* @Version 1.0
*/
@Mapper
public interface SystemLogMapper extends BaseMapper<SystemLog> {
IPage<SystemLog> pageByCondition(Page page);
}

@ -0,0 +1,66 @@
package com.daqing.financial.hrauth.enums;
/**
* 日志操作类型
*/
public enum BusinessType
{
/**
* 其它
*/
OTHER,
/**
* 新增
*/
INSERT,
/**
* 修改
*/
UPDATE,
/**
* 删除
*/
DELETE,
/**
* 查询
*/
SELECT,
/**
* 导出
*/
EXPORT,
/**
* 导入
*/
IMPORT;
public static String getMsg(BusinessType type){
String result = null;
switch (type) {
case INSERT:
result = "新增";
break;
case UPDATE:
result = "修改";
break;
case DELETE:
result = "删除";
break;
case SELECT:
result = "查询";
break;
case EXPORT:
result = "导出";
break;
case IMPORT:
result = "导入";
break;
case OTHER:
result = "其它";
break;
default:
break;
}
return result;
}
}

@ -0,0 +1,52 @@
package com.daqing.financial.hrauth.enums;
public enum OperationType {
/**
* 操作类型
*/
UNKNOWN("UNKNOWN"),
DELETE("DELETE"),
SELECT("SELECT"),
UPDATE("UPDATE"),
INSERT("INSERT");
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
OperationType(String s) {
this.value = s;
}
public static String getMsg(BusinessType type){
String result = null;
switch (type) {
case INSERT:
result = "新增";
break;
case UPDATE:
result = "修改";
break;
case DELETE:
result = "删除";
break;
case SELECT:
result = "查询";
break;
case OTHER:
result = "其它";
break;
default:
break;
}
return result;
}
}

@ -0,0 +1,37 @@
package com.daqing.financial.hrauth.enums;
public enum OperationUnit {
/**
* 被操作的单元
*/
UNKNOWN("unknown"),
USER("user"),
LOG("log"),
PERMISSION("permission"),
ROLE("role"),
DEVICE("device"),
WITHDRAW("withdraw"),
ATRUSER("atrUser"),
ASSERT("ASSERT"),
COIN("coin"),
NOTICE("notice"),
DATASTATISTIC("datastatistic"),
BlockGroup("blockGroup"),
C2C("c2c"),
USERROLE("userRole");
private String value;
OperationUnit(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -2,6 +2,10 @@ package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.request.UserLoginLogRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.utils.PageUtils;
public interface LoginLogService extends IService<LoginLog> { public interface LoginLogService extends IService<LoginLog> {
PageUtils queryPage(Integer page, Integer size, UserLoginLogRequest userLoginLogRequest);
} }

@ -0,0 +1,11 @@
package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.utils.PageUtils;
public interface SystemLogService extends IService<SystemLog> {
PageUtils queryPage(Integer page, Integer size);
}

@ -3,6 +3,7 @@ package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest; import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
@ -16,4 +17,6 @@ public interface UserLoginService extends IService<UserEntity> {
//登录 //登录
ResponseResult login(LoginRequest loginRequest); ResponseResult login(LoginRequest loginRequest);
Boolean updatePwd(UpdatePwdRequest user);
} }

@ -1,11 +1,30 @@
package com.daqing.financial.hrauth.service.impl; package com.daqing.financial.hrauth.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrauth.dao.LoginLogMapper; import com.daqing.financial.hrauth.dao.LoginLogMapper;
import com.daqing.financial.hrauth.service.LoginLogService; import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.request.UserLoginLogRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.utils.PageUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService { public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService {
@Override
public PageUtils queryPage(Integer page, Integer size, UserLoginLogRequest userLoginLogRequest) {
//分页参数
if (page <= 0) {
page = 1;
}
if (size <= 0) {
size = 10;
}
IPage<LoginLog> loginLogVo = this.getBaseMapper().pageByCondition(new Page(page, size),userLoginLogRequest);
return new PageUtils(loginLogVo);
}
} }

@ -0,0 +1,32 @@
package com.daqing.financial.hrauth.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrauth.dao.LoginLogMapper;
import com.daqing.financial.hrauth.dao.SystemLogMapper;
import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.financial.hrauth.service.SystemLogService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.daqing.framework.utils.PageUtils;
import org.springframework.stereotype.Service;
@Service
public class SystemLogServiceImpl extends ServiceImpl<SystemLogMapper, SystemLog> implements SystemLogService {
@Override
public PageUtils queryPage(Integer page, Integer size) {
//分页参数
if (page <= 0) {
page = 1;
}
if (size <= 0) {
size = 10;
}
IPage<SystemLog> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size));
return new PageUtils(systemLogVo);
}
}

@ -10,6 +10,7 @@ import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.Token; import com.daqing.framework.domain.hrms.Token;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest; import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode; import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.domain.hrms.response.LoginResponse; import com.daqing.framework.domain.hrms.response.LoginResponse;
@ -18,6 +19,7 @@ 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.util.JwtUtils; import com.daqing.framework.util.JwtUtils;
import com.daqing.framework.util.Md5Util; import com.daqing.framework.util.Md5Util;
import com.daqing.framework.util.RedisUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -61,14 +63,6 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
*/ */
@Override @Override
public UserLoginRequest verifyMobile(UserLoginRequest user){ public UserLoginRequest verifyMobile(UserLoginRequest user){
//判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getPhoneAccount())){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY);
}
if(StringUtils.isEmpty(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
}
//校验手机账号是否存在 //校验手机账号是否存在
/* int count = this.count(new QueryWrapper<UserEntity>() /* int count = this.count(new QueryWrapper<UserEntity>()
.eq("phone_account", user.getPhoneAccount()));*/ .eq("phone_account", user.getPhoneAccount()));*/
@ -91,13 +85,6 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
*/ */
@Override @Override
public Boolean getBackPwd(UserLoginRequest user){ public Boolean getBackPwd(UserLoginRequest user){
//判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY);
}
if(StringUtils.isEmpty(user.getConfirmPwd())){
ExceptionCast.cast(HrmsCode.CONFIRM_PWD_NOT_EMPTY);
}
if(!user.getConfirmPwd().equals(user.getNewPwd())){ if(!user.getConfirmPwd().equals(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT); ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT);
} }
@ -120,6 +107,10 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
public ResponseResult login(LoginRequest loginRequest) { public ResponseResult login(LoginRequest loginRequest) {
//判断用户登录方式 //判断用户登录方式
UserEntity userEntity = baseMapper.login(loginRequest); UserEntity userEntity = baseMapper.login(loginRequest);
if(userEntity != null){
//删除redis里面的userEntity
JwtUtils.removeUserEntityByUserId(userEntity.getId());
}
if(loginRequest.getType() == 1){//手机号码登录 if(loginRequest.getType() == 1){//手机号码登录
if(userEntity == null){ if(userEntity == null){
@ -134,9 +125,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
} }
//登录成功,token生成 //登录成功,token生成
long times = 84600; long times = 8460000;
if(loginRequest.getTenDayEffective() == 1){ if(loginRequest.getTenDayEffective() == 1){
times = 846000; times = 846000000;
} }
String token = JwtUtils.createJWT(userEntity.getId()+"","token", times); String token = JwtUtils.createJWT(userEntity.getId()+"","token", times);
Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("user_id", userEntity.getId())); Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("user_id", userEntity.getId()));
@ -156,6 +147,8 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
} }
//设置最新的token到redis //设置最新的token到redis
JwtUtils.putTokenToRedis(userEntity.getId(), token, times); JwtUtils.putTokenToRedis(userEntity.getId(), token, times);
//设置userEntity到redis
JwtUtils.putUserEntityToRedis(userEntity.getId(),userEntity,times);
//新增登录日志 //新增登录日志
LoginLog loginLog = loginLogService.getOne(new QueryWrapper<LoginLog>().eq("user_id", userEntity.getId())); LoginLog loginLog = loginLogService.getOne(new QueryWrapper<LoginLog>().eq("user_id", userEntity.getId()));
@ -179,4 +172,40 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
return ResponseResult.SUCCESS(loginResponse); return ResponseResult.SUCCESS(loginResponse);
} }
/**
* 修改平台超管员密码
*/
@Override
public Boolean updatePwd(UpdatePwdRequest user){
if(!user.getConfirmPwd().equals(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT);
}
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
if(userEntity == null){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST);
}
//新密码不能与账号相同
if(user.getNewPwd().equals(userEntity.getAccount())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_DIFFERENT);
}
//检测当前密码是否输入正确
if(!Md5Util.md5(user.getPassword()+userEntity.getId()).equals(userEntity.getPassword())){
ExceptionCast.cast(HrmsCode.PASSWORD_ERROR);
}
//新密码不能与当前密码保持一致
if(Md5Util.md5(user.getNewPwd()+userEntity.getId()).equals(userEntity.getPassword())){
ExceptionCast.cast(HrmsCode.NEWPWD_PASSWORD_SAME);
}
String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId());
//根据手机号码修改密码
int i = userLoginDao.updatePasswordByPhoneAccount(user.getPhoneAccount(),newMD5);
return i > 0;
}
} }

@ -0,0 +1,67 @@
package com.daqing.financial.hrauth.util;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
/**
* @ClassName IpUtils
* @Description Ip工具类获取ip
* @Date 2020/9/30
* @Version 1.0
*/
public class IpUtils {
/***
* 获取外网IP
* @return
*/
public static String internetIp() {
try {
Enumeration<NetworkInterface> networks = NetworkInterface.getNetworkInterfaces();
InetAddress inetAddress = null;
Enumeration<InetAddress> inetAddresses = null;
while (networks.hasMoreElements()) {
inetAddresses = networks.nextElement().getInetAddresses();
while (inetAddresses.hasMoreElements()) {
inetAddress = inetAddresses.nextElement();
if (inetAddress != null
&& inetAddress instanceof Inet4Address
&& !inetAddress.isSiteLocalAddress()
&& !inetAddress.isLoopbackAddress()
&& inetAddress.getHostAddress().indexOf(":") == -1) {
return inetAddress.getHostAddress();
}
}
}
return null;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取内网IP
*
* @return
*/
public static String intranetIp() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取服务启动host
* @return
*/
public static String getHost(){
return internetIp()==null?intranetIp():internetIp();
}
}

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.LoginLogMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.LoginLog" id="LoginLogMap">
<result property="id" column="id"/>
</resultMap>
<resultMap type="com.daqing.framework.domain.hrms.LoginLogEntity" id="userLoginLogMap">
<result property="id" column="id"/>
</resultMap>
<select id="pageByCondition" parameterType="com.daqing.framework.domain.hrms.request.UserLoginLogRequest" resultMap="userLoginLogMap">
SELECT
hll.user_id,hll.login_num,hll.create_time,hll.newest_time,he.name as empName,he.job_number,
he.phone,hp.name as posName,hd.name as deptName
FROM hrms_login_log hll
left join hrms_employee he on he.user_id=hll.user_id
left join hrms_employee_position hep on hep.emp_id=he.id
left join hrms_position hp on hp.id=hep.position_id
left join hrms_employee_dept hed on hed.employee_id=he.id
left join hrms_dept hd on hd.id=hed.dept_id
<where>
<if test="loginLog.name != null and loginLog.name != ''">
AND he.`name` LIKE CONCAT('%',#{loginLog.name},'%')
</if>
<if test="loginLog.jobNumber != null and loginLog.jobNumber != ''">
AND he.job_number = #{loginLog.jobNumber}
</if>
<if test="loginLog.startTime != null and loginLog.startTime != '' ">
AND hll.create_time &gt;= #{loginLog.startTime}
</if>
<if test="loginLog.endTime != null and loginLog.endTime != '' ">
AND hll.create_time &lt;= #{loginLog.endTime}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.SystemLogMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.SystemLog" id="SystemLogMap">
<result property="id" column="id"/>
</resultMap>
<select id="pageByCondition" resultMap="SystemLogMap">
SELECT *
FROM
sys_action_log
</select>
</mapper>

@ -35,7 +35,7 @@
</select> </select>
<select id="selectByPhoneAccount" resultType="com.daqing.framework.domain.hrms.UserEntity"> <select id="selectByPhoneAccount" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT id,account FROM hrms_user WHERE phone_account = #{phoneAccount} SELECT id,account,password FROM hrms_user WHERE phone_account = #{phoneAccount}
</select> </select>
</mapper> </mapper>

@ -0,0 +1,29 @@
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
spring.application.name=dq-financial-hrms-auth
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
spring.cloud.nacos.config.server-addr=192.168.31.142:8848
spring.cloud.nacos.config.namespace=7632bdaa-3381-4669-b3f9-2fc73be451e8
#spring.cloud.nacos.config.group=prod
spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml
spring.cloud.nacos.config.ext-config[0].group=dev
spring.cloud.nacos.config.ext-config[0].refresh=true
spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml
spring.cloud.nacos.config.ext-config[1].group=dev
spring.cloud.nacos.config.ext-config[1].refresh=true
spring.cloud.nacos.config.ext-config[2].data-id=other.yml
spring.cloud.nacos.config.ext-config[2].group=dev
spring.cloud.nacos.config.ext-config[2].refresh=true
spring.redis.host=192.168.232.128
spring.redis.port=6379
spring.redis.password=
spring.redis.database=0
spring.redis.timeout=30000
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--定义日志文件的存储地址,使用绝对路径-->
<property name="LOG_HOME" value="d:/logs/daqing/hrms_auth"/>
<!-- Console 输出设置 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<fileNamePattern>${LOG_HOME}/hrms_auth.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- 异步输出 -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="FILE"/>
</appender>
<logger name="org.apache.ibatis.cache.decorators.LoggingCache" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.boot" level="DEBUG"/>
<root level="info">
<!--<appender-ref ref="ASYNC"/>-->
<appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/>
</root>
</configuration>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.UserLoginDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.UserEntity" id="userMap">
<result property="id" column="id"/>
<result property="account" column="account"/>
<result property="phoneAccount" column="phone_account"/>
<result property="password" column="password"/>
<result property="loginNum" column="login_num"/>
<result property="createTime" column="create_time"/>
<result property="motifyTime" column="motify_time"/>
</resultMap>
<update id="updatePasswordByPhoneAccount">
update hrms_user set password = #{password} where phone_account = #{phoneAccount}
</update>
<select id="getUser" parameterType="string" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT account,password FROM hrms_user WHERE account = #{account}
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(1) from hrms_user where phone_account = #{phoneAccount}
</select>
<select id="login" parameterType="com.daqing.framework.domain.hrms.request.LoginRequest" resultType="com.daqing.framework.domain.hrms.UserEntity">
select id,account,phone_account,password,login_num from hrms_user
where del_or_not = 0 and status = 0
<if test="phone != null and phone != '' ">
and phone_account = #{phone}
</if>
<if test="wechatId != null and wechatId != '' ">
and wechat_id = #{wechatId}
</if>
</select>
<select id="selectByPhoneAccount" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT id,account FROM hrms_user WHERE phone_account = #{phoneAccount}
</select>
</mapper>

@ -62,11 +62,17 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>org.springframework.security.oauth</groupId> <groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId> <artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version> <version>2.3.5.RELEASE</version>
<scope>compile</scope> <scope>compile</scope>
</dependency>-->
<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-hrms-auth</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

@ -0,0 +1,33 @@
//package com.daqing.financial.hrms.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.cors.CorsConfiguration;
//import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
//import org.springframework.web.filter.CorsFilter;
//
///**
// * 实现基本的跨域请求
// *
// * @auther River
// * @date 2020/9/25 15:09
// */
//@Configuration
//public class CorsConfig {
//
// @Bean
// public CorsFilter corsFilter() {
// final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
// final CorsConfiguration corsConfiguration = new CorsConfiguration();
// /*是否允许请求带有验证信息*/
// corsConfiguration.setAllowCredentials(true);
// /*允许访问的客户端域名*/
// corsConfiguration.addAllowedOrigin("*");
// /*允许服务端访问的客户端请求头*/
// corsConfiguration.addAllowedHeader("*");
// /*允许访问的方法名,GET POST等*/
// corsConfiguration.addAllowedMethod("*");
// urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
// return new CorsFilter(urlBasedCorsConfigurationSource);
// }
//}

@ -104,9 +104,18 @@ public class DeptController implements DeptControllerApi {
/** /**
*所有部门及员工 *所有部门及员工
*/ */
@Override /*@Override
@GetMapping("/trees") @GetMapping("/trees")
public ResponseResult trees() { public ResponseResult trees() {
return new ResponseResult<List<DepartmentVO>>().SUCCESS(deptService.listDepartmentAndEmployeeTree()); return new ResponseResult<List<DepartmentVO>>().SUCCESS(deptService.listDepartmentAndEmployeeTree());
}*/
/**
* 该部门下所有子部门及部门下员工
*/
@Override
@GetMapping("/children")
public ResponseResult children(Long id){
return new ResponseResult<DepartmentVO>().SUCCESS(deptService.getDepartmentAndEmployee(id));
} }
} }

@ -1,5 +1,8 @@
package com.daqing.financial.hrms.controller; package com.daqing.financial.hrms.controller;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit;
import com.daqing.financial.hrms.EmployeeControllerApi; import com.daqing.financial.hrms.EmployeeControllerApi;
import com.daqing.financial.hrms.service.EmployeeService; import com.daqing.financial.hrms.service.EmployeeService;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
@ -30,6 +33,7 @@ public class EmployeeController implements EmployeeControllerApi {
private EmployeeService employeeService; private EmployeeService employeeService;
@GetMapping("/list") @GetMapping("/list")
@Log(detail = "员工列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.INSERT)
//@RequiresPermissions("hrms:employee:info") //@RequiresPermissions("hrms:employee:info")
public ResponseResult list(@RequestParam("page") Integer page, public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size, @RequestParam("size") Integer size,
@ -87,7 +91,7 @@ public class EmployeeController implements EmployeeControllerApi {
* @param ids * @param ids
* @return * @return
*/ */
@Override //@Override
@GetMapping("/getEmployeeAndDeptById") @GetMapping("/getEmployeeAndDeptById")
public ResponseResult getEmployeeAndDeptById(@RequestParam("ids") Long[] ids) { public ResponseResult getEmployeeAndDeptById(@RequestParam("ids") Long[] ids) {
List<EmployeeTO> employeeTO = employeeService.getEmployeeAndDeptById(Arrays.asList(ids)); List<EmployeeTO> employeeTO = employeeService.getEmployeeAndDeptById(Arrays.asList(ids));

@ -5,9 +5,6 @@ import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
@ -88,7 +85,7 @@ public class UserController {
* @param authentication * @param authentication
* @return * @return
*/ */
@GetMapping(value = "get") /* @GetMapping(value = "get")
@PreAuthorize("hasAnyRole('ROLE_ADMIN')") @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
public Object get(Authentication authentication){ public Object get(Authentication authentication){
//Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); //Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
@ -96,5 +93,5 @@ public class UserController {
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)authentication.getDetails(); OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)authentication.getDetails();
String token = details.getTokenValue(); String token = details.getTokenValue();
return token; return token;
} }*/
} }

@ -25,4 +25,6 @@ public interface DeptDao extends BaseMapper<DeptEntity> {
List<DepartmentVO> listDepartment(); List<DepartmentVO> listDepartment();
List<DepartmentVO> getDepartmentByParentId(Long parentId);
} }

@ -24,6 +24,8 @@ public interface DeptService extends IService<DeptEntity> {
boolean deleteByIds(Long[] ids); boolean deleteByIds(Long[] ids);
List<DepartmentVO> listDepartmentAndEmployeeTree(); /*List<DepartmentVO> listDepartmentAndEmployeeTree();*/
DepartmentVO getDepartmentAndEmployee(Long id);
} }

@ -7,6 +7,7 @@ import com.daqing.financial.hrms.dao.EmployeeDao;
import com.daqing.financial.hrms.service.DeptService; import com.daqing.financial.hrms.service.DeptService;
import com.daqing.framework.domain.hrms.DepartmentVO; import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.daqing.framework.domain.hrms.request.DeptAddRequest; import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode; import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.exception.ExceptionCast; import com.daqing.framework.exception.ExceptionCast;
@ -64,7 +65,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
//实体类 //实体类
DeptEntity deptEntity = new DeptEntity(); DeptEntity deptEntity = new DeptEntity();
//设置id //设置id
deptEntity.setId(SnowflakeIdUtils.getRandomid()); //deptEntity.setId(SnowflakeIdUtils.getRandomid());
//属性拷贝,将上级部门id(如果有)、部门名称设置到实体类 //属性拷贝,将上级部门id(如果有)、部门名称设置到实体类
BeanUtils.copyProperties(deptAddRequest, deptEntity); BeanUtils.copyProperties(deptAddRequest, deptEntity);
//2、判断部门上级id是否为空,为空则此部门是一级部门,否则查询并计算部门层级,并判断部门层级是否大于5级或小于1级 //2、判断部门上级id是否为空,为空则此部门是一级部门,否则查询并计算部门层级,并判断部门层级是否大于5级或小于1级
@ -154,11 +155,10 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
* 获取所有的部门及部门下的员工信息 * 获取所有的部门及部门下的员工信息
* @return * @return
*/ */
@Override /* @Override
public List<DepartmentVO> listDepartmentAndEmployeeTree() { public List<DepartmentVO> listDepartmentAndEmployeeTree() {
return this.getListDepartmentAndEmployeeTree(deptDao.listDepartment(), 0L); return this.getListDepartmentAndEmployeeTree(deptDao.listDepartment(), 0L);
} }
private List<DepartmentVO> getListDepartmentAndEmployeeTree(List<DepartmentVO> list, Long parentId){ private List<DepartmentVO> getListDepartmentAndEmployeeTree(List<DepartmentVO> list, Long parentId){
return list.stream() return list.stream()
.filter(dept -> parentId.equals(dept.getParentId())) // 过滤出部门id为所选id的部门信息(也为递归的结果条件,找不到所对应的部门id) .filter(dept -> parentId.equals(dept.getParentId())) // 过滤出部门id为所选id的部门信息(也为递归的结果条件,找不到所对应的部门id)
@ -168,5 +168,24 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
}) })
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) // 根据所选排序信息进行排序 .sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) // 根据所选排序信息进行排序
.collect(Collectors.toList()); .collect(Collectors.toList());
}*/
/**
* 获取该部门下子部门及部门下的员工
*/
@Override
public DepartmentVO getDepartmentAndEmployee(Long id) {
DepartmentVO departmentVO = new DepartmentVO();
if (id == null){
List<DepartmentVO> departments = deptDao.getDepartmentByParentId(0L);
departmentVO.setChildren(departments);
return departmentVO;
}else {
List<DepartmentVO> departments = deptDao.getDepartmentByParentId(id);
List<EmployeeVO> employeeS = employeeDao.listEmployeeByDeptId(id);
departmentVO.setChildren(departments);
departmentVO.setEmployee(employeeS);
return departmentVO;
}
} }
} }

@ -55,5 +55,4 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
return this.getBaseMapper().listEmployeeName(); return this.getBaseMapper().listEmployeeName();
} }
} }

@ -0,0 +1,12 @@
#security:
# oauth2:
# client:
# client-id: user-client
# client-secret: user-secret-8888
# user-authorization-uri: http://localhost:7000/oauth/authorize
# access-token-uri: http://localhost:7000/oauth/token
# resource:
# id: user-client
# user-info-uri: user-info
# authorization:
# check-token-access: http://localhost:7000/oauth/check_token

@ -1,4 +1,3 @@
# 开发和测试环境(dev)
#服务名称 #服务名称
spring.application.name=dq-financial-hrms spring.application.name=dq-financial-hrms
#配置中心地址 #配置中心地址
@ -18,6 +17,16 @@ spring.cloud.nacos.config.ext-config[2].data-id=other.yml
spring.cloud.nacos.config.ext-config[2].group=dev spring.cloud.nacos.config.ext-config[2].group=dev
spring.cloud.nacos.config.ext-config[2].refresh=true spring.cloud.nacos.config.ext-config[2].refresh=true
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=123456
spring.redis.database=0
spring.redis.timeout=30000
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
# 正式环境(prod) # 正式环境(prod)
#服务名称 #服务名称
#spring.application.name=dq-financial-hrms #spring.application.name=dq-financial-hrms

@ -36,4 +36,9 @@
FROM hrms_dept FROM hrms_dept
</select> </select>
<select id="getDepartmentByParentId" parameterType="long" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name,parent_id,sort
FROM hrms_dept WHERE parent_id = #{parentId}
</select>
</mapper> </mapper>

@ -35,7 +35,10 @@
ON e.id = ed.employee_id ON e.id = ed.employee_id
LEFT JOIN hrms_dept d LEFT JOIN hrms_dept d
ON d.id = ed.dept_id ON d.id = ed.dept_id
WHERE e.id LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND e.id
IN IN
<foreach collection="ids" open="(" separator="," close=")" item="id"> <foreach collection="ids" open="(" separator="," close=")" item="id">
#{id} #{id}
@ -44,7 +47,12 @@
<!-- 根据id查询员工姓名 --> <!-- 根据id查询员工姓名 -->
<select id="getEmployeeById" parameterType="long" resultType="com.daqing.framework.domain.hrms.EmployeeEntity"> <select id="getEmployeeById" parameterType="long" resultType="com.daqing.framework.domain.hrms.EmployeeEntity">
SELECT name FROM hrms_employee WHERE id = #{id} SELECT e.name name
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND e.id = #{id}
</select> </select>
<!-- 根据部门id获取该部门下面所有的员工 --> <!-- 根据部门id获取该部门下面所有的员工 -->
@ -55,15 +63,22 @@
ON e.id = ed.employee_id ON e.id = ed.employee_id
LEFT JOIN hrms_dept d LEFT JOIN hrms_dept d
ON ed.dept_id = d.id ON ed.dept_id = d.id
WHERE d.id = #{id} LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND d.id = #{id}
</select> </select>
<!-- 查询所有的员工姓名和id --> <!-- 查询所有的员工姓名和id -->
<select id="listEmployeeName" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO"> <select id="listEmployeeName" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO">
SELECT id,name SELECT e.id id,e.name name
FROM hrms_employee FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
</select> </select>
<!-- //TODO 修改查询员工为user表的del_or_not = 0的员工 -->
<select id="pageByCondition" resultMap="employeeMap"> <select id="pageByCondition" resultMap="employeeMap">
SELECT e.id eid,e.name emp_name,d.name SELECT e.id eid,e.name emp_name,d.name
,u.account,e.job_number,u.create_time,p.name pos_name ,u.account,e.job_number,u.create_time,p.name pos_name
@ -80,6 +95,7 @@
<if test="employee.jobNumber != null and employee.jobNumber != ''"> <if test="employee.jobNumber != null and employee.jobNumber != ''">
AND e.job_number = #{employee.jobNumber} AND e.job_number = #{employee.jobNumber}
</if> </if>
AND u.del_or_not = 0
</where> </where>
</select> </select>
</mapper> </mapper>

@ -34,6 +34,7 @@
INNER JOIN hrms_dept_position dp ON p.id = dp.position_id INNER JOIN hrms_dept_position dp ON p.id = dp.position_id
INNER JOIN hrms_dept d ON dp.dept_id = d.id INNER JOIN hrms_dept d ON dp.dept_id = d.id
INNER JOIN hrms_employee e ON p.create_user = e.id INNER JOIN hrms_employee e ON p.create_user = e.id
INNER JOIN hrms_user u ON e.user_id = u.id
<if test="queryMsg != null and queryMsg != ''"> <if test="queryMsg != null and queryMsg != ''">
WHERE WHERE
( (
@ -41,6 +42,7 @@
OR p.`name` LIKE CONCAT('%',#{queryMsg},'%') OR p.`name` LIKE CONCAT('%',#{queryMsg},'%')
) )
</if> </if>
AND u.del_or_not = 0
GROUP BY GROUP BY
p.id p.id
ORDER BY ORDER BY

@ -0,0 +1,12 @@
#security:
# oauth2:
# client:
# client-id: user-client
# client-secret: user-secret-8888
# user-authorization-uri: http://localhost:7000/oauth/authorize
# access-token-uri: http://localhost:7000/oauth/token
# resource:
# id: user-client
# user-info-uri: user-info
# authorization:
# check-token-access: http://localhost:7000/oauth/check_token

@ -15,4 +15,14 @@ spring.cloud.nacos.config.ext-config[1].refresh=true
spring.cloud.nacos.config.ext-config[2].data-id=other.yml spring.cloud.nacos.config.ext-config[2].data-id=other.yml
spring.cloud.nacos.config.ext-config[2].group=dev spring.cloud.nacos.config.ext-config[2].group=dev
spring.cloud.nacos.config.ext-config[2].refresh=true spring.cloud.nacos.config.ext-config[2].refresh=true
#spring.redis.host=127.0.0.1
#spring.redis.port=6379
#spring.redis.password=123456
#spring.redis.database=0
#spring.redis.timeout=30000
#spring.redis.jedis.pool.max-active=8
#spring.redis.jedis.pool.max-wait=-1
#spring.redis.jedis.pool.max-idle=8
#spring.redis.jedis.pool.min-idle=0

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save