mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-26 19:51:56 +08:00
[feat] 微信的绑定和解绑
This commit is contained in:
@@ -2,10 +2,12 @@ package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.ruoyi.system.service.IKSysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -46,6 +48,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private IKSysUserService kSysUserService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@@ -324,6 +329,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,5 +24,7 @@ interface KSysUserMapper {
|
||||
*/
|
||||
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 结果
|
||||
*/
|
||||
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 {
|
||||
sysUserService.selectUserByUserName(user.userName)
|
||||
kSysUserMapper.insert(mapOf(
|
||||
"userId" to user.userId,
|
||||
"wxUnionId" to wxUnionId,
|
||||
))
|
||||
kSysUserMapper.insertSysUserAccount(
|
||||
mapOf(
|
||||
"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>
|
||||
|
||||
<insert id="insert">
|
||||
<insert id="insertSysUserAccount">
|
||||
insert into sys_user_account(user_id, wx_unionid) values (#{userId},#{wxUnionId})
|
||||
</insert>
|
||||
<insert id="updateSysUserAccount">
|
||||
update sys_user_account set wx_unionid = #{wxUnionId} where user_id = #{userId}
|
||||
</insert>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user