mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-29 04:51:58 +08:00
[feat] 微信的绑定和解绑
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.6.5.0.2</version>
|
<version>3.6.5.0.3</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依微服务系统</description>
|
<description>若依微服务系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.6.5.0.2</ruoyi.version>
|
<ruoyi.version>3.6.5.0.3</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ 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.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
|
import com.ruoyi.system.service.IKSysUserService;
|
||||||
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;
|
||||||
@@ -46,6 +48,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IKSysUserService kSysUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMapper roleMapper;
|
private SysRoleMapper roleMapper;
|
||||||
|
|
||||||
@@ -324,6 +329,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
userPostMapper.deleteUserPostByUserId(userId);
|
userPostMapper.deleteUserPostByUserId(userId);
|
||||||
// 新增用户与岗位管理
|
// 新增用户与岗位管理
|
||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
|
// 重绑定微信信息
|
||||||
|
if (Objects.nonNull(user.getSysUserAccount()) && Objects.nonNull(user.getSysUserAccount().getWxUnionId())) {
|
||||||
|
kSysUserService.unBindWxUnionIdByUserId(userId);
|
||||||
|
kSysUserService.bindWxUnionIdByUserId(userId, user.getSysUserAccount().getWxUnionId());
|
||||||
|
}
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,5 +24,7 @@ interface KSysUserMapper {
|
|||||||
*/
|
*/
|
||||||
fun checkWxUnionIdUnique(wxUnionId: String): SysUser?
|
fun checkWxUnionIdUnique(wxUnionId: String): SysUser?
|
||||||
|
|
||||||
fun insert(params: Map<String, Any>): Int
|
fun insertSysUserAccount(params: Map<String, Any>): Int
|
||||||
|
|
||||||
|
fun updateSysUserAccount(params: Map<String, Any?>): Int
|
||||||
}
|
}
|
||||||
@@ -28,4 +28,12 @@ interface IKSysUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
fun registerUserByWxUnionId(wxUnionId: String, deptId: Long?): Boolean
|
fun registerUserByWxUnionId(wxUnionId: String, deptId: Long?): Boolean
|
||||||
|
/**
|
||||||
|
* 绑定微信
|
||||||
|
*/
|
||||||
|
fun bindWxUnionIdByUserId(userId: Long,wxUnionId: String): Int
|
||||||
|
/**
|
||||||
|
* 解绑微信
|
||||||
|
*/
|
||||||
|
fun unBindWxUnionIdByUserId(userId: Long): Int
|
||||||
}
|
}
|
||||||
@@ -37,10 +37,38 @@ open class KSysUserServiceImpl : IKSysUserService {
|
|||||||
}
|
}
|
||||||
return sysUserService.registerUser(user).apply {
|
return sysUserService.registerUser(user).apply {
|
||||||
sysUserService.selectUserByUserName(user.userName)
|
sysUserService.selectUserByUserName(user.userName)
|
||||||
kSysUserMapper.insert(mapOf(
|
kSysUserMapper.insertSysUserAccount(
|
||||||
"userId" to user.userId,
|
mapOf(
|
||||||
"wxUnionId" to wxUnionId,
|
"userId" to user.userId,
|
||||||
))
|
"wxUnionId" to wxUnionId,
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun bindWxUnionIdByUserId(userId: Long, wxUnionId: String): Int {
|
||||||
|
if (sysUserService.selectUserById(userId).sysUserAccount != null)
|
||||||
|
return kSysUserMapper.updateSysUserAccount(
|
||||||
|
mapOf(
|
||||||
|
"userId" to userId,
|
||||||
|
"wxUnionId" to wxUnionId,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
return kSysUserMapper.insertSysUserAccount(
|
||||||
|
mapOf(
|
||||||
|
"userId" to userId,
|
||||||
|
"wxUnionId" to wxUnionId,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun unBindWxUnionIdByUserId(userId: Long): Int {
|
||||||
|
return kSysUserMapper.updateSysUserAccount(
|
||||||
|
mapOf(
|
||||||
|
"userId" to userId,
|
||||||
|
"wxUnionId" to null,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select u.user_id, u.user_name from sys_user u left join sys_user_account ua on ua.user_id=u.user_id where ua.wx_unionid = #{wxUnionId} and u.del_flag = '0' limit 1
|
select u.user_id, u.user_name from sys_user u left join sys_user_account ua on ua.user_id=u.user_id where ua.wx_unionid = #{wxUnionId} and u.del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insert">
|
<insert id="insertSysUserAccount">
|
||||||
insert into sys_user_account(user_id, wx_unionid) values (#{userId},#{wxUnionId})
|
insert into sys_user_account(user_id, wx_unionid) values (#{userId},#{wxUnionId})
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="updateSysUserAccount">
|
||||||
|
update sys_user_account set wx_unionid = #{wxUnionId} where user_id = #{userId}
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user