|
|
@@ -1,14 +1,18 @@
|
|
|
package org.dromara.server.sync.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.common.core.constant.DefaultConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.message.kafka.constant.EventTypeConstants;
|
|
|
import org.dromara.common.message.kafka.constant.KafkaTopicConstants;
|
|
|
import org.dromara.common.message.kafka.enums.EventSenderEnum;
|
|
|
+import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.server.sync.business.card.CardBusiness;
|
|
|
import org.dromara.server.sync.domain.UserAccount;
|
|
|
import org.dromara.server.sync.domain.bo.UserAccountBo;
|
|
|
@@ -53,7 +57,7 @@ public class UserAccountServiceImpl implements IUserAccountService {
|
|
|
@Override
|
|
|
public Boolean doUserAccount(UserAccountBo bo) {
|
|
|
UserAccount entity = MapstructUtils.convert(bo, UserAccount.class);
|
|
|
- UserAccountVo vo = baseMapper.selectVoById(bo.getUserId());
|
|
|
+ UserAccountVo vo = TenantHelper.ignore(() -> baseMapper.selectVoById(bo.getUserId()));
|
|
|
int rows;
|
|
|
if(ObjectUtil.isEmpty(vo)){
|
|
|
// 当前没有一卡通账户,先增加账户信息
|
|
|
@@ -78,7 +82,7 @@ public class UserAccountServiceImpl implements IUserAccountService {
|
|
|
}
|
|
|
} else{
|
|
|
// 已有账户,更新
|
|
|
- rows = baseMapper.updateById(entity);
|
|
|
+ rows = TenantHelper.ignore(() -> baseMapper.updateById(entity));
|
|
|
if(rows != 1){
|
|
|
return false;
|
|
|
}
|
|
|
@@ -86,8 +90,38 @@ public class UserAccountServiceImpl implements IUserAccountService {
|
|
|
// 如果卡类或有效期变了,需要同步更新主卡的卡类与有效期
|
|
|
}
|
|
|
}
|
|
|
- vo = baseMapper.selectVoById(bo.getUserId());
|
|
|
+ vo = TenantHelper.ignore(() -> baseMapper.selectVoById(bo.getUserId()));
|
|
|
kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.ACCOUNT, EventSenderEnum.BACKSTAGE.code(), vo);
|
|
|
return true;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 根据userId删除账户
|
|
|
+ * @param userId 用户Id
|
|
|
+ * @return 删除结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteById(String userId) {
|
|
|
+ UserAccountVo vo = baseMapper.selectVoById(userId);
|
|
|
+ vo.setDelFlag(DefaultConstants.DELETED);
|
|
|
+ kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.ACCOUNT, EventSenderEnum.BACKSTAGE.code(), vo);
|
|
|
+ return TenantHelper.ignore(() -> baseMapper.update(null, new LambdaUpdateWrapper<UserAccount>()
|
|
|
+ .set(UserAccount::getDelFlag, DefaultConstants.DELETED)
|
|
|
+ .set(UserAccount::getUpdateBy, userId)
|
|
|
+ .set(UserAccount::getUpdateTime, DateUtil.date())
|
|
|
+ .eq(UserAccount::getUserId, userId)) > 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteById(Long userId, Long operationId) {
|
|
|
+ UserAccountVo vo = baseMapper.selectVoById(userId);
|
|
|
+ vo.setDelFlag(DefaultConstants.DELETED);
|
|
|
+ vo.setUpdateBy(operationId);
|
|
|
+ vo.setUpdateTime(DateUtil.date());
|
|
|
+ kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.ACCOUNT, EventSenderEnum.BACKSTAGE.code(), vo);
|
|
|
+ return TenantHelper.ignore(() -> baseMapper.update(null, new LambdaUpdateWrapper<UserAccount>()
|
|
|
+ .set(UserAccount::getDelFlag, DefaultConstants.DELETED)
|
|
|
+ .set(UserAccount::getUpdateBy, operationId)
|
|
|
+ .set(UserAccount::getUpdateTime, DateUtil.date())
|
|
|
+ .eq(UserAccount::getUserId, userId)) > 0);
|
|
|
+ }
|
|
|
}
|