删除用户时删除用户与仪器的绑定记录、并解绑序列号

master
382696293@qq.com 2 years ago
parent b9d11f1798
commit 070362680f

@ -59,4 +59,6 @@ public interface WxUserInstrumentLogMapper
* @return
*/
public int deleteWxUserInstrumentLogByIds(Long[] ids);
void deleteByUserId(Long userId);
}

@ -1,6 +1,7 @@
package com.flossom.common.core.mapper;
import com.flossom.common.core.domain.entity.WxUserInstrument;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -63,4 +64,6 @@ public interface WxUserInstrumentMapper
Integer selectUiByInstrumentId(WxUserInstrument wxUserInstrument);
List<WxUserInstrument> selectListByUserIdAndInstrumentId(WxUserInstrument wxUserInstrument);
void deleteByUserId(@Param("userId") Long userId);
}

@ -107,4 +107,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<delete id="deleteByUserId" parameterType="Long">
delete from wx_user_instrument_log where user_id = #{userId}
</delete>
</mapper>

@ -160,6 +160,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from wx_user_instrument where id = #{id}
</delete>
<delete id="deleteByUserId" parameterType="Long">
delete from wx_user_instrument where user_id = #{userId}
</delete>
<delete id="deleteWxUserInstrumentByIds" parameterType="String">
delete from wx_user_instrument where id in
<foreach item="id" collection="array" open="(" separator="," close=")">

@ -64,6 +64,12 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
@Autowired
private WxUserInstrumentMapper wxUserInstrumentMapper;
@Autowired
private WxUserInstrumentLogMapper wxUserInstrumentLogMapper;
@Autowired
private WxInstrumentSerialMapper wxInstrumentSerialMapper;
/**
*
*
@ -207,6 +213,27 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
wxUserScriptLogMapper.deleteWxUserScriptLogByWxUserId(wxUserMember.getId());
// wx_user_tag 用户标签关联表
wxUserTagMapper.deleteWxUserTagByUserId(wxUserMember.getId());
// wx_instrument_serial 仪器序列号解绑
WxUserInstrument query = new WxUserInstrument();
query.setUserId(wxUserMember.getId());
query.setBindingStatus(BindingStatusEnums.BINDED.getCode());
query.setStatus(Status.OK.getCode().longValue());
List<WxUserInstrument> wxUserInstruments = wxUserInstrumentMapper.selectWxUserInstrumentList(query);
if (wxUserInstruments != null && wxUserInstruments.size() > 0) {
List<String> serialList = wxUserInstruments.stream().map(WxUserInstrument::getSerial).collect(Collectors.toList());
for (String serial : serialList) {
WxInstrumentSerial wxInstrumentSerial = new WxInstrumentSerial();
wxInstrumentSerial.setSerial(serial);
wxInstrumentSerial.setBindingStatus(BindingStatusEnums.UN_BOUND.getCode());
wxInstrumentSerial.setCreateBy(SecurityUtils.getUsername());
wxInstrumentSerial.setCreateTime(DateUtils.getNowDate());
wxInstrumentSerialMapper.updateBySerial(wxInstrumentSerial);
}
}
// wx_user_instrument 用户仪器关联表
wxUserInstrumentMapper.deleteByUserId(wxUserMember.getId());
// wx_user_instrument_log 用户仪器关联表记录
wxUserInstrumentLogMapper.deleteByUserId(wxUserMember.getId());
}
}
// wx_user_member 微信用户表

Loading…
Cancel
Save