结构更新
This commit is contained in:
parent
bd2af58d80
commit
705747be89
4
pom.xml
4
pom.xml
@ -210,14 +210,14 @@
|
||||
<!-- 集成第三方登录 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth</artifactId>
|
||||
<artifactId>ruoyi-oauth-start</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 集成支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay</artifactId>
|
||||
<artifactId>ruoyi-pay-start</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
@ -55,11 +55,16 @@
|
||||
<!-- 集成第三方登录 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
<artifactId>ruoyi-oauth-start</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 在线接口 -->
|
||||
<!-- 集成第三方支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-start</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 在线接口 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-online</artifactId>
|
||||
|
@ -1,12 +1,18 @@
|
||||
# 请输入自己的appid和appsecret
|
||||
wx:
|
||||
miniapp:
|
||||
open: true
|
||||
appId: appId
|
||||
appSecret: appSecret
|
||||
url: https://api.weixin.qq.com/sns/jscode2session
|
||||
pub:
|
||||
open: true
|
||||
appId: appId
|
||||
appSecret: appSecret
|
||||
url: https://api.weixin.qq.com/sns/oauth2/access_token
|
||||
oauth:
|
||||
wx:
|
||||
miniapp:
|
||||
open: true
|
||||
appId: appId
|
||||
appSecret: appSecret
|
||||
url: https://api.weixin.qq.com/sns/jscode2session
|
||||
pub:
|
||||
open: true
|
||||
appId: appId
|
||||
appSecret: appSecret
|
||||
url: https://api.weixin.qq.com/sns/oauth2/access_token
|
||||
|
||||
phone:
|
||||
dysms:
|
||||
appId: appId
|
||||
appSecret: appSecret
|
||||
|
8
ruoyi-admin/src/main/resources/application-pay.yml
Normal file
8
ruoyi-admin/src/main/resources/application-pay.yml
Normal file
@ -0,0 +1,8 @@
|
||||
pay:
|
||||
sqb:
|
||||
apiDomain: "apiDomain"
|
||||
terminalSn: "terminalSn"
|
||||
terminalKey: "terminalKey"
|
||||
appId: "appId"
|
||||
vendorSn: "vendorSn"
|
||||
vendorKey: "vendorKey"
|
@ -55,7 +55,7 @@ spring:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: druid,mybatis,oauth
|
||||
active: druid,mybatis,oauth,pay
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
|
@ -82,6 +82,20 @@
|
||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 手机号认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-phone</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 邮箱认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-email</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@ -90,6 +104,9 @@
|
||||
<module>ruoyi-oauth-common</module>
|
||||
<module>ruoyi-oauth-justauth</module>
|
||||
<module>ruoyi-oauth-wx</module>
|
||||
<module>ruoyi-oauth-phone</module>
|
||||
<module>ruoyi-oauth-email</module>
|
||||
<module>ruoyi-oauth-start</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
@ -15,393 +15,279 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
* @date 2024-01-18
|
||||
*/
|
||||
@Schema(description = "第三方认证对象")
|
||||
public class OauthUser extends BaseEntity
|
||||
{
|
||||
public class OauthUser extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@Schema(defaultValue = "主键")
|
||||
private Long id;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方系统的唯一ID,详细解释请参考:名词解释 */
|
||||
@Schema(defaultValue = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
||||
@Excel(name = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
||||
private String uuid;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 用户ID */
|
||||
@Schema(defaultValue = "用户ID")
|
||||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window) */
|
||||
/**
|
||||
* 第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)
|
||||
*/
|
||||
@Schema(defaultValue = "第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)")
|
||||
@Excel(name = "第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)")
|
||||
private String source;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 用户的授权令牌 */
|
||||
@Schema(defaultValue = "用户的授权令牌")
|
||||
@Excel(name = "用户的授权令牌")
|
||||
private String accessToken;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户的授权令牌的有效期,部分平台可能没有 */
|
||||
@Schema(defaultValue = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
||||
@Excel(name = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
||||
private Long expireIn;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 刷新令牌,部分平台可能没有 */
|
||||
@Schema(defaultValue = "刷新令牌,部分平台可能没有")
|
||||
@Excel(name = "刷新令牌,部分平台可能没有")
|
||||
private String refreshToken;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户的 open id,部分平台可能没有 */
|
||||
@Schema(defaultValue = "第三方用户的 open id,部分平台可能没有")
|
||||
@Excel(name = "第三方用户的 open id,部分平台可能没有")
|
||||
private String openId;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户的 ID,部分平台可能没有 */
|
||||
@Schema(defaultValue = "第三方用户的 ID,部分平台可能没有")
|
||||
@Excel(name = "第三方用户的 ID,部分平台可能没有")
|
||||
private String uid;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 个别平台的授权信息,部分平台可能没有 */
|
||||
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
||||
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
||||
private String accessCode;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户的 union id,部分平台可能没有 */
|
||||
@Schema(defaultValue = "第三方用户的 union id,部分平台可能没有")
|
||||
@Excel(name = "第三方用户的 union id,部分平台可能没有")
|
||||
private String unionId;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 第三方用户授予的权限,部分平台可能没有 */
|
||||
@Schema(defaultValue = "第三方用户授予的权限,部分平台可能没有")
|
||||
@Excel(name = "第三方用户授予的权限,部分平台可能没有")
|
||||
private String scope;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 个别平台的授权信息,部分平台可能没有 */
|
||||
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
||||
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
||||
private String tokenType;
|
||||
|
||||
|
||||
|
||||
|
||||
/** id token,部分平台可能没有 */
|
||||
@Schema(defaultValue = "id token,部分平台可能没有")
|
||||
@Excel(name = "id token,部分平台可能没有")
|
||||
private String idToken;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 小米平台用户的附带属性,部分平台可能没有 */
|
||||
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
||||
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
||||
private String macAlgorithm;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 小米平台用户的附带属性,部分平台可能没有 */
|
||||
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
||||
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
||||
private String macKey;
|
||||
|
||||
|
||||
|
||||
|
||||
/** 用户的授权code,部分平台可能没有 */
|
||||
@Schema(defaultValue = "用户的授权code,部分平台可能没有")
|
||||
@Excel(name = "用户的授权code,部分平台可能没有")
|
||||
private String code;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
||||
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||
private String oauthToken;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
||||
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||
private String oauthTokenSecret;
|
||||
|
||||
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid)
|
||||
{
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUuid()
|
||||
{
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
|
||||
public void setSource(String source)
|
||||
{
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getSource()
|
||||
{
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
public void setAccessToken(String accessToken)
|
||||
{
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public String getAccessToken()
|
||||
{
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
|
||||
public void setExpireIn(Long expireIn)
|
||||
{
|
||||
public void setExpireIn(Long expireIn) {
|
||||
this.expireIn = expireIn;
|
||||
}
|
||||
|
||||
public Long getExpireIn()
|
||||
{
|
||||
public Long getExpireIn() {
|
||||
return expireIn;
|
||||
}
|
||||
|
||||
|
||||
public void setRefreshToken(String refreshToken)
|
||||
{
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
public String getRefreshToken()
|
||||
{
|
||||
public String getRefreshToken() {
|
||||
return refreshToken;
|
||||
}
|
||||
|
||||
|
||||
public void setOpenId(String openId)
|
||||
{
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getOpenId()
|
||||
{
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
|
||||
public void setUid(String uid)
|
||||
{
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getUid()
|
||||
{
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
public void setAccessCode(String accessCode)
|
||||
{
|
||||
public void setAccessCode(String accessCode) {
|
||||
this.accessCode = accessCode;
|
||||
}
|
||||
|
||||
public String getAccessCode()
|
||||
{
|
||||
public String getAccessCode() {
|
||||
return accessCode;
|
||||
}
|
||||
|
||||
|
||||
public void setUnionId(String unionId)
|
||||
{
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
public String getUnionId()
|
||||
{
|
||||
public String getUnionId() {
|
||||
return unionId;
|
||||
}
|
||||
|
||||
|
||||
public void setScope(String scope)
|
||||
{
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getScope()
|
||||
{
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
||||
public void setTokenType(String tokenType)
|
||||
{
|
||||
public void setTokenType(String tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
}
|
||||
|
||||
public String getTokenType()
|
||||
{
|
||||
public String getTokenType() {
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
|
||||
public void setIdToken(String idToken)
|
||||
{
|
||||
public void setIdToken(String idToken) {
|
||||
this.idToken = idToken;
|
||||
}
|
||||
|
||||
public String getIdToken()
|
||||
{
|
||||
public String getIdToken() {
|
||||
return idToken;
|
||||
}
|
||||
|
||||
|
||||
public void setMacAlgorithm(String macAlgorithm)
|
||||
{
|
||||
public void setMacAlgorithm(String macAlgorithm) {
|
||||
this.macAlgorithm = macAlgorithm;
|
||||
}
|
||||
|
||||
public String getMacAlgorithm()
|
||||
{
|
||||
public String getMacAlgorithm() {
|
||||
return macAlgorithm;
|
||||
}
|
||||
|
||||
|
||||
public void setMacKey(String macKey)
|
||||
{
|
||||
public void setMacKey(String macKey) {
|
||||
this.macKey = macKey;
|
||||
}
|
||||
|
||||
public String getMacKey()
|
||||
{
|
||||
public String getMacKey() {
|
||||
return macKey;
|
||||
}
|
||||
|
||||
|
||||
public void setCode(String code)
|
||||
{
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
public void setOauthToken(String oauthToken)
|
||||
{
|
||||
public void setOauthToken(String oauthToken) {
|
||||
this.oauthToken = oauthToken;
|
||||
}
|
||||
|
||||
public String getOauthToken()
|
||||
{
|
||||
public String getOauthToken() {
|
||||
return oauthToken;
|
||||
}
|
||||
|
||||
|
||||
public void setOauthTokenSecret(String oauthTokenSecret)
|
||||
{
|
||||
public void setOauthTokenSecret(String oauthTokenSecret) {
|
||||
this.oauthTokenSecret = oauthTokenSecret;
|
||||
}
|
||||
|
||||
public String getOauthTokenSecret()
|
||||
{
|
||||
public String getOauthTokenSecret() {
|
||||
return oauthTokenSecret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("uuid", getUuid())
|
||||
.append("userId", getUserId())
|
||||
.append("source", getSource())
|
||||
.append("accessToken", getAccessToken())
|
||||
.append("expireIn", getExpireIn())
|
||||
.append("refreshToken", getRefreshToken())
|
||||
.append("openId", getOpenId())
|
||||
.append("uid", getUid())
|
||||
.append("accessCode", getAccessCode())
|
||||
.append("unionId", getUnionId())
|
||||
.append("scope", getScope())
|
||||
.append("tokenType", getTokenType())
|
||||
.append("idToken", getIdToken())
|
||||
.append("macAlgorithm", getMacAlgorithm())
|
||||
.append("macKey", getMacKey())
|
||||
.append("code", getCode())
|
||||
.append("oauthToken", getOauthToken())
|
||||
.append("oauthTokenSecret", getOauthTokenSecret())
|
||||
.toString();
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("uuid", getUuid())
|
||||
.append("userId", getUserId())
|
||||
.append("source", getSource())
|
||||
.append("accessToken", getAccessToken())
|
||||
.append("expireIn", getExpireIn())
|
||||
.append("refreshToken", getRefreshToken())
|
||||
.append("openId", getOpenId())
|
||||
.append("uid", getUid())
|
||||
.append("accessCode", getAccessCode())
|
||||
.append("unionId", getUnionId())
|
||||
.append("scope", getScope())
|
||||
.append("tokenType", getTokenType())
|
||||
.append("idToken", getIdToken())
|
||||
.append("macAlgorithm", getMacAlgorithm())
|
||||
.append("macKey", getMacKey())
|
||||
.append("code", getCode())
|
||||
.append("oauthToken", getOauthToken())
|
||||
.append("oauthTokenSecret", getOauthTokenSecret())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
28
ruoyi-oauth/ruoyi-oauth-email/pom.xml
Normal file
28
ruoyi-oauth/ruoyi-oauth-email/pom.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-oauth</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-oauth-email</artifactId>
|
||||
|
||||
<description>
|
||||
邮箱认证模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -12,7 +12,7 @@
|
||||
<artifactId>ruoyi-oauth-justauth</artifactId>
|
||||
|
||||
<description>
|
||||
system系统模块
|
||||
justauth框架认证模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -5,6 +5,7 @@ import java.net.Proxy;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
@ -61,6 +62,7 @@ import me.zhyd.oauth.request.AuthWeiboRequest;
|
||||
import me.zhyd.oauth.request.AuthXmlyRequest;
|
||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||
|
||||
@Service
|
||||
public class OAuthServiceImpl implements OAuthService {
|
||||
|
||||
@Autowired
|
||||
|
34
ruoyi-oauth/ruoyi-oauth-phone/pom.xml
Normal file
34
ruoyi-oauth/ruoyi-oauth-phone/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-oauth</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-oauth-phone</artifactId>
|
||||
|
||||
<description>
|
||||
手机号认证模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>2.0.24</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
package com.ruoyi.oauth.phone.constant;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DySmsConstant {
|
||||
@Value("${oauth.phone.dysms.appId}")
|
||||
private String accessKeyId;
|
||||
@Value("${oauth.phone.dysms.appSecret}")
|
||||
private String accessKeySecret;
|
||||
|
||||
public String getAccessKeyId() {
|
||||
return accessKeyId;
|
||||
}
|
||||
|
||||
public void setAccessKeyId(String accessKeyId) {
|
||||
this.accessKeyId = accessKeyId;
|
||||
}
|
||||
|
||||
public String getAccessKeySecret() {
|
||||
return accessKeySecret;
|
||||
}
|
||||
|
||||
public void setAccessKeySecret(String accessKeySecret) {
|
||||
this.accessKeySecret = accessKeySecret;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.ruoyi.oauth.phone.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oauth/phone")
|
||||
public class DySmsController {
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.ruoyi.oauth.phone.enums;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
public enum DySmsTemplate {
|
||||
/** 登录短信模板编码 */
|
||||
LOGIN_TEMPLATE_CODE("SMS_175435174", "Ruoyi", "code"),
|
||||
/** 忘记密码短信模板编码 */
|
||||
FORGET_PASSWORD_TEMPLATE_CODE("SMS_175435174", "Ruoyi", "code"),
|
||||
/** 测试 */
|
||||
Test_TEMPLATE_CODE("SMS_154950909", "阿里云短信测试", "code");
|
||||
|
||||
/**
|
||||
* 短信模板编码
|
||||
*/
|
||||
private String templateCode;
|
||||
/**
|
||||
* 签名
|
||||
*/
|
||||
private String signName;
|
||||
/**
|
||||
* 短信模板必需的数据名称,多个key以逗号分隔,此处配置作为校验
|
||||
*/
|
||||
private String keys;
|
||||
|
||||
private DySmsTemplate(String templateCode, String signName, String keys) {
|
||||
this.templateCode = templateCode;
|
||||
this.signName = signName;
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public String getTemplateCode() {
|
||||
return templateCode;
|
||||
}
|
||||
|
||||
public void setTemplateCode(String templateCode) {
|
||||
this.templateCode = templateCode;
|
||||
}
|
||||
|
||||
public String getSignName() {
|
||||
return signName;
|
||||
}
|
||||
|
||||
public void setSignName(String signName) {
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
public String getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public void setKeys(String keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public static DySmsTemplate toEnum(String templateCode) {
|
||||
if (StringUtils.isEmpty(templateCode)) {
|
||||
return null;
|
||||
}
|
||||
for (DySmsTemplate item : DySmsTemplate.values()) {
|
||||
if (item.getTemplateCode().equals(templateCode)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.ruoyi.oauth.phone.service;
|
||||
|
||||
public interface DySmsService {
|
||||
public String doLogin(String phone);
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.ruoyi.oauth.phone.service.Impl;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.framework.web.service.UserDetailsServiceImpl;
|
||||
import com.ruoyi.oauth.phone.service.DySmsService;
|
||||
import com.ruoyi.oauth.phone.utils.DySmsUtil;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
@Service
|
||||
public class DySmsServiceImpl implements DySmsService {
|
||||
|
||||
@Autowired
|
||||
private DySmsUtil dySmsUtil;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
@Autowired
|
||||
private UserDetailsServiceImpl userDetailsServiceImpl;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
public static String generateRandomString(int n) {
|
||||
String characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
StringBuilder result = new StringBuilder();
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
int index = random.nextInt(characters.length());
|
||||
result.append(characters.charAt(index));
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doLogin(String phone) {
|
||||
String verify = redisCache.getCacheObject("phone_codes_login" + phone);
|
||||
if(verify != null){
|
||||
throw new ServiceException("该手机号验证码未过期");
|
||||
}
|
||||
String code = generateRandomString(6);
|
||||
SysUser sysUser = userService.selectUserByPhone(phone);
|
||||
if (sysUser == null) {
|
||||
throw new ServiceException("该手机号未绑定用户");
|
||||
}
|
||||
try {
|
||||
dySmsUtil.sendSms(null, null, phone);
|
||||
redisCache.setCacheObject("phone_codes_login" + phone, code, 1, TimeUnit.MINUTES);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public String doLoginVerify(String phone, String code) {
|
||||
String verify = redisCache.getCacheObject("phone_codes_login" + phone);
|
||||
if (code.equals(verify)) {
|
||||
SysUser sysUser = userService.selectUserByPhone(phone);
|
||||
LoginUser loginUser = (LoginUser) userDetailsServiceImpl.createLoginUser(sysUser);
|
||||
return tokenService.createToken(loginUser);
|
||||
} else {
|
||||
throw new ServiceException("验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
public String doRegister(String phone) {
|
||||
String code = generateRandomString(6);
|
||||
redisCache.setCacheObject("phone_codes_register" + phone, code, 1, TimeUnit.MINUTES);
|
||||
String verify = redisCache.getCacheObject("phone_codes_register" + phone);
|
||||
if(verify != null){
|
||||
throw new ServiceException("该手机号验证码未过期");
|
||||
}else{
|
||||
try {
|
||||
dySmsUtil.sendSms(null, null, phone);
|
||||
redisCache.setCacheObject("phone_codes_register" + phone, code, 1, TimeUnit.MINUTES);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.ruoyi.oauth.phone.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.ruoyi.oauth.phone.constant.DySmsConstant;
|
||||
import com.ruoyi.oauth.phone.enums.DySmsTemplate;
|
||||
|
||||
@Component
|
||||
public class DySmsUtil {
|
||||
protected final Logger logger = LoggerFactory.getLogger(DySmsUtil.class);
|
||||
|
||||
@Autowired
|
||||
private DySmsConstant dySmsConfig;
|
||||
|
||||
/**
|
||||
* 使用AK&SK初始化账号Client
|
||||
*
|
||||
* @param accessKeyId
|
||||
* @param accessKeySecret
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
private Client createClient() throws Exception {
|
||||
Config config = new Config()
|
||||
// 必填,您的 AccessKey ID
|
||||
.setAccessKeyId(dySmsConfig.getAccessKeyId())
|
||||
// 必填,您的 AccessKey Secret
|
||||
.setAccessKeySecret(dySmsConfig.getAccessKeySecret());
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
|
||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
return new Client(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证参数
|
||||
*
|
||||
* @param templateParamJson
|
||||
* @param dySmsTemplate
|
||||
* @throws Exception
|
||||
*/
|
||||
private void validateParam(JSONObject templateParamJson, DySmsTemplate dySmsTemplate) {
|
||||
String keys = dySmsTemplate.getKeys();
|
||||
String[] keyArr = keys.split(",");
|
||||
for (String item : keyArr) {
|
||||
if (!templateParamJson.containsKey(item)) {
|
||||
throw new RuntimeException("模板缺少参数:" + item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSms(DySmsTemplate dySmsTemplate, JSONObject templateParamJson, String phone)
|
||||
throws Exception {
|
||||
// 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和
|
||||
// ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey
|
||||
// 的方式进行调用,仅供参考,建议使用更安全的 STS
|
||||
// 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
|
||||
validateParam(templateParamJson, dySmsTemplate);
|
||||
Client client = createClient();
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setPhoneNumbers(phone)
|
||||
.setSignName(dySmsTemplate.getSignName())
|
||||
.setTemplateCode(dySmsTemplate.getTemplateCode())
|
||||
.setTemplateParam(templateParamJson.toJSONString());
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
|
||||
logger.info("短信接口返回的数据----------------");
|
||||
logger.info(sendSmsResponse.toString());
|
||||
} catch (TeaException error) {
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
}
|
68
ruoyi-oauth/ruoyi-oauth-start/pom.xml
Normal file
68
ruoyi-oauth/ruoyi-oauth-start/pom.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-oauth</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-oauth-start</artifactId>
|
||||
|
||||
<description>
|
||||
第三方认证模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 第三方认证通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- justauth通用认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-justauth</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信小程序和公众号认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 手机号认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-phone</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 邮箱认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-oauth-email</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -12,7 +12,7 @@
|
||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||
|
||||
<description>
|
||||
system系统模块
|
||||
微信认证模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -5,16 +5,16 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class WxMiniAppConstant {
|
||||
@Value("${wx.miniapp.appId}")
|
||||
@Value("${oauth.wx.miniapp.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${wx.miniapp.appSecret}")
|
||||
@Value("${oauth.wx.miniapp.appSecret}")
|
||||
private String appSecret;
|
||||
|
||||
@Value("${wx.miniapp.url}")
|
||||
@Value("${oauth.wx.miniapp.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${wx.miniapp.open}")
|
||||
@Value("${oauth.wx.miniapp.open}")
|
||||
private Boolean open;
|
||||
|
||||
public Boolean getOpen() {
|
||||
|
@ -5,16 +5,16 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class WxPubConstant {
|
||||
@Value("${wx.pub.appId}")
|
||||
@Value("${oauth.wx.pub.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${wx.pub.appSecret}")
|
||||
@Value("${oauth.wx.pub.appSecret}")
|
||||
private String appSecret;
|
||||
|
||||
@Value("${wx.pub.url}")
|
||||
@Value("${oauth.wx.pub.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${wx.pub.open}")
|
||||
@Value("${oauth.wx.pub.open}")
|
||||
private Boolean open;
|
||||
|
||||
public String getUrl() {
|
||||
|
@ -18,7 +18,7 @@ import com.ruoyi.oauth.wx.constant.WxPubConstant;
|
||||
import com.ruoyi.oauth.wx.service.Impl.WxLoginServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wx")
|
||||
@RequestMapping("/oauth/wx")
|
||||
public class WxLoginController extends BaseController {
|
||||
@Autowired
|
||||
public WxPubConstant wxH5AppConstant;
|
||||
|
@ -16,7 +16,7 @@
|
||||
</properties>
|
||||
|
||||
<description>
|
||||
第三方认证模块
|
||||
支付模块
|
||||
</description>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@ -27,18 +27,41 @@
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<!-- 收钱吧支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-sqb</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 支付宝支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-alipay</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-wx</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-start</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<modules>
|
||||
<module>ruoyi-pay-sqb</module>
|
||||
<module>ruoyi-pay-alipay</module>
|
||||
<module>ruoyi-pay-wx</module>
|
||||
<module>ruoyi-pay-start</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
28
ruoyi-pay/ruoyi-pay-alipay/pom.xml
Normal file
28
ruoyi-pay/ruoyi-pay-alipay/pom.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-pay</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-pay-alipay</artifactId>
|
||||
|
||||
<description>
|
||||
支付宝支付模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -12,7 +12,7 @@
|
||||
<artifactId>ruoyi-pay-sqb</artifactId>
|
||||
|
||||
<description>
|
||||
system系统模块
|
||||
收钱吧支付模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.ruoyi.pay.sqb.constant;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SqbConstant {
|
||||
@Value("${pay.sqb.apiDomain}")
|
||||
private String apiDomain;
|
||||
|
||||
|
||||
@Value("${pay.sqb.terminalSn}")
|
||||
private String terminalSn;
|
||||
|
||||
@ -15,6 +17,12 @@ public class SqbConstant {
|
||||
@Value("${pay.sqb.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${pay.sqb.vendorSn}")
|
||||
private String vendorSn;
|
||||
|
||||
@Value("${pay.sqb.vendorKey}")
|
||||
private String vendorKey;
|
||||
|
||||
public String getApiDomain() {
|
||||
return apiDomain;
|
||||
}
|
||||
@ -62,10 +70,4 @@ public class SqbConstant {
|
||||
public void setVendorKey(String vendorKey) {
|
||||
this.vendorKey = vendorKey;
|
||||
}
|
||||
|
||||
@Value("${pay.sqb.vendorSn}")
|
||||
private String vendorSn;
|
||||
|
||||
@Value("${pay.sqb.vendorKey}")
|
||||
private String vendorKey;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import com.ruoyi.pay.sqb.utils.HttpUtil;
|
||||
@Service
|
||||
public class SQBServiceImpl {
|
||||
@Autowired
|
||||
SqbConstant sqbConstant;
|
||||
private SqbConstant sqbConstant;
|
||||
|
||||
/**
|
||||
* 计算字符串的MD5值
|
||||
|
46
ruoyi-pay/ruoyi-pay-start/pom.xml
Normal file
46
ruoyi-pay/ruoyi-pay-start/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-pay</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-pay-start</artifactId>
|
||||
|
||||
<description>
|
||||
第三方支付模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 收钱吧支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-sqb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 支付宝支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-alipay</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信支付 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-pay-wx</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
28
ruoyi-pay/ruoyi-pay-wx/pom.xml
Normal file
28
ruoyi-pay/ruoyi-pay-wx/pom.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-pay</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.7.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-pay-wx</artifactId>
|
||||
|
||||
<description>
|
||||
微信支付模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,7 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
|
||||
/**
|
||||
@ -51,6 +53,14 @@ public interface SysUserMapper
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
|
||||
/**
|
||||
@ -8,8 +9,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysUserService
|
||||
{
|
||||
public interface ISysUserService {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@ -50,6 +50,14 @@ public interface ISysUserService
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户所属角色组
|
||||
*
|
||||
@ -131,7 +139,7 @@ public interface ISysUserService
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||
@ -156,7 +164,7 @@ public interface ISysUserService
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean updateUserAvatar(String userName, String avatar);
|
||||
@ -197,9 +205,9 @@ public interface ISysUserService
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
@ -3,13 +3,14 @@ package com.ruoyi.system.service.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import jakarta.validation.Validator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
@ -30,14 +31,15 @@ import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
import jakarta.validation.Validator;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
@ -69,8 +71,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
@ -82,8 +83,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectAllocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||
return userMapper.selectAllocatedList(user);
|
||||
}
|
||||
|
||||
@ -95,8 +95,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||
return userMapper.selectUnallocatedList(user);
|
||||
}
|
||||
|
||||
@ -107,8 +106,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName)
|
||||
{
|
||||
public SysUser selectUserByUserName(String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
@ -119,11 +117,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
public SysUser selectUserById(Long userId) {
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByPhone(String phone) {
|
||||
return userMapper.selectUserByPhone(phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属角色组
|
||||
*
|
||||
@ -131,11 +139,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName)
|
||||
{
|
||||
public String selectUserRoleGroup(String userName) {
|
||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
{
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||
@ -148,11 +154,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserPostGroup(String userName)
|
||||
{
|
||||
public String selectUserPostGroup(String userName) {
|
||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
{
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
||||
@ -165,12 +169,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUserNameUnique(SysUser user)
|
||||
{
|
||||
public boolean checkUserNameUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@ -183,12 +185,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPhoneUnique(SysUser user)
|
||||
{
|
||||
public boolean checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@ -201,12 +201,10 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUser user)
|
||||
{
|
||||
public boolean checkEmailUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@ -218,10 +216,8 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
{
|
||||
public void checkUserAllowed(SysUser user) {
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
@ -232,15 +228,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId)
|
||||
{
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
||||
{
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
if (StringUtils.isEmpty(users))
|
||||
{
|
||||
if (StringUtils.isEmpty(users)) {
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
@ -254,8 +247,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertUser(SysUser user)
|
||||
{
|
||||
public int insertUser(SysUser user) {
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
@ -272,8 +264,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUser user)
|
||||
{
|
||||
public boolean registerUser(SysUser user) {
|
||||
return userMapper.insertUser(user) > 0;
|
||||
}
|
||||
|
||||
@ -285,8 +276,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateUser(SysUser user)
|
||||
{
|
||||
public int updateUser(SysUser user) {
|
||||
Long userId = user.getUserId();
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
@ -302,13 +292,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void insertUserAuth(Long userId, Long[] roleIds)
|
||||
{
|
||||
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
insertUserRole(userId, roleIds);
|
||||
}
|
||||
@ -320,8 +309,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(SysUser user)
|
||||
{
|
||||
public int updateUserStatus(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@ -332,8 +320,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUser user)
|
||||
{
|
||||
public int updateUserProfile(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@ -341,12 +328,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar)
|
||||
{
|
||||
public boolean updateUserAvatar(String userName, String avatar) {
|
||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||
}
|
||||
|
||||
@ -357,8 +343,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwd(SysUser user)
|
||||
{
|
||||
public int resetPwd(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@ -370,8 +355,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password)
|
||||
{
|
||||
public int resetUserPwd(String userName, String password) {
|
||||
return userMapper.resetUserPwd(userName, password);
|
||||
}
|
||||
|
||||
@ -380,8 +364,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserRole(SysUser user)
|
||||
{
|
||||
public void insertUserRole(SysUser user) {
|
||||
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
||||
}
|
||||
|
||||
@ -390,15 +373,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserPost(SysUser user)
|
||||
{
|
||||
public void insertUserPost(SysUser user) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (StringUtils.isNotEmpty(posts))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(posts)) {
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
||||
for (Long postId : posts)
|
||||
{
|
||||
for (Long postId : posts) {
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
up.setPostId(postId);
|
||||
@ -411,17 +391,14 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
public void insertUserRole(Long userId, Long[] roleIds)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(roleIds))
|
||||
{
|
||||
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||
if (StringUtils.isNotEmpty(roleIds)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
||||
for (Long roleId : roleIds)
|
||||
{
|
||||
for (Long roleId : roleIds) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
@ -439,8 +416,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteUserById(Long userId)
|
||||
{
|
||||
public int deleteUserById(Long userId) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 删除用户与岗位表
|
||||
@ -456,10 +432,8 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteUserByIds(Long[] userIds)
|
||||
{
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
public int deleteUserByIds(Long[] userIds) {
|
||||
for (Long userId : userIds) {
|
||||
checkUserAllowed(new SysUser(userId));
|
||||
checkUserDataScope(userId);
|
||||
}
|
||||
@ -473,16 +447,14 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||
throw new ServiceException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
@ -490,23 +462,18 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||
for (SysUser user : userList)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (SysUser user : userList) {
|
||||
try {
|
||||
// 验证是否存在这个用户
|
||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||
if (StringUtils.isNull(u))
|
||||
{
|
||||
if (StringUtils.isNull(u)) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||
user.setCreateBy(operName);
|
||||
userMapper.insertUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||
}
|
||||
else if (isUpdateSupport)
|
||||
{
|
||||
} else if (isUpdateSupport) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
checkUserAllowed(u);
|
||||
checkUserDataScope(u.getUserId());
|
||||
@ -515,28 +482,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
userMapper.updateUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
|
@ -129,6 +129,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.phonenumber = #{phone}
|
||||
</select>
|
||||
|
||||
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||
|
Loading…
Reference in New Issue
Block a user