工作台微信绑定

master
river 4 years ago
parent 3f57da32ad
commit 996c59417b
  1. 10
      dq-financial-api/src/main/java/com/daqing/financial/hrms/UserControllerApi.java
  2. 11
      dq-financial-crms/pom.xml
  3. 28
      dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java
  4. 32
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerWorkbenchServiceImpl.java
  5. 2
      dq-financial-crms/src/main/resources/mapper/crms/CustomerWorkbenchDao.xml
  6. 2
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/feign/HrauthFeignService.java
  7. 10
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java
  8. 28
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/config/IPageConfig.java
  9. 34
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/UserController.java
  10. 1
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java
  11. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java
  12. 13
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/UserService.java
  13. 170
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java
  14. 1
      dq-financial-hrms/src/main/resources/mapper/hrms/EmployeeDao.xml
  15. 15
      dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml
  16. 6
      dq-framework-common/src/main/java/com/daqing/framework/model/response/PromptSuccess.java
  17. 5
      dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java
  18. 5
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeAndUserVO.java
  19. 1
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java

@ -5,6 +5,7 @@ import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpResponse;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@ -25,9 +26,14 @@ public interface UserControllerApi {
ResponseResult code(String phone);
@ApiOperation(value = "修改密码",notes = "修改密码")
ResponseResult updatePassword(Long id, String primaryPassword, String newPassword, String affirmNewPassword);
ResponseResult updatePassword(String primaryPassword, String newPassword, String affirmNewPassword);
@ApiOperation(value = "绑定手机号",notes = "绑定手机号")
ResponseResult binding(Long id,String phone,String code);
ResponseResult binding(String phone,String code);
@ApiOperation(value = "取消微信绑定",notes = "取消微信绑定")
ResponseResult cancel();
@ApiOperation(value = "图像文件上传",notes = "图像文件上传")
ResponseResult uploadFile(MultipartFile file);
}

@ -21,13 +21,13 @@
<dependencies>
<dependency>
<!--<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-hrms-auth</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
@ -39,12 +39,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
<!--<dependency>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

@ -1,15 +1,13 @@
/*
package com.daqing.financial.crms.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class IPageConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
*/
//package com.daqing.financial.crms.config;
//
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class IPageConfig {
// @Bean
// public PaginationInterceptor paginationInterceptor() {
// return new PaginationInterceptor();
// }
//}

@ -17,12 +17,16 @@ import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.exception.ExceptionCatch;
import com.daqing.framework.model.response.CommonCode;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.util.RedisUtil;
import com.daqing.framework.utils.PageUtils;
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.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
@ -34,12 +38,6 @@ import java.util.*;
public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchDao, CustomerEntity>
implements CustomerWorkbenchService {
//TODO 从redis获取当前登录用户信息
/*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);*/
Long userId = Long.parseLong("1");
@Autowired
private HrmsFeignService hrmsFeignService;
@ -76,7 +74,7 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
}
}
if (customerIds.length != 0){
// TODO:调用担保服务查询每个客户的审批状态
// TODO:远程调用担保服务查询每个客户的审批状态
for (CustomerWorkbenchListVO customerWorkbenchListVO : customerWorkbenchListVOS) {
customerWorkbenchListVO.setStatus(2);
}
@ -85,7 +83,6 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
customerWorkbenchListVOS.removeIf(customerWorkbenchListVO -> !Objects.equals(customerWorkbenchListVO.getStatus(),cwr.getStatus()));
}
}
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
IPage<CustomerWorkbenchListVO> iPage = new Page<>();
BeanUtils.copyProperties(customerEntityIPage,iPage);
@ -120,6 +117,7 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
@Override
public Boolean savePersonal(CustomerPersonalTOI customerPersonalTOI) {
Long userId = Long.parseLong(this.getUserId());
customerPersonalTOI.setManager(userId); // 从redis当前登录用户
boolean result = customerService.saveCustomerPersonal(customerPersonalTOI);
// TODO 将当前客户状态和自增的客户id新增到担保表中
@ -136,6 +134,7 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
@Override
public Boolean saveCompany(CustomerCompanyTOI customerCompanyTOI) {
Long userId = Long.parseLong(this.getUserId());
customerCompanyTOI.setManager(userId); // 从redis获取当前登录用户
boolean result = customerService.saveCustomerCompany(customerCompanyTOI);
// TODO 将当前客户状态和自增的客户id新增到担保表中
@ -152,8 +151,8 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
@Override
public Boolean updatePersonal(CustomerPersonalTOU customerPersonalTOU) {
Long userId = Long.parseLong(this.getUserId());
customerPersonalTOU.setManager(userId);
return customerService.updateCustomerPersonal(customerPersonalTOU);
}
@ -164,8 +163,8 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
@Override
public Boolean updateCompany(CustomerCompanyTOU customerCompanyTOU) {
Long userId = Long.parseLong(this.getUserId());
customerCompanyTOU.setManager(userId);
return customerService.updateCustomerCompany(customerCompanyTOU);
}
@ -193,7 +192,7 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
public Boolean noPass(Long id, String cause) {
// TODO 将当前客户id、不通过原因、客户状态status = 1(不通过)更新到担保业务的表中
return null;
return true;
}
/**
@ -202,8 +201,8 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
@Override
public List<EmployeeEntity> getCustomerManager() {
Long userId = Long.parseLong(this.getUserId());
ResponseResult<List<EmployeeEntity>> employees = hrmsFeignService.listEmployeeById(userId);
return employees.getData();
}
@ -263,4 +262,13 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
}
return customerWorkbenchListVOS;
}
/**
* 获取当前登录用户信息
*/
private String getUserId(){
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
return RedisUtil.get("dq:token:"+token);
}
}

@ -41,7 +41,7 @@
</select>
<update id="passById">
UPDATE hrms_customer SET manager = #{manager} WHERE id = #{id}
UPDATE crms_customer SET manager = #{manager} WHERE id = #{id}
</update>
</mapper>

@ -12,7 +12,7 @@ import java.util.List;
/**
* 这是一个声明式的远程调用
*/
@FeignClient("dq-financial-hrms-auth")
@FeignClient(value = "dq-financial-hrms-auth",contextId = "hrms-auth")
public interface HrauthFeignService {
@GetMapping("/hrms/auth/permission/getUserRoles")

@ -12,14 +12,18 @@ import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.response.LoginResponse;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@ -132,11 +136,9 @@ public class UserServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> imple
return false;
}
String openId = (String) baseMap.get("openid");
/*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);*/
//TODO:测试环境模拟从redis中拿取用户id
String userId = "1";
String userId = RedisUtil.get("dq:token:"+token);
Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(userId), openId);
log.info("绑定成功---------------------------------------");
if (result){

@ -1,15 +1,13 @@
/*
package com.daqing.financial.hrms.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class IPageConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
*/
//package com.daqing.financial.hrms.config;
//
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class IPageConfig {
// @Bean
// public PaginationInterceptor paginationInterceptor() {
// return new PaginationInterceptor();
// }
//}

@ -10,6 +10,7 @@ import com.daqing.framework.utils.PageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@ -57,12 +58,23 @@ public class UserController implements UserControllerApi {
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
}
/**
* 图像文件上传
*/
@PostMapping("/uploadFile")
public ResponseResult uploadFile(@RequestParam("file") MultipartFile file){
String result = userService.uploadFile(file);
return ResponseResult.SUCCESS(result);
}
/**
* 获取验证码
*/
@GetMapping("/code")
@Override
public ResponseResult code(String phone) {
public ResponseResult code(@RequestParam("phone") String phone) {
Boolean result = userService.getVerificationCode(phone);
@ -74,9 +86,10 @@ public class UserController implements UserControllerApi {
*/
@GetMapping("/updatePassword")
@Override
public ResponseResult updatePassword(@RequestParam("id") Long id, String primaryPassword,
String newPassword, String affirmNewPassword) {
Boolean result = userService.updatePassword(id, primaryPassword, newPassword, affirmNewPassword);
public ResponseResult updatePassword(@RequestParam("primaryPassword") String primaryPassword,
@RequestParam("newPassword") String newPassword,
@RequestParam("affirmNewPassword") String affirmNewPassword) {
Boolean result = userService.updatePassword(primaryPassword, newPassword, affirmNewPassword);
return result ? ResponseResult.SUCCESS() : new ResponseResult(CommonCode.UPDATE_FAIL);
}
@ -86,20 +99,21 @@ public class UserController implements UserControllerApi {
*/
@GetMapping("/binding")
@Override
public ResponseResult binding(@RequestParam("id") Long id, String phone, String code) {
public ResponseResult binding(String phone, String code) {
Boolean result = userService.bindingPhoneAccount(id, phone, code);
Boolean result = userService.bindingPhoneAccount(phone, code);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 微信绑定回调
* 取消微信绑定
*/
@GetMapping("/callbackBinding")
public ResponseResult weChatCallback(@RequestParam("code") String code, HttpServletResponse response) throws IOException {
@GetMapping("/cancel")
@Override
public ResponseResult cancel() {
Boolean result = userService.weChatCallback(code, response);
Boolean result = userService.cancel();
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}

@ -80,4 +80,5 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
EmployeeAndUserVO getEmployeeByUserId(Long id);
Boolean updateEmployeeAndUser(EmployeeEntity employeeEntity);
}

@ -26,4 +26,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
Boolean updatePhoneAccount(@Param("id")Long id,@Param("phoneAccount") String phoneAccount);
Boolean updateWeChat(@Param("id") Long id, @Param("weChatId") String weChatId);
Long getEmployeeIdByUserId(Long userId);
}

@ -2,12 +2,9 @@ package com.daqing.financial.hrms.service;
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.domain.hrms.UserEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
/**
* 人资管理系统员工账号信息表用于存储员工账号密码等登录相关数据
@ -22,12 +19,14 @@ public interface UserService extends IService<UserEntity> {
Boolean update(EmployeeAndUserVO employeeAndUserVO);
Boolean updatePassword(Long id,String primaryPassword,String newPassword,String affirmNewPassword);
String uploadFile(MultipartFile file);
Boolean updatePassword(String primaryPassword,String newPassword,String affirmNewPassword);
Boolean getVerificationCode(String phone);
Boolean bindingPhoneAccount(Long id,String phone,String code);
Boolean bindingPhoneAccount(String phone,String code);
Boolean weChatCallback(String code, HttpServletResponse response) throws IOException;
Boolean cancel();
}

@ -11,7 +11,6 @@ import com.daqing.framework.domain.hrms.UserEntity;
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.HttpUtils;
import com.daqing.framework.util.Md5Util;
@ -22,13 +21,18 @@ 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.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
@Slf4j
@ -41,28 +45,25 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Autowired
private HrmsAuthFeignService hrmsAuthFeignService;
/**
* 当前登录的用户信息
*/
@Override
public EmployeeAndUserVO info() {
/*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);*/
//TODO:测试环境模拟从redis中拿取用户id
String userId = "1";
String userId = this.getUserId();
EmployeeAndUserVO employeeAndUser = employeeDao.getEmployeeByUserId(Long.parseLong(userId));
if (employeeAndUser.getWechatId() == null || employeeAndUser.getWechatId().length() == 0){
JSONObject responseResult = hrmsAuthFeignService.getWeChatConfig();
JSONObject weChatConfig = responseResult.getJSONObject("data");
if (weChatConfig == null){
employeeAndUser.setWechatId("二维码获取失败,请稍后重试");
employeeAndUser.setWechatId(PromptSuccess.QR_CODE_FAIL);
}else {
employeeAndUser.setWechatId(String.format(weChatConfig.get("OPEN_QRCODE_URL").toString(),weChatConfig.get("openAppid"),
weChatConfig.get("openRedirectUrl"),weChatConfig.get("openAppsecret")));
employeeAndUser.setWechatId(String.format(weChatConfig.get("open_QRCODE_URL").toString(),weChatConfig.get("openAppid"),
weChatConfig.get("openRedirectUrl"),1)); // state=1作为回调时分辨绑定和登陆的标识
}
}else {
employeeAndUser.setWechatId("已绑定,微信扫码即可登录");
employeeAndUser.setWechatId(PromptSuccess.QR_CODE_BINDING_SUCCESS);
}
return employeeAndUser;
}
@ -74,59 +75,11 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Override
public Boolean update(EmployeeAndUserVO employeeAndUserVO) {
EmployeeEntity employee = new EmployeeEntity();
String userId = this.getUserId();
Long employeeId = this.getBaseMapper().getEmployeeIdByUserId(Long.parseLong(userId));
employeeAndUserVO.setId(employeeId);
employeeAndUserVO.setUserId(Long.parseLong(userId));
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)
@ -172,15 +125,44 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
return result && employeeDao.updateEmployeeAndUser(employee);
}
/**
* 图像文件上传
*/
@Override
public String uploadFile(MultipartFile file) {
if (file == null || file.isEmpty()){
ExceptionCast.cast(HrmsCode.USER_FILE_IS_NULL);
}
try {
// 通过获取图片文件的宽度和高度来校验是否为图片文件
BufferedImage image = ImageIO.read(file.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);
}
String filename = file.getOriginalFilename();
if (filename == null){
ExceptionCast.cast(HrmsCode.USER_FILE_TYPE_MISTAKE);
}
String substring = filename.substring(filename.lastIndexOf("."));
String filePrefix = UUID.randomUUID().toString();
String filePath = PromptSuccess.UPLOAD_FILE_PATH+filePrefix+substring;
try {
file.transferTo(new File(filePath));
} catch (IOException e) {
ExceptionCast.cast(HrmsCode.USER_FILE_UPLOAD_FAIL);
}
return filePath;
}
/**
* 修改密码
*/
@Transactional
@Override
public Boolean updatePassword(Long id, String primaryPassword, String newPassword, String affirmNewPassword) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
public Boolean updatePassword(String primaryPassword, String newPassword, String affirmNewPassword) {
if (primaryPassword == null || primaryPassword.length() == 0
|| newPassword == null || newPassword.length() == 0
|| affirmNewPassword == null || affirmNewPassword.length() == 0){
@ -190,7 +172,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
if (!Objects.equals(affirmNewPassword, newPassword)){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_NO_CONSISTENT);
}
if (!Objects.equals(Md5Util.md5(primaryPassword + id),this.getBaseMapper().getPasswordById(id))){
String userId = this.getUserId();
if (!Objects.equals(Md5Util.md5(primaryPassword + Long.parseLong(userId)),this.getBaseMapper().getPasswordById(Long.parseLong(userId)))){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_MISTAKE);
}
// 正则校验
@ -198,10 +181,10 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
ExceptionCast.cast(HrmsCode.USER_PASSWORD_MATCHES);
}
// 是否与账号相同
if (Objects.equals(newPassword,this.getBaseMapper().getAccountById(id))){
if (Objects.equals(newPassword,this.getBaseMapper().getAccountById(Long.parseLong(userId)))){
ExceptionCast.cast(HrmsCode.USER_PASSWORD_IS_NO_ACCOUNT);
}
return this.getBaseMapper().updatePassword(id,Md5Util.md5(newPassword + id));
return this.getBaseMapper().updatePassword(Long.parseLong(userId),Md5Util.md5(newPassword + Long.parseLong(userId)));
}
/**
@ -227,10 +210,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
*/
@Transactional
@Override
public Boolean bindingPhoneAccount(Long id,String phone, String code) {
if (id == null){
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
public Boolean bindingPhoneAccount(String phone, String code) {
if (phone == null || phone.length() == 0 || code == null || code.length() == 0){
ExceptionCast.cast(HrmsCode.USER_PHONE_OR_CODE_NOT_NULL);
}
@ -239,43 +219,25 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
ExceptionCast.cast(HrmsCode.USER_BINDING_FAIL);
}
RedisUtil.del(phone);
return this.getBaseMapper().updatePhoneAccount(id, phone);
String userId = this.getUserId();
return this.getBaseMapper().updatePhoneAccount(Long.parseLong(userId), phone);
}
/**
* 绑定微信回调接收接口
* @param code 微信端返回的code,用于申请openid
* @return
* 取消微信绑定
*/
@Override
public Boolean weChatCallback(String code, HttpServletResponse response) {
log.info("微信回调成功---------------------------------------");
JSONObject responseResult = hrmsAuthFeignService.getWeChatConfig();
JSONObject weChatConfig = responseResult.getJSONObject("data");
String accessTokenUrl = String.format(weChatConfig.get("OPEN_ACCESS_TOKEN_URL").toString(), weChatConfig.get("openAppid"), weChatConfig.get("openAppsecret"), code);
//获取access_token
Map<String ,Object> baseMap = HttpUtils.doGet(accessTokenUrl);
public Boolean cancel() {
String userId = this.getUserId();
return this.getBaseMapper().updateWeChat(Long.parseLong(userId),null);
}
if(baseMap == null || baseMap.isEmpty()){ return false; }
String openId = (String) baseMap.get("openid");
/*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
/**
* 获取当前登录用户信息
*/
private String getUserId(){
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
String userId = RedisUtil.get("dq:token:"+token);*/
//TODO:测试环境模拟从redis中拿取用户id
String userId = "1";
Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(userId), openId);
log.info("绑定成功---------------------------------------");
if (result){
try {
log.info("转发成功---------------------------------------");
response.sendRedirect("https://www.baidu.com?openId="+openId);
}catch (IOException e){
e.printStackTrace();
}
}
return false;
return RedisUtil.get("dq:token:"+token);
}
}

@ -459,4 +459,5 @@
company_mail = #{companyMail},spare_mail = #{spareMail},head_portarit_url = #{headPortaritUrl}
WHERE id = #{id}
</update>
</mapper>

@ -22,11 +22,11 @@
</resultMap>
<select id="getPasswordById" parameterType="long" resultType="string">
SELECT password FROM hrms_user WHERE id = #{id}
SELECT password FROM hrms_user WHERE del_or_not = 0 AND id = #{id}
</select>
<select id="getAccountById" parameterType="long" resultType="string">
SELECT account FROM hrms_user WHERE id = #{id}
SELECT account FROM hrms_user WHERE del_or_not = 0 AND id = #{id}
</select>
<update id="updatePassword">
@ -34,7 +34,7 @@
</update>
<select id="getPhoneAccount" parameterType="long" resultType="string">
SELECT phone_account FROM hrms_user WHERE id = #{id}
SELECT phone_account FROM hrms_user WHERE del_or_not = 0 AND id = #{id}
</select>
<update id="updatePhoneAccount">
@ -45,4 +45,13 @@
UPDATE hrms_user SET wechat_id = #{weChatId} WHERE id = #{id}
</update>
<select id="getEmployeeIdByUserId" parameterType="long" resultType="long">
SELECT e.id id
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE del_or_not = 0
AND u.id = #{userId}
</select>
</mapper>

@ -25,4 +25,10 @@ public class PromptSuccess {
public static final String MATCHES_STRING = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,}$";
public static final Long OVERDUE_TIME = 70L; // 过期时间,单位为秒
public static final String QR_CODE_FAIL = "二维码获取失败,请稍后重试";
public static final String QR_CODE_BINDING_SUCCESS = "已绑定,扫码即可登录";
public static final String UPLOAD_FILE_PATH = "D://upload//";
}

@ -22,12 +22,13 @@ public class Md5Util {
}
public static void main(String[] args) throws UnsupportedEncodingException {
System.out.printf(md5("1111Aa5"));
//System.out.printf(md5("1111Aa5"));
/*String s = URLEncoder.encode("www.occupationlab.com", "utf-8");
System.out.println(s);*/
//System.out.printf(md5("1234561"));
String s = URLEncoder.encode("www.occupationlab.com", "utf-8");
//String s = URLEncoder.encode("www.occupationlab.com", "utf-8");
//System.out.println(s);
//System.out.println(md5("1234564"));
System.out.println(md5("Aa12344"));
}
}

@ -27,7 +27,6 @@ import java.util.List;
public class EmployeeAndUserVO implements Serializable {
@ApiModelProperty("id")
@NotNull(message = "员工id不能为空")
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@ -67,7 +66,6 @@ public class EmployeeAndUserVO implements Serializable {
@ApiModelProperty("图像地址")
private String headPortaritUrl;
@NotNull(message = "用户id不能为空")
@ApiModelProperty("用户id")
private Long userId;
@ -105,9 +103,6 @@ public class EmployeeAndUserVO implements Serializable {
/**
* 修改信息字段
*/
@ApiModelProperty("接收图像文件")
private MultipartFile file;
@ApiModelProperty("旧手机号")
private String primaryPhone;

@ -53,6 +53,7 @@ public enum HrmsCode implements ResultCode {
USER_PRIMARY_PHONE_MISTAKE(false,88010,"原手机号码错误!"),
USER_PHONE_OR_CODE_NOT_NULL(false,88011,"手机号码或验证码不能为空!"),
USER_BINDING_FAIL(false,88012,"绑定失败,手机验证码错误!"),
USER_FILE_IS_NULL(false,88015,"当前文件不存在,请正确选择文件!"),
USER_FILE_TYPE_MISTAKE(false,88013,"文件格式不正确,请重新选择图片文件!"),
USER_FILE_UPLOAD_FAIL(false,88014,"上传图像失败,请稍后刷新再试!"),

Loading…
Cancel
Save