Commit f9ce9d5c by 杨林龙

开发1.29.0 修改删除web端用户没有删除小程序相关数据的问题

1 parent cefebeb7
...@@ -3,7 +3,13 @@ package cn.com.glsx.shield.modules.mapper; ...@@ -3,7 +3,13 @@ package cn.com.glsx.shield.modules.mapper;
import cn.com.glsx.shield.modules.entity.CustUserAuthRel; import cn.com.glsx.shield.modules.entity.CustUserAuthRel;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface CustUserAuthRelMapper extends CommonBaseMapper<CustUserAuthRel> { public interface CustUserAuthRelMapper extends CommonBaseMapper<CustUserAuthRel> {
void logicDeleteByUserId(@Param("userId") Long userId);
List<CustUserAuthRel> selectByUserId(@Param("userId") Long userId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -16,4 +16,5 @@ public interface CustUserLocalAccountMapper extends CommonBaseMapper<CustUserLoc ...@@ -16,4 +16,5 @@ public interface CustUserLocalAccountMapper extends CommonBaseMapper<CustUserLoc
List<CUser> selectByRelUserIds(@Param("relUserIds") Collection<Long> relUserIds); List<CUser> selectByRelUserIds(@Param("relUserIds") Collection<Long> relUserIds);
void logicDeleteByAuthIds(@Param("authIds") List<Long> authIds);
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,12 @@ package cn.com.glsx.shield.modules.mapper; ...@@ -3,7 +3,12 @@ package cn.com.glsx.shield.modules.mapper;
import cn.com.glsx.shield.modules.entity.CustUserLocalAuth; import cn.com.glsx.shield.modules.entity.CustUserLocalAuth;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.stream.Stream;
@Mapper @Mapper
public interface CustUserLocalAuthMapper extends CommonBaseMapper<CustUserLocalAuth> { public interface CustUserLocalAuthMapper extends CommonBaseMapper<CustUserLocalAuth> {
void logicDeleteByAuthIds(@Param("authIds") List<Long> authIds);
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,22 @@ package cn.com.glsx.shield.modules.mapper; ...@@ -3,7 +3,22 @@ package cn.com.glsx.shield.modules.mapper;
import cn.com.glsx.shield.modules.entity.CustUser; import cn.com.glsx.shield.modules.entity.CustUser;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface CustUserMapper extends CommonBaseMapper<CustUser> { public interface CustUserMapper extends CommonBaseMapper<CustUser> {
/**
* 根据关联用户id查询用户信息
*
* @param relUserId 关联ID
* @return
*/
CustUser selectByRelUserId(@Param("relUserId") Long relUserId);
/**
* 根据id删除用户
*
* @param relUserId 关联ID
*/
void logicDeleteByRelUserId(@Param("relUserId") Long relUserId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -27,6 +27,7 @@ import cn.hutool.json.JSONUtil; ...@@ -27,6 +27,7 @@ import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.neshield.modules.mapper.CustUserMapper;
import com.glsx.plat.common.utils.ObjectUtils; import com.glsx.plat.common.utils.ObjectUtils;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.enums.SysConstants; import com.glsx.plat.core.enums.SysConstants;
...@@ -99,6 +100,18 @@ public class UserService { ...@@ -99,6 +100,18 @@ public class UserService {
@Resource @Resource
private DepartmentService departmentService; private DepartmentService departmentService;
@Autowired
private CustUserMapper custUserMapper;
@Autowired
private CustUserAuthRelMapper custUserAuthRelMapper;
@Autowired
private CustUserLocalAccountMapper custUserLocalAccountMapper;
@Autowired
private CustUserLocalAuthMapper custUserLocalAuthMapper;
private static SuperTreeModel applySuperTreeModel(Department dept) { private static SuperTreeModel applySuperTreeModel(Department dept) {
SuperTreeModel model = new SuperTreeModel(); SuperTreeModel model = new SuperTreeModel();
model.setId(dept.getId()); model.setId(dept.getId());
...@@ -212,10 +225,32 @@ public class UserService { ...@@ -212,10 +225,32 @@ public class UserService {
throw new UserCenterException(SystemMessage.FAILURE.getCode(), "该用户存在下级用户,请移除这部分用户后再重试"); throw new UserCenterException(SystemMessage.FAILURE.getCode(), "该用户存在下级用户,请移除这部分用户后再重试");
} }
userPathMapper.deleteUserAllPath(id); userPathMapper.deleteUserAllPath(id);
logicDeleteMiniById(id);
return userMapper.logicDeleteById(id); return userMapper.logicDeleteById(id);
} }
private void logicDeleteMiniById(Long id) {
// 删除 t_cust_user 中数据
CustUser custUser = custUserMapper.selectByRelUserId(id);
if (Objects.isNull(custUser)) {
log.warn("logicDeleteMiniById==" + id + "==custUser is null");
return;
}
// 删除用户
custUserMapper.logicDeleteByRelUserId(id);
// 通过userId获取authId
List<CustUserAuthRel> custUserAuthRels = custUserAuthRelMapper.selectByUserId(custUser.getId());
// 删除 t_cust_user_auth_rel 中数据
custUserAuthRelMapper.logicDeleteByUserId(custUser.getId());
// 删除 t_cust_user_local_account 中数据
if (CollectionUtils.isNotEmpty(custUserAuthRels)) {
List<Long> authIds = custUserAuthRels.stream().map(CustUserAuthRel::getAuthId).collect(Collectors.toList());
custUserLocalAccountMapper.logicDeleteByAuthIds(authIds);
// 删除 t_cust_user_local_auth 中数据
custUserLocalAuthMapper.logicDeleteByAuthIds(authIds);
}
}
public PageInfo<UserDTO> search(UserSearch search) { public PageInfo<UserDTO> search(UserSearch search) {
Page page = null; Page page = null;
......
...@@ -22,4 +22,18 @@ ...@@ -22,4 +22,18 @@
id, user_id, auth_id, auth_type, del_flag, created_date, created_by, updated_date, id, user_id, auth_id, auth_type, del_flag, created_date, created_by, updated_date,
updated_by updated_by
</sql> </sql>
<update id="logicDeleteByUserId">
update t_cust_user_auth_rel
set del_flag = -1
where user_id = #{userId}
and del_flag = 0
</update>
<select id="selectByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_cust_user_auth_rel
where user_id = #{userId}
and del_flag = 0
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -24,6 +24,15 @@ ...@@ -24,6 +24,15 @@
updated_by updated_by
</sql> </sql>
<update id="logicDeleteByAuthIds">
update t_cust_user_local_account
set del_flag = -1
where auth_id in
<foreach collection="authIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<select id="selectByUserIds" resultType="cn.com.glsx.usercenter.api.dto.response.CUser"> <select id="selectByUserIds" resultType="cn.com.glsx.usercenter.api.dto.response.CUser">
select tcuar.user_id userId, tcu.rel_user_id relUserId, tcula.account, tcula2.username, tcula2.avatar select tcuar.user_id userId, tcu.rel_user_id relUserId, tcula.account, tcula2.username, tcula2.avatar
from t_cust_user_auth_rel tcuar from t_cust_user_auth_rel tcuar
......
...@@ -20,4 +20,13 @@ ...@@ -20,4 +20,13 @@
--> -->
id, account, `password`, del_flag, created_date, created_by, updated_date, updated_by id, account, `password`, del_flag, created_date, created_by, updated_date, updated_by
</sql> </sql>
<update id="logicDeleteByAuthIds">
update t_cust_user_local_auth
set del_flag = -1
where id in
<foreach collection="authIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -24,4 +24,18 @@ ...@@ -24,4 +24,18 @@
id, token, expire_in, try_times, rel_user_id, blacklist, del_flag, created_date, id, token, expire_in, try_times, rel_user_id, blacklist, del_flag, created_date,
created_by, updated_date, updated_by created_by, updated_date, updated_by
</sql> </sql>
<update id="logicDeleteByRelUserId">
update t_cust_user
set del_flag = -1
where rel_user_id = #{relUserId}
</update>
<select id="selectByRelUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_cust_user
where rel_user_id = #{relUserId}
and del_flag =0
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!