|
@@ -2,12 +2,17 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.rongwei.bscommon.sys.dao.ZhcxApiDao;
|
|
import com.rongwei.bscommon.sys.dao.ZhcxApiDao;
|
|
import com.rongwei.bscommon.sys.service.ZhcxApiService;
|
|
import com.rongwei.bscommon.sys.service.ZhcxApiService;
|
|
import com.rongwei.bscommon.sys.utils.HwSmsUtil;
|
|
import com.rongwei.bscommon.sys.utils.HwSmsUtil;
|
|
import com.rongwei.bsentity.vo.ZhcxOutsideInspectionVo;
|
|
import com.rongwei.bsentity.vo.ZhcxOutsideInspectionVo;
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
|
|
+import com.rongwei.rwadmincommon.system.service.SysUserService;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,6 +31,8 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
private ZhcxApiDao zhcxApiDao;
|
|
private ZhcxApiDao zhcxApiDao;
|
|
@Autowired
|
|
@Autowired
|
|
private RedisService redisService;
|
|
private RedisService redisService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ZhcxOutsideInspectionVo> getOutsideInspectionList(Map<String, Object> map) {
|
|
public List<ZhcxOutsideInspectionVo> getOutsideInspectionList(Map<String, Object> map) {
|
|
@@ -34,16 +41,34 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public R sendCode(Map<String, Object> map) {
|
|
public R sendCode(Map<String, Object> map) {
|
|
- Object phoneObj = map.get("phone");
|
|
|
|
|
|
+ //Object phoneObj = map.get("phone");
|
|
Object loginTypeObj = map.get("loginType");
|
|
Object loginTypeObj = map.get("loginType");
|
|
- Object accountObj = map.get("accountObj");
|
|
|
|
- if(ObjectUtil.isEmpty(phoneObj) || ObjectUtil.isEmpty(loginTypeObj)
|
|
|
|
- || ObjectUtil.isEmpty(accountObj)){
|
|
|
|
|
|
+ Object accountObj = map.get("account");
|
|
|
|
+ Object passwordObj = map.get("password");
|
|
|
|
+ if(ObjectUtil.isEmpty(loginTypeObj)
|
|
|
|
+ || ObjectUtil.isEmpty(accountObj) || ObjectUtil.isEmpty(passwordObj)){
|
|
return R.error();
|
|
return R.error();
|
|
}
|
|
}
|
|
- String phone = (String) phoneObj;
|
|
|
|
|
|
+ //String phone = (String) phoneObj;
|
|
String loginType = (String) loginTypeObj;
|
|
String loginType = (String) loginTypeObj;
|
|
String account = (String) accountObj;
|
|
String account = (String) accountObj;
|
|
|
|
+ String password = (String) passwordObj;
|
|
|
|
+ LambdaQueryWrapper<SysUserDo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.and(i -> i.eq(SysUserDo::getAccount, account).
|
|
|
|
+ or().eq(SysUserDo::getMobile, account).
|
|
|
|
+ or().eq(SysUserDo::getEmail, account));
|
|
|
|
+ SysUserDo sysUserDo = sysUserService.getOne(queryWrapper);
|
|
|
|
+ if (sysUserDo == null || StringUtils.isEmpty(sysUserDo.getId())) {
|
|
|
|
+ return R.error("用户名密码不正确");
|
|
|
|
+ }
|
|
|
|
+ String secPas = SecurityUtil.getSaltMd5AndSha(password, sysUserDo.getId());
|
|
|
|
+ if (!secPas.equals(sysUserDo.getPassword())) {
|
|
|
|
+ return R.error("用户名密码不正确");
|
|
|
|
+ }
|
|
|
|
+ String phone = sysUserDo.getMobile();
|
|
|
|
+ if(StringUtils.isBlank(phone)){
|
|
|
|
+ return R.error("未获取到手机号,请联系系统管理员");
|
|
|
|
+ }
|
|
boolean exists = redisService.hasKey(loginType + phone);
|
|
boolean exists = redisService.hasKey(loginType + phone);
|
|
String sendCodeTimeObj = (String) redisService.getRedisCatchObj(loginType + phone);
|
|
String sendCodeTimeObj = (String) redisService.getRedisCatchObj(loginType + phone);
|
|
if (StringUtils.isBlank(sendCodeTimeObj)) {
|
|
if (StringUtils.isBlank(sendCodeTimeObj)) {
|
|
@@ -52,7 +77,7 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
int sendCodeTime = Integer.parseInt(sendCodeTimeObj);
|
|
int sendCodeTime = Integer.parseInt(sendCodeTimeObj);
|
|
if( exists && sendCodeTime >= 3 ){
|
|
if( exists && sendCodeTime >= 3 ){
|
|
sendCodeTime += 1;
|
|
sendCodeTime += 1;
|
|
- redisService.redisCatchInit(loginType + phone,sendCodeTime,300);
|
|
|
|
|
|
+ redisService.redisCatchInit(loginType + phone,String.valueOf(sendCodeTime),300);
|
|
return R.error("验证发送次数频繁,请过5分钟后再尝试");
|
|
return R.error("验证发送次数频繁,请过5分钟后再尝试");
|
|
}
|
|
}
|
|
StringBuilder code = new StringBuilder();
|
|
StringBuilder code = new StringBuilder();
|
|
@@ -71,9 +96,11 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
redisService.redisCatchInit(loginType + phone,0,300);
|
|
redisService.redisCatchInit(loginType + phone,0,300);
|
|
}
|
|
}
|
|
sendCodeTime += 1;
|
|
sendCodeTime += 1;
|
|
- redisService.redisCatchInit(loginType + phone,sendCodeTime,300);
|
|
|
|
|
|
+ redisService.redisCatchInit(loginType + phone,String.valueOf(sendCodeTime),300);
|
|
redisService.redisCatchInit(loginType + account,code.toString(),60);
|
|
redisService.redisCatchInit(loginType + account,code.toString(),60);
|
|
- return R.ok("发送成功");
|
|
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("phone",phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
|
|
|
|
+ return R.ok("发送成功").putData(json);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|