工作台人力接口

master
river 4 years ago
parent 2a143a4bd3
commit 0c4dd630fb
  1. 23
      dq-financial-api/src/main/java/com/daqing/financial/crms/CustomerWorkbenchControllerApi.java
  2. 4
      dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java
  3. 51
      dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java
  4. 18
      dq-financial-api/src/main/java/com/daqing/financial/hrms/PositionControllerApi.java
  5. 29
      dq-financial-api/src/main/java/com/daqing/financial/hrms/UserControllerApi.java
  6. 3
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java
  7. 38
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerWorkbenchController.java
  8. 19
      dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerWorkbenchDao.java
  9. 16
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerWorkbenchService.java
  10. 12
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  11. 133
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerWorkbenchServiceImpl.java
  12. 2
      dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml
  13. 43
      dq-financial-crms/src/main/resources/mapper/crms/CustomerWorkbenchDao.xml
  14. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java
  15. 67
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/config/CorsConfig.java
  16. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java
  17. 143
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java
  18. 18
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/PositionController.java
  19. 73
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/UserController.java
  20. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/DeptDao.java
  21. 1
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/DeptPositionDao.java
  22. 55
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java
  23. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/PermissionDao.java
  24. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/PositionDao.java
  25. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/RoleDao.java
  26. 10
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java
  27. 14
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/feign/HrmsAuthFeignService.java
  28. 35
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/EmployeeService.java
  29. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/PositionService.java
  30. 12
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/UserService.java
  31. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java
  32. 470
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java
  33. 27
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/PositionServiceImpl.java
  34. 214
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java
  35. 25
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/task/DisableDetectionTask.java
  36. 3
      dq-financial-hrms/src/main/resources/bootstrap.properties
  37. 4
      dq-financial-hrms/src/main/resources/mapper/hrms/DeptDao.xml
  38. 363
      dq-financial-hrms/src/main/resources/mapper/hrms/EmployeeDao.xml
  39. 10
      dq-financial-hrms/src/main/resources/mapper/hrms/PermissionDao.xml
  40. 4
      dq-financial-hrms/src/main/resources/mapper/hrms/PositionDao.xml
  41. 3
      dq-financial-hrms/src/main/resources/mapper/hrms/RoleDao.xml
  42. 19
      dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml
  43. 4
      dq-framework-common/src/main/java/com/daqing/framework/model/response/CommonCode.java
  44. 11
      dq-framework-common/src/main/java/com/daqing/framework/model/response/PromptSuccess.java
  45. 9
      dq-framework-common/src/main/java/com/daqing/framework/util/SendSMS.java
  46. 34
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/request/CustomerWorkbenchRequest.java
  47. 37
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/request/EmployeeDisableRequest.java
  48. 43
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CustomerWorkbenchListVO.java
  49. 2
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/PositionEntity.java
  50. 8
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java
  51. 122
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeAndUserVO.java
  52. 35
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeExcelImport.java
  53. 84
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeInfoVO.java
  54. 63
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeListVO.java
  55. 38
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeTemplate.java
  56. 28
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/PositionVO.java
  57. 22
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/RoleVO.java
  58. 22
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/EmployeeRequest.java
  59. 26
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/PositionRequest.java
  60. 37
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java
  61. 5
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/PositionResponse.java
  62. 9
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/RolePermissionResponse.java
  63. 27
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/TestResult.java
  64. 0
      员工信息一览表.xlsx
  65. 0
      员工信息导入模板.xlsx

@ -0,0 +1,23 @@
package com.daqing.financial.crms;
import com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest;
import com.daqing.framework.domain.crms.response.CustomerWorkbenchListVO;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 工作台客户资源接口定义
*
* @auther River
* @date 2020/10/19 10:24
*/
@Api(value = "工作台客户资源", tags = "提供工作台客户信息增删改查等相关方法")
public interface CustomerWorkbenchControllerApi {
/**
* 列表展示
*/
@ApiOperation(value = "客户信息列表展示", notes = "客户信息列表展示",response = CustomerWorkbenchListVO.class)
ResponseResult List(Integer page, Integer size, CustomerWorkbenchRequest customerWorkbenchRequest);
}

@ -7,6 +7,8 @@ import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List;
/** /**
* @Author: gongsj. * @Author: gongsj.
* @Description: 部门管理controllerApi定义 * @Description: 部门管理controllerApi定义
@ -32,7 +34,7 @@ public interface DeptControllerApi {
* 拖拉拽重新排序批量修改部门信息 * 拖拉拽重新排序批量修改部门信息
*/ */
@ApiOperation(value = "拖拉拽重新排序,批量修改部门信息", notes = "拖拉拽重新排序,批量修改部门信息") @ApiOperation(value = "拖拉拽重新排序,批量修改部门信息", notes = "拖拉拽重新排序,批量修改部门信息")
ResponseResult updateSort(DeptEntity[] depts); ResponseResult updateSort(List<DeptEntity> depts);
/** /**
* 根据id查询部门详细信息 * 根据id查询部门详细信息

@ -1,9 +1,18 @@
package com.daqing.financial.hrms; package com.daqing.financial.hrms;
import com.daqing.framework.domain.crms.request.EmployeeDisableRequest;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeInfoVO;
import com.daqing.framework.domain.hrms.ext.EmployeeListVO;
import com.daqing.framework.domain.hrms.request.EmployeeRequest;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* @auther River * @auther River
@ -18,14 +27,44 @@ public interface EmployeeControllerApi {
@ApiOperation(value = "根据id查询员工姓名", notes = "根据id查询员工姓名") @ApiOperation(value = "根据id查询员工姓名", notes = "根据id查询员工姓名")
ResponseResult getEmployeeById(Long id); ResponseResult getEmployeeById(Long id);
/** @ApiOperation(value = "分页加条件查询员工信息", notes = "分页加条件查询员工信息",response = EmployeeListVO.class)
* 分页加条件查询员工信息 ResponseResult list(Integer page, Integer size, EmployeeRequest employeeRequest);
*/
@ApiOperation(value = "分页加条件查询员工信息", notes = "分页加条件查询员工信息")
ResponseResult list(Integer page, Integer size,EmployeeEntity employee);
@ApiOperation(value = "根据id删除员工信息", notes = "根据id删除员工信息") @ApiOperation(value = "根据id删除员工信息", notes = "根据id删除员工信息")
ResponseResult delete(Long[] ids); ResponseResult delete(List<Long> ids);
@ApiOperation(value = "启用",notes = "启用")
ResponseResult start(Long id);
@ApiOperation(value = "禁用",notes = "禁用")
ResponseResult stop(EmployeeDisableRequest employeeDisableRequest);
@ApiOperation(value = "禁用详情",notes = "禁用详情")
ResponseResult forbidInfo(Long id);
@ApiOperation(value = "重置密码",notes = "重置密码")
ResponseResult reset(Long id);
@ApiOperation(value = "详细信息",notes = "相信信息",response = EmployeeInfoVO.class)
ResponseResult info(Long id);
@ApiOperation(value = "角色对应的权限",notes = "角色对应的权限",response = RolePermissionResponse.class)
ResponseResult tree(List<Long> ids);
@ApiOperation(value = "更新",notes = "更新")
ResponseResult update(EmployeeInfoVO employeeInfoVO);
@ApiOperation(value = "新增",notes = "新增")
ResponseResult save(EmployeeInfoVO employeeInfoVO);
@ApiOperation(value = "导出",notes = "导出")
ResponseResult excelExport(HttpServletResponse response);
@ApiOperation(value = "导出模板",notes = "导出模板")
ResponseResult excelTemplate(HttpServletResponse response);
@ApiOperation(value = "导入",notes = "导入")
ResponseResult excelImport(MultipartFile file);
@ApiOperation(value = "查询所有员工id和姓名",notes = "查询所有员工id和姓名") @ApiOperation(value = "查询所有员工id和姓名",notes = "查询所有员工id和姓名")
ResponseResult listEmployeeName(); ResponseResult listEmployeeName();

@ -1,6 +1,8 @@
package com.daqing.financial.hrms; package com.daqing.financial.hrms;
import com.daqing.framework.domain.hrms.ext.PositionVO;
import com.daqing.framework.domain.hrms.request.PositionRequest; import com.daqing.framework.domain.hrms.request.PositionRequest;
import com.daqing.framework.domain.hrms.response.PositionResponse;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -22,7 +24,7 @@ public interface PositionControllerApi {
/** /**
* 分页加条件查询职位信息 * 分页加条件查询职位信息
*/ */
@ApiOperation(value = "分页加条件查询职位信息", notes = "分页加条件查询职位信息") @ApiOperation(value = "分页加条件查询职位信息", notes = "分页加条件查询职位信息",response = PositionVO.class)
ResponseResult list(Integer page, Integer size, String queryMsg); ResponseResult list(Integer page, Integer size, String queryMsg);
/** /**
@ -34,7 +36,7 @@ public interface PositionControllerApi {
/** /**
* 根据职位id查询职位信息详情 * 根据职位id查询职位信息详情
*/ */
@ApiOperation(value = "修改职位信息", notes = "修改职位信息") @ApiOperation(value = "根据职位id查询职位信息详情", notes = "根据职位id查询职位信息详情",response = PositionResponse.class)
ResponseResult info(Long id); ResponseResult info(Long id);
/** /**
@ -42,4 +44,16 @@ public interface PositionControllerApi {
*/ */
@ApiOperation(value = "删除职位信息", notes = "删除职位信息") @ApiOperation(value = "删除职位信息", notes = "删除职位信息")
ResponseResult delete(Long[] ids); ResponseResult delete(Long[] ids);
/**
* 所有的职位id和名称
*/
@ApiOperation(value = "所有的职位id和名称", notes = "所有的职位id和名称")
ResponseResult listPositionIdAndName();
/**
* 所有的角色id和名称
*/
@ApiOperation(value = "所有的角色id和名称", notes = "所有的角色id和名称")
ResponseResult listRoleIdAndName();
} }

@ -0,0 +1,29 @@
package com.daqing.financial.hrms;
import com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @auther River
* @date 2020/10/15 9:44
*/
@Api(value = "用户相关操作", tags = "提供工作台人力资源等相关方法")
public interface UserControllerApi {
@ApiOperation(value = "用户详情",notes = "用户详情",response = EmployeeAndUserVO.class)
ResponseResult info();
@ApiOperation(value = "修改用户信息",notes = "修改用户信息")
ResponseResult update(EmployeeAndUserVO employeeAndUserVO);
@ApiOperation(value = "获取验证码",notes = "获取验证码")
ResponseResult code(String phone);
@ApiOperation(value = "修改密码",notes = "修改密码")
ResponseResult updatePassword(Long id, String primaryPassword, String newPassword, String affirmNewPassword);
@ApiOperation(value = "绑定手机号",notes = "绑定手机号")
ResponseResult binding(Long id,String phone,String code);
}

@ -35,9 +35,6 @@ public class CustomerController implements CustomerControllerApi {
@Autowired @Autowired
private CustomerService customerService; private CustomerService customerService;
/*@Autowired
private HrmsFeignService hrmsFeignService;*/
/** /**
* 列表 * 列表
*/ */

@ -0,0 +1,38 @@
package com.daqing.financial.crms.controller;
import com.daqing.financial.crms.CustomerWorkbenchControllerApi;
import com.daqing.financial.crms.service.CustomerWorkbenchService;
import com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 工作台客户资源系统
*
* @auther River
* @date 2020/10/19 10:05
*/
@RestController
@RequestMapping("/crms/workbench")
public class CustomerWorkbenchController implements CustomerWorkbenchControllerApi {
@Autowired
private CustomerWorkbenchService customerWorkbenchService;
/**
* 列表
*/
@Override
@GetMapping("/list")
public ResponseResult List(@RequestParam("page") Integer page, @RequestParam("size") Integer size, CustomerWorkbenchRequest customerWorkbenchRequest) {
PageUtils list = customerWorkbenchService.list(page, size, customerWorkbenchRequest);
return new ResponseResult<PageUtils>().SUCCESS(list);
}
}

@ -0,0 +1,19 @@
package com.daqing.financial.crms.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.crms.CustomerEntity;
import com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @auther River
* @date 2020/10/19 10:45
*/
@Mapper
public interface CustomerWorkbenchDao extends BaseMapper<CustomerEntity> {
IPage<CustomerEntity> queryList(Page page, @Param("cr")CustomerWorkbenchRequest customerWorkbenchRequest);
}

@ -0,0 +1,16 @@
package com.daqing.financial.crms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest;
import com.daqing.framework.utils.PageUtils;
/**
* @auther River
* @date 2020/10/19 10:39
*/
public interface CustomerWorkbenchService extends IService<CustomerEntity> {
PageUtils list(Integer page, Integer size, CustomerWorkbenchRequest customerWorkbenchRequest);
}

@ -72,11 +72,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
// 获取所有的客户基本信息 // 获取所有的客户基本信息
List<CustomerEntity> customers = customerEntityIPage.getRecords(); List<CustomerEntity> customers = customerEntityIPage.getRecords();
// 获取所有的客户经理id // 获取所有的客户经理id
Long[] ids = customers.stream().map(CustomerEntity::getManager).toArray(Long[]::new); Long[] managerIds = customers.stream().map(CustomerEntity::getManager).toArray(Long[]::new);
if (ids != null && ids.length != 0) { if (managerIds.length != 0) {
//TODO 远程调用查询客户经理信息的接口 //TODO 远程调用查询客户经理信息的接口
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds);
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData();
if (employeeTO != null){ if (employeeTO != null){
// 将客户信息和客户经理及部门信息拼装起来 // 将客户信息和客户经理及部门信息拼装起来
@ -203,6 +203,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
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());
customerEntity.setType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType());
boolean customer = customerDao.saveCustomer(customerEntity); boolean customer = customerDao.saveCustomer(customerEntity);
personalCustomerEntity.setCustomerId(customerEntity.getId()); personalCustomerEntity.setCustomerId(customerEntity.getId());
boolean personal = personalCustomerDao.savePersonalCustomer(personalCustomerEntity); boolean personal = personalCustomerDao.savePersonalCustomer(personalCustomerEntity);
@ -223,6 +224,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
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());
customerEntity.setType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType());
boolean customer = customerDao.saveCustomer(customerEntity); boolean customer = customerDao.saveCustomer(customerEntity);
companyCustomerEntity.setCustomerId(customerEntity.getId()); companyCustomerEntity.setCustomerId(customerEntity.getId());
boolean company = companyCustomerDao.saveCompanyCustomer(companyCustomerEntity); boolean company = companyCustomerDao.saveCompanyCustomer(companyCustomerEntity);
@ -320,7 +322,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
@Override @Override
public ResponseResult excelImportCustomer(MultipartFile excel) { public ResponseResult excelImportCustomer(MultipartFile excel) {
//TODO 导入excel数据到数据库,思路耗时太长,有待优化 //TODO 导入excel数据到数据库,思路耗时太长,有待优化
if (excel == null){ if (excel.isEmpty()){
ExceptionCast.cast(CrmsCode.NOT_NULL); ExceptionCast.cast(CrmsCode.NOT_NULL);
} }
try { try {
@ -393,7 +395,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
} }
} }
// 选择了自定义时间且选择了固定时间则固定时间无效 // 选择了自定义时间且选择了固定时间则固定时间无效
if (createTime != null && (startTime != null || endTime != null)) { if (createTime != null && ((startTime != null && startTime.length() !=0) || (endTime != null && endTime.length() != 0))) {
customerRequest.setCreateTime(null); customerRequest.setCreateTime(null);
} }
} }

@ -0,0 +1,133 @@
package com.daqing.financial.crms.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.crms.dao.CustomerWorkbenchDao;
import com.daqing.financial.crms.feign.HrmsFeignService;
import com.daqing.financial.crms.service.CustomerWorkbenchService;
import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.ext.CustomerTO;
import com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest;
import com.daqing.framework.domain.crms.response.CustomerWorkbenchListVO;
import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @auther River
* @date 2020/10/19 10:44
*/
@Service
public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchDao, CustomerEntity>
implements CustomerWorkbenchService {
@Autowired
private HrmsFeignService hrmsFeignService;
/**
* 列表
*/
@Override
public PageUtils list(Integer page, Integer size, CustomerWorkbenchRequest cwr) {
if (page == null || size == null){
page = 1;
size = 10;
}
// 校验时间参数
this.timeCheckout(cwr.getCreateTime(),cwr.getStartTime(),cwr.getEndTime(),cwr);
IPage<CustomerEntity> customerEntityIPage = this.getBaseMapper().queryList(new Page(page, size), cwr);
List<CustomerEntity> customers = customerEntityIPage.getRecords();
// 获取所有的客户经理id
Long[] managerIds = customers.stream().map(CustomerEntity::getManager).toArray(Long[]::new);
// 获取所有的客户id
Long[] customerIds = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new);
// 返回列表实体类集合
List<CustomerWorkbenchListVO> customerWorkbenchListVOS = new ArrayList<>();
BeanUtils.copyProperties(customers,customerWorkbenchListVOS);
if (managerIds.length != 0){
// 远程调用查询客户对应的客户经理信息
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds);
List<EmployeeTO> employeeTOs = (List<EmployeeTO>) responseResult.getData();
if (employeeTOs != null){
customerWorkbenchListVOS = this.jointCustomerEmployee(customers, employeeTOs);
}
}
if (customerIds.length != 0){
// TODO:调用担保服务查询每个客户的审批状态
for (CustomerWorkbenchListVO customerWorkbenchListVO : customerWorkbenchListVOS) {
customerWorkbenchListVO.setStatus(2);
}
}
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
IPage<CustomerWorkbenchListVO> iPage = new Page<>();
BeanUtils.copyProperties(customerEntityIPage,iPage);
iPage.setRecords(customerWorkbenchListVOS);
return new PageUtils(iPage);
}
/**
* 选择某段时间内客户信息的时间参数校验
*/
private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerWorkbenchRequest customerWorkbenchRequest) {
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间
if ((startTime == null || startTime.length() == 0) && (endTime == null || endTime.length() == 0) && createTime != null) {
if (createTime == 3 || createTime == 6 || createTime == 9 || createTime == 12) {
String pastTime = this.pastTime(createTime);
customerWorkbenchRequest.setStartTime(pastTime);
} else {
customerWorkbenchRequest.setStartTime(null);
}
}
// 选择了自定义时间且选择了固定时间则固定时间无效
if (createTime != null && ((startTime != null && startTime.length() != 0) || (endTime != null && endTime.length() != 0))) {
customerWorkbenchRequest.setCreateTime(null);
}
}
/**
* 得到过去number月内的时间
*/
private String pastTime(Integer number) {
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -number);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
return sdf.format(calendar.getTime());
}
/**
* 拼接客户及其对应的客户经理及部门信息
*/
private List<CustomerWorkbenchListVO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO) {
List<CustomerWorkbenchListVO> customerWorkbenchListVOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
CustomerWorkbenchListVO customerWorkbenchListVO;
// 将客户信息和客户经理及部门信息拼装起来
for (CustomerEntity customer : customers) {
// 每一个客户对应一个不同的对象
customerWorkbenchListVO = new CustomerWorkbenchListVO();
for (EmployeeTO anEmployeeTO : employeeTO) {
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) {
BeanUtils.copyProperties(customer,customerWorkbenchListVO);
customerWorkbenchListVO.setManager(anEmployeeTO.getEmpName());
customerWorkbenchListVO.setDepartments(anEmployeeTO.getDeptNames());
customerWorkbenchListVOS.add(customerWorkbenchListVO);
}
}
if (!Objects.equals(customerWorkbenchListVO.getId(), customer.getId())) {
BeanUtils.copyProperties(customer,customerWorkbenchListVO);
customerWorkbenchListVOS.add(customerWorkbenchListVO);
}
}
return customerWorkbenchListVOS;
}
}

@ -90,4 +90,6 @@
WHERE del_or_not = 0; WHERE del_or_not = 0;
</select> </select>
</mapper> </mapper>

@ -0,0 +1,43 @@
<?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.crms.dao.CustomerWorkbenchDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.crms.CustomerEntity" id="customerMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="type" column="type"/>
<result property="manager" column="manager"/>
<result property="name" column="name"/>
<result property="addr" column="addr"/>
<result property="phone" column="phone"/>
<result property="password" column="password"/>
<result property="wechatId" column="wechat_id"/>
<result property="delOrNot" column="del_or_not"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="motifyTime" column="motify_time"/>
</resultMap>
<!-- 查询客户列表(所有)、根据创建时间筛选、根据客户类型筛选、根据客户编号或者名称搜索 -->
<select id="queryList" parameterType="com.daqing.framework.domain.crms.request.CustomerWorkbenchRequest" resultType="com.daqing.framework.domain.crms.CustomerEntity">
SELECT id,code,type,name,phone,manager
FROM crms_customer
WHERE del_or_not = 0
<if test="cr.codeOrName != null and cr.codeOrName != '' ">
AND (name LIKE CONCAT('%',#{cr.codeOrName},'%') OR code LIKE CONCAT('%',#{cr.codeOrName},'%'))
</if>
<if test="cr.customerType != null">
AND type = #{cr.customerType}
</if>
<if test="cr.startTime != null and cr.startTime != '' ">
AND create_time &gt;= #{cr.startTime}
</if>
<if test="cr.endTime != null and cr.endTime != '' ">
AND create_time &lt;= #{cr.endTime}
</if>
ORDER BY create_time DESC
</select>
</mapper>

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

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

@ -6,8 +6,6 @@ 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.request.DeptAddRequest; import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -65,8 +63,8 @@ public class DeptController implements DeptControllerApi {
@Override @Override
@PutMapping("/update/sort") @PutMapping("/update/sort")
//@RequiresPermissions("hrms:dept:update_sort") //@RequiresPermissions("hrms:dept:update_sort")
public ResponseResult updateSort(@RequestBody DeptEntity[] depts) { public ResponseResult updateSort(@RequestBody List<DeptEntity> depts) {
return deptService.updateBatchById(Arrays.asList(depts)) ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); return deptService.updateBatchById(depts) ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**

@ -5,16 +5,25 @@ import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit; 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.crms.request.EmployeeDisableRequest;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeInfoVO;
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.request.EmployeeRequest;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
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.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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
@ -37,19 +46,44 @@ public class EmployeeController implements EmployeeControllerApi {
//@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,
@Valid EmployeeEntity employee) { EmployeeRequest employeeRequest) {
PageUtils data = employeeService.queryPage(page, size, employee); PageUtils data = employeeService.queryPage(page, size, employeeRequest);
return new ResponseResult<PageUtils>().SUCCESS(data); return new ResponseResult<PageUtils>().SUCCESS(data);
} }
/** /**
* 信息 * 详情
*/ */
@GetMapping("/info/{id}") @GetMapping("/info")
//@RequiresPermissions("hrms:employee:info") //@RequiresPermissions("hrms:employee:info")
public ResponseResult info(@PathVariable("id") Long id) { public ResponseResult info(@RequestParam("id") Long id) {
EmployeeEntity employee = employeeService.getById(id);
return ResponseResult.SUCCESS(); EmployeeInfoVO data = employeeService.info(id);
return new ResponseResult<EmployeeInfoVO>().SUCCESS(data);
}
/**
* 权限树
*/
@Override
@PostMapping("/tree")
public ResponseResult tree(@RequestBody List<Long> ids) {
List<RolePermissionResponse> result = employeeService.permissionTreeList(ids);
return result == null ? new ResponseResult(CommonCode.PERMISSION_IS_NOT) :
new ResponseResult<List<RolePermissionResponse>>().SUCCESS(result);
}
/**
* 修改
*/
@Override
@PostMapping("/update")
public ResponseResult update(@RequestBody @Valid EmployeeInfoVO employeeInfoVO) {
Boolean result = employeeService.update(employeeInfoVO);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
} }
/** /**
@ -57,21 +91,46 @@ public class EmployeeController implements EmployeeControllerApi {
*/ */
@PostMapping("/save") @PostMapping("/save")
//@RequiresPermissions("hrms:employee:save") //@RequiresPermissions("hrms:employee:save")
public ResponseResult save(@RequestBody EmployeeEntity employee) { public ResponseResult save(@RequestBody EmployeeInfoVO employeeInfoVO) {
employeeService.save(employee); Boolean result = employeeService.save(employeeInfoVO);
return ResponseResult.SUCCESS(); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.SAVE_FAIL);
} }
/** /**
* 修改 * 导出
*/
@GetMapping("/excelExport")
@Override
public ResponseResult excelExport(HttpServletResponse response) {
Boolean result = employeeService.excelExport(response);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 导出模板
*/
@GetMapping("/excelTemplate")
@Override
public ResponseResult excelTemplate(HttpServletResponse response) {
Boolean result = employeeService.excelTemplate(response);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 导入
*/ */
@PutMapping("/update") @PostMapping("/excelImport")
//@RequiresPermissions("hrms:employee:update") @Override
public ResponseResult update(@RequestBody EmployeeEntity employee) { public ResponseResult excelImport(MultipartFile file) {
employeeService.updateById(employee);
return ResponseResult.SUCCESS(); Boolean result = employeeService.excelImport(file);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
@ -79,10 +138,56 @@ public class EmployeeController implements EmployeeControllerApi {
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
//@RequiresPermissions("hrms:employee:delete") //@RequiresPermissions("hrms:employee:delete")
public ResponseResult delete(@RequestBody Long[] ids) { public ResponseResult delete(@RequestBody List<Long> ids) {
employeeService.removeByIds(Arrays.asList(ids)); Boolean result = employeeService.delete(ids);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.DELETE_FAIL);
}
return ResponseResult.SUCCESS(); /**
* 启用
*/
@Override
@GetMapping("/start")
public ResponseResult start(@RequestParam("id")Long id) {
Boolean result = employeeService.start(id);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 禁用
*/
@Override
@PostMapping("/stop")
public ResponseResult stop(@RequestBody @Valid EmployeeDisableRequest employeeDisableRequest) {
Boolean result = employeeService.stop(employeeDisableRequest);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.DISABLE_FAIL);
}
/**
* 禁用详情
*/
@GetMapping("/forbidInfo")
@Override
public ResponseResult forbidInfo(@RequestParam("id")Long id) {
UserEntity user = employeeService.forbidInfo(id);
return new ResponseResult<UserEntity>().SUCCESS(user);
}
/**
* 重置密码
*/
@Override
@GetMapping("/reset")
public ResponseResult reset(@RequestParam("id") Long id) {
Boolean result = employeeService.reset(id);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.RESET_FAIL);
} }
/** /**

@ -66,4 +66,22 @@ public class PositionController implements PositionControllerApi {
positionService.removePositionByIds(Arrays.asList(ids)); positionService.removePositionByIds(Arrays.asList(ids));
return ResponseResult.SUCCESS(); return ResponseResult.SUCCESS();
} }
/**
* 所有的职位id和名称
*/
@GetMapping("/listPositionIdAndName")
@Override
public ResponseResult listPositionIdAndName() {
return new ResponseResult<PositionResponse>().SUCCESS(positionService.listPositionIdAndName());
}
/**
* 所有的角色id和名称
*/
@GetMapping("/listRoleIdAndName")
@Override
public ResponseResult listRoleIdAndName() {
return new ResponseResult<PositionResponse>().SUCCESS(positionService.listRoleIdAndName());
}
} }

@ -1,12 +1,16 @@
package com.daqing.financial.hrms.controller; package com.daqing.financial.hrms.controller;
import com.daqing.financial.hrms.UserControllerApi;
import com.daqing.financial.hrms.service.UserService; import com.daqing.financial.hrms.service.UserService;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO;
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.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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
@ -20,63 +24,68 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping("hrms/user") @RequestMapping("hrms/user")
public class UserController { public class UserController implements UserControllerApi {
@Autowired @Autowired
private UserService userService; private UserService userService;
/** /**
* 列表 * 信息
*/ */
@GetMapping("/list") @GetMapping("/info")
//@RequiresPermissions("hrms:user:list") //@RequiresPermissions("hrms:user:info")
public ResponseResult list(@RequestParam Map<String, Object> params) { public ResponseResult info() {
PageUtils page = userService.queryPage(params);
return ResponseResult.SUCCESS(); EmployeeAndUserVO info = userService.info();
}
return new ResponseResult<EmployeeAndUserVO>().SUCCESS(info);
}
/** /**
* 信息 * 修改
*/ */
@GetMapping("/info/{id}") @PostMapping("/update")
//@RequiresPermissions("hrms:user:info") @Override
public ResponseResult info(@PathVariable("id") Long id) { public ResponseResult update(@RequestBody @Valid EmployeeAndUserVO employeeAndUserVO) {
UserEntity user = userService.getById(id);
Boolean result = userService.update(employeeAndUserVO);
return ResponseResult.SUCCESS(); return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
} }
/** /**
* 保存 * 获取验证码
*/ */
@PostMapping("/save") @GetMapping("/code")
//@RequiresPermissions("hrms:user:save") @Override
public ResponseResult save(@RequestBody UserEntity user) { public ResponseResult code(String phone) {
userService.save(user);
Boolean result = userService.getVerificationCode(phone);
return ResponseResult.SUCCESS(); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**
* 修改 * 修改密码
*/ */
@PutMapping("/update") @GetMapping("/updatePassword")
//@RequiresPermissions("hrms:user:update") @Override
public ResponseResult update(@RequestBody UserEntity user) { public ResponseResult updatePassword(@RequestParam("id") Long id, String primaryPassword,
userService.updateById(user); String newPassword, String affirmNewPassword) {
return ResponseResult.SUCCESS(); Boolean result = userService.updatePassword(id, primaryPassword, newPassword, affirmNewPassword);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
} }
/** /**
* 删除 * 绑定手机号
*/ */
@DeleteMapping("/delete") @Override
//@RequiresPermissions("hrms:user:delete") public ResponseResult binding(@RequestParam("id") Long id, String phone, String code) {
public ResponseResult delete(@RequestBody Long[] ids) {
userService.removeByIds(Arrays.asList(ids)); Boolean result = userService.bindingPhoneAccount(id, phone, code);
return ResponseResult.SUCCESS(); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
} }
/** /**

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

@ -19,4 +19,5 @@ public interface DeptPositionDao extends BaseMapper<DeptPositionEntity> {
int saveBatch(@Param("list") List<DeptPositionEntity> deptPositionList); int saveBatch(@Param("list") List<DeptPositionEntity> deptPositionList);
int deleteByPositionId(@Param("positionId") Long positionId); int deleteByPositionId(@Param("positionId") Long positionId);
} }

@ -4,12 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.ext.EmployeeTO; import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeVO; import com.daqing.framework.domain.hrms.ext.*;
import com.daqing.framework.domain.hrms.ext.PositionVO; import com.daqing.framework.domain.hrms.request.EmployeeRequest;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -31,4 +32,52 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
List<EmployeeVO> listEmployeeName(); List<EmployeeVO> listEmployeeName();
IPage<EmployeeVO> pageByCondition(Page page, @Param("employee") EmployeeEntity employee); IPage<EmployeeVO> pageByCondition(Page page, @Param("employee") EmployeeEntity employee);
IPage<EmployeeListVO> pageList(Page page, @Param("employee") EmployeeRequest employeeRequest);
List<EmployeeListVO> excelList();
IPage<EmployeeListVO> pageListByDept(Page page, @Param("employee") EmployeeRequest employeeRequest);
List<Long> queryIds(@Param("ids") List<Long> ids);
Boolean deleteByIds(@Param("ids") List<Long> ids);
Integer getStatus(Long id);
Boolean startOrStop(UserEntity user);
UserEntity forbidInfo(Long id);
List<UserEntity> listDisableTime();
Long getUserId(Long id);
Boolean updatePassword(@Param("id")Long id,@Param("password")String password);
EmployeeInfoVO getInfo(Long id);
Boolean updateEmployee(EmployeeEntity employeeEntity);
Boolean updateUser(@Param("id")Long id, @Param("account")String account, @Param("modifyTime")Date modifyTime);
Boolean deleteDepartment(Long id);
Boolean deletePosition(Long id);
Boolean deleteRole(Long id);
Boolean insertDepartment(@Param("id") Long id,@Param("deptIds") List<Long> ids);
Boolean insertPosition(@Param("id") Long id,@Param("positionIds") List<Long> ids);
Boolean insertRole(@Param("id")Long id,@Param("roleIds") List<Long> roleIds);
Boolean insertUser(UserEntity user);
Boolean insertEmployee(EmployeeEntity employeeEntity);
EmployeeAndUserVO getEmployeeByUserId(Long id);
Boolean updateEmployeeAndUser(EmployeeEntity employeeEntity);
} }

@ -2,7 +2,11 @@ package com.daqing.financial.hrms.dao;
import com.daqing.framework.domain.hrms.PermissionEntity; import com.daqing.framework.domain.hrms.PermissionEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 记录菜单权限 * 记录菜单权限
@ -14,4 +18,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface PermissionDao extends BaseMapper<PermissionEntity> { public interface PermissionDao extends BaseMapper<PermissionEntity> {
List<RolePermissionResponse> listPermissionByRoleIds(@Param("ids") List<Long> ids);
} }

@ -8,6 +8,8 @@ import com.daqing.framework.domain.hrms.ext.PositionVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 记录职位信息 * 记录职位信息
* *
@ -23,4 +25,6 @@ public interface PositionDao extends BaseMapper<PositionEntity> {
Integer getCountByNameAndDeptIdAndId(@Param("deptId") Long deptId, @Param("name") String name, @Param("id") Long id); Integer getCountByNameAndDeptIdAndId(@Param("deptId") Long deptId, @Param("name") String name, @Param("id") Long id);
IPage<PositionVO> pageByCondition(Page page, @Param("queryMsg") String queryMsg); IPage<PositionVO> pageByCondition(Page page, @Param("queryMsg") String queryMsg);
List<PositionVO> listPositionIdAndName();
} }

@ -2,8 +2,11 @@ package com.daqing.financial.hrms.dao;
import com.daqing.framework.domain.hrms.RoleEntity; import com.daqing.framework.domain.hrms.RoleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.ext.RoleVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* 员工角色表 * 员工角色表
* *
@ -14,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface RoleDao extends BaseMapper<RoleEntity> { public interface RoleDao extends BaseMapper<RoleEntity> {
List<RoleVO> listRoleIdAndName();
} }

@ -3,6 +3,7 @@ package com.daqing.financial.hrms.dao;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 人资管理系统员工账号信息表用于存储员工账号密码等登录相关数据 * 人资管理系统员工账号信息表用于存储员工账号密码等登录相关数据
@ -14,4 +15,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface UserDao extends BaseMapper<UserEntity> { public interface UserDao extends BaseMapper<UserEntity> {
String getPasswordById(Long id);
String getAccountById(Long id);
Boolean updatePassword(@Param("id") Long id, @Param("password") String password);
String getPhoneAccount(Long id);
Boolean updatePhoneAccount(@Param("id")Long id,@Param("phoneAccount") String phoneAccount);
} }

@ -0,0 +1,14 @@
package com.daqing.financial.hrms.feign;
import org.springframework.cloud.openfeign.FeignClient;
/**
* 声明这是一个远程调用
* @auther River
* @date 2020/10/12 17:58
*/
@FeignClient("dq-financial-hrms-auht")
public interface HrmsAuthFeignService {
}

@ -1,11 +1,18 @@
package com.daqing.financial.hrms.service; package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.crms.request.EmployeeDisableRequest;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeInfoVO;
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.request.EmployeeRequest;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -24,6 +31,32 @@ public interface EmployeeService extends IService<EmployeeEntity> {
List<EmployeeVO> listEmployeeName(); List<EmployeeVO> listEmployeeName();
PageUtils queryPage(Integer page, Integer size, EmployeeEntity employee); PageUtils queryPage(Integer page, Integer size, EmployeeRequest employeeRequest);
Boolean delete(List<Long> ids);
Boolean start(Long id);
Boolean stop(EmployeeDisableRequest employeeDisableRequest);
UserEntity forbidInfo(Long id);
void disableDetection();
Boolean reset(Long id);
EmployeeInfoVO info(Long id);
List<RolePermissionResponse> permissionTreeList(List<Long> ids);
Boolean update(EmployeeInfoVO employeeInfoVO);
Boolean save(EmployeeInfoVO employeeInfoVO);
Boolean excelExport(HttpServletResponse response);
Boolean excelTemplate(HttpServletResponse response);
Boolean excelImport(MultipartFile file);
} }

@ -2,6 +2,8 @@ package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.PositionEntity; import com.daqing.framework.domain.hrms.PositionEntity;
import com.daqing.framework.domain.hrms.ext.PositionVO;
import com.daqing.framework.domain.hrms.ext.RoleVO;
import com.daqing.framework.domain.hrms.request.PositionRequest; import com.daqing.framework.domain.hrms.request.PositionRequest;
import com.daqing.framework.domain.hrms.response.PositionResponse; import com.daqing.framework.domain.hrms.response.PositionResponse;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
@ -26,5 +28,9 @@ public interface PositionService extends IService<PositionEntity> {
PositionResponse getPositionById(Long id); PositionResponse getPositionById(Long id);
void removePositionByIds(List<Long> asList); void removePositionByIds(List<Long> asList);
List<PositionVO> listPositionIdAndName();
List<RoleVO> listRoleIdAndName();
} }

@ -1,9 +1,11 @@
package com.daqing.financial.hrms.service; package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import java.io.IOException;
import java.util.Map; import java.util.Map;
/** /**
@ -15,6 +17,14 @@ import java.util.Map;
*/ */
public interface UserService extends IService<UserEntity> { public interface UserService extends IService<UserEntity> {
PageUtils queryPage(Map<String, Object> params); EmployeeAndUserVO info();
Boolean update(EmployeeAndUserVO employeeAndUserVO);
Boolean updatePassword(Long id,String primaryPassword,String newPassword,String affirmNewPassword);
Boolean getVerificationCode(String phone);
Boolean bindingPhoneAccount(Long id,String phone,String code);
} }

@ -102,6 +102,10 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
return this.save(deptEntity); return this.save(deptEntity);
} }
/**
* 树形结构部门查询
* @return
*/
@Override @Override
public List<DeptEntity> listWithTree() { public List<DeptEntity> listWithTree() {
return getDeptTreeList(this.list(), 0L); return getDeptTreeList(this.list(), 0L);

@ -2,57 +2,479 @@ package com.daqing.financial.hrms.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.daqing.framework.domain.hrms.ext.PositionVO;
import com.daqing.framework.utils.PageUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrms.dao.EmployeeDao; import com.daqing.financial.hrms.dao.*;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.financial.hrms.service.EmployeeService; import com.daqing.financial.hrms.service.EmployeeService;
import com.daqing.framework.domain.crms.request.EmployeeDisableRequest;
import com.daqing.framework.domain.crms.response.CrmsCode;
import com.daqing.framework.domain.hrms.*;
import com.daqing.framework.domain.hrms.ext.*;
import com.daqing.framework.domain.hrms.request.EmployeeRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.PromptSuccess;
import com.daqing.framework.util.Md5Util;
import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.utils.excel.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@Service("employeeService") @Service("employeeService")
@Slf4j
public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity> implements EmployeeService { public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity> implements EmployeeService {
@Autowired
private PermissionDao permissionDao;
@Autowired
private DeptDao deptDao;
@Autowired
private PositionDao positionDao;
@Autowired
private RoleDao roleDao;
/** /**
* 根据员工id查询员工的姓名和部门信息 * 列表
* @param ids 员工id集合
* @return
*/ */
@Override @Override
public List<EmployeeTO> getEmployeeAndDeptById(List<Long> ids) { public PageUtils queryPage(Integer page, Integer size, EmployeeRequest employeeRequest) {
return this.getBaseMapper().getEmployeeAndDeptById(ids); //分页参数参数校验,后续优化为自定义选择每页条数和跳转到第几页
if (page == null || size == null){
page = 1;
size = 10;
}
IPage<EmployeeListVO> iPage;
if (employeeRequest.getId() == null) {
iPage = this.getBaseMapper().pageList(new Page(page, size), employeeRequest);
} else {
iPage = this.getBaseMapper().pageListByDept(new Page(page, size), employeeRequest);
}
return new PageUtils(iPage);
} }
/**
* 删除
*/
@Transactional
@Override @Override
public PageUtils queryPage(Integer page, Integer size, EmployeeEntity employee) { public Boolean delete(List<Long> ids) {
//分页参数 if (ids == null || ids.size() == 0) {
if (page <= 0) { ExceptionCast.cast(CommonCode.INVALID_PARAM);
page = 1;
} }
if (size <= 0) { List<Long> user_ids = this.getBaseMapper().queryIds(ids);
size = 10; if (user_ids == null || user_ids.size() == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_IS_NULL);
}
return this.getBaseMapper().deleteByIds(user_ids);
} }
IPage<EmployeeVO> employeeVO = this.getBaseMapper().pageByCondition(new Page(page, size), employee);
return new PageUtils(employeeVO); /**
* 启用
*/
@Transactional
@Override
public Boolean start(Long id) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
Long userId = this.getBaseMapper().getUserId(id);
UserEntity user = new UserEntity();
user.setId(userId);
user.setStatus(PromptSuccess.START_STATUS);
return this.getBaseMapper().startOrStop(user);
} }
/** /**
* 根据id查询员工的id * 禁用
* @param id */
* @return @Transactional
@Override
public Boolean stop(EmployeeDisableRequest employeeDisableRequest) {
UserEntity user = new UserEntity();
BeanUtils.copyProperties(employeeDisableRequest,user);
if (employeeDisableRequest.getEmployeeId() == null || user.getDisableStartTime() == null
|| user.getDisableEndTime() == null || user.getDisableCause() == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
if (user.getDisableStartTime().getTime() >= user.getDisableEndTime().getTime()){
ExceptionCast.cast(HrmsCode.EMPLOYEE_DISABLE_TIME_ERROR);
}
Long userId = this.getBaseMapper().getUserId(employeeDisableRequest.getEmployeeId());
if (user.getDisableStartTime().getTime() <= (new Date()).getTime()
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()){
user.setId(userId);
user.setStatus(PromptSuccess.STOP_STATUS);
return this.getBaseMapper().startOrStop(user);
}else if (user.getDisableStartTime().getTime() > (new Date()).getTime()){
user.setId(userId);
user.setStatus(PromptSuccess.UPCOMING_STOP_STATUS);
return this.getBaseMapper().startOrStop(user);
}else {
return false;
}
}
/**
* 禁用详情
*/
@Override
public UserEntity forbidInfo(Long id) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
Long userId = this.getBaseMapper().getUserId(id);
return this.getBaseMapper().forbidInfo(userId);
}
/**
* 定时检测是否禁用
*/
@Transactional
@Override
public void disableDetection() {
List<UserEntity> users = this.getBaseMapper().listDisableTime();
if (users.size() != 0){
for (UserEntity user : users) {
if (user.getDisableStartTime().getTime() <= (new Date()).getTime()
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()){
user.setStatus(PromptSuccess.STOP_STATUS);
this.getBaseMapper().startOrStop(user);
}else if ((new Date()).getTime() < user.getDisableStartTime().getTime()){
user.setStatus(PromptSuccess.UPCOMING_STOP_STATUS);
this.getBaseMapper().startOrStop(user);
}else if ((new Date()).getTime() > user.getDisableEndTime().getTime()){
user.setStatus(PromptSuccess.START_STATUS);
user.setDisableStartTime(null);
user.setDisableEndTime(null);
user.setDisableCause(null);
this.getBaseMapper().startOrStop(user);
}
}
}
}
/**
* 重置密码
*/
@Override
public Boolean reset(Long id) {
if (id == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
Long userId = this.getBaseMapper().getUserId(id);
if (userId == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_IS_NULL);
}
String password = Md5Util.md5(PromptSuccess.RESET_PASSWORD + userId);
return this.getBaseMapper().updatePassword(id, password);
}
/**
* 详细信息
*/
@Override
public EmployeeInfoVO info(Long id) {
if (id == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
EmployeeInfoVO info = this.getBaseMapper().getInfo(id);
if (info == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_IS_NULL);
}
if (info.getRoles().size() != 0 && info.getRoles() != null) {
List<Long> roleIds = new ArrayList<>();
for (RoleEntity role : info.getRoles()) {
roleIds.add(role.getId());
}
List<RolePermissionResponse> list = permissionDao.listPermissionByRoleIds(roleIds);
if (list.size() != 0) {
// 去重
Map<Long,RolePermissionResponse> map = new HashMap<>();
for (RolePermissionResponse rolePermissionResponse : list) {
map.put(rolePermissionResponse.getPermissionId(),rolePermissionResponse);
}
list.clear();
for (Long key : map.keySet()) {
list.add(map.get(key));
}
List<RolePermissionResponse> permissionTreeList = this.getRolePermissionTreeList(list, 0L);
if (permissionTreeList != null && permissionTreeList.size() != 0) {
info.setPermissions(permissionTreeList);
}
}
}
return info;
}
/**
* 选择角色后对应的权限展示
*/
@Override
public List<RolePermissionResponse> permissionTreeList(List<Long> ids) {
if (ids == null || ids.size() == 0) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
List<RolePermissionResponse> list = permissionDao.listPermissionByRoleIds(ids);
if (list.size() != 0) {
// 去重
Map<Long,RolePermissionResponse> map = new HashMap<>();
for (RolePermissionResponse rolePermissionResponse : list) {
map.put(rolePermissionResponse.getPermissionId(),rolePermissionResponse);
}
list.clear();
for (Long key : map.keySet()) {
list.add(map.get(key));
}
return this.getRolePermissionTreeList(list, 0L);
} else {
return null;
}
}
/**
* 更新
*/
@Transactional
@Override
public Boolean update(EmployeeInfoVO employeeInfoVO) {
if (employeeInfoVO.getId() == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
if (employeeInfoVO.getDepartmentIds() == null || employeeInfoVO.getDepartmentIds().size() == 0) {
ExceptionCast.cast(HrmsCode.DEPT_NOT_NULL);
}
if (employeeInfoVO.getPositionIds() == null || employeeInfoVO.getPositionIds().size() == 0) {
ExceptionCast.cast(HrmsCode.POSITION_NOT_NULL);
}
if (employeeInfoVO.getRoleIds() == null || employeeInfoVO.getRoleIds().size() == 0) {
ExceptionCast.cast(HrmsCode.ROLE_NOT_NULL);
}
Long userId = this.getBaseMapper().getUserId(employeeInfoVO.getId());
if (userId == null){
ExceptionCast.cast(HrmsCode.EMPLOYEE_USER_IS_NULL);
}
String account = employeeInfoVO.getAccount();
EmployeeEntity employee = new EmployeeEntity();
BeanUtils.copyProperties(employeeInfoVO, employee);
Boolean result1 = this.getBaseMapper().updateEmployee(employee);
Boolean result2 = this.getBaseMapper().updateUser(userId, account, new Date());
this.getBaseMapper().deleteDepartment(employeeInfoVO.getId());
this.getBaseMapper().deletePosition(employeeInfoVO.getId());
this.getBaseMapper().deleteRole(userId);
Boolean result3 = this.getBaseMapper().insertDepartment(employeeInfoVO.getId(), employeeInfoVO.getDepartmentIds());
Boolean result4 = this.getBaseMapper().insertPosition(employeeInfoVO.getId(), employeeInfoVO.getPositionIds());
Boolean result5 = this.getBaseMapper().insertRole(userId, employeeInfoVO.getRoleIds());
return result1 && result2 && result3 && result4 && result5;
}
/**
* 新增
*/
@Transactional
@Override
public Boolean save(EmployeeInfoVO employeeInfoVO) {
if (employeeInfoVO.getDepartmentIds() == null || employeeInfoVO.getDepartmentIds().size() == 0) {
ExceptionCast.cast(HrmsCode.DEPT_NOT_NULL);
}
if (employeeInfoVO.getPositionIds() == null || employeeInfoVO.getPositionIds().size() == 0) {
ExceptionCast.cast(HrmsCode.POSITION_NOT_NULL);
}
if (employeeInfoVO.getRoleIds() == null || employeeInfoVO.getRoleIds().size() == 0) {
ExceptionCast.cast(HrmsCode.ROLE_NOT_NULL);
}
UserEntity user = new UserEntity();
user.setAccount(employeeInfoVO.getAccount());
user.setCreateTime(new Date());
Boolean result1 = this.getBaseMapper().insertUser(user);
EmployeeEntity employee = new EmployeeEntity();
if (result1) {
employee.setUserId(user.getId());
BeanUtils.copyProperties(employeeInfoVO, employee);
Boolean result2 = this.getBaseMapper().insertEmployee(employee);
if (result2) {
Boolean result3 = this.getBaseMapper().insertDepartment(employee.getId(), employeeInfoVO.getDepartmentIds());
Boolean result4 = this.getBaseMapper().insertPosition(employee.getId(), employeeInfoVO.getPositionIds());
Boolean result5 = this.getBaseMapper().insertRole(user.getId(), employeeInfoVO.getRoleIds());
return result3 && result4 && result5;
}
}
return false;
}
/**
* 导出
*/
@Transactional
@Override
public Boolean excelExport(HttpServletResponse response) {
try {
List<EmployeeListVO> list = this.getBaseMapper().excelList();
ExcelUtil.writeExcelWithSheets(response, list, "员工信息一览表", "employee", new EmployeeListVO())
.finish();
return true;
} catch (Exception e) {
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORT_EXSIT);
return false;
}
}
/**
* 导出模板
*/
@Transactional
@Override
public Boolean excelTemplate(HttpServletResponse response) {
try {
ExcelUtil.writeExcelWithSheets(response, new ArrayList<EmployeeTemplate>(), "员工信息导入模板", "employee", new EmployeeTemplate())
.finish();
return true;
} catch (Exception e) {
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORT_EXSIT);
return false;
}
}
/**
* 导入
*/
@Transactional
@Override
public Boolean excelImport(MultipartFile file) {
if (file == null || file.isEmpty()){
ExceptionCast.cast(CrmsCode.NOT_NULL);
}
EmployeeExcelImport employeeExcelImport = new EmployeeExcelImport();
UserEntity user = new UserEntity();
EmployeeEntity employee = new EmployeeEntity();
List<DepartmentVO> listDepartmentIdAndName = deptDao.listDepartmentIdAndName();
List<PositionVO> listPositionIdAndName = positionDao.listPositionIdAndName();
List<RoleVO> listRoleIdAndName = roleDao.listRoleIdAndName();
Set<Long> deptIds = new HashSet<>();
Set<Long> positionIds = new HashSet<>();
Set<Long> roleIds = new HashSet<>();
List<Object> employees = ExcelUtil.readExcel(file, employeeExcelImport, 1);
if (employees.size() == 0) {
ExceptionCast.cast(HrmsCode.EXCEL_DATA_IS_NULL);
}
for (Object e : employees) {
BeanUtils.copyProperties(e, employeeExcelImport);
if (employeeExcelImport.getName() == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_NAME_IS_NULL);
}
if (employeeExcelImport.getAccount() == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_ACCOUNT_IS_NULL);
}
if (employeeExcelImport.getJobNumber() == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_JOBNUMBER_IS_NULL);
}
user.setAccount(employeeExcelImport.getAccount());
user.setCreateTime(new Date());
this.getBaseMapper().insertUser(user);
BeanUtils.copyProperties(e, employee);
employee.setUserId(user.getId());
this.getBaseMapper().insertEmployee(employee);
// 部门
String[] departmentNames = employeeExcelImport.getDepartmentNameList().split(",");
if (departmentNames.length == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_DEPARTMENT_IS_NULL);
}
for (DepartmentVO department : listDepartmentIdAndName) {
for (String s : departmentNames) {
if (Objects.equals(department.getName(), s)) {
deptIds.add(department.getId());
}
}
}
if (deptIds.size() != departmentNames.length) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_DEPARTMENT_NAME_IS_NOT);
}
this.getBaseMapper().insertDepartment(employee.getId(), new ArrayList<>(deptIds));
// 职位
String[] positionNames = employeeExcelImport.getPositionNameList().split(",");
if (positionNames.length == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_POSITION_IS_NULL);
}
for (PositionVO position : listPositionIdAndName) {
for (String s : positionNames) {
if (Objects.equals(position.getName(), s)) {
positionIds.add(position.getId());
}
}
}
if (positionIds.size() != positionNames.length) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_POSITION_NAME_IS_NOT);
}
this.getBaseMapper().insertPosition(employee.getId(), new ArrayList<>(positionIds));
// 角色
String[] roleNames = employeeExcelImport.getRoleNameList().split(",");
if (roleNames.length == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_ROLE_IS_NULL);
}
for (RoleVO role : listRoleIdAndName) {
for (String s : roleNames) {
if (Objects.equals(role.getName(), s)) {
roleIds.add(role.getId());
}
}
}
if (roleIds.size() != roleNames.length) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_ROLE_NAME_IS_NOT);
}
this.getBaseMapper().insertRole(employee.getId(), new ArrayList<>(roleIds));
}
return true;
}
/**
* 封装员工的权限树
*/
private List<RolePermissionResponse> getRolePermissionTreeList(List<RolePermissionResponse> list, Long parentId) {
return list.stream()
.filter(item -> parentId.equals(item.getParentId()))
.peek(item -> item.setChildren(getRolePermissionTreeList(list, item.getPermissionId())))
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort())))
.collect(Collectors.toList());
}
/**
* 根据id查询员工的姓名
*/ */
@Override @Override
public EmployeeEntity getEmployeeById(Long id) { public EmployeeEntity getEmployeeById(Long id) {
return this.getBaseMapper().getEmployeeById(id); return this.getBaseMapper().getEmployeeById(id);
} }
/**
* 查询所有的员工id和姓名
*/
@Override @Override
public List<EmployeeVO> listEmployeeName() { public List<EmployeeVO> listEmployeeName() {
return this.getBaseMapper().listEmployeeName(); return this.getBaseMapper().listEmployeeName();
} }
/**
* 根据员工id查询员工的姓名和部门信息
*
* @param ids 员工id集合
* @return
*/
@Override
public List<EmployeeTO> getEmployeeAndDeptById(List<Long> ids) {
return this.getBaseMapper().getEmployeeAndDeptById(ids);
}
} }

@ -4,16 +4,14 @@ 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.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.hrms.dao.DeptDao; import com.daqing.financial.hrms.dao.*;
import com.daqing.financial.hrms.dao.DeptPositionDao;
import com.daqing.financial.hrms.dao.EmployeePositionDao;
import com.daqing.financial.hrms.dao.PositionDao;
import com.daqing.financial.hrms.service.PositionService; import com.daqing.financial.hrms.service.PositionService;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.DeptPositionEntity; import com.daqing.framework.domain.hrms.DeptPositionEntity;
import com.daqing.framework.domain.hrms.EmployeePositionEntity; import com.daqing.framework.domain.hrms.EmployeePositionEntity;
import com.daqing.framework.domain.hrms.PositionEntity; import com.daqing.framework.domain.hrms.PositionEntity;
import com.daqing.framework.domain.hrms.ext.PositionVO; import com.daqing.framework.domain.hrms.ext.PositionVO;
import com.daqing.framework.domain.hrms.ext.RoleVO;
import com.daqing.framework.domain.hrms.request.PositionRequest; import com.daqing.framework.domain.hrms.request.PositionRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode; import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.domain.hrms.response.PositionResponse; import com.daqing.framework.domain.hrms.response.PositionResponse;
@ -44,6 +42,9 @@ public class PositionServiceImpl extends ServiceImpl<PositionDao, PositionEntity
@Autowired @Autowired
EmployeePositionDao employeePositionDao; EmployeePositionDao employeePositionDao;
@Autowired
private RoleDao roleDao;
@Override @Override
public PageUtils queryPage(Integer page, Integer size, String queryMsg) { public PageUtils queryPage(Integer page, Integer size, String queryMsg) {
//分页参数 //分页参数
@ -80,7 +81,6 @@ public class PositionServiceImpl extends ServiceImpl<PositionDao, PositionEntity
//添加职位信息 //添加职位信息
PositionEntity positionEntity = new PositionEntity(); PositionEntity positionEntity = new PositionEntity();
BeanUtils.copyProperties(position, positionEntity); BeanUtils.copyProperties(position, positionEntity);
positionEntity.setId(SnowflakeIdUtils.getRandomid());
positionEntity.setCreateUser(position.getUserId()); positionEntity.setCreateUser(position.getUserId());
positionEntity.setCreateTime(new Date()); positionEntity.setCreateTime(new Date());
positionEntity.setMotifyTime(new Date()); positionEntity.setMotifyTime(new Date());
@ -152,10 +152,25 @@ public class PositionServiceImpl extends ServiceImpl<PositionDao, PositionEntity
idList.forEach(id -> deptPositionDao.deleteByPositionId(id)); idList.forEach(id -> deptPositionDao.deleteByPositionId(id));
} }
/**
* 所有的职位id和名称
*/
@Override
public List<PositionVO> listPositionIdAndName() {
return this.getBaseMapper().listPositionIdAndName();
}
/**
* 所有的角色id和名称
*/
@Override
public List<RoleVO> listRoleIdAndName() {
return roleDao.listRoleIdAndName();
}
private List<DeptPositionEntity> getDeptPositionList(List<Long> deptIdList, Long id) { private List<DeptPositionEntity> getDeptPositionList(List<Long> deptIdList, Long id) {
return deptIdList.stream().map(deptId -> { return deptIdList.stream().map(deptId -> {
DeptPositionEntity deptPositionEntity = new DeptPositionEntity(); DeptPositionEntity deptPositionEntity = new DeptPositionEntity();
deptPositionEntity.setId(SnowflakeIdUtils.getRandomid());
deptPositionEntity.setDeptId(deptId); deptPositionEntity.setDeptId(deptId);
deptPositionEntity.setPositionId(id); deptPositionEntity.setPositionId(id);
return deptPositionEntity; return deptPositionEntity;

@ -1,7 +1,25 @@
package com.daqing.financial.hrms.service.impl; package com.daqing.financial.hrms.service.impl;
import com.daqing.financial.hrms.dao.EmployeeDao;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO;
import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.PromptSuccess;
import com.daqing.framework.util.Md5Util;
import com.daqing.framework.util.RedisUtil;
import com.daqing.framework.util.SendSMS;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Map; import java.util.Map;
import java.util.Objects;
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.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -11,19 +29,203 @@ import com.daqing.framework.utils.Query;
import com.daqing.financial.hrms.dao.UserDao; import com.daqing.financial.hrms.dao.UserDao;
import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.financial.hrms.service.UserService; import com.daqing.financial.hrms.service.UserService;
import org.springframework.transaction.annotation.Transactional;
import javax.imageio.ImageIO;
@Slf4j
@Service("userService") @Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService { public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {
@Autowired
private EmployeeDao employeeDao;
/**
* 当前登录的用户信息
*/
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public EmployeeAndUserVO info() {
IPage<UserEntity> page = this.page( /*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
new Query<UserEntity>().getPage(params), String token = request.getHeader("token");
new QueryWrapper<UserEntity>() String userId = RedisUtil.get("dq:token:"+token);*/
); //TODO:测试环境模拟从redis中拿取用户id
String userId = "1";
return employeeDao.getEmployeeByUserId(Long.parseLong(userId));
}
return new PageUtils(page); /**
* 更新
*/
@Transactional
@Override
public Boolean update(EmployeeAndUserVO employeeAndUserVO) {
EmployeeEntity employee = new EmployeeEntity();
Boolean result = true;
if (employeeAndUserVO.getFile() != null && !employeeAndUserVO.getFile().isEmpty()){
//TODO:上传图像文件到oss服务器,返回一个路径地址
try {
// 通过获取图片文件的宽度和高度来校验是否为图片文件
BufferedImage image = ImageIO.read(employeeAndUserVO.getFile().getInputStream());
if (image == null || image.getHeight() <= 0 || image.getWidth() <= 0){
ExceptionCast.cast(HrmsCode.USER_FILE_TYPE_MISTAKE);
}
}catch (IOException e){
ExceptionCast.cast(HrmsCode.USER_FILE_UPLOAD_FAIL);
}
OutputStream os = null;
InputStream inputStream = null;
String fileName = null;
try {
inputStream = employeeAndUserVO.getFile().getInputStream();
fileName = employeeAndUserVO.getFile().getOriginalFilename();
log.info("fileName="+fileName);
} catch (IOException e) {
e.printStackTrace();
}
try {
String path = "D:\\image";
// 2、保存到临时文件
// 1K的数据缓冲
byte[] bs = new byte[1024];
// 读取到的数据长度
int len;
// 输出的文件流保存到本地文件
File tempFile = new File(path);
if (!tempFile.exists()) {
tempFile.mkdirs();
}
os = new FileOutputStream(tempFile.getPath() + File.separator + "MyFileName.png");
// 开始读取
while ((len = inputStream.read(bs)) != -1) {
os.write(bs, 0, len);
}
} catch (IOException e) {
ExceptionCast.cast(HrmsCode.USER_FILE_UPLOAD_FAIL);
} catch (Exception e) {
e.printStackTrace();
} finally {
// 完毕,关闭所有链接
try {
os.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
BeanUtils.copyProperties(employeeAndUserVO,employee);
String phoneAccount = this.getBaseMapper().getPhoneAccount(employee.getUserId());
if ((phoneAccount == null || phoneAccount.length() == 0)
&& employeeAndUserVO.getPrimaryPhone() != null
&& employeeAndUserVO.getPrimaryPhone().length() != 0
&& employeeAndUserVO.getPrimaryCode() != null
&& employeeAndUserVO.getPrimaryCode().length() != 0){
// 没有绑定手机号,现在绑定
String code = RedisUtil.get(employeeAndUserVO.getPrimaryPhone());
if (code == null || code.length() == 0 || !Objects.equals(employeeAndUserVO.getPrimaryCode(),code)){
ExceptionCast.cast(HrmsCode.USER_PHONE_CODE_MISTAKE);
}
RedisUtil.del(employeeAndUserVO.getPrimaryPhone());
result = this.getBaseMapper().updatePhoneAccount(employee.getUserId(), employeeAndUserVO.getPrimaryPhone());
}
if (employeeAndUserVO.getPrimaryPhone() != null
&& employeeAndUserVO.getPrimaryPhone().length() != 0
&& employeeAndUserVO.getPrimaryCode() != null
&& employeeAndUserVO.getPrimaryCode().length() != 0
&& employeeAndUserVO.getNewPhone() != null
&& employeeAndUserVO.getNewPhone().length() != 0
&& employeeAndUserVO.getNewCode() != null
&& employeeAndUserVO.getNewCode().length() != 0
&& phoneAccount != null && phoneAccount.length() != 0){
// 更换绑定的手机号
if (!Objects.equals(phoneAccount,employeeAndUserVO.getPrimaryPhone())){
ExceptionCast.cast(HrmsCode.USER_PRIMARY_PHONE_MISTAKE);
}
String primaryCode = RedisUtil.get(employeeAndUserVO.getPrimaryPhone());
if (primaryCode == null || primaryCode.length() == 0
|| !Objects.equals(primaryCode,employeeAndUserVO.getPrimaryCode())){
ExceptionCast.cast(HrmsCode.USER_PRIMARY_CODE_MISTAKE);
}
RedisUtil.del(employeeAndUserVO.getPrimaryPhone());
String newCode = RedisUtil.get(employeeAndUserVO.getNewPhone());
if (newCode == null || newCode.length() == 0
|| !Objects.equals(newCode,employeeAndUserVO.getNewCode())){
ExceptionCast.cast(HrmsCode.USER_NEW_CODE_MISTAKE);
}
RedisUtil.del(employeeAndUserVO.getNewPhone());
result = this.getBaseMapper().updatePhoneAccount(employee.getUserId(), employeeAndUserVO.getNewPhone());
}
return result && employeeDao.updateEmployeeAndUser(employee);
} }
/**
* 修改密码
*/
@Transactional
@Override
public Boolean updatePassword(Long id, String primaryPassword, String newPassword, String affirmNewPassword) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
if (primaryPassword == null || primaryPassword.length() == 0
|| newPassword == null || newPassword.length() == 0
|| affirmNewPassword == null || affirmNewPassword.length() == 0){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_NOT_NULL);
}
// 两次输入是否相同
if (!Objects.equals(affirmNewPassword, newPassword)){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_NO_CONSISTENT);
}
if (!Objects.equals(Md5Util.md5(primaryPassword + id),this.getBaseMapper().getPasswordById(id))){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_MISTAKE);
}
// 正则校验
if (!newPassword.matches(PromptSuccess.MATCHES_STRING)){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_MATCHES);
}
// 是否与账号相同
if (Objects.equals(newPassword,this.getBaseMapper().getAccountById(id))){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_IS_NO_ACCOUNT);
}
return this.getBaseMapper().updatePassword(id,Md5Util.md5(newPassword + id));
}
/**
* 获取验证码
*/
@Override
public Boolean getVerificationCode(String phone) {
if (phone == null || phone.length() == 0){
ExceptionCast.cast(HrmsCode.USER_PHONE_NOT_NULL);
}
String code = (int)((Math.random() * 9 + 1) * 100000)+ "";
// 发送短信
Boolean result = SendSMS.sendCode(phone, code);
if (result){
RedisUtil.setEx(phone,code,PromptSuccess.OVERDUE_TIME);
return true;
}
return false;
}
/**
* 绑定手机号
*/
@Transactional
@Override
public Boolean bindingPhoneAccount(Long id,String phone, String code) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
if (phone == null || phone.length() == 0 || code == null || code.length() == 0){
ExceptionCast.cast(HrmsCode.USER_PHONE_OR_CODE_NOT_NULL);
}
if (RedisUtil.get(phone) == null || RedisUtil.get(phone).length() == 0
|| !Objects.equals(code,RedisUtil.get(phone))){
ExceptionCast.cast(HrmsCode.USER_BINDING_FAIL);
}
RedisUtil.del(phone);
return this.getBaseMapper().updatePhoneAccount(id, phone);
}
} }

@ -0,0 +1,25 @@
package com.daqing.financial.hrms.task;
import com.daqing.financial.hrms.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 定时禁用检测类
* @auther River
* @date 2020/10/14 16:04
*/
@Component
public class DisableDetectionTask {
@Autowired
private EmployeeService employeeService;
//格式 :秒 分 时 日 月 年
@Scheduled(cron = "0 0 0 * * ?")
public void disableDetection(){
employeeService.disableDetection();
}
}

@ -27,6 +27,9 @@ spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=8 spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
# 正式环境(prod) # 正式环境(prod)
#服务名称 #服务名称
#spring.application.name=dq-financial-hrms #spring.application.name=dq-financial-hrms

@ -41,4 +41,8 @@
FROM hrms_dept WHERE parent_id = #{parentId} FROM hrms_dept WHERE parent_id = #{parentId}
</select> </select>
<select id="listDepartmentIdAndName" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name FROM hrms_dept
</select>
</mapper> </mapper>

@ -19,10 +19,125 @@
<result property="userId" column="user_id"/> <result property="userId" column="user_id"/>
</resultMap> </resultMap>
<!-- 不含部门id时列表 -->
<resultMap id="employeeList" type="com.daqing.framework.domain.hrms.ext.EmployeeListVO">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="jobNumber" column="job_number"/>
<association property="account" javaType="string">
<result column="account"/>
</association>
<association property="createTime" javaType="java.util.Date">
<result column="create_time"/>
</association>
<association property="status" javaType="integer">
<result column="status"/>
</association>
<collection property="departmentNameList" ofType="string" column="id" select="departmentList"/>
<collection property="positionNameList" ofType="string" column="id" select="positionList"/>
<collection property="roleNameList" ofType="string" column="id" select="roleList"/>
</resultMap>
<!-- 含有部门时列表 -->
<resultMap id="employeeAndDeptList" type="com.daqing.framework.domain.hrms.ext.EmployeeListVO">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="jobNumber" column="job_number"/>
<association property="account" javaType="string">
<result column="account"/>
</association>
<association property="createTime" javaType="java.util.Date">
<result column="create_time"/>
</association>
<association property="status" javaType="integer">
<result column="status"/>
</association>
<collection property="departmentNameList" ofType="string" column="id" select="departmentList"/>
<collection property="positionNameList" ofType="string" column="id" select="positionList"/>
<collection property="roleNameList" ofType="string" column="id" select="roleList"/>
</resultMap>
<!-- 员工详情(人力后台展示) -->
<resultMap id="employeeInfo" type="com.daqing.framework.domain.hrms.ext.EmployeeInfoVO">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="jobNumber" column="job_number"/>
<result property="gender" column="gender"/>
<result property="birthday" column="birthday"/>
<result property="phone" column="phone"/>
<result property="companyMail" column="company_mail"/>
<association property="account" javaType="string">
<result column="account"/>
</association>
<association property="status" javaType="integer">
<result column="status"/>
</association>
<collection property="departments" ofType="com.daqing.framework.domain.hrms.DeptEntity">
<id property="id" column="dept_id"/>
<result property="name" column="dept_name"/>
</collection>
<collection property="positions" ofType="com.daqing.framework.domain.hrms.PositionEntity">
<id property="id" column="position_id"/>
<result property="name" column="position_name"/>
</collection>
<collection property="roles" ofType="com.daqing.framework.domain.hrms.RoleEntity">
<id property="id" column="role_id"/>
<result property="name" column="role_name"/>
</collection>
</resultMap>
<!-- 员工详情(人力工作台展示) -->
<resultMap id="employeeInfoByUserId" type="com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="jobNumber" column="job_number"/>
<result property="gender" column="gender"/>
<result property="birthday" column="birthday"/>
<result property="phone" column="phone"/>
<result property="companyMail" column="company_mail"/>
<result property="spareMail" column="spare_mail"/>
<result property="officePhone" column="office_phone"/>
<result property="positionDescription" column="position_description"/>
<result property="headPortaritUrl" column="head_portarit_url"/>
<result property="userId" column="user_id"/>
<association property="account" javaType="string">
<result column="account"/>
</association>
<association property="password" javaType="string">
<result column="password"/>
</association>
<association property="loginNum" javaType="integer">
<result column="login_num"/>
</association>
<association property="lasttime" javaType="java.util.Date">
<result column="lasttime"/>
</association>
<association property="phoneAccount" javaType="string">
<result column="phone_account"/>
</association>
<association property="wechatId" javaType="string">
<result column="wechat_id"/>
</association>
<collection property="departments" ofType="string">
<result column="dept_name"/>
</collection>
<collection property="positions" ofType="string">
<result column="position_name"/>
</collection>
<collection property="roles" ofType="string">
<result column="role_name"/>
</collection>
</resultMap>
<!-- 映射user实体类和数据库表主键,使之能获取到新增的主键 -->
<resultMap type="com.daqing.framework.domain.hrms.UserEntity" id="userMap">
<result property="id" column="id"/>
</resultMap>
<resultMap type="com.daqing.framework.domain.hrms.ext.EmployeeTO" id="employeeTO"> <resultMap type="com.daqing.framework.domain.hrms.ext.EmployeeTO" id="employeeTO">
<id property="id" column="eid"/> <id property="id" column="eid"/>
<result property="empName" column="emp_name"/> <result property="empName" column="emp_name"/>
<collection property="deptNames" ofType="string"> <collection property="deptNames" ofType="string" >
<result column="dept_name"/> <!-- 员工和部门是多对多,从单个员工的角度看为一对多 --> <result column="dept_name"/> <!-- 员工和部门是多对多,从单个员工的角度看为一对多 -->
</collection> </collection>
</resultMap> </resultMap>
@ -98,4 +213,250 @@
AND u.del_or_not = 0 AND u.del_or_not = 0
</where> </where>
</select> </select>
<select id="pageList" parameterType="com.daqing.framework.domain.hrms.request.EmployeeRequest" resultMap="employeeList">
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
u.create_time create_time,u.status status
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
<if test="employee.codeOrName != null and employee.codeOrName != ''">
AND (e.name LIKE CONCAT('%',#{employee.codeOrName},'%') OR u.account LIKE CONCAT('%',#{employee.codeOrName},'%')
OR e.job_number LIKE CONCAT('%',#{employee.codeOrName},'%'))
</if>
</select>
<select id="excelList" resultMap="employeeList">
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
u.create_time create_time,u.status status
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
</select>
<select id="pageListByDept" parameterType="com.daqing.framework.domain.hrms.request.EmployeeRequest" resultMap="employeeList">
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
u.create_time create_time,u.status status
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
LEFT JOIN hrms_employee_dept ed
ON e.id = ed.employee_id
LEFT JOIN hrms_dept d
ON ed.dept_id = d.id
WHERE u.del_or_not = 0
<if test="employee.id != null and employee.id != ''">
AND d.id = #{employee.id}
</if>
<if test="employee.codeOrName != null and employee.codeOrName != ''">
AND (e.name LIKE CONCAT('%',#{employee.codeOrName},'%') OR u.account LIKE CONCAT('%',#{employee.codeOrName},'%')
OR e.job_number LIKE CONCAT('%',#{employee.codeOrName},'%'))
</if>
</select>
<select id="departmentList" parameterType="long" resultType="string">
SELECT d.name
FROM hrms_dept d
LEFT JOIN hrms_employee_dept ed
ON d.id = ed.dept_id
LEFT JOIN hrms_employee e
ON ed.employee_id = e.id
WHERE e.id = #{id}
</select>
<select id="positionList" parameterType="long" resultType="string">
SELECT p.name
FROM hrms_position p
LEFT JOIN hrms_employee_position ep
ON p.id = ep.position_id
LEFT JOIN hrms_employee e
ON ep.emp_id = e.id
WHERE e.id = #{id}
</select>
<select id="roleList" parameterType="long" resultType="string">
SELECT r.name
FROM hrms_role r
LEFT JOIN hrms_employee_role er
ON r.id = er.role_id
LEFT JOIN hrms_user u
ON u.id = er.user_id
LEFT JOIN hrms_employee e
ON e.user_id = u.id
WHERE e.id = #{id}
</select>
<!-- 根据employee id得到 user_id-->
<select id="queryIds" parameterType="long" resultType="long">
SELECT user_id FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND e.id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
</select>
<!-- 删除:del_or_not = 1 -->
<delete id="deleteByIds" parameterType="long">
UPDATE hrms_user SET del_or_not = 1 WHERE id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
</delete>
<select id="getStatus" parameterType="long" resultType="integer">
SELECT u.status status FROM hrms_user u
LEFT JOIN hrms_employee e
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND e.id = #{id}
</select>
<!-- 启用或者禁用 -->
<update id="startOrStop" parameterType="com.daqing.framework.domain.hrms.UserEntity">
UPDATE hrms_user SET status = #{status},disable_start_time = #{disableStartTime},
disable_end_time = #{disableEndTime},disable_cause = #{disableCause}
WHERE id = #{id}
</update>
<!-- 禁用详情-->
<select id="forbidInfo" parameterType="long" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT disable_start_time,disable_end_time,disable_cause
FROM hrms_user WHERE id = #{id}
</select>
<!-- 所有的禁用时间 -->
<select id="listDisableTime" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT id,disable_start_time,disable_end_time,disable_cause
FROM hrms_user WHERE status = 1 OR status = 2
</select>
<!-- 获取user_id-->
<select id="getUserId" resultType="long">
SELECT user_id FROM hrms_employee WHERE id = #{id}
</select>
<!-- 重置密码 -->
<update id="updatePassword">
UPDATE hrms_user SET password = #{password} WHERE id = #{id}
</update>
<select id="getInfo" resultMap="employeeInfo" parameterType="long">
SELECT e.id id,e.name name,e.job_number job_number,e.phone phone,e.gender gender,
e.birthday birthday,e.company_mail company_mail,u.account account,u.status status,
d.id dept_id,d.name dept_name,r.id role_id,r.name role_name,po.id position_id,
po.name position_name
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
LEFT JOIN hrms_employee_dept ed
ON ed.employee_id = e.id
LEFT JOIN hrms_dept d
ON ed.dept_id = d.id
LEFT JOIN hrms_employee_role er
ON er.user_id = u.id
LEFT JOIN hrms_role r
ON er.role_id = r.id
LEFT JOIN hrms_employee_position ep
ON ep.emp_id = e.id
LEFT JOIN hrms_position po
ON ep.position_id = po.id
WHERE u.del_or_not = 0
AND e.id = #{id}
</select>
<update id="updateEmployee" parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
UPDATE hrms_employee SET name = #{name},job_number = #{jobNumber},gender = #{gender},birthday = #{birthday},
phone = #{phone},company_mail = #{companyMail}
WHERE id = #{id}
</update>
<update id="updateUser">
UPDATE hrms_user SET account = #{account},motify_time = #{modifyTime} WHERE id = #{id}
</update>
<delete id="deleteDepartment" parameterType="long">
DELETE FROM hrms_employee_dept WHERE employee_id = #{id}
</delete>
<delete id="deletePosition" parameterType="long">
DELETE FROM hrms_employee_position WHERE emp_id = #{id}
</delete>
<delete id="deleteRole" parameterType="long">
DELETE FROM hrms_employee_role WHERE user_id = #{id}
</delete>
<insert id="insertDepartment">
INSERT INTO hrms_employee_dept
(employee_id,dept_id)
VALUES
<foreach collection="deptIds" item="deptId" separator=",">
(#{id},#{deptId})
</foreach>
</insert>
<insert id="insertPosition">
INSERT INTO hrms_employee_position
(emp_id,position_id)
VALUES
<foreach collection="positionIds" item="positionId" separator=",">
(#{id},#{positionId})
</foreach>
</insert>
<insert id="insertRole">
INSERT INTO hrms_employee_role
(user_id,role_id)
VALUES
<foreach collection="roleIds" item="roleId" separator=",">
(#{id},#{roleId})
</foreach>
</insert>
<insert id="insertEmployee" keyProperty="id" useGeneratedKeys="true" parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
INSERT INTO hrms_employee (name,job_number,gender,birthday,phone,company_mail,user_id)
VALUES (#{name},#{jobNumber},#{gender},#{birthday},#{phone},#{companyMail},#{userId})
</insert>
<insert id="insertUser" keyProperty="id" useGeneratedKeys="true" parameterType="com.daqing.framework.domain.hrms.UserEntity">
INSERT INTO hrms_user (account,create_time) VALUES (#{account},#{createTime})
</insert>
<select id="getEmployeeByUserId" parameterType="long" resultMap="employeeInfoByUserId">
SELECT e.id id,e.name name,e.job_number job_number,e.phone phone,e.gender gender,
e.birthday birthday,e.company_mail company_mail,e.spare_mail spare_mail,
e.office_phone office_phone,e.position_description position_description,
e.head_portarit_url head_portarit_url,e.user_id user_id,u.account account,
u.password password,u.login_num login_num,u.lasttime lasttime,u.phone_account
phone_account,u.wechat_id wechat_id,d.name dept_name,r.name role_name,
po.name position_name
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
LEFT JOIN hrms_employee_dept ed
ON ed.employee_id = e.id
LEFT JOIN hrms_dept d
ON ed.dept_id = d.id
LEFT JOIN hrms_employee_role er
ON er.user_id = u.id
LEFT JOIN hrms_role r
ON er.role_id = r.id
LEFT JOIN hrms_employee_position ep
ON ep.emp_id = e.id
LEFT JOIN hrms_position po
ON ep.position_id = po.id
WHERE u.del_or_not = 0
AND u.id = #{id}
</select>
<update id="updateEmployeeAndUser" parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
UPDATE hrms_employee SET gender = #{gender},office_phone = #{officePhone},phone = #{phone},
company_mail = #{companyMail},spare_mail = #{spareMail},head_portarit_url = #{headPortaritUrl}
WHERE id = #{id}
</update>
</mapper> </mapper>

@ -19,5 +19,15 @@
<result property="motifyTime" column="motify_time"/> <result property="motifyTime" column="motify_time"/>
</resultMap> </resultMap>
<select id="listPermissionByRoleIds" parameterType="long" resultType="com.daqing.framework.domain.hrms.response.RolePermissionResponse">
SELECT rp.permission_id, hp.name permissionName, hp.parent_id, hp.sort
FROM hrms_role_permission rp
LEFT JOIN hrms_permission hp
ON hp.id=rp.permission_id
WHERE rp.role_id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
</select>
</mapper> </mapper>

@ -81,5 +81,7 @@
p.id != #{id} p.id != #{id}
</select> </select>
<select id="listPositionIdAndName" resultType="com.daqing.framework.domain.hrms.ext.PositionVO">
SELECT id,name FROM hrms_position
</select>
</mapper> </mapper>

@ -12,5 +12,8 @@
<result property="motifyTime" column="motify_time"/> <result property="motifyTime" column="motify_time"/>
</resultMap> </resultMap>
<select id="listRoleIdAndName" resultType="com.daqing.framework.domain.hrms.ext.RoleVO">
SELECT id,name FROM hrms_role
</select>
</mapper> </mapper>

@ -21,5 +21,24 @@
<result property="motifyTime" column="motify_time"/> <result property="motifyTime" column="motify_time"/>
</resultMap> </resultMap>
<select id="getPasswordById" parameterType="long" resultType="string">
SELECT password FROM hrms_user WHERE id = #{id}
</select>
<select id="getAccountById" parameterType="long" resultType="string">
SELECT account FROM hrms_user WHERE id = #{id}
</select>
<update id="updatePassword">
UPDATE hrms_user SET password = #{password} WHERE id = #{id}
</update>
<select id="getPhoneAccount" parameterType="long" resultType="string">
SELECT phone_account FROM hrms_user WHERE id = #{id}
</select>
<update id="updatePhoneAccount">
UPDATE hrms_user SET phone_account = #{phoneAccount} WHERE id = #{id}
</update>
</mapper> </mapper>

@ -17,6 +17,10 @@ public enum CommonCode implements ResultCode {
SUCCESS(true, 10000, "操作成功!"), SUCCESS(true, 10000, "操作成功!"),
FAIL(false, 11111, "操作失败!"), FAIL(false, 11111, "操作失败!"),
INEXISTENCE(false,10004,"抱歉,当前客户信息已不存在!"), INEXISTENCE(false,10004,"抱歉,当前客户信息已不存在!"),
START_FAIL(false,10009,"启用或禁用失败,当前用户状态异常!"),
RESET_FAIL(false,10010,"重置密码失败,当前用户状态异常!"),
PERMISSION_IS_NOT(false,10011,"当前角色的权限信息不存在!"),
DISABLE_FAIL(false,10012,"禁用失败,禁用结束时间可能早于当前时间"),
UPDATE_FAIL(false,10005,"更新信息失败!"), UPDATE_FAIL(false,10005,"更新信息失败!"),
SAVE_FAIL(false,10006,"新增信息失败!"), SAVE_FAIL(false,10006,"新增信息失败!"),
DELETE_FAIL(false,10007,"删除失败!"), DELETE_FAIL(false,10007,"删除失败!"),

@ -14,4 +14,15 @@ public class PromptSuccess {
public static final String NOT_BEING = "该员工已不存在"; public static final String NOT_BEING = "该员工已不存在";
public static final Integer STOP_STATUS = 1;
public static final Integer START_STATUS = 0;
public static final Integer UPCOMING_STOP_STATUS = 2;
public static final String RESET_PASSWORD = "666666";
public static final String MATCHES_STRING = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,}$";
public static final Long OVERDUE_TIME = 70L; // 过期时间,单位为秒
} }

@ -14,17 +14,16 @@ public class SendSMS {
public static void main(String[] args){ public static void main(String[] args){
String mobile="18707074784";//需要接受短信验证码的手机号 String mobile="15773390498";//需要接受短信验证码的手机号
String sendTemplate="SMS_204155294";//短信模板ID,需要去阿里云平台申请,审核通过后方能使用,通常是以"SMS_"开头字符串 String sendTemplate="SMS_204155294";//短信模板ID,需要去阿里云平台申请,审核通过后方能使用,通常是以"SMS_"开头字符串
String code = (int)((Math.random() * 9 + 1) * 100000)+ "";//要发送给用户的短信验证码,行业通常使用六位纯数字 String code = (int)((Math.random() * 9 + 1) * 100000)+ "";//要发送给用户的短信验证码,行业通常使用六位纯数字
boolean result= sendCode(mobile,sendTemplate,code); boolean result= sendCode(mobile,code);
if(result){ if(result){
System.out.println("短信发送成功"); System.out.println("短信发送成功");
}else{ }else{
System.out.println("短信发送失败"); System.out.println("短信发送失败");
} }
} }
/** /**
* 通过阿里云平台发送短信如果发送成功返回"OK" ;否则返回的是错误信息 * 通过阿里云平台发送短信如果发送成功返回"OK" ;否则返回的是错误信息
@ -32,7 +31,7 @@ public class SendSMS {
* @param sendTemplate 短信模板id此处将其封装为变量是为了由该方法的调用者决定自己来发送哪种类型的短信验证码比如注册重置密码类的 * @param sendTemplate 短信模板id此处将其封装为变量是为了由该方法的调用者决定自己来发送哪种类型的短信验证码比如注册重置密码类的
* @param code 您将发送到用户手机的短信验证码 * @param code 您将发送到用户手机的短信验证码
*/ */
public static Boolean sendCode(String mobile,String sendTemplate,String code){ public static Boolean sendCode(String mobile,String code){
boolean isSend = false; boolean isSend = false;
//请求失败这里会抛ClientException异常 //请求失败这里会抛ClientException异常
String result=""; String result="";
@ -60,7 +59,7 @@ public class SendSMS {
//必填:短信签名-可在短信控制台中找到 //必填:短信签名-可在短信控制台中找到
request.setSignName("职站");//注意要与你在短信控制台中的签名一致 request.setSignName("职站");//注意要与你在短信控制台中的签名一致
//必填:短信模板-可在短信控制台中找到 //必填:短信模板-可在短信控制台中找到
request.setTemplateCode(sendTemplate); request.setTemplateCode("SMS_204155294");
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败 //友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
// request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}"); // request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}");

@ -0,0 +1,34 @@
package com.daqing.framework.domain.crms.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/10/19 10:32
*/
@Data
@ToString
public class CustomerWorkbenchRequest implements Serializable {
@ApiModelProperty(value = "客户编号或者名称")
private String codeOrName;
@ApiModelProperty(value = "客户类型")
private Integer customerType;
@ApiModelProperty(value = "创建时间")
private Integer createTime;
@ApiModelProperty(value = "起始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "审批状态(0:通过,1:不通过,2:待审核)")
private Integer status;
}

@ -0,0 +1,37 @@
package com.daqing.framework.domain.crms.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @auther River
* @date 2020/10/19 11:52
*/
@Data
@ToString
public class EmployeeDisableRequest implements Serializable {
@NotNull(message = "员工id不能为空")
@ApiModelProperty("员工id")
private Long employeeId;
@NotNull(message = "禁用开始时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("禁用开始时间")
private Date disableStartTime;
@NotNull(message = "禁用结束时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("禁用结束时间")
private Date disableEndTime;
@NotNull(message = "禁用原因不能为空")
@ApiModelProperty("禁用原因")
private String disableCause;
}

@ -0,0 +1,43 @@
package com.daqing.framework.domain.crms.response;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
/**
* 工作台客户资源列表展示类
*
* @auther River
* @date 2020/10/19 14:19
*/
@Data
@ToString
public class CustomerWorkbenchListVO implements Serializable {
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "客户编号")
private String code;
@ApiModelProperty(value = "客户名称")
private String name;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "客户类型(0:个人类型,1:企业类型)")
private Integer type;
@ApiModelProperty(value = "客户经理")
private String manager;
@ApiModelProperty(value = "所属部门")
private List<String> departments;
@ApiModelProperty(value = "审批状态(0:,1:,2:)")
private Integer status;
}

@ -23,7 +23,7 @@ public class PositionEntity implements Serializable {
/** /**
* 主键 * 主键
*/ */
@TableId(value = "id", type = IdType.INPUT) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
/** /**
* 职位名称 * 职位名称

@ -3,8 +3,11 @@ package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -56,14 +59,19 @@ public class UserEntity implements Serializable {
/** /**
* 禁用开始时间 * 禁用开始时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("禁用开始时间")
private Date disableStartTime; private Date disableStartTime;
/** /**
* 禁用结束时间 * 禁用结束时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("禁用结束时间")
private Date disableEndTime; private Date disableEndTime;
/** /**
* 禁用原因 * 禁用原因
*/ */
@ApiModelProperty("禁用原因")
private String disableCause; private String disableCause;
/** /**
* 是否删除0未删除1删除 * 是否删除0未删除1删除

@ -0,0 +1,122 @@
package com.daqing.framework.domain.hrms.ext;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.PositionEntity;
import com.daqing.framework.domain.hrms.RoleEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 员工+用户详情展示类
*
* @auther River
* @date 2020/10/15 10:01
*/
@Data
@ToString
public class EmployeeAndUserVO implements Serializable {
@ApiModelProperty("id")
@NotNull(message = "员工id不能为空")
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@ApiModelProperty("员工姓名")
private String name;
@NotNull(message = "性别不能为空")
@ApiModelProperty("性别")
private Integer gender;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("生日")
private Date birthday;
@NotNull(message = "办公电话不能为空")
@ApiModelProperty("办公电话")
private String officePhone;
@NotNull(message = "手机号码不能为空")
@ApiModelProperty("手机号码")
private String phone;
@NotNull(message = "公司邮箱不能为空")
@ApiModelProperty("公司邮箱")
private String companyMail;
@NotNull(message = "备用邮箱不能为空")
@ApiModelProperty("备用邮箱")
private String spareMail;
@ApiModelProperty("职位描述")
private String positionDescription;
@ApiModelProperty("工号")
private String jobNumber;
@ApiModelProperty("图像地址")
private String headPortaritUrl;
@NotNull(message = "用户id不能为空")
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("部门")
private List<String> departments;
@ApiModelProperty("职位")
private List<String> positions;
/**
* 用户
*/
@ApiModelProperty("账号")
private String account;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("登录次数")
private Integer loginNum;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("上次登录时间")
private Date lasttime;
@ApiModelProperty("手机账号")
private String phoneAccount;
@ApiModelProperty("微信账号")
private String wechatId;
@ApiModelProperty("角色")
private List<String> roles;
/**
* 修改信息字段
*/
@ApiModelProperty("接收图像文件")
private MultipartFile file;
@ApiModelProperty("旧手机号")
private String primaryPhone;
@ApiModelProperty("旧验证码")
private String primaryCode;
@ApiModelProperty("新手机号")
private String newPhone;
@ApiModelProperty("新验证码")
private String newCode;
}

@ -0,0 +1,35 @@
package com.daqing.framework.domain.hrms.ext;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/10/14 11:48
*/
@Data
@ToString
public class EmployeeExcelImport extends BaseRowModel implements Serializable {
@ExcelProperty(value = "姓名",index = 0)
private String name;
@ExcelProperty(value = "账号",index = 1)
private String account;
@ExcelProperty(value = "工号",index = 2)
private String jobNumber;
@ExcelProperty(value = "部门",index = 3)
private String departmentNameList;
@ExcelProperty(value = "职位",index = 4)
private String positionNameList;
@ExcelProperty(value = "角色",index = 5)
private String roleNameList;
}

@ -0,0 +1,84 @@
package com.daqing.framework.domain.hrms.ext;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.PositionEntity;
import com.daqing.framework.domain.hrms.RoleEntity;
import com.daqing.framework.domain.hrms.response.RolePermissionResponse;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 员工详细信息展示类
* @auther River
* @date 2020/10/12 16:23
*/
@Data
@ToString
public class EmployeeInfoVO implements Serializable {
@ApiModelProperty("id")
private Long id;
@NotNull(message = "姓名不能为空")
@ApiModelProperty("姓名")
private String name;
@NotNull(message = "工号不能为空")
@ApiModelProperty("工号")
private String jobNumber;
@NotNull(message = "性别不能为空")
@ApiModelProperty("性别")
private Integer gender;
@NotNull(message = "生日不能为空")
@ApiModelProperty("生日")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday;
@NotNull(message = "手机号码不能为空")
@ApiModelProperty("手机号码")
private String phone;
@NotNull(message = "公司邮箱不能为空")
@ApiModelProperty("公司邮箱")
private String companyMail;
@NotNull(message = "账号不能为空")
@ApiModelProperty("账号")
private String account;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("部门")
private List<DeptEntity> departments;
@ApiModelProperty("职位")
private List<PositionEntity> positions;
@ApiModelProperty("角色")
private List<RoleEntity> roles;
@ApiModelProperty("权限")
private List<RolePermissionResponse> permissions;
/**
* 接收部门职位角色
*/
@ApiModelProperty("部门id集合")
private List<Long> departmentIds;
@ApiModelProperty("职位id集合")
private List<Long> positionIds;
@ApiModelProperty("角色id集合")
private List<Long> roleIds;
}

@ -0,0 +1,63 @@
package com.daqing.framework.domain.hrms.ext;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 员工列表展示pojo类
* @auther River
* @date 2020/10/10 15:44
*/
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class EmployeeListVO extends BaseRowModel implements Serializable {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
@ExcelProperty(value = "姓名",index = 0)
private String name;
@ExcelProperty(value = "账号",index = 1)
@ApiModelProperty("账号")
private String account;
@ExcelProperty(value = "工号",index = 2)
@ApiModelProperty("工号")
private String jobNumber;
@ExcelProperty(value = "部门",index = 3)
@ApiModelProperty("部门")
@Transient
private List<String> departmentNameList;
@ExcelProperty(value = "职位",index = 4)
@ApiModelProperty("职位")
private List<String> positionNameList;
@ExcelProperty(value = "角色",index = 5)
@ApiModelProperty("角色")
private List<String> roleNameList;
@ExcelProperty(value = "创建时间",index = 6)
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("状态(0:启用,1:禁用,2:即将禁用(展示的时候属于启用))")
private Integer status;
}

@ -0,0 +1,38 @@
package com.daqing.framework.domain.hrms.ext;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
/**
* 导出员工信息模板
* @auther River
* @date 2020/10/13 16:08
*/
@Data
@ToString
public class EmployeeTemplate extends BaseRowModel implements Serializable {
@ExcelProperty(value = "姓名",index = 0)
private String name;
@ExcelProperty(value = "账号",index = 1)
private String account;
@ExcelProperty(value = "工号",index = 2)
private String jobNumber;
@ExcelProperty(value = "部门(eg:安全部门,技术部门,请按照格式填写正常且已存在的部门名称)",index = 3)
private List<String> departmentNameList;
@ExcelProperty(value = "职位(eg:总经理,产品经理,请按照格式填写正常且已存在的职位名称)",index = 4)
private List<String> positionNameList;
@ExcelProperty(value = "角色(eg:管理员,员工,请按照格式填写正常且已存在的角色名称)",index = 5)
private List<String> roleNameList;
}

@ -1,5 +1,7 @@
package com.daqing.framework.domain.hrms.ext; package com.daqing.framework.domain.hrms.ext;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -14,25 +16,21 @@ import java.util.Date;
*/ */
@Data @Data
public class PositionVO implements Serializable { public class PositionVO implements Serializable {
/**
* 主键 @ApiModelProperty("id")
*/
private Long id; private Long id;
/**
* 职位名称 @ApiModelProperty("职位名称")
*/
private String name; private String name;
/**
* 所属部门 @ApiModelProperty("所属部门")
*/
private String deptNames; private String deptNames;
/**
* 创建人 @ApiModelProperty("创建人")
*/
private String createUserName; private String createUserName;
/**
* 创建时间 @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
*/ @ApiModelProperty("创建时间")
private Date createTime; private Date createTime;
} }

@ -0,0 +1,22 @@
package com.daqing.framework.domain.hrms.ext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/10/13 17:15
*/
@Data
@ToString
public class RoleVO implements Serializable {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("名称")
private String name;
}

@ -0,0 +1,22 @@
package com.daqing.framework.domain.hrms.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
/**
* 员工列表请求参数类
* @auther River
* @date 2020/10/10 15:29
*/
@Data
@ToString
public class EmployeeRequest {
@ApiModelProperty("部门id")
private Long id;
@ApiModelProperty("姓名、账号、工号")
private String codeOrName;
}

@ -1,5 +1,6 @@
package com.daqing.framework.domain.hrms.request; package com.daqing.framework.domain.hrms.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -13,24 +14,19 @@ import java.io.Serializable;
*/ */
@Data @Data
public class PositionRequest implements Serializable { public class PositionRequest implements Serializable {
/**
* 主键 @ApiModelProperty("id")
*/
private Long id; private Long id;
/**
* 用户id @ApiModelProperty("用户id")
*/
private Long userId; private Long userId;
/**
* 部门id @ApiModelProperty("部门id")
*/
private Long[] deptIds; private Long[] deptIds;
/**
* 职位名称 @ApiModelProperty("职位名称id")
*/
private String name; private String name;
/**
* 职位介绍 @ApiModelProperty("职位介绍")
*/
private String introduction; private String introduction;
} }

@ -20,6 +20,41 @@ public enum HrmsCode implements ResultCode {
DEPT_LEVEL_ILLEGAL(false, 22003, "部门层级不可超出5级!"), DEPT_LEVEL_ILLEGAL(false, 22003, "部门层级不可超出5级!"),
DEPT_EMP_EXSIT(false, 22004, "请将部门下所有员工移除后再执行删除操作!"), DEPT_EMP_EXSIT(false, 22004, "请将部门下所有员工移除后再执行删除操作!"),
DEPT_POSITION_EXSIT(false, 22005, "该部门下已存在该职位!"), DEPT_POSITION_EXSIT(false, 22005, "该部门下已存在该职位!"),
DEPT_NOT_NULL(false,22006,"部门不能为空!"),
EMPLOYEE_IS_NULL(false,44001,"当前员工已不存在!"),
EMPLOYEE_NAME_IS_NULL(false,44002,"请完善员工姓名!"),
EMPLOYEE_ACCOUNT_IS_NULL(false,44003,"请完善员工账号!"),
EMPLOYEE_JOBNUMBER_IS_NULL(false,44004,"请完善员工工号!"),
EMPLOYEE_DEPARTMENT_IS_NULL(false,44005,"请完善员工部门!"),
EMPLOYEE_POSITION_IS_NULL(false,44006,"请完善员工职位!"),
EMPLOYEE_ROLE_IS_NULL(false,44007,"请完善员工角色!"),
EMPLOYEE_DEPARTMENT_NAME_IS_NOT(false,44008,"部门名称重复或不存在,请输入正常的部门名称!"),
EMPLOYEE_POSITION_NAME_IS_NOT(false,44009,"职位名称重复或不存在,请输入正常的职位名称!"),
EMPLOYEE_ROLE_NAME_IS_NOT(false,44010,"角色名称重复或不存在,请输入正常的角色名称!"),
EMPLOYEE_DISABLE_TIME_ERROR(false,44011,"禁用失败,当前禁用开始时间可能大于或等于结束时间!"),
EMPLOYEE_USER_IS_NULL(false,44012,"当前员工的用户信息已不存在!"),
POSITION_NOT_NULL(false,55001,"职位不能为空!"),
ROLE_NOT_NULL(false,66001,"角色不能为空!"),
EXCEL_DATA_IS_NULL(false,77001,"当前数据为空,请填写数据!"),
USER_PASSWORD_NOT_NULL(false,88001,"原密码或者新密码不能为空!"),
USER_PASSWORD_MISTAKE(false,88002,"原密码不正确,请重新输入!"),
USER_PASSWORD_NO_CONSISTENT(false,88003,"确认密码和新密码不一致,请重新输入!"),
USER_PASSWORD_MATCHES(false,88004,"新密码必须包含大写字母、小写字母、数字,且长度不小于6位!"),
USER_PASSWORD_IS_NO_ACCOUNT(false,88005,"新密码不能和账户相同,请重新输入!"),
USER_PHONE_NOT_NULL(false,88006,"手机号码不能为空,请输入手机号码!"),
USER_PRIMARY_CODE_MISTAKE(false,88007,"更新失败,原手机号验证码错误!"),
USER_NEW_CODE_MISTAKE(false,88008,"更新失败,新手机号验证码错误!"),
USER_PHONE_CODE_MISTAKE(false,88009,"更新失败,手机验证码错误!"),
USER_PRIMARY_PHONE_MISTAKE(false,88010,"原手机号码错误!"),
USER_PHONE_OR_CODE_NOT_NULL(false,88011,"手机号码或验证码不能为空!"),
USER_BINDING_FAIL(false,88012,"绑定失败,手机验证码错误!"),
USER_FILE_TYPE_MISTAKE(false,88013,"文件格式不正确,请重新选择图片文件!"),
USER_FILE_UPLOAD_FAIL(false,88014,"上传图像失败,请稍后刷新再试!"),
PHNOE_ACCOUNT_NOT_EMPTY(false,33001,"手机号码为空!"), PHNOE_ACCOUNT_NOT_EMPTY(false,33001,"手机号码为空!"),
VERIFY_CODE_NOT_EMPTY(false,33002,"短信验证码为空!"), VERIFY_CODE_NOT_EMPTY(false,33002,"短信验证码为空!"),
@ -51,6 +86,8 @@ public enum HrmsCode implements ResultCode {
@Getter @Getter
private int code; private int code;
public static HrmsCode hrmsCode;
/** /**
* 提示信息 * 提示信息
*/ */

@ -1,6 +1,7 @@
package com.daqing.framework.domain.hrms.response; package com.daqing.framework.domain.hrms.response;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -19,17 +20,21 @@ public class PositionResponse implements Serializable {
/** /**
* 主键 * 主键
*/ */
@ApiModelProperty("id")
private Long id; private Long id;
/** /**
* 职位名称 * 职位名称
*/ */
@ApiModelProperty("职位名称")
private String name; private String name;
/** /**
* 职位介绍 * 职位介绍
*/ */
@ApiModelProperty("职位介绍")
private String introduction; private String introduction;
/** /**
* 部门列表 * 部门列表
*/ */
@ApiModelProperty("部门列表")
private List<DeptEntity> deptList; private List<DeptEntity> deptList;
} }

@ -3,6 +3,7 @@ package com.daqing.framework.domain.hrms.response;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -23,35 +24,42 @@ public class RolePermissionResponse implements Serializable {
/** /**
* 角色id * 角色id
*/ */
@ApiModelProperty("id")
private Long roleId; private Long roleId;
/** /**
* 角色名称 * 角色名称
*/ */
@ApiModelProperty("名称")
private String name; private String name;
/** /**
* 角色描述 * 角色描述
*/ */
@ApiModelProperty("角色描述")
private String description; private String description;
/** /**
* 权限id * 权限id
*/ */
@ApiModelProperty("权限id")
private Long permissionId; private Long permissionId;
/** /**
* 拥有权限名称 * 拥有权限名称
*/ */
@ApiModelProperty("权限名称")
private String permissionName; private String permissionName;
/** /**
* 父级id * 父级id
*/ */
@ApiModelProperty("父级id")
private Long parentId; private Long parentId;
/** /**
* 子权限 * 子权限
*/ */
@ApiModelProperty("子权限")
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false) @TableField(exist = false)
private List<RolePermissionResponse> children; private List<RolePermissionResponse> children;
@ -59,6 +67,7 @@ public class RolePermissionResponse implements Serializable {
/** /**
* 排序 * 排序
*/ */
@ApiModelProperty("子权限")
private Integer sort; private Integer sort;
/** /**

@ -0,0 +1,27 @@
package com.daqing.framework.domain.hrms.response;
import com.daqing.framework.model.response.ResultCode;
/**
* @auther River
* @date 2020/10/14 10:05
*/
public class TestResult implements ResultCode
{
public static String message1 = null;
public boolean success() {
return false;
}
public int code() {
return 88888;
}
public String message() {
return message1;
}
public String test(String message){
return message1 = message;
}
}
Loading…
Cancel
Save