结构更新
This commit is contained in:
parent
bd2af58d80
commit
705747be89
4
pom.xml
4
pom.xml
@ -210,14 +210,14 @@
|
|||||||
<!-- 集成第三方登录 -->
|
<!-- 集成第三方登录 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-oauth</artifactId>
|
<artifactId>ruoyi-oauth-start</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 集成支付 -->
|
<!-- 集成支付 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-pay</artifactId>
|
<artifactId>ruoyi-pay-start</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -55,11 +55,16 @@
|
|||||||
<!-- 集成第三方登录 -->
|
<!-- 集成第三方登录 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
<artifactId>ruoyi-oauth-start</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 在线接口 -->
|
<!-- 集成第三方支付 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-pay-start</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 在线接口 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-online</artifactId>
|
<artifactId>ruoyi-online</artifactId>
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
# 请输入自己的appid和appsecret
|
# 请输入自己的appid和appsecret
|
||||||
wx:
|
oauth:
|
||||||
miniapp:
|
wx:
|
||||||
open: true
|
miniapp:
|
||||||
appId: appId
|
open: true
|
||||||
appSecret: appSecret
|
appId: appId
|
||||||
url: https://api.weixin.qq.com/sns/jscode2session
|
appSecret: appSecret
|
||||||
pub:
|
url: https://api.weixin.qq.com/sns/jscode2session
|
||||||
open: true
|
pub:
|
||||||
appId: appId
|
open: true
|
||||||
appSecret: appSecret
|
appId: appId
|
||||||
url: https://api.weixin.qq.com/sns/oauth2/access_token
|
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
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
active: druid,mybatis,oauth
|
active: druid,mybatis,oauth,pay
|
||||||
# 文件上传
|
# 文件上传
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
@ -82,6 +82,20 @@
|
|||||||
<artifactId>ruoyi-oauth-wx</artifactId>
|
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@ -90,6 +104,9 @@
|
|||||||
<module>ruoyi-oauth-common</module>
|
<module>ruoyi-oauth-common</module>
|
||||||
<module>ruoyi-oauth-justauth</module>
|
<module>ruoyi-oauth-justauth</module>
|
||||||
<module>ruoyi-oauth-wx</module>
|
<module>ruoyi-oauth-wx</module>
|
||||||
|
<module>ruoyi-oauth-phone</module>
|
||||||
|
<module>ruoyi-oauth-email</module>
|
||||||
|
<module>ruoyi-oauth-start</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
</project>
|
</project>
|
@ -15,393 +15,279 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
* @date 2024-01-18
|
* @date 2024-01-18
|
||||||
*/
|
*/
|
||||||
@Schema(description = "第三方认证对象")
|
@Schema(description = "第三方认证对象")
|
||||||
public class OauthUser extends BaseEntity
|
public class OauthUser extends BaseEntity {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
/** 主键 */
|
/** 主键 */
|
||||||
@Schema(defaultValue = "主键")
|
@Schema(defaultValue = "主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方系统的唯一ID,详细解释请参考:名词解释 */
|
/** 第三方系统的唯一ID,详细解释请参考:名词解释 */
|
||||||
@Schema(defaultValue = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
@Schema(defaultValue = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
||||||
@Excel(name = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
@Excel(name = "第三方系统的唯一ID,详细解释请参考:名词解释")
|
||||||
private String uuid;
|
private String uuid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
@Schema(defaultValue = "用户ID")
|
@Schema(defaultValue = "用户ID")
|
||||||
@Excel(name = "用户ID")
|
@Excel(name = "用户ID")
|
||||||
private Long userId;
|
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)")
|
@Schema(defaultValue = "第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)")
|
||||||
@Excel(name = "第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)")
|
@Excel(name = "第三方用户来源,可选值:GITHUB、GITEE、QQ,更多请参考:AuthDefaultSource.java(opens new window)")
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 用户的授权令牌 */
|
/** 用户的授权令牌 */
|
||||||
@Schema(defaultValue = "用户的授权令牌")
|
@Schema(defaultValue = "用户的授权令牌")
|
||||||
@Excel(name = "用户的授权令牌")
|
@Excel(name = "用户的授权令牌")
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方用户的授权令牌的有效期,部分平台可能没有 */
|
/** 第三方用户的授权令牌的有效期,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
@Schema(defaultValue = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
||||||
@Excel(name = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
@Excel(name = "第三方用户的授权令牌的有效期,部分平台可能没有")
|
||||||
private Long expireIn;
|
private Long expireIn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 刷新令牌,部分平台可能没有 */
|
/** 刷新令牌,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "刷新令牌,部分平台可能没有")
|
@Schema(defaultValue = "刷新令牌,部分平台可能没有")
|
||||||
@Excel(name = "刷新令牌,部分平台可能没有")
|
@Excel(name = "刷新令牌,部分平台可能没有")
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方用户的 open id,部分平台可能没有 */
|
/** 第三方用户的 open id,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "第三方用户的 open id,部分平台可能没有")
|
@Schema(defaultValue = "第三方用户的 open id,部分平台可能没有")
|
||||||
@Excel(name = "第三方用户的 open id,部分平台可能没有")
|
@Excel(name = "第三方用户的 open id,部分平台可能没有")
|
||||||
private String openId;
|
private String openId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方用户的 ID,部分平台可能没有 */
|
/** 第三方用户的 ID,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "第三方用户的 ID,部分平台可能没有")
|
@Schema(defaultValue = "第三方用户的 ID,部分平台可能没有")
|
||||||
@Excel(name = "第三方用户的 ID,部分平台可能没有")
|
@Excel(name = "第三方用户的 ID,部分平台可能没有")
|
||||||
private String uid;
|
private String uid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 个别平台的授权信息,部分平台可能没有 */
|
/** 个别平台的授权信息,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
||||||
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
||||||
private String accessCode;
|
private String accessCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方用户的 union id,部分平台可能没有 */
|
/** 第三方用户的 union id,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "第三方用户的 union id,部分平台可能没有")
|
@Schema(defaultValue = "第三方用户的 union id,部分平台可能没有")
|
||||||
@Excel(name = "第三方用户的 union id,部分平台可能没有")
|
@Excel(name = "第三方用户的 union id,部分平台可能没有")
|
||||||
private String unionId;
|
private String unionId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 第三方用户授予的权限,部分平台可能没有 */
|
/** 第三方用户授予的权限,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "第三方用户授予的权限,部分平台可能没有")
|
@Schema(defaultValue = "第三方用户授予的权限,部分平台可能没有")
|
||||||
@Excel(name = "第三方用户授予的权限,部分平台可能没有")
|
@Excel(name = "第三方用户授予的权限,部分平台可能没有")
|
||||||
private String scope;
|
private String scope;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 个别平台的授权信息,部分平台可能没有 */
|
/** 个别平台的授权信息,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
@Schema(defaultValue = "个别平台的授权信息,部分平台可能没有")
|
||||||
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
@Excel(name = "个别平台的授权信息,部分平台可能没有")
|
||||||
private String tokenType;
|
private String tokenType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** id token,部分平台可能没有 */
|
/** id token,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "id token,部分平台可能没有")
|
@Schema(defaultValue = "id token,部分平台可能没有")
|
||||||
@Excel(name = "id token,部分平台可能没有")
|
@Excel(name = "id token,部分平台可能没有")
|
||||||
private String idToken;
|
private String idToken;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 小米平台用户的附带属性,部分平台可能没有 */
|
/** 小米平台用户的附带属性,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
||||||
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
||||||
private String macAlgorithm;
|
private String macAlgorithm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 小米平台用户的附带属性,部分平台可能没有 */
|
/** 小米平台用户的附带属性,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
@Schema(defaultValue = "小米平台用户的附带属性,部分平台可能没有")
|
||||||
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
@Excel(name = "小米平台用户的附带属性,部分平台可能没有")
|
||||||
private String macKey;
|
private String macKey;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 用户的授权code,部分平台可能没有 */
|
/** 用户的授权code,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "用户的授权code,部分平台可能没有")
|
@Schema(defaultValue = "用户的授权code,部分平台可能没有")
|
||||||
@Excel(name = "用户的授权code,部分平台可能没有")
|
@Excel(name = "用户的授权code,部分平台可能没有")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||||
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||||
private String oauthToken;
|
private String oauthToken;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
/** Twitter平台用户的附带属性,部分平台可能没有 */
|
||||||
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
@Schema(defaultValue = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||||
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
@Excel(name = "Twitter平台用户的附带属性,部分平台可能没有")
|
||||||
private String oauthTokenSecret;
|
private String oauthTokenSecret;
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
|
||||||
public void setId(Long id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId()
|
public Long getId() {
|
||||||
{
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUuid(String uuid) {
|
||||||
public void setUuid(String uuid)
|
|
||||||
{
|
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUuid()
|
public String getUuid() {
|
||||||
{
|
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUserId(Long userId) {
|
||||||
public void setUserId(Long userId)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUserId()
|
public Long getUserId() {
|
||||||
{
|
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
public void setSource(String source)
|
|
||||||
{
|
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource()
|
public String getSource() {
|
||||||
{
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
public void setAccessToken(String accessToken)
|
|
||||||
{
|
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessToken()
|
public String getAccessToken() {
|
||||||
{
|
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExpireIn(Long expireIn) {
|
||||||
public void setExpireIn(Long expireIn)
|
|
||||||
{
|
|
||||||
this.expireIn = expireIn;
|
this.expireIn = expireIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getExpireIn()
|
public Long getExpireIn() {
|
||||||
{
|
|
||||||
return expireIn;
|
return expireIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRefreshToken(String refreshToken) {
|
||||||
public void setRefreshToken(String refreshToken)
|
|
||||||
{
|
|
||||||
this.refreshToken = refreshToken;
|
this.refreshToken = refreshToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRefreshToken()
|
public String getRefreshToken() {
|
||||||
{
|
|
||||||
return refreshToken;
|
return refreshToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOpenId(String openId) {
|
||||||
public void setOpenId(String openId)
|
|
||||||
{
|
|
||||||
this.openId = openId;
|
this.openId = openId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpenId()
|
public String getOpenId() {
|
||||||
{
|
|
||||||
return openId;
|
return openId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUid(String uid) {
|
||||||
public void setUid(String uid)
|
|
||||||
{
|
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUid()
|
public String getUid() {
|
||||||
{
|
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAccessCode(String accessCode) {
|
||||||
public void setAccessCode(String accessCode)
|
|
||||||
{
|
|
||||||
this.accessCode = accessCode;
|
this.accessCode = accessCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessCode()
|
public String getAccessCode() {
|
||||||
{
|
|
||||||
return accessCode;
|
return accessCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnionId(String unionId) {
|
||||||
public void setUnionId(String unionId)
|
|
||||||
{
|
|
||||||
this.unionId = unionId;
|
this.unionId = unionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnionId()
|
public String getUnionId() {
|
||||||
{
|
|
||||||
return unionId;
|
return unionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setScope(String scope) {
|
||||||
public void setScope(String scope)
|
|
||||||
{
|
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getScope()
|
public String getScope() {
|
||||||
{
|
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTokenType(String tokenType) {
|
||||||
public void setTokenType(String tokenType)
|
|
||||||
{
|
|
||||||
this.tokenType = tokenType;
|
this.tokenType = tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTokenType()
|
public String getTokenType() {
|
||||||
{
|
|
||||||
return tokenType;
|
return tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIdToken(String idToken) {
|
||||||
public void setIdToken(String idToken)
|
|
||||||
{
|
|
||||||
this.idToken = idToken;
|
this.idToken = idToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdToken()
|
public String getIdToken() {
|
||||||
{
|
|
||||||
return idToken;
|
return idToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMacAlgorithm(String macAlgorithm) {
|
||||||
public void setMacAlgorithm(String macAlgorithm)
|
|
||||||
{
|
|
||||||
this.macAlgorithm = macAlgorithm;
|
this.macAlgorithm = macAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMacAlgorithm()
|
public String getMacAlgorithm() {
|
||||||
{
|
|
||||||
return macAlgorithm;
|
return macAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMacKey(String macKey) {
|
||||||
public void setMacKey(String macKey)
|
|
||||||
{
|
|
||||||
this.macKey = macKey;
|
this.macKey = macKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMacKey()
|
public String getMacKey() {
|
||||||
{
|
|
||||||
return macKey;
|
return macKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
public void setCode(String code)
|
|
||||||
{
|
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode()
|
public String getCode() {
|
||||||
{
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOauthToken(String oauthToken) {
|
||||||
public void setOauthToken(String oauthToken)
|
|
||||||
{
|
|
||||||
this.oauthToken = oauthToken;
|
this.oauthToken = oauthToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOauthToken()
|
public String getOauthToken() {
|
||||||
{
|
|
||||||
return oauthToken;
|
return oauthToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOauthTokenSecret(String oauthTokenSecret) {
|
||||||
public void setOauthTokenSecret(String oauthTokenSecret)
|
|
||||||
{
|
|
||||||
this.oauthTokenSecret = oauthTokenSecret;
|
this.oauthTokenSecret = oauthTokenSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOauthTokenSecret()
|
public String getOauthTokenSecret() {
|
||||||
{
|
|
||||||
return oauthTokenSecret;
|
return oauthTokenSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
.append("uuid", getUuid())
|
.append("uuid", getUuid())
|
||||||
.append("userId", getUserId())
|
.append("userId", getUserId())
|
||||||
.append("source", getSource())
|
.append("source", getSource())
|
||||||
.append("accessToken", getAccessToken())
|
.append("accessToken", getAccessToken())
|
||||||
.append("expireIn", getExpireIn())
|
.append("expireIn", getExpireIn())
|
||||||
.append("refreshToken", getRefreshToken())
|
.append("refreshToken", getRefreshToken())
|
||||||
.append("openId", getOpenId())
|
.append("openId", getOpenId())
|
||||||
.append("uid", getUid())
|
.append("uid", getUid())
|
||||||
.append("accessCode", getAccessCode())
|
.append("accessCode", getAccessCode())
|
||||||
.append("unionId", getUnionId())
|
.append("unionId", getUnionId())
|
||||||
.append("scope", getScope())
|
.append("scope", getScope())
|
||||||
.append("tokenType", getTokenType())
|
.append("tokenType", getTokenType())
|
||||||
.append("idToken", getIdToken())
|
.append("idToken", getIdToken())
|
||||||
.append("macAlgorithm", getMacAlgorithm())
|
.append("macAlgorithm", getMacAlgorithm())
|
||||||
.append("macKey", getMacKey())
|
.append("macKey", getMacKey())
|
||||||
.append("code", getCode())
|
.append("code", getCode())
|
||||||
.append("oauthToken", getOauthToken())
|
.append("oauthToken", getOauthToken())
|
||||||
.append("oauthTokenSecret", getOauthTokenSecret())
|
.append("oauthTokenSecret", getOauthTokenSecret())
|
||||||
.toString();
|
.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>
|
<artifactId>ruoyi-oauth-justauth</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
system系统模块
|
justauth框架认证模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -5,6 +5,7 @@ import java.net.Proxy;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
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.request.AuthXmlyRequest;
|
||||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||||
|
|
||||||
|
@Service
|
||||||
public class OAuthServiceImpl implements OAuthService {
|
public class OAuthServiceImpl implements OAuthService {
|
||||||
|
|
||||||
@Autowired
|
@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>
|
<artifactId>ruoyi-oauth-wx</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
system系统模块
|
微信认证模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -5,16 +5,16 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class WxMiniAppConstant {
|
public class WxMiniAppConstant {
|
||||||
@Value("${wx.miniapp.appId}")
|
@Value("${oauth.wx.miniapp.appId}")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
@Value("${wx.miniapp.appSecret}")
|
@Value("${oauth.wx.miniapp.appSecret}")
|
||||||
private String appSecret;
|
private String appSecret;
|
||||||
|
|
||||||
@Value("${wx.miniapp.url}")
|
@Value("${oauth.wx.miniapp.url}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Value("${wx.miniapp.open}")
|
@Value("${oauth.wx.miniapp.open}")
|
||||||
private Boolean open;
|
private Boolean open;
|
||||||
|
|
||||||
public Boolean getOpen() {
|
public Boolean getOpen() {
|
||||||
|
@ -5,16 +5,16 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class WxPubConstant {
|
public class WxPubConstant {
|
||||||
@Value("${wx.pub.appId}")
|
@Value("${oauth.wx.pub.appId}")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
@Value("${wx.pub.appSecret}")
|
@Value("${oauth.wx.pub.appSecret}")
|
||||||
private String appSecret;
|
private String appSecret;
|
||||||
|
|
||||||
@Value("${wx.pub.url}")
|
@Value("${oauth.wx.pub.url}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Value("${wx.pub.open}")
|
@Value("${oauth.wx.pub.open}")
|
||||||
private Boolean open;
|
private Boolean open;
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
@ -18,7 +18,7 @@ import com.ruoyi.oauth.wx.constant.WxPubConstant;
|
|||||||
import com.ruoyi.oauth.wx.service.Impl.WxLoginServiceImpl;
|
import com.ruoyi.oauth.wx.service.Impl.WxLoginServiceImpl;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wx")
|
@RequestMapping("/oauth/wx")
|
||||||
public class WxLoginController extends BaseController {
|
public class WxLoginController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
public WxPubConstant wxH5AppConstant;
|
public WxPubConstant wxH5AppConstant;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
第三方认证模块
|
支付模块
|
||||||
</description>
|
</description>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -27,18 +27,41 @@
|
|||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 通用工具-->
|
<!-- 收钱吧支付 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-pay-sqb</artifactId>
|
<artifactId>ruoyi-pay-sqb</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>ruoyi-pay-sqb</module>
|
<module>ruoyi-pay-sqb</module>
|
||||||
|
<module>ruoyi-pay-alipay</module>
|
||||||
|
<module>ruoyi-pay-wx</module>
|
||||||
|
<module>ruoyi-pay-start</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
</project>
|
</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>
|
<artifactId>ruoyi-pay-sqb</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
system系统模块
|
收钱吧支付模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.pay.sqb.constant;
|
package com.ruoyi.pay.sqb.constant;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SqbConstant {
|
public class SqbConstant {
|
||||||
@Value("${pay.sqb.apiDomain}")
|
@Value("${pay.sqb.apiDomain}")
|
||||||
@ -15,6 +17,12 @@ public class SqbConstant {
|
|||||||
@Value("${pay.sqb.appId}")
|
@Value("${pay.sqb.appId}")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
|
@Value("${pay.sqb.vendorSn}")
|
||||||
|
private String vendorSn;
|
||||||
|
|
||||||
|
@Value("${pay.sqb.vendorKey}")
|
||||||
|
private String vendorKey;
|
||||||
|
|
||||||
public String getApiDomain() {
|
public String getApiDomain() {
|
||||||
return apiDomain;
|
return apiDomain;
|
||||||
}
|
}
|
||||||
@ -62,10 +70,4 @@ public class SqbConstant {
|
|||||||
public void setVendorKey(String vendorKey) {
|
public void setVendorKey(String vendorKey) {
|
||||||
this.vendorKey = 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
|
@Service
|
||||||
public class SQBServiceImpl {
|
public class SQBServiceImpl {
|
||||||
@Autowired
|
@Autowired
|
||||||
SqbConstant sqbConstant;
|
private SqbConstant sqbConstant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算字符串的MD5值
|
* 计算字符串的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;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,6 +53,14 @@ public interface SysUserMapper
|
|||||||
*/
|
*/
|
||||||
public SysUser selectUserById(Long userId);
|
public SysUser selectUserById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号查询用户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
public SysUser selectUserByPhone(String phone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户信息
|
* 新增用户信息
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,8 +9,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface ISysUserService
|
public interface ISysUserService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
@ -50,6 +50,14 @@ public interface ISysUserService
|
|||||||
*/
|
*/
|
||||||
public SysUser selectUserById(Long userId);
|
public SysUser selectUserById(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号查询用户
|
||||||
|
*
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return 用户对象信息
|
||||||
|
*/
|
||||||
|
public SysUser selectUserByPhone(String phone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询用户所属角色组
|
* 根据用户ID查询用户所属角色组
|
||||||
*
|
*
|
||||||
@ -131,7 +139,7 @@ public interface ISysUserService
|
|||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserAuth(Long userId, Long[] roleIds);
|
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||||
@ -156,7 +164,7 @@ public interface ISysUserService
|
|||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @param avatar 头像地址
|
* @param avatar 头像地址
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public boolean updateUserAvatar(String userName, String avatar);
|
public boolean updateUserAvatar(String userName, String avatar);
|
||||||
@ -197,9 +205,9 @@ public interface ISysUserService
|
|||||||
/**
|
/**
|
||||||
* 导入用户数据
|
* 导入用户数据
|
||||||
*
|
*
|
||||||
* @param userList 用户数据列表
|
* @param userList 用户数据列表
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||||
* @param operName 操作用户
|
* @param operName 操作用户
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import jakarta.validation.Validator;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
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.ISysConfigService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
|
import jakarta.validation.Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 业务层处理
|
* 用户 业务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysUserServiceImpl implements ISysUserService
|
public class SysUserServiceImpl implements ISysUserService {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -69,8 +71,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectUserList(SysUser user)
|
public List<SysUser> selectUserList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectUserList(user);
|
return userMapper.selectUserList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +83,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectAllocatedList(SysUser user)
|
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectAllocatedList(user);
|
return userMapper.selectAllocatedList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,8 +95,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectUnallocatedList(user);
|
return userMapper.selectUnallocatedList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +106,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserByUserName(String userName)
|
public SysUser selectUserByUserName(String userName) {
|
||||||
{
|
|
||||||
return userMapper.selectUserByUserName(userName);
|
return userMapper.selectUserByUserName(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,11 +117,21 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserById(Long userId)
|
public SysUser selectUserById(Long userId) {
|
||||||
{
|
|
||||||
return userMapper.selectUserById(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 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectUserRoleGroup(String userName)
|
public String selectUserRoleGroup(String userName) {
|
||||||
{
|
|
||||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||||
if (CollectionUtils.isEmpty(list))
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||||
@ -148,11 +154,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectUserPostGroup(String userName)
|
public String selectUserPostGroup(String userName) {
|
||||||
{
|
|
||||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||||
if (CollectionUtils.isEmpty(list))
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
||||||
@ -165,12 +169,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkUserNameUnique(SysUser user)
|
public boolean checkUserNameUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
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.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -183,12 +185,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkPhoneUnique(SysUser user)
|
public boolean checkPhoneUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
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.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -201,12 +201,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEmailUnique(SysUser user)
|
public boolean checkEmailUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
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.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -218,10 +216,8 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserAllowed(SysUser user)
|
public void checkUserAllowed(SysUser user) {
|
||||||
{
|
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
|
||||||
{
|
|
||||||
throw new ServiceException("不允许操作超级管理员用户");
|
throw new ServiceException("不允许操作超级管理员用户");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,15 +228,12 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserDataScope(Long userId)
|
public void checkUserDataScope(Long userId) {
|
||||||
{
|
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
|
||||||
{
|
|
||||||
SysUser user = new SysUser();
|
SysUser user = new SysUser();
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||||
if (StringUtils.isEmpty(users))
|
if (StringUtils.isEmpty(users)) {
|
||||||
{
|
|
||||||
throw new ServiceException("没有权限访问用户数据!");
|
throw new ServiceException("没有权限访问用户数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,8 +247,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int insertUser(SysUser user)
|
public int insertUser(SysUser user) {
|
||||||
{
|
|
||||||
// 新增用户信息
|
// 新增用户信息
|
||||||
int rows = userMapper.insertUser(user);
|
int rows = userMapper.insertUser(user);
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
@ -272,8 +264,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean registerUser(SysUser user)
|
public boolean registerUser(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.insertUser(user) > 0;
|
return userMapper.insertUser(user) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +276,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int updateUser(SysUser user)
|
public int updateUser(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = user.getUserId();
|
Long userId = user.getUserId();
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
@ -302,13 +292,12 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void insertUserAuth(Long userId, Long[] roleIds)
|
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||||
{
|
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
insertUserRole(userId, roleIds);
|
insertUserRole(userId, roleIds);
|
||||||
}
|
}
|
||||||
@ -320,8 +309,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateUserStatus(SysUser user)
|
public int updateUserStatus(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,8 +320,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateUserProfile(SysUser user)
|
public int updateUserProfile(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,12 +328,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @param avatar 头像地址
|
* @param avatar 头像地址
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean updateUserAvatar(String userName, String avatar)
|
public boolean updateUserAvatar(String userName, String avatar) {
|
||||||
{
|
|
||||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,8 +343,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int resetPwd(SysUser user)
|
public int resetPwd(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,8 +355,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int resetUserPwd(String userName, String password)
|
public int resetUserPwd(String userName, String password) {
|
||||||
{
|
|
||||||
return userMapper.resetUserPwd(userName, password);
|
return userMapper.resetUserPwd(userName, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,8 +364,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*
|
*
|
||||||
* @param user 用户对象
|
* @param user 用户对象
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(SysUser user)
|
public void insertUserRole(SysUser user) {
|
||||||
{
|
|
||||||
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,15 +373,12 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*
|
*
|
||||||
* @param user 用户对象
|
* @param user 用户对象
|
||||||
*/
|
*/
|
||||||
public void insertUserPost(SysUser user)
|
public void insertUserPost(SysUser user) {
|
||||||
{
|
|
||||||
Long[] posts = user.getPostIds();
|
Long[] posts = user.getPostIds();
|
||||||
if (StringUtils.isNotEmpty(posts))
|
if (StringUtils.isNotEmpty(posts)) {
|
||||||
{
|
|
||||||
// 新增用户与岗位管理
|
// 新增用户与岗位管理
|
||||||
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
||||||
for (Long postId : posts)
|
for (Long postId : posts) {
|
||||||
{
|
|
||||||
SysUserPost up = new SysUserPost();
|
SysUserPost up = new SysUserPost();
|
||||||
up.setUserId(user.getUserId());
|
up.setUserId(user.getUserId());
|
||||||
up.setPostId(postId);
|
up.setPostId(postId);
|
||||||
@ -411,17 +391,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
/**
|
/**
|
||||||
* 新增用户角色信息
|
* 新增用户角色信息
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(Long userId, Long[] roleIds)
|
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||||
{
|
if (StringUtils.isNotEmpty(roleIds)) {
|
||||||
if (StringUtils.isNotEmpty(roleIds))
|
|
||||||
{
|
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
||||||
for (Long roleId : roleIds)
|
for (Long roleId : roleIds) {
|
||||||
{
|
|
||||||
SysUserRole ur = new SysUserRole();
|
SysUserRole ur = new SysUserRole();
|
||||||
ur.setUserId(userId);
|
ur.setUserId(userId);
|
||||||
ur.setRoleId(roleId);
|
ur.setRoleId(roleId);
|
||||||
@ -439,8 +416,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int deleteUserById(Long userId)
|
public int deleteUserById(Long userId) {
|
||||||
{
|
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
// 删除用户与岗位表
|
// 删除用户与岗位表
|
||||||
@ -456,10 +432,8 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int deleteUserByIds(Long[] userIds)
|
public int deleteUserByIds(Long[] userIds) {
|
||||||
{
|
for (Long userId : userIds) {
|
||||||
for (Long userId : userIds)
|
|
||||||
{
|
|
||||||
checkUserAllowed(new SysUser(userId));
|
checkUserAllowed(new SysUser(userId));
|
||||||
checkUserDataScope(userId);
|
checkUserDataScope(userId);
|
||||||
}
|
}
|
||||||
@ -473,16 +447,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
/**
|
/**
|
||||||
* 导入用户数据
|
* 导入用户数据
|
||||||
*
|
*
|
||||||
* @param userList 用户数据列表
|
* @param userList 用户数据列表
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||||
* @param operName 操作用户
|
* @param operName 操作用户
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
|
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
||||||
{
|
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
|
||||||
{
|
|
||||||
throw new ServiceException("导入用户数据不能为空!");
|
throw new ServiceException("导入用户数据不能为空!");
|
||||||
}
|
}
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
@ -490,23 +462,18 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
StringBuilder successMsg = new StringBuilder();
|
StringBuilder successMsg = new StringBuilder();
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||||
for (SysUser user : userList)
|
for (SysUser user : userList) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
// 验证是否存在这个用户
|
// 验证是否存在这个用户
|
||||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||||
if (StringUtils.isNull(u))
|
if (StringUtils.isNull(u)) {
|
||||||
{
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
BeanValidators.validateWithException(validator, user);
|
||||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||||
user.setCreateBy(operName);
|
user.setCreateBy(operName);
|
||||||
userMapper.insertUser(user);
|
userMapper.insertUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||||
}
|
} else if (isUpdateSupport) {
|
||||||
else if (isUpdateSupport)
|
|
||||||
{
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
BeanValidators.validateWithException(validator, user);
|
||||||
checkUserAllowed(u);
|
checkUserAllowed(u);
|
||||||
checkUserDataScope(u.getUserId());
|
checkUserDataScope(u.getUserId());
|
||||||
@ -515,28 +482,21 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
userMapper.updateUser(user);
|
userMapper.updateUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
failureNum++;
|
failureNum++;
|
||||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
failureNum++;
|
failureNum++;
|
||||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0) {
|
||||||
{
|
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
throw new ServiceException(failureMsg.toString());
|
throw new ServiceException(failureMsg.toString());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
}
|
}
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
|
@ -130,6 +130,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where u.user_id = #{userId}
|
where u.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.phonenumber = #{phone}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
<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
|
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user