Commit 149a23a8 authored by dongyu's avatar dongyu

登录注册相关

parent ac2bd44c
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-common:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-common:9.4.45.v20220203" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-hpack:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-hpack:9.4.45.v20220203" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-http-client-transport:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.http2:http2-http-client-transport:9.4.45.v20220203" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-alpn-openjdk8-client:9.4.45.v20220203" level="project" />
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.6" level="project" /> <orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.6" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" /> <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
<orderEntry type="library" name="Maven: com.ums86:send-api-sdk:1.2" level="project" /> <orderEntry type="library" name="Maven: com.ums86:send-api-sdk:1.2" level="project" />
...@@ -140,7 +141,6 @@ ...@@ -140,7 +141,6 @@
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" /> <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.8" level="project" /> <orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.8" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.8" level="project" /> <orderEntry type="library" name="Maven: com.alibaba:druid:1.2.8" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.5.10" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.5.10" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.58" level="project" /> <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.58" level="project" />
...@@ -188,5 +188,19 @@ ...@@ -188,5 +188,19 @@
<orderEntry type="library" name="Maven: joda-time:joda-time:2.8.1" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.8.1" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.13.2" level="project" /> <orderEntry type="library" name="Maven: junit:junit:4.13.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.2" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.2" level="project" />
<orderEntry type="library" name="Maven: com.aliyun.oss:aliyun-sdk-oss:3.10.2" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jettison:jettison:1.1" level="project" />
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-ram:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-sts:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-ecs:4.2.0" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-kms:2.7.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.14.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-core:3.7.1" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20170516" level="project" />
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-dysmsapi:1.1.0" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -308,6 +308,29 @@ ...@@ -308,6 +308,29 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<!-- 阿里云oss服务-->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<!--用于阿里云短信验证的-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.supServer.common;
import com.supServer.common.exception.user.UserPasswordNotMatchException;
import com.supServer.framework.redis.RedisCache;
import com.supServer.framework.security.service.UserDetailsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
/**
* 短信登录自定义校验类
*/
@Component
public class MyAuthenticationProvider implements AuthenticationProvider {
@Autowired
private RedisCache redisCache;
@Autowired
private UserDetailsServiceImpl userDetailsService;
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException, UserPasswordNotMatchException {
String name = authentication.getName();
String password = (String) authentication.getCredentials();
UserDetails user = userDetailsService.loadUserByUsername(name);
String encoderPassword = bCryptPasswordEncoder.encode(password);
// 数据库账号密码的校验能通过就通过
if (bCryptPasswordEncoder.matches(password, user.getPassword())) {
return new UsernamePasswordAuthenticationToken(user, encoderPassword);
}
Boolean checkValid = checkValid(name, password);
if (checkValid && null != user) {
return new UsernamePasswordAuthenticationToken(user, password);
} else {
// 如果都登录不了,就返回异常输出
throw new UserPasswordNotMatchException();
}
}
@Override
public boolean supports(Class<?> aClass) {
return true;
}
/**
* 非账号密码登录-验证合法,短信登陆已经验证过验证码,直接返回 true
* @param userName
* @param pwd
*/
public boolean checkValid(String userName, String pwd) {
// Object code = redisCache.getCacheObject(userName);
// if (null != code && code.toString().equals(pwd)) {
// return true;
// }
return true;
}
}
...@@ -175,4 +175,11 @@ public class Constants ...@@ -175,4 +175,11 @@ public class Constants
* 操作员缓存风控评估报告 redis key * 操作员缓存风控评估报告 redis key
*/ */
public static final String RISK_MODEL_OPERATOR_RESULT_KEY = "risk_model_operator_result:"; public static final String RISK_MODEL_OPERATOR_RESULT_KEY = "risk_model_operator_result:";
/**
* 免密常量
*/
public static final String CUSTOM_LOGIN_SMS = "CUSTOM_LOGIN_SMS";
} }
...@@ -6,8 +6,8 @@ import javax.crypto.spec.SecretKeySpec; ...@@ -6,8 +6,8 @@ import javax.crypto.spec.SecretKeySpec;
import java.util.Base64; import java.util.Base64;
/** /**
* @author zmy * @author
* date 2022-08-03 * date
*/ */
public class AesUtil { public class AesUtil {
//偏移量,AES 为16bytes. DES 为8bytes //偏移量,AES 为16bytes. DES 为8bytes
...@@ -48,7 +48,7 @@ public class AesUtil { ...@@ -48,7 +48,7 @@ public class AesUtil {
public static String decode(String encodePassword){ public static String decode(String encodePassword){
try { try {
byte[] decodeByte = Base64.getDecoder().decode(encodePassword); byte[] decodeByte = Base64.getDecoder().decode(encodePassword);
byte[] bytes1 = Base64.getMimeDecoder().decode(encodePassword);
IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes()); IvParameterSpec ivParameterSpec = new IvParameterSpec(IV.getBytes());
SecretKeySpec secretKeySpec = new SecretKeySpec(AES_KEY.getBytes(), "AES"); SecretKeySpec secretKeySpec = new SecretKeySpec(AES_KEY.getBytes(), "AES");
...@@ -57,7 +57,7 @@ public class AesUtil { ...@@ -57,7 +57,7 @@ public class AesUtil {
//解密模式 //解密模式
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
byte[] bytes = cipher.doFinal(decodeByte); byte[] bytes = cipher.doFinal(bytes1);
return new String(bytes); return new String(bytes);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
package com.supServer.common.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
/**
* Created on 17/6/7.
* 短信API产品的DEMO程序,工程中包含了一个SmsDemo类,直接通过
* 执行main函数即可体验短信产品API功能(只需要将AK替换成开通了云通信-短信产品功能的AK即可)
* 工程依赖了2个jar包(存放在工程的libs目录下)
* 1:aliyun-java-sdk-core.jar
* 2:aliyun-java-sdk-dysmsapi.jar
*
* 备注:Demo工程编码采用UTF-8
* 国际短信发送请勿参照此DEMO
*/
public class SmsUtil {
public static Logger logger = LoggerFactory.getLogger(SmsUtil.class);
//产品名称:云通信短信API产品,开发者无需替换
static final String product = "Dysmsapi";
//产品域名,开发者无需替换
static final String domain = "dysmsapi.aliyuncs.com";
// TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
static final String accessKeyId = "LTAIC4Pb2jJZbUmD";
static final String accessKeySecret = "L7VANFwqaTludkczLsg9jhvidk0e28";
public static SendSmsResponse sendSms() throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers("15000000000");
//必填:短信签名-可在短信控制台中找到
request.setSignName("建设库");
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode("SMS_136390617");
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam("{ \"code\":\"123\"}");
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
return sendSmsResponse;
}
/**
* @param phone
* @param smsAliCode
* @param map
* @return
* @throws ClientException
*/
public static boolean sendSms(String phone, String smsAliCode, Map<String,String> map) throws ClientException {
SendSmsResponse response = null;
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers(phone);
//必填:短信签名-可在短信控制台中找到
request.setSignName("建设库");
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(smsAliCode);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam(JsonUtil.toJSONString(map));
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
// request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch
response = acsClient.getAcsResponse(request);
if(response.getCode() != null && response.getCode().equals("OK")) {
return true;
}
return false;
}
public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象
QuerySendDetailsRequest request = new QuerySendDetailsRequest();
//必填-号码
request.setPhoneNumber("15000000000");
//可选-流水号
request.setBizId(bizId);
//必填-发送日期 支持30天内记录查询,格式yyyyMMdd
SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
request.setSendDate(ft.format(new Date()));
//必填-页大小
request.setPageSize(10L);
//必填-当前页码从1开始计数
request.setCurrentPage(1L);
//hint 此处可能会抛出异常,注意catch
QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
return querySendDetailsResponse;
}
}
This diff is collapsed.
package com.supServer.framework.config; package com.supServer.framework.config;
import com.supServer.common.MyAuthenticationProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
...@@ -32,6 +33,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -32,6 +33,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
@Autowired @Autowired
private UserDetailsService userDetailsService; private UserDetailsService userDetailsService;
@Autowired
private MyAuthenticationProvider myAuthenticationProvider;
/** /**
* 认证失败处理类 * 认证失败处理类
*/ */
...@@ -97,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -97,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage","/resetPwd","/findAccount").anonymous() .antMatchers("/login", "/register", "/captchaImage","/resetPwd","/findAccount","/smsLogin","/forgotPassword","/checkUser").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/", "/",
...@@ -146,6 +150,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -146,6 +150,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception protected void configure(AuthenticationManagerBuilder auth) throws Exception
{ {
auth.authenticationProvider(myAuthenticationProvider);
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
} }
} }
package com.supServer.framework.security.mode; package com.supServer.framework.security.mode;
import com.supServer.project.entity.UserInfo; import com.supServer.project.entity.UserInfo;
import java.util.Date;
/**
* @description:
* @Author: ly
* @Date: 2022/3/29 15:50
*/
public class RegisterBody extends UserInfo { public class RegisterBody extends UserInfo {
private String companyName; private String companyName;
...@@ -22,25 +15,31 @@ public class RegisterBody extends UserInfo { ...@@ -22,25 +15,31 @@ public class RegisterBody extends UserInfo {
private String legalPersonData; private String legalPersonData;
private String legalPersonName; private String legalPerson;
private String legalPersonCardType; private Double registeredCapital;
private String legalPersonCardNum; private String registeredDate;
private String idCardName; private String registeredAddress;
private Date createTime; private String addressDetail;
private Date updateTime; private String briefing;
public String getIdCardName() { private String licenseUrl;
return idCardName;
}
public void setIdCardName(String idCardName) { private String cardUrl;
this.idCardName = idCardName;
} private int catId;
private String fileUrl;
private String source;
private String smsCode;
private String fileName;
public String getCompanyName() { public String getCompanyName() {
return companyName; return companyName;
...@@ -82,48 +81,108 @@ public class RegisterBody extends UserInfo { ...@@ -82,48 +81,108 @@ public class RegisterBody extends UserInfo {
this.legalPersonData = legalPersonData; this.legalPersonData = legalPersonData;
} }
public String getLegalPersonName() { public String getLegalPerson() {
return legalPersonName; return legalPerson;
} }
public void setLegalPersonName(String legalPersonName) { public void setLegalPerson(String legalPerson) {
this.legalPersonName = legalPersonName; this.legalPerson = legalPerson;
} }
public String getLegalPersonCardType() { public Double getRegisteredCapital() {
return legalPersonCardType; return registeredCapital;
} }
public void setLegalPersonCardType(String legalPersonCardType) { public void setRegisteredCapital(Double registeredCapital) {
this.legalPersonCardType = legalPersonCardType; this.registeredCapital = registeredCapital;
} }
public String getLegalPersonCardNum() { public String getRegisteredDate() {
return legalPersonCardNum; return registeredDate;
} }
public void setLegalPersonCardNum(String legalPersonCardNum) { public void setRegisteredDate(String registeredDate) {
this.legalPersonCardNum = legalPersonCardNum; this.registeredDate = registeredDate;
} }
@Override public String getRegisteredAddress() {
public Date getCreateTime() { return registeredAddress;
return createTime;
} }
@Override public void setRegisteredAddress(String registeredAddress) {
public void setCreateTime(Date createTime) { this.registeredAddress = registeredAddress;
this.createTime = createTime;
} }
@Override public String getAddressDetail() {
public Date getUpdateTime() { return addressDetail;
return updateTime;
} }
@Override public void setAddressDetail(String addressDetail) {
public void setUpdateTime(Date updateTime) { this.addressDetail = addressDetail;
this.updateTime = updateTime; }
public String getBriefing() {
return briefing;
}
public void setBriefing(String briefing) {
this.briefing = briefing;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getCardUrl() {
return cardUrl;
}
public void setCardUrl(String cardUrl) {
this.cardUrl = cardUrl;
}
public int getCatId() {
return catId;
}
public void setCatId(int catId) {
this.catId = catId;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getSmsCode() {
return smsCode;
}
public void setSmsCode(String smsCode) {
this.smsCode = smsCode;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
} }
@Override @Override
...@@ -134,12 +193,19 @@ public class RegisterBody extends UserInfo { ...@@ -134,12 +193,19 @@ public class RegisterBody extends UserInfo {
", status='" + status + '\'' + ", status='" + status + '\'' +
", companyData='" + companyData + '\'' + ", companyData='" + companyData + '\'' +
", legalPersonData='" + legalPersonData + '\'' + ", legalPersonData='" + legalPersonData + '\'' +
", legalPersonName='" + legalPersonName + '\'' + ", legalPerson='" + legalPerson + '\'' +
", legalPersonCardType='" + legalPersonCardType + '\'' + ", registeredCapital=" + registeredCapital +
", legalPersonCardNum='" + legalPersonCardNum + '\'' + ", registeredDate=" + registeredDate +
", idCardName='" + idCardName + '\'' + ", registeredAddress='" + registeredAddress + '\'' +
", createTime=" + createTime + ", addressDetail='" + addressDetail + '\'' +
", updateTime=" + updateTime + ", briefing='" + briefing + '\'' +
", licenseUrl='" + licenseUrl + '\'' +
", cardUrl='" + cardUrl + '\'' +
", catId=" + catId +
", fileUrl='" + fileUrl + '\'' +
", source='" + source + '\'' +
", smsCode='" + smsCode + '\'' +
", fileName='" + fileName + '\'' +
'}'; '}';
} }
} }
package com.supServer.framework.security.mode;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 短信登录对象
*
* @author Lion Li
*/
@Data
public class SmsLoginBody {
/**
* 用户名
*/
@NotBlank(message = "{user.phonenumber.not.blank}")
private String phone;
/**
* 用户密码
*/
@NotBlank(message = "{sms.code.not.blank}")
private String smsCode;
}
...@@ -5,13 +5,14 @@ import com.supServer.common.exception.ServiceException; ...@@ -5,13 +5,14 @@ import com.supServer.common.exception.ServiceException;
import com.supServer.common.exception.user.CaptchaException; import com.supServer.common.exception.user.CaptchaException;
import com.supServer.common.exception.user.CaptchaExpireException; import com.supServer.common.exception.user.CaptchaExpireException;
import com.supServer.common.exception.user.UserPasswordNotMatchException; import com.supServer.common.exception.user.UserPasswordNotMatchException;
import com.supServer.common.utils.MessageUtils;
import com.supServer.common.utils.StringUtils; import com.supServer.common.utils.StringUtils;
import com.supServer.framework.manager.AsyncManager;
import com.supServer.framework.redis.RedisCache; import com.supServer.framework.redis.RedisCache;
import com.supServer.framework.security.mode.LoginUser; import com.supServer.framework.security.mode.LoginUser;
import com.supServer.project.entity.UserInfo; import com.supServer.project.entity.UserInfo;
import com.supServer.project.service.SmsService;
import com.supServer.project.service.UserInfoService; import com.supServer.project.service.UserInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
...@@ -19,6 +20,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio ...@@ -19,6 +20,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* @description: * @description:
* @Author: ly * @Author: ly
...@@ -39,6 +41,11 @@ public class UserLoginService { ...@@ -39,6 +41,11 @@ public class UserLoginService {
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired
private SmsService smsService;
//免密常量
public static final String CUSTOM_LOGIN_SMS = "CUSTOM_LOGIN_SMS";
/** /**
* 登录验证 * 登录验证
...@@ -49,18 +56,16 @@ public class UserLoginService { ...@@ -49,18 +56,16 @@ public class UserLoginService {
* @param uuid 唯一标识 * @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */
public String login(String username, String password, String code, String uuid,String type) { public String login(String username, String password, String code, String uuid) {
//校验图形验证码 // //校验图形验证码
validateCaptcha(code, uuid); // validateCaptcha(code, uuid);
//校验用户类型是否匹配 //校验用户类型是否匹配
UserInfo userInfo = userInfoService.selectUserByUserName(username); // UserInfo userInfo = userInfoService.selectUserByUserName(username);
if(!ObjectUtils.isEmpty(userInfo)){ // if(!ObjectUtils.isEmpty(userInfo)){
if (!type.equals(userInfo.getType())){ // if (!type.equals(userInfo.getType())){
throw new ServiceException("登录错误,请检查用户类型"); // throw new ServiceException("登录错误,请检查用户类型");
} // }
} // }
// 用户验证 // 用户验证
Authentication authentication = null; Authentication authentication = null;
try { try {
...@@ -73,11 +78,9 @@ public class UserLoginService { ...@@ -73,11 +78,9 @@ public class UserLoginService {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
} }
LoginUser loginUser = (LoginUser) authentication.getPrincipal(); LoginUser loginUser = (LoginUser) authentication.getPrincipal();
String userId = loginUser.getUserId(); String userId = loginUser.getUserId();
int i = userInfoService.updateLoginTime(userId); int i = userInfoService.updateLoginTime(userId);
// 生成token // 生成token
return tokenService.createToken(loginUser); return tokenService.createToken(loginUser);
...@@ -103,4 +106,28 @@ public class UserLoginService { ...@@ -103,4 +106,28 @@ public class UserLoginService {
} }
} }
public String smsLogin(String phonenumber, String smsCode) {
//校验用户类型是否匹配
UserInfo userInfo = userInfoService.selectUserByPhone(phonenumber);
// 用户验证
Authentication authentication = null;
try {
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userInfo.getAccount(), smsCode));
} catch (Exception e) {
if (e instanceof BadCredentialsException) {
throw new UserPasswordNotMatchException();
} else {
throw new ServiceException(e.getMessage());
}
}
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
String userId = loginUser.getUserId();
int i = userInfoService.updateLoginTime(userId);
// 生成token
return tokenService.createToken(loginUser);
}
} }
package com.supServer.project.controller;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.vo.BizCategoryVo;
import com.supServer.project.service.BizCompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 认证管理
* </p>
*
* @author DY
* @since 2022-10-31
*/
@RestController
@RequestMapping("/attestation")
public class AttestationController {
@Autowired
private BizCompanyInfoService bizCompanyInfoService;
/**
* 认证管理信息
*/
@PostMapping("/information")
public AjaxResult seleceById () {
return bizCompanyInfoService.seleceById();
}
}
package com.supServer.project.controller;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCategory;
import com.supServer.project.entity.vo.BizCategoryVo;
import com.supServer.project.service.BizCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 供应商类型
* </p>
* @since 2022-10—24
*/
@RestController
@RequestMapping("/category")
public class BizCategoryController {
@Autowired
private BizCategoryService bizCategoryService;
/**
* 供应商类型查询
*/
@PostMapping("/list/tree")
public AjaxResult list (@RequestBody BizCategoryVo vo) {
AjaxResult ajaxResult = bizCategoryService.listTree(vo);
return AjaxResult.success(ajaxResult);
}
}
package com.supServer.project.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 审核状态 前端控制器
* </p>
*
* @author
* @since 2022-10-28
*/
@Controller
@RequestMapping("/bizVerify")
public class BizVerifyController {
}
package com.supServer.project.controller;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.service.BizCompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 认证管理
*/
@RestController
@RequestMapping("/authentication")
public class CompanyAuthenticationController {
@Autowired
private BizCompanyInfoService companyInfoService;
/***
*
* 认证信息
*/
@GetMapping("/information")
public AjaxResult information(String phone){
return companyInfoService.information(phone);
}
}
package com.supServer.project.controller;
import com.supServer.common.utils.file.AliOssUtil;
import com.supServer.framework.web.domain.AjaxResult;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException;
/**
* @description:
* @Author:
* @Date: 2022/4/13 12:43
*/
@RequestMapping("/file")
@RestController
public class FileController {
/**
* 上传文件
* @param file
* @return
*/
@PostMapping("/uploadFile")
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws ParseException, IOException {
if (ObjectUtils.isEmpty(file) || ObjectUtils.isEmpty(file.getOriginalFilename())){
return AjaxResult.error("文件流或文件名称为空");
}
//上传
String s = AliOssUtil.uploadFile(file);
AjaxResult ajaxResult = AjaxResult.success();
ajaxResult.put("url",s);
ajaxResult.put("fileName",file.getOriginalFilename());
return ajaxResult;
}
}
package com.supServer.project.controller;
import com.supServer.common.constant.UserConstants;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.UserInfo;
import com.supServer.project.service.SmsService;
import com.supServer.project.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
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;
/**
* @description:
* @Author:
* @Date: 2022/10/31 13:18
*/
@RestController
@RequestMapping("/sms")
public class SmsController {
@Autowired
private SmsService smsService;
@Autowired
private UserInfoService userInfoService;
/**
* 注册 - 发送验证码
* @param phone
* @return
*/
@GetMapping("/sendRegisterCode")
public AjaxResult sendCode(String phone,String type){
if("0".equals(type)){
String s = userInfoService.checkUserPhoneUnique(phone);
if(UserConstants.NOT_UNIQUE.equals(s)){
return AjaxResult.error("当前手机号码已注册");
}
}
// codeType : 0-注册
return smsService.sendCode(phone,"0");
}
/**
* 个人用户找回密码 - 发送验证码
* @param phone
* @return
*/
@GetMapping("/sendResetPwdCode")
public AjaxResult sendResetPwdCode(String phone){
UserInfo userInfo = userInfoService.selectUserByPhone(phone);
if (ObjectUtils.isEmpty(userInfo)){
return AjaxResult.error("手机号未注册");
}
if (!"0".equals(userInfo.getType())){
return AjaxResult.error("该账号为企业用户");
}
// codeType : 1-个人用户找回密码
smsService.sendCode(phone,"1");
return AjaxResult.success();
}
/**
* 修改联系人 - 发送验证码
* @param phone
* @return
*/
@GetMapping("/sendResetContactCode")
public AjaxResult sendResetContactCode(String phone){
// codeType : 2-修改联系人
smsService.sendCode(phone,"2");
return AjaxResult.success();
}
/**
* 校验验证码
* @param phone
* @param code
* @return
*/
@GetMapping("/validateSmsCode")
public AjaxResult validate(@RequestParam("phone") String phone, @RequestParam("code") String code){
boolean bool = smsService.validateCode(phone, code);
if (bool){
return AjaxResult.success();
}else{
return AjaxResult.error("验证失败");
}
}
/**
* 登录 - 发送验证码
* @param phone
* @return
*/
@GetMapping("/sendLoginCode")
public AjaxResult sendLoginCode(String phone){
if(UserConstants.NOT_UNIQUE.equals(userInfoService.checkUserPhoneUnique(phone))){
return AjaxResult.error("当前手机号码已注册");
}
// codeType : 3-登录
smsService.sendCode(phone,"3");
return AjaxResult.success();
}
}
package com.supServer.project.controller;
import com.supServer.common.constant.Constants;
import com.supServer.common.constant.UserConstants;
import com.supServer.framework.security.mode.LoginBody;
import com.supServer.framework.security.mode.RegisterBody;
import com.supServer.framework.security.mode.SmsLoginBody;
import com.supServer.framework.security.service.TokenService;
import com.supServer.framework.security.service.UserLoginService;
import com.supServer.framework.security.service.UserRegisterService;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.UserInfo;
import com.supServer.project.entity.vo.ForgotPasswordVo;
import com.supServer.project.entity.vo.UserResetPwdVo;
import com.supServer.project.service.SmsService;
import com.supServer.project.service.UserInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static com.supServer.common.utils.SecurityUtils.getLoginUser;
@RestController
public class UserController {
@Autowired
private UserLoginService userLoginService;
@Autowired
private UserRegisterService registerService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private SmsService smsService;
@Autowired
private TokenService tokenService;
/**
* 登录
* @param loginBody
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody) {
//AesUtil.decode(loginBody.getUserName())
UserInfo userInfo = userInfoService.selectUserByNumber(loginBody.getUserName());
if(ObjectUtils.isEmpty(userInfo)||userInfo.getAccountStatus().equals("2")){
return AjaxResult.error("当前手机号码未注册");
}
if(userInfo.getAccountStatus().equals("0")){
return AjaxResult.error("当前账号认证审核中,请耐心等待!");
}
if(userInfo.getAccountStatus().equals("3")){
return AjaxResult.error("当前账号已注销");
}
//AesUtil.decode(loginBody.getUserName()),AesUtil.decode(loginBody.getPassword()),loginBody.getCode(),loginBody.getUuid(),loginBody.getType()
String token = userLoginService.login(loginBody.getUserName(),loginBody.getPassword(),loginBody.getCode(),loginBody.getUuid());
AjaxResult ajax = AjaxResult.success();
// 生成令牌
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
* 短信登录
*
* @param smsLoginBody 登录信息
* @return 结果
*/
@PostMapping("/smsLogin")
public AjaxResult smsLogin( @RequestBody SmsLoginBody smsLoginBody) {
// UserInfo userInfo = userInfoService.selectUserByNumber(smsLoginBody.getPhone());
// if(ObjectUtils.isEmpty(userInfo)||userInfo.getAccountStatus().equals("2")){
// return AjaxResult.error("当前手机号码未注册");
// }
// if(userInfo.getAccountStatus().equals("0")){
// return AjaxResult.error("当前账号认证审核中,请耐心等待!");
// }
if(!smsService.validateCode(smsLoginBody.getPhone(), smsLoginBody.getSmsCode())){
return AjaxResult.error("验证码错误!");
}
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = userLoginService.smsLogin(smsLoginBody.getPhone(),smsLoginBody.getSmsCode());
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
* 注册
* @param user
* @return
*/
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user) throws IOException {
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? AjaxResult.success() : AjaxResult.error(msg);
}
/*** 修改密码
*@Param:
*@return:
*/
@PostMapping("/system/userInfo/resetPwd")
public AjaxResult resetPwd(@RequestBody UserResetPwdVo userInfoVo, HttpServletRequest request){
if (StringUtils.isEmpty(userInfoVo.getOldPassword())) {
return AjaxResult.error("请输入原密码");
}
if (StringUtils.isEmpty(userInfoVo.getNewPassword())) {
return AjaxResult.error("新输入新密码");
}
if (userInfoVo.getNewPassword().length() < UserConstants.PASSWORD_MIN_LENGTH ||
userInfoVo.getNewPassword().length() > UserConstants.PASSWORD_MAX_LENGTH) {
return AjaxResult.error("密码长度必须在8到12个字符之间");
}
return userInfoService.resetPwd(userInfoVo);
}
/***忘记密码
*@Param:
*@return:
*/
@PostMapping("/forgotPassword")
public AjaxResult forgotPassword(@RequestBody ForgotPasswordVo forgotPasswordVo){
return userInfoService.forgotPassword(forgotPasswordVo);
}
/***校验账户
*@Param:
*@return:
*/
@PostMapping("/checkUser")
public AjaxResult checkUser(@RequestBody ForgotPasswordVo forgotPasswordVo){
UserInfo userInfo = userInfoService.selectUserByNumber(forgotPasswordVo.getPhone());
if("0".equals(forgotPasswordVo.getType())&&ObjectUtils.isNotEmpty(userInfo)&&userInfo.getAccountStatus().equals("1")){
return AjaxResult.error("当前手机号码已注册");
}
if("0".equals(forgotPasswordVo.getType())&&ObjectUtils.isNotEmpty(userInfo)&&userInfo.getAccountStatus().equals("0")){
return AjaxResult.error("注册审核中,请耐心等待");
}
if("1".equals(forgotPasswordVo.getType())&&ObjectUtils.isEmpty(userInfo)){
return AjaxResult.error("当前手机号码未注册");
}
if("1".equals(forgotPasswordVo.getType())&&ObjectUtils.isNotEmpty(userInfo)&&!userInfo.getAccountStatus().equals("1")){
return AjaxResult.error("当前手机号码未注册");
}
return smsService.sendCode(forgotPasswordVo.getPhone(),"1");
}
/***退出登录
*@Param:
*@return:
*/
@GetMapping("/logOut")
public void logOut(){
tokenService.resetPwd(getLoginUser().getUserId());
}
}
package com.supServer.project.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.List;
/**
*供应商类型
*/
@Data
public class BizCategory {
/**
* 分类id
*/
private Integer catId;
/**
* 分类名称
*/
private String name;
/**
* 父分类id
*/
private BigInteger parentCode;
/**
* 层级
*/
private Integer level;
/**
* 是否显示[0-不显示,1显示]
*/
private Integer showStatus;
/**
* 排序
*/
private Integer sort;
/**
* 备注
*/
private String mark;
/**
* 更新人
*/
private Integer userId;
/**
* 编码
*/
private BigInteger code;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
private List<BizCategory> children;
private String userName;
}
package com.supServer.project.entity;
import java.util.Date;
public class BizCompanyInfo {
/**
* 主键id
*/
private Integer id;
/**
* 用户id
*/
private String userId;
/**
* 企业名称
*/
private String companyName;
/**
* 统一社会信用代码
*/
private String creditCode;
/**
* 法人
*/
private String legalPerson;
/**
* 注册资本
*/
private Double registeredCapital;
/**
* 成立日期
*/
private Date registeredDate;
/**
* 注册地址
*/
private String registeredAddress;
/**
* 办公地址
*/
private String addressDetail;
/**
* 企业简介
*/
private String briefing;
/**
* 营业执照地址
*/
private String licenseUrl;
/**
* 身份证地址
*/
private String cardUrl;
/**
* 供应商类型
*/
private Integer catId;
/**
* 承诺函
*/
private String fileUrl;
/**
* 承诺函文件名称
*/
private String fileName;
/**
* 来源0、注册 1、后台添加 2、批量导入
*/
private String source;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 联系人
*/
private String contacts;
/**
* 手机号
*/
private String phone;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCreditCode() {
return creditCode;
}
public void setCreditCode(String creditCode) {
this.creditCode = creditCode;
}
public String getLegalPerson() {
return legalPerson;
}
public void setLegalPerson(String legalPerson) {
this.legalPerson = legalPerson;
}
public Double getRegisteredCapital() {
return registeredCapital;
}
public void setRegisteredCapital(Double registeredCapital) {
this.registeredCapital = registeredCapital;
}
public Date getRegisteredDate() {
return registeredDate;
}
public void setRegisteredDate(Date registeredDate) {
this.registeredDate = registeredDate;
}
public String getRegisteredAddress() {
return registeredAddress;
}
public void setRegisteredAddress(String registeredAddress) {
this.registeredAddress = registeredAddress;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
public String getBriefing() {
return briefing;
}
public void setBriefing(String briefing) {
this.briefing = briefing;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getCardUrl() {
return cardUrl;
}
public void setCardUrl(String cardUrl) {
this.cardUrl = cardUrl;
}
public Integer getCatId() {
return catId;
}
public void setCatId(Integer catId) {
this.catId = catId;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getContacts() {
return contacts;
}
public void setContacts(String contacts) {
this.contacts = contacts;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public String toString() {
return "BizCompanyInfo{" +
"id=" + id +
", userId='" + userId + '\'' +
", companyName='" + companyName + '\'' +
", creditCode='" + creditCode + '\'' +
", legalPerson='" + legalPerson + '\'' +
", registeredCapital=" + registeredCapital +
", registeredDate=" + registeredDate +
", registeredAddress='" + registeredAddress + '\'' +
", addressDetail='" + addressDetail + '\'' +
", briefing='" + briefing + '\'' +
", licenseUrl='" + licenseUrl + '\'' +
", cardUrl='" + cardUrl + '\'' +
", catId='" + catId + '\'' +
", fileUrl='" + fileUrl + '\'' +
", fileName='" + fileName + '\'' +
", source='" + source + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", contacts='" + contacts + '\'' +
", phone='" + phone + '\'' +
'}';
}
}
package com.supServer.project.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 审核状态
* </p>
*
* @author
* @since 2022-10-28
*/
public class BizVerify implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 统一社会信用代码
*/
private String creditCode;
/**
* 初审状态(1-待提交、2-提交审核、3-准入、4-未通过)
*/
private Integer status;
/**
* 人工复审状态(0-审批中、1-通过、2-驳回)
*/
private Integer reviewStatus;
/**
* 人工审核意见
*/
private String opinion;
/**
* 审核人id
*/
private String userId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改时间
*/
private LocalDateTime updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCreditCode() {
return creditCode;
}
public void setCreditCode(String creditCode) {
this.creditCode = creditCode;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getReviewStatus() {
return reviewStatus;
}
public void setReviewStatus(Integer reviewStatus) {
this.reviewStatus = reviewStatus;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "BizVerify{" +
"id=" + id +
", creditCode=" + creditCode +
", status=" + status +
", reviewStatus=" + reviewStatus +
", opinion=" + opinion +
", userId=" + userId +
", createTime=" + createTime +
", updateTime=" + updateTime +
"}";
}
}
package com.supServer.project.entity;
import java.util.Date;
/**
* @description:
* @Author:
* @Date:
*/
public class SmsCode {
private Long id;
/**
* 手机号
*/
private String phone;
/**
* 验证码
*/
private String smsCode;
/**
* 验证码类型(1.注册 )
*/
private String codeType;
/**
* 状态(0-成功,1-失败)
*/
private String status;
/**
* 创建时间
*/
private Date createTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getSmsCode() {
return smsCode;
}
public void setSmsCode(String smsCode) {
this.smsCode = smsCode;
}
public String getCodeType() {
return codeType;
}
public void setCodeType(String codeType) {
this.codeType = codeType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "SmsCode{" +
"id=" + id +
", phone='" + phone + '\'' +
", smsCode='" + smsCode + '\'' +
", codeType='" + codeType + '\'' +
", status='" + status + '\'' +
", createTime=" + createTime +
'}';
}
}
...@@ -17,6 +17,7 @@ public class UserInfo { ...@@ -17,6 +17,7 @@ public class UserInfo {
private Date updateTime; private Date updateTime;
private String accountStatus; private String accountStatus;
private Date loginTime; private Date loginTime;
private String sex;
@Override @Override
public String toString() { public String toString() {
...@@ -35,17 +36,10 @@ public class UserInfo { ...@@ -35,17 +36,10 @@ public class UserInfo {
", updateTime=" + updateTime + ", updateTime=" + updateTime +
", accountStatus='" + accountStatus + '\'' + ", accountStatus='" + accountStatus + '\'' +
", loginTime=" + loginTime + ", loginTime=" + loginTime +
", sex='" + sex + '\'' +
'}'; '}';
} }
public Date getLoginTime() {
return loginTime;
}
public void setLoginTime(Date loginTime) {
this.loginTime = loginTime;
}
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
...@@ -149,4 +143,20 @@ public class UserInfo { ...@@ -149,4 +143,20 @@ public class UserInfo {
public void setAccountStatus(String accountStatus) { public void setAccountStatus(String accountStatus) {
this.accountStatus = accountStatus; this.accountStatus = accountStatus;
} }
public Date getLoginTime() {
return loginTime;
}
public void setLoginTime(Date loginTime) {
this.loginTime = loginTime;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
} }
package com.supServer.project.entity.dto;
import java.util.List;
public class CompanyAuthenticationDto {
private String companyName;
private String phone;
private String userName;
private String sex;
private String email;
private String creditCode;
private String provinceCode;
private String legalPerson;
private Double registeredCapital;
private String registeredDate;
private String registeredAddress;
private String addressDetail;
private String licenseUrl;
private String cardUrl;
private String catId;
private List<String> typeName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCreditCode() {
return creditCode;
}
public void setCreditCode(String creditCode) {
this.creditCode = creditCode;
}
public String getProvinceCode() {
return provinceCode;
}
public void setProvinceCode(String provinceCode) {
this.provinceCode = provinceCode;
}
public String getLegalPerson() {
return legalPerson;
}
public void setLegalPerson(String legalPerson) {
this.legalPerson = legalPerson;
}
public Double getRegisteredCapital() {
return registeredCapital;
}
public void setRegisteredCapital(Double registeredCapital) {
this.registeredCapital = registeredCapital;
}
public String getRegisteredDate() {
return registeredDate;
}
public void setRegisteredDate(String registeredDate) {
this.registeredDate = registeredDate;
}
public String getRegisteredAddress() {
return registeredAddress;
}
public void setRegisteredAddress(String registeredAddress) {
this.registeredAddress = registeredAddress;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getCardUrl() {
return cardUrl;
}
public void setCardUrl(String cardUrl) {
this.cardUrl = cardUrl;
}
public String getCatId() {
return catId;
}
public void setCatId(String catId) {
this.catId = catId;
}
public List<String> getTypeName() {
return typeName;
}
public void setTypeName(List<String> typeName) {
this.typeName = typeName;
}
@Override
public String toString() {
return "CompanyAuthenticationDto{" +
"companyName='" + companyName + '\'' +
", phone='" + phone + '\'' +
", userName='" + userName + '\'' +
", sex='" + sex + '\'' +
", email='" + email + '\'' +
", creditCode='" + creditCode + '\'' +
", provinceCode='" + provinceCode + '\'' +
", legalPerson='" + legalPerson + '\'' +
", registeredCapital=" + registeredCapital +
", registeredDate='" + registeredDate + '\'' +
", registeredAddress='" + registeredAddress + '\'' +
", addressDetail='" + addressDetail + '\'' +
", licenseUrl='" + licenseUrl + '\'' +
", cardUrl='" + cardUrl + '\'' +
", catId='" + catId + '\'' +
", typeName=" + typeName +
'}';
}
}
package com.supServer.project.entity.vo;
import java.util.Date;
public class AttestationVo {
/**
* 用户id
*/
private String userId;
/**
* 真实姓名
*/
private String userName;
/**
* 电话
*/
private String phone;
/**
* 企业类型
*/
private String type;
/**
* 邮箱
*/
private String email;
/**
* 性别
*/
private String sex;
/**
* 企业名称
*/
private String companyName;
/**
* 统一社会信用代码
*/
private String creditCode;
/**
* 法人
*/
private String legalPerson;
/**
* 注册资本
*/
private Double registeredCapital;
/**
* 成立日期
*/
private Date registeredDate;
/**
* 注册地址
*/
private String registeredAddress;
/**
* 办公地址
*/
private String addressDetail;
/**
* 营业执照地址
*/
private String licenseUrl;
/**
* 身份证地址
*/
private String cardUrl;
/**
* 供应商类型
*/
private Integer catId;
/**
* 承诺函
*/
private String fileUrl;
/**
* 承诺函文件名称
*/
private String fileName;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCreditCode() {
return creditCode;
}
public void setCreditCode(String creditCode) {
this.creditCode = creditCode;
}
public String getLegalPerson() {
return legalPerson;
}
public void setLegalPerson(String legalPerson) {
this.legalPerson = legalPerson;
}
public Double getRegisteredCapital() {
return registeredCapital;
}
public void setRegisteredCapital(Double registeredCapital) {
this.registeredCapital = registeredCapital;
}
public Date getRegisteredDate() {
return registeredDate;
}
public void setRegisteredDate(Date registeredDate) {
this.registeredDate = registeredDate;
}
public String getRegisteredAddress() {
return registeredAddress;
}
public void setRegisteredAddress(String registeredAddress) {
this.registeredAddress = registeredAddress;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getCardUrl() {
return cardUrl;
}
public void setCardUrl(String cardUrl) {
this.cardUrl = cardUrl;
}
public Integer getCatId() {
return catId;
}
public void setCatId(Integer catId) {
this.catId = catId;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
@Override
public String toString() {
return "AttestationVo{" +
"userId='" + userId + '\'' +
", userName='" + userName + '\'' +
", phone='" + phone + '\'' +
", type='" + type + '\'' +
", email='" + email + '\'' +
", sex='" + sex + '\'' +
", companyName='" + companyName + '\'' +
", creditCode='" + creditCode + '\'' +
", legalPerson='" + legalPerson + '\'' +
", registeredCapital=" + registeredCapital +
", registeredDate=" + registeredDate +
", registeredAddress='" + registeredAddress + '\'' +
", addressDetail='" + addressDetail + '\'' +
", licenseUrl='" + licenseUrl + '\'' +
", cardUrl='" + cardUrl + '\'' +
", catId=" + catId +
", fileUrl='" + fileUrl + '\'' +
", fileName='" + fileName + '\'' +
'}';
}
}
package com.supServer.project.entity.vo;
public class BizCategoryVo {
private String name;
private int code;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
@Override
public String toString() {
return "BizCategoryVo{" +
"name='" + name + '\'' +
", code=" + code +
'}';
}
}
package com.supServer.project.entity.vo;
public class ForgetPwdVo {
/**
* 手机号
*/
private String phone;
/**
* 短信验证码
*/
private String smsCode;
/**
* 图形验证码
*/
private String code;
/**
* 唯一标识
*/
private String uuid;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getSmsCode() {
return smsCode;
}
public void setSmsCode(String smsCode) {
this.smsCode = smsCode;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Override
public String toString() {
return "ForgetPwdVo{" +
"phone='" + phone + '\'' +
", smsCode='" + smsCode + '\'' +
", code='" + code + '\'' +
", uuid='" + uuid + '\'' +
'}';
}
}
package com.supServer.project.entity.vo;
public class ForgotPasswordVo {
private String phone;
private String passWord;
//账号验证:0:注册,1:短信登录/忘记密码
private String type;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "ForgotPasswordVo{" +
"phone='" + phone + '\'' +
", passWord='" + passWord + '\'' +
", type='" + type + '\'' +
'}';
}
}
package com.supServer.project.mapper;
import com.supServer.project.entity.BizCategory;
import com.supServer.project.entity.vo.BizCategoryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface BizCategoryMapper {
List<BizCategory> listTree(@Param("vo") BizCategoryVo vo);
}
package com.supServer.project.mapper;
import com.supServer.project.entity.BizCompanyInfo;
import com.supServer.project.entity.dto.CompanyAuthenticationDto;
import com.supServer.project.entity.vo.AttestationVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface BizCompanyInfoMapper {
int insertCompany(BizCompanyInfo companyInfo);
CompanyAuthenticationDto information(String phone);
Integer selectBycode(@Param("creditCode") String creditCode);
BizCompanyInfo selectCompanyInfo(String creditCode);
int updateCompany(BizCompanyInfo bizcompanyInfoId);
AttestationVo seleceById(String userId);
}
package com.supServer.project.mapper;
import com.supServer.project.entity.BizVerify;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* 审核状态 Mapper 接口
* </p>
*
* @author
* @since 2022-10-28
*/
@Mapper
public interface BizVerifyMapper{
void insert(BizVerify bizVerify);
}
...@@ -64,4 +64,12 @@ public interface UserInfoMapper { ...@@ -64,4 +64,12 @@ public interface UserInfoMapper {
*/ */
int updateLoginTime(String userId); int updateLoginTime(String userId);
/**
* 根据手机号获取用户
* @param
* @return
*/
UserInfo selectUserByNumber(String userName);
Integer forgotPassword(String phone, String passWord);
} }
package com.supServer.project.service;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.vo.BizCategoryVo;
public interface BizCategoryService {
//供应商类型查询
AjaxResult listTree(BizCategoryVo vo);
}
package com.supServer.project.service;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCompanyInfo;
public interface BizCompanyInfoService {
int insertCompany(BizCompanyInfo companyInfo);
/**
* 认证信息
* @param
* @return
*/
AjaxResult information(String phone);
Integer selectBycode(String creditCode);
BizCompanyInfo selectCompanyInfo(String creditCode);
int updateCompany(BizCompanyInfo bizcompanyInfoId);
AjaxResult seleceById();
}
package com.supServer.project.service;
import com.supServer.project.entity.BizVerify;
/**
* <p>
* 审核状态 服务类
* </p>
*
* @author
* @since 2022-10-28
*/
public interface IBizVerifyService {
void insert(BizVerify bizVerify);
}
package com.supServer.project.service;
import com.supServer.framework.web.domain.AjaxResult;
/**
* @description:
* @Author:
* @Date:
*/
public interface SmsService {
/**
* 发送短信
* @param phone
* @param code
*/
void sendSMS(String phone,String code);
/**
* 获取验证码
* @param phone
*/
AjaxResult sendCode(String phone, String codeType);
/**
* 校验
* @param phone
* @param code
* @return
*/
boolean validateCode(String phone, String code);
}
...@@ -4,6 +4,7 @@ package com.supServer.project.service; ...@@ -4,6 +4,7 @@ package com.supServer.project.service;
import com.supServer.framework.web.domain.AjaxResult; import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.dto.UserDto; import com.supServer.project.entity.dto.UserDto;
import com.supServer.project.entity.UserInfo; import com.supServer.project.entity.UserInfo;
import com.supServer.project.entity.vo.ForgotPasswordVo;
import com.supServer.project.entity.vo.UserResetPwdVo; import com.supServer.project.entity.vo.UserResetPwdVo;
import com.supServer.project.entity.vo.UserUpdateVo; import com.supServer.project.entity.vo.UserUpdateVo;
...@@ -88,4 +89,8 @@ public interface UserInfoService { ...@@ -88,4 +89,8 @@ public interface UserInfoService {
* @return * @return
*/ */
UserInfo selectUserByPhone(String phone); UserInfo selectUserByPhone(String phone);
UserInfo selectUserByNumber(String userName);
AjaxResult forgotPassword(ForgotPasswordVo forgotPasswordVo);
} }
package com.supServer.project.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCategory;
import com.supServer.project.entity.vo.BizCategoryVo;
import com.supServer.project.mapper.BizCategoryMapper;
import com.supServer.project.service.BizCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigInteger;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class BizCategoryServiceImpl implements BizCategoryService {
@Autowired
private BizCategoryMapper bizCategoryMapper;
@Override
public AjaxResult listTree(BizCategoryVo vo) {
List<BizCategory> list=bizCategoryMapper.listTree(vo);
if (CollectionUtil.isEmpty(list)) {
return AjaxResult.success(list);
}
// 2 组装成父子的树形结构
List<BizCategory> level1Menus = list.stream().filter(bizCategory ->
bizCategory.getParentCode().equals(BigInteger.ZERO)
).map((menu) -> {
menu.setChildren(getChildrens(menu, list));
return menu;
}).collect(Collectors.toList());
return AjaxResult.success(level1Menus);
}
/**
* 递归查找所有菜单的子菜单
*
* @param root
* @param all
* @return
*/
private List<BizCategory> getChildrens (BizCategory root, List<BizCategory> all) {
List<BizCategory> children = all.stream().filter(bizCategory -> {
return bizCategory.getParentCode().equals(root.getCode());
}).map(bizCategory -> {
// 1 找到子菜单
bizCategory.setChildren(getChildrens(bizCategory, all));
return bizCategory;
}).collect(Collectors.toList());
return children;
}
}
package com.supServer.project.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.BizCompanyInfo;
import com.supServer.project.entity.dto.CompanyAuthenticationDto;
import com.supServer.project.entity.vo.AttestationVo;
import com.supServer.project.mapper.BizCompanyInfoMapper;
import com.supServer.project.service.BizCompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static com.supServer.common.utils.SecurityUtils.getLoginUser;
@Service
public class BizCompanyInfoServiceImpl implements BizCompanyInfoService {
@Autowired
private BizCompanyInfoMapper bizCompanyInfoMapper;
@Override
public int insertCompany(BizCompanyInfo companyInfo) {
return bizCompanyInfoMapper.insertCompany(companyInfo);
}
@Override
public AjaxResult information(String phone) {
CompanyAuthenticationDto dto=bizCompanyInfoMapper.information(phone);
if(ObjectUtil.isNotEmpty(dto)){
}
return null;
}
@Override
public Integer selectBycode(String creditCode) {
return bizCompanyInfoMapper.selectBycode(creditCode);
}
@Override
public BizCompanyInfo selectCompanyInfo(String creditCode) {
return bizCompanyInfoMapper.selectCompanyInfo(creditCode);
}
@Override
public int updateCompany(BizCompanyInfo bizcompanyInfoId) {
return bizCompanyInfoMapper.updateCompany(bizcompanyInfoId);
}
/**
* 认证管理信息
* @return
*/
@Override
public AjaxResult seleceById() {
String userId = getLoginUser().getUserId();
AttestationVo vo=bizCompanyInfoMapper.seleceById(userId);
return AjaxResult.success("操作成功", vo);
}
}
package com.supServer.project.service.impl;
import com.supServer.project.entity.BizVerify;
import com.supServer.project.mapper.BizVerifyMapper;
import com.supServer.project.service.IBizVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 审核状态 服务实现类
* </p>
*
* @author
* @since 2022-10-28
*/
@Service
public class BizVerifyServiceImpl implements IBizVerifyService {
@Autowired
private BizVerifyMapper bizVerifyMapper;
@Override
public void insert(BizVerify bizVerify) {
bizVerifyMapper.insert(bizVerify);
}
}
package com.supServer.project.service.impl;
import cn.com.flaginfo.sdk.cmc.api.ApiProvider;
import cn.com.flaginfo.sdk.cmc.api.request.ApiConfig;
import cn.com.flaginfo.sdk.cmc.api.result.ComResult;
import cn.com.flaginfo.sdk.cmc.api.sms.dynsend.DynSMSAPI;
import cn.com.flaginfo.sdk.cmc.api.sms.dynsend.DynSMSSendDataResult;
import cn.com.flaginfo.sdk.cmc.api.sms.dynsend.DynSMSSendRequest;
import cn.com.flaginfo.sdk.cmc.common.ApiEnum;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.exceptions.ClientException;
import com.supServer.common.exception.ServiceException;
import com.supServer.common.utils.SmsUtil;
import com.supServer.common.utils.StringUtils;
import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
/**
* @description:
* @Author:
* @Date:
*/
@Service
public class SmsServiceImpl implements SmsService {
@Value("${sms.templates.login}")
private String templateId;
@Value("${sms.verificationCode.bitNum}")
private Integer codeBit;
@Value("${sms.verificationCode.effectiveSecond}")
private Integer effectiveSecond;
@Value("${sms.verificationCode.intervalSecond}")
private Integer intervalSecond;
@Value("${sms.redisNamespace}")
private String redisNamespace;
@Value("${sms.spcode}")
private String spcode;
@Value("${sms.appKey}")
private String appKey;
@Value("${sms.appSecret}")
private String appSecret;
@Autowired
private StringRedisTemplate stringRedisTemplate;
private static ApiProvider provider;
private String sendServer = "https://api.ums86.com";
@Override
public void sendSMS(String phone, String code) {
ApiConfig apiConfig = new ApiConfig(spcode, appKey, appSecret);
provider = ApiProvider.getInstance(apiConfig);
//请求接口
// SMSApi api = (SMSApi) provider.getApi(ApiEnum.SENDSMS);
DynSMSAPI api = (DynSMSAPI) provider.getApi(ApiEnum.SENDDYNSMS);
api.setRequestUrl(sendServer+"/api/sms-var/send");
//请求参数
// SMSSendRequest sendRequest = new SMSSendRequest();
// sendRequest.setMessageContent(code);
// //模板编号
// sendRequest.setTemplateId(templateId);
// sendRequest.setUserNumber(phone);
// sendRequest.setSerialNumber("20210801120000123456"); 流水号
// ComResult<SMSSendDataResult> request = api.request(sendRequest);
DynSMSSendRequest sendRequest = new DynSMSSendRequest();
sendRequest.setTemplateId(templateId);
sendRequest.setDynData(new String[][]{{"手机号码", "验证码"}, {phone, code}});
// sendRequest.setSerialNumber("20210804120000123457");
ComResult<DynSMSSendDataResult> result = api.request(sendRequest);
System.out.println(JSON.toJSONString(result));
}
@Override
public AjaxResult sendCode(String phone, String codeType) {
final String key = "system:smsCode:" + redisNamespace + ":" + templateId + ":" + phone;
if (this.stringRedisTemplate.hasKey(key) && (effectiveSecond - this.stringRedisTemplate.getExpire(key)) < intervalSecond ) {
throw new ServiceException("60秒内不能重复获取验证码");
}
String code = StringUtils.getRandomNumber(codeBit);
//短信发送
// sendSMS(phone, code);
HashMap<String, String> map = new HashMap<>();
map.put("code", code);
try {
boolean sendSms = SmsUtil.sendSms(phone, "SMS_181860796", map);
this.stringRedisTemplate.opsForValue().set(key, code, effectiveSecond, TimeUnit.SECONDS);
if(sendSms){
return AjaxResult.success("短信发送成功");
}
} catch (ClientException e) {
e.printStackTrace();
}
return AjaxResult.success("短信发送失败");
}
@Override
public boolean validateCode(String phone, String code) {
final String key = "system:smsCode:" + redisNamespace + ":" + templateId + ":" + phone;
// 验证成功
if (code.equalsIgnoreCase(this.stringRedisTemplate.opsForValue().get(key))) {
this.stringRedisTemplate.delete(key);
return true;
}
// 验证失败
final String errKey = "system:smsCodeError:" + redisNamespace + ":" + templateId + ":" + phone;
if (!this.stringRedisTemplate.hasKey(errKey)) {
this.stringRedisTemplate.opsForValue().set(errKey, "1", effectiveSecond, TimeUnit.SECONDS);
}else{
// 验证错误超过10次自动删除这个验证码
Integer errCount = Integer.valueOf(this.stringRedisTemplate.opsForValue().get(errKey));
if (errCount > 10) {
this.stringRedisTemplate.delete(key);
this.stringRedisTemplate.delete(errKey);
return false;
}
this.stringRedisTemplate.opsForValue().set(errKey, String.valueOf(errCount+1), effectiveSecond, TimeUnit.SECONDS);
}
return false;
}
}
...@@ -12,6 +12,7 @@ import com.supServer.framework.security.service.TokenService; ...@@ -12,6 +12,7 @@ import com.supServer.framework.security.service.TokenService;
import com.supServer.framework.web.domain.AjaxResult; import com.supServer.framework.web.domain.AjaxResult;
import com.supServer.project.entity.dto.UserDto; import com.supServer.project.entity.dto.UserDto;
import com.supServer.project.entity.UserInfo; import com.supServer.project.entity.UserInfo;
import com.supServer.project.entity.vo.ForgotPasswordVo;
import com.supServer.project.entity.vo.UserResetPwdVo; import com.supServer.project.entity.vo.UserResetPwdVo;
import com.supServer.project.entity.vo.UserUpdateVo; import com.supServer.project.entity.vo.UserUpdateVo;
import com.supServer.project.mapper.UserInfoMapper; import com.supServer.project.mapper.UserInfoMapper;
...@@ -24,6 +25,7 @@ import org.springframework.security.crypto.bcrypt.BCrypt; ...@@ -24,6 +25,7 @@ import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@Service @Service
...@@ -179,6 +181,12 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -179,6 +181,12 @@ public class UserInfoServiceImpl implements UserInfoService {
return userInfoMapper.selectUserByPhone(phone); return userInfoMapper.selectUserByPhone(phone);
} }
@Override
public UserInfo selectUserByNumber(String userName) {
return userInfoMapper.selectUserByNumber(userName);
}
/*** /***
*@Description: 获取请求token *@Description: 获取请求token
*@Param: *@Param:
...@@ -195,4 +203,18 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -195,4 +203,18 @@ public class UserInfoServiceImpl implements UserInfoService {
} }
return token; return token;
} }
/**
* 忘记密码
* @param forgotPasswordVo
* @return
*/
@Override
public AjaxResult forgotPassword(ForgotPasswordVo forgotPasswordVo) {
Integer num = userInfoMapper.forgotPassword(forgotPasswordVo.getPhone(), SecurityUtils.encryptPassword(forgotPasswordVo.getPassWord()));
if(num<=0){
return AjaxResult.error("修改失败");
}
return AjaxResult.success("修改成功");
}
} }
...@@ -175,3 +175,16 @@ dsk-acc: ...@@ -175,3 +175,16 @@ dsk-acc:
accessSecret: V7xfV7Rr0yONN6aUM90vMjF8mVlKxpL4 accessSecret: V7xfV7Rr0yONN6aUM90vMjF8mVlKxpL4
accessIp: 47.105.97.36:8099 accessIp: 47.105.97.36:8099
# accessIp: 192.168.60.178:8099 # accessIp: 192.168.60.178:8099
sms:
redisNamespace: sup-server
spcode: 264612
appKey: admin2
appSecret: de9eb48036f184a3d6f7645e3c40d1d2
templates:
login: SMS_181860796
verificationCode:
bitNum: 6
effectiveSecond: 300
intervalSecond: 60
\ No newline at end of file
...@@ -168,28 +168,17 @@ xss: ...@@ -168,28 +168,17 @@ xss:
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*
sms: sms:
redisNamespace: cqzx-server redisNamespace: sup-server
spcode: 264612 spcode: 264612
appKey: admin2 appKey: admin2
appSecret: de9eb48036f184a3d6f7645e3c40d1d2 appSecret: de9eb48036f184a3d6f7645e3c40d1d2
templates: templates:
login: 2091012030523 login: SMS_181860796
verificationCode: verificationCode:
bitNum: 6 bitNum: 6
effectiveSecond: 300 effectiveSecond: 300
intervalSecond: 60 intervalSecond: 60
oos: oos:
endpoint: cq4oss.ctyunxs.cn endpoint: cq4oss.ctyunxs.cn
accessKey: L6pr75HLgfpCW2ULNSq9 accessKey: L6pr75HLgfpCW2ULNSq9
......
<?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.supServer.project.mapper.BizCategoryMapper">
<resultMap type="com.supServer.project.entity.BizCategory" id="BizCategoryResult">
<id property="catId" column="cat_id" />
<result property="name" column="name" />
<result property="parentCode" column="parent_code" />
<result property="level" column="level" />
<result property="showStatus" column="show_status" />
<result property="sort" column="sort" />
<result property="mark" column="mark"/>
<result property="userName" column="user_name" />
<result property="code" column="code" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<select id="listTree" parameterType="com.supServer.project.entity.vo.BizCategoryVo" resultMap="BizCategoryResult">
select bc.*
from biz_category bc
<where>
<if test="vo.name != null and vo.name != ''">
and bc.name like concat('%', #{vo.name}, '%')
</if>
and bc.show_status='1'
</where>
</select>
</mapper>
\ No newline at end of file
<?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.supServer.project.mapper.BizCompanyInfoMapper">
<resultMap type="com.supServer.project.entity.BizCompanyInfo" id="BizCompanyInfoResult">
<id property="id" column="id" />
<result property="userId" column="user_id" />
<result property="companyName" column="company_name" />
<result property="creditCode" column="credit_code" />
<result property="legalPerson" column="legal_person" />
<result property="registeredCapital" column="registered_capital" />
<result property="registeredDate" column="registered_date"/>
<result property="registeredAddress" column="registered_address" />
<result property="addressDetail" column="address_detail" />
<result property="briefing" column="briefing" />
<result property="licenseUrl" column="license_url" />
<result property="cardUrl" column="card_url" />
<result property="type" column="type" />
<result property="fileUrl" column="file_url" />
<result property="source" column="source" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<insert id="insertCompany" parameterType="com.supServer.project.entity.BizCompanyInfo">
insert into biz_company_info(user_id,company_name,credit_code,legal_person,registered_capital,registered_date,registered_address,
address_detail,briefing,license_url,card_url,cat_id,file_url,file_name,source,create_time,update_time,contacts,phone
)
values (#{userId},#{companyName},#{creditCode},#{legalPerson},#{registeredCapital},#{registeredDate},#{registeredAddress},#{addressDetail},
#{briefing},#{licenseUrl},#{cardUrl},#{catId},#{fileUrl},#{fileName},#{source},NOW(),NOW(),#{contacts},#{phone})
</insert>
<select id="information" resultType="com.supServer.project.entity.dto.CompanyAuthenticationDto">
SELECT
bci.company_name,sui.phone,sui.user_name,sui.sex,sui.email,bci.credit_code,bci.legal_person,bci.registered_capital,
bci.registered_date,bci.registered_address,bci.address_detail,bci.license_url,bci.card_url,bci.cat_id
FROM
sup_user_info sui
left join biz_company_info bci on sui.user_id = bci.user_id
WHERE
sui.phone = #{phone}
</select>
<select id="selectBycode" resultType="java.lang.Integer">
select bv.review_status
from biz_company_info bci
left join biz_verify bv on bci.credit_code=bv.credit_code
where bci.credit_code=#{creditCode}
and bv.status=3
order by bv.update_time desc
limit 1
</select>
<select id="selectCompanyInfo" resultType="com.supServer.project.entity.BizCompanyInfo">
select bci.*
from biz_company_info bci
where bci.credit_code=#{creditCode}
</select>
<update id="updateCompany" parameterType="com.supServer.project.entity.BizCompanyInfo">
update biz_company_info
<set>
update_time = now(),
<if test="companyName != null and companyName !=''">company_name = #{companyName},</if>
<if test="creditCode != null and creditCode !=''">credit_code = #{creditCode},</if>
<if test="legalPerson != null and legalPerson !=''">legal_person = #{legalPerson},</if>
<if test="registeredCapital != null and registeredCapital !=''">registered_capital = #{registeredCapital},</if>
<if test="registeredDate != null ">registered_date = #{registeredDate},</if>
<if test="registeredAddress != null and registeredAddress !=''">registered_address = #{registeredAddress},</if>
<if test="addressDetail != null and addressDetail !=''">address_detail = #{addressDetail},</if>
<if test="briefing != null and briefing !=''">briefing = #{briefing},</if>
<if test="licenseUrl != null and licenseUrl !=''">license_url = #{licenseUrl},</if>
<if test="cardUrl != null and cardUrl !=''">card_url = #{cardUrl},</if>
<if test="catId != null and catId !=''">cat_id = #{catId},</if>
<if test="fileUrl != null and fileUrl !=''">file_url = #{fileUrl},</if>
<if test="fileName != null and fileName !=''">file_name = #{fileName},</if>
<if test="source != null and source !=''">source = #{source},</if>
<if test="contacts != null and contacts !=''">contacts = #{contacts},</if>
<if test="phone != null and phone !=''">phone = #{phone},</if>
</set>
where id = #{id}
</update>
<select id="seleceById" resultType="com.supServer.project.entity.vo.AttestationVo">
select
sui.user_id as userId,sui.user_name as userName,sui.phone,sui.sex,sui.email,
bci.company_name as companyName,bci.credit_code as creditCode,bci.legal_person as legalPerson,
bci.registered_capital as registeredCapital,bci.registered_date as registeredDate,
bci.registered_address as registeredAddress,bci.address_detail as addressDetail,bci.license_url as licenseUrl,
bci.card_url as cardUrl,bci.cat_id as catId,bci.file_url as fileUrl,bci.file_name as fileName
from biz_company_info bci
left join sup_user_info sui on bci.user_id=sui.user_id
where bci.user_id=#{userId}
</select>
</mapper>
\ No newline at end of file
<?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.supServer.project.mapper.BizVerifyMapper">
<resultMap type="BizVerify" id="BizVerifyResult">
<id property="id" column="id"/>
<result property="creditCode" column="credit_code"/>
<result property="status" column="status"/>
<result property="reviewStatus" column="review_status"/>
<result property="opinion" column="opinion"/>
<result property="userId" column="user_id"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<insert id="insert" >
insert into biz_verify(credit_code,status,review_status,opinion,user_id,create_time,update_time)
values (#{creditCode},#{status},#{reviewStatus},#{opinion},#{userId},now(),now())
</insert>
</mapper>
...@@ -19,12 +19,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,12 +19,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="accountStatus" column="account_status" /> <result property="accountStatus" column="account_status" />
<result property="loginTime" column="login_time" /> <result property="loginTime" column="login_time" />
<result property="sex" column="sex" />
</resultMap> </resultMap>
<select id="selectUserByUserName" parameterType="String" resultMap="DissentInfoResult"> <select id="selectUserByUserName" parameterType="String" resultMap="DissentInfoResult">
select user_id,user_name,password,phone,type,account,email,province_code,city_code,area_code,create_time,account_status,login_time select user_id,user_name,password,phone,type,account,email,province_code,city_code,area_code,create_time,account_status,login_time,sex
from sup_user_info from sup_user_info
where BINARY user_name = #{userName} and account_status = '1' where BINARY account = #{userName} and account_status = '1'
</select> </select>
<select id="checkUserNameUnique" parameterType="String" resultType="int"> <select id="checkUserNameUnique" parameterType="String" resultType="int">
...@@ -35,16 +36,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -35,16 +36,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="registerUser" parameterType="com.supServer.project.entity.UserInfo"> <insert id="registerUser" parameterType="com.supServer.project.entity.UserInfo">
insert into sup_user_info(user_id,user_name,account,password,phone,`type`,email,province_code,city_code,area_code,create_time,update_time,account_status) insert into sup_user_info(user_id,user_name,account,password,phone,`type`,email,province_code,city_code,area_code,create_time,update_time,account_status,sex)
values (#{userId},#{userName},#{account},#{password},#{phone},#{type},#{email},#{provinceCode},#{cityCode},#{areaCode},now(),now(),#{accountStatus}); values (#{userId},#{userName},#{account},#{password},#{phone},#{type},#{email},#{provinceCode},#{cityCode},#{areaCode},now(),now(),#{accountStatus},#{sex});
</insert> </insert>
<select id="selectUserByPhone" resultMap="DissentInfoResult"> <select id="selectUserByPhone" resultMap="DissentInfoResult">
select user_id,user_name,password,phone,type,account,email,province_code,city_code,area_code,create_time,account_status select user_id,user_name,password,phone,type,account,email,province_code,city_code,area_code,create_time,account_status,sex
from sup_user_info from sup_user_info
where phone = #{phone} and account_status = '1' where phone = #{phone} and account_status = '1'
</select> </select>
<select id="selectUserByNumber" resultMap="DissentInfoResult">
select user_id,user_name,password,phone,type,account,email,province_code,city_code,area_code,create_time,account_status,sex
from sup_user_info
where account = #{userName}
</select>
<update id="updateUserInfo" parameterType="com.supServer.project.entity.UserInfo"> <update id="updateUserInfo" parameterType="com.supServer.project.entity.UserInfo">
update sup_user_info update sup_user_info
<set> <set>
...@@ -58,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -58,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="cityCode != null and cityCode !=''">city_code = #{cityCode},</if> <if test="cityCode != null and cityCode !=''">city_code = #{cityCode},</if>
<if test="areaCode != null and areaCode !=''">area_code = #{areaCode},</if> <if test="areaCode != null and areaCode !=''">area_code = #{areaCode},</if>
<if test="accountStatus != null and accountStatus !=''">account_status = #{accountStatus},</if> <if test="accountStatus != null and accountStatus !=''">account_status = #{accountStatus},</if>
<if test="sex != null and sex !=''">sex = #{sex},</if>
</set> </set>
where user_id = #{userId} where user_id = #{userId}
</update> </update>
...@@ -80,11 +88,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -80,11 +88,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
cui.create_time createTime, cui.create_time createTime,
cui.update_time updateTime, cui.update_time updateTime,
cui.account_status accountStatus, cui.account_status accountStatus,
cui.login_time loginTime cui.login_time loginTime,
cui.sex
FROM FROM
sup_user_info cui sup_user_info cui
WHERE WHERE
cui.user_id = #{userId} cui.user_id = #{userId}
</select> </select>
<update id="forgotPassword" >
update sup_user_info
<set>
update_time = now(),
<if test="passWord != null and passWord !=''">password = #{passWord},</if>
</set>
where account = #{phone}
</update>
</mapper> </mapper>
\ No newline at end of file
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