Commit ba54792c authored by chenyuxi's avatar chenyuxi

feat: C端登录处理

parent cbf55a66
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* C端登录处查系统用户数据
* @author chenyuxi
* @date 2024/10/15
* @since mvp1.7.0
*/
@Data
public class EmpMainToCVo implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "预入职审核状态(0草稿;1待完善;2待审核;3审核不通过;4审核通过;5初始未保存)")
private String preStatus;
@Schema(description = "员工姓名")
private String empName;
@Schema(description = "身份证号")
private String empIdcard;
@Schema(description = "手机号码")
private String empPhone;
@Schema(description = "来源(0:在档,1:预入职,2:不在系统)")
private String empFrom;
}
......@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpMain;
import com.yifu.cloud.plus.v1.yifu.archives.service.TPreEmpMainService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......@@ -263,4 +264,62 @@ public class TPreEmpMainController {
return tPreEmpMainService.uploadPreEmp(file, vo);
}
/**
* 根据身份证与姓名查询用户手机号和来源
*
* @param empIdCard 身份证
* @param empName 姓名
* @return R<EmpMainToCVo>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*
**/
@Operation(summary = "根据身份证与姓名查询用户手机号和来源", description = "根据身份证与姓名查询用户手机号和来源")
@GetMapping("/getPhoneByCardAndName")
public R<EmpMainToCVo> getPhoneByCardAndName(@Param("empIdCard") String empIdCard, @Param("empName") String empName) {
return tPreEmpMainService.getPhoneByCardAndName(empIdCard, empName);
}
/**
* 发送手机验证码
*
* @param empPhone 手机号
* @return R<String>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
@PostMapping("/sendCode")
public R<String> sendCode(@Param("empPhone") String empPhone) {
if (Common.isEmpty(empPhone)) {
return R.failed("手机号不能为空");
}
return tPreEmpMainService.sendCode(empPhone);
}
/**
* 校验手机验证码
*
* @param empPhone 手机号
* @param code 验证码
* @return R<String>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
@PostMapping("/checkCode")
public R<String> checkCode(@Param("empPhone") String empPhone,@Param("verifyCode") String verifyCode) {
if (Common.isEmpty(empPhone)) {
return R.failed("手机号不能为空");
}
if (Common.isEmpty(verifyCode)) {
return R.failed("验证码不能为空");
}
return tPreEmpMainService.checkCode(empPhone, verifyCode);
}
}
......@@ -95,4 +95,40 @@ public interface TPreEmpMainService extends IService<TPreEmpMain> {
**/
R<List<PreUploadEmpImportVo>> uploadPreEmp(MultipartFile file, PreUploadImportParamVo vo) throws Exception;
/**
* 根据身份证与姓名查询用户手机号和来源
* @param empIdCard 身份证
* @param empName 姓名
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
* @return EmpMainToCVo
**/
R<EmpMainToCVo> getPhoneByCardAndName(String empIdCard, String empName);
/**
* 发送手机验证码
*
* @param empPhone 手机号
* @return R<String>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
R<String> sendCode(String empPhone);
/**
* 校验手机验证码
*
* @param empPhone 手机号
* @param verifyCode 验证码
* @return R<String>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
R<String> checkCode(String empPhone, String verifyCode);
}
......@@ -44,6 +44,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.AliSmsResult;
import com.yifu.cloud.plus.v1.yifu.common.core.util.alisms.SmsUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprCheckProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
......@@ -153,6 +155,8 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
public static final String taxMonthRegex = "^2\\d{5}";
private final RedisUtil redisUtil;
/**
* 预入职-主表简单分页查询
*
......@@ -3038,7 +3042,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
List<TPreEmpEducation> preEmpEducationList = new ArrayList<>();
List<TPreEmpFamily> preEmpFamilyList = new ArrayList<>();
List<TPreEmpWorkRecording> preEmpWorkRecordingList = new ArrayList<>();
TPreEmpBadRecord tPreEmpBadRecord;
TPreEmpContactInfo tPreEmpContactInfo;
TPreEmpDisabilityInfo tPreEmpDisabilityInfo;
......@@ -4003,4 +4007,114 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
return content.matches("^.*\\d{14}.*$");
}
/**
* 根据身份证与姓名查询用户手机号和来源
*
* @param empIdCard 身份证
* @param empName 姓名
* @return EmpMainToCVo
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
@Override
public R<EmpMainToCVo> getPhoneByCardAndName(String empIdCard, String empName) {
if(Common.isEmpty(empIdCard) || Common.isEmpty(empName)){
return R.failed("身份证、姓名都要必填");
}
EmpMainToCVo empMainToCVo = new EmpMainToCVo();
// 默认不在系统
empMainToCVo.setEmpFrom(CommonConstants.TWO_STRING);
empMainToCVo.setEmpPhone("");
empMainToCVo.setPreStatus("");
// 用身份证先查是否在【在档人员】里
TEmployeeInfo employee = tEmployeeInfoService.getInfoByIdcard(empIdCard);
if (employee != null) {
// 在档人员
if (!empName.equals(employee.getEmpName())) {
return R.failed("在档人员里找不到身份证对应的人员");
} else {
empMainToCVo.setEmpFrom(CommonConstants.ZERO_STRING);
empMainToCVo.setEmpPhone(employee.getEmpPhone());
empMainToCVo.setPreStatus("");
return R.ok(empMainToCVo);
}
} else {
// 用身份证先查是否在【预入职】里
TPreEmpMain preEmpMain = baseMapper.selectOne(Wrappers.<TPreEmpMain>query().lambda()
.eq(TPreEmpMain::getEmpIdcard, empIdCard)
.ne(TPreEmpMain::getStatus, CommonConstants.FIVE_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (preEmpMain != null) {
// 在档人员
if (!empName.equals(preEmpMain.getEmpName())) {
return R.failed("预入职里找不到身份证对应的人员");
} else {
empMainToCVo.setEmpFrom(CommonConstants.ONE_STRING);
empMainToCVo.setEmpPhone(preEmpMain.getEmpPhone());
empMainToCVo.setPreStatus(preEmpMain.getStatus());
return R.ok(empMainToCVo);
}
}
}
return R.ok(empMainToCVo);
}
/**
* 发送手机验证码
*
* @param empPhone 手机号
* @return R<String>
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
@Override
public R<String> sendCode(String empPhone) {
//获取验证码
String code = RandomUtil.getSix();
String phoneCodeKey = CacheConstants.MVP_TOC_PHONE_CODE_PREFIX.concat(empPhone);
if (Common.isNotNull(redisUtil.get(phoneCodeKey))) {
code = (String)redisUtil.get(phoneCodeKey);
}
//发短信
AliSmsResult result = SmsUtil.sendSms(empPhone, code);
//验证码存缓存
if (AliSmsResult.SUCCESS_CODE.equals(result.getCode())) {
redisUtil.set(phoneCodeKey, code, 300L);
return R.ok("验证码已发送");
} else {
return R.failed(null == result.getMessage() ? "获取验证码错误,告知管理员,阿里云短信配置错误!" : result.getMessage());
}
}
/**
* 校验手机验证码
*
* @param empPhone 手机号
* @param verifyCode 验证码
* @return R<String>
*
* @author chenyuxi
* @date 2024-10-24 16:01:47
* @since mvp1.7.0
*/
@Override
public R<String> checkCode(String empPhone, String verifyCode) {
String phoneCodeKey = CacheConstants.MVP_TOC_PHONE_CODE_PREFIX.concat(empPhone);
if (Common.isNotNull(redisUtil.get(phoneCodeKey))) {
String code = (String)redisUtil.get(phoneCodeKey);
if (!verifyCode.equals(code)) {
return R.failed("验证码错误!");
}
} else {
return R.failed("验证码过期!");
}
// 校验通过移除已使用的验证码
redisUtil.remove(phoneCodeKey);
return R.ok("验证码通过");
}
}
......@@ -183,4 +183,9 @@ public interface CacheConstants {
* 登录用户最近一次选择的收入证明单位名称
*/
public static final String WXHR_LAST_SELECT_COMPANY_NAME = "wxhr_last_select_company_name";
/**
* C端发验证码前缀
*/
public static final String MVP_TOC_PHONE_CODE_PREFIX = "MVP_TOC_PHONE_CODE_";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment