correct number of installations

This commit is contained in:
wanjia 2023-04-25 08:56:58 +08:00
parent 06cadbe055
commit 6bbff95334
2 changed files with 11 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
.idea

View File

@ -3,6 +3,7 @@ package com.gitlink.softbot.service.user.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.gitlink.softbot.dao.db.*;
@ -730,6 +731,7 @@ public class UserService extends AbstractUserBot implements IUserService {
for (InstallBot installBot : installBotList) {
//插入表
installMapper.insert(installBot);
botInstallNumIncrement(installBot.getBotId());
asyncAddWebhookService.asyncAddWebhookAndRetry(installMarketBotRequest.getUserId(), botLimitEvents, installBot);
}
@ -885,11 +887,19 @@ public class UserService extends AbstractUserBot implements IUserService {
for (Integer store : storeList){
InstallBot installBot = getInstallBot(updateInstallBotRequest,store);
installMapper.insert(installBot);
botInstallNumIncrement(installBot.getBotId());
asyncAddWebhookService.asyncAddWebhookAndRetry(updateInstallBotRequest.getUserId(), botLimitEvents, installBot);
}
}
private void botInstallNumIncrement(Integer botId) {
UpdateWrapper<Bot> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(Bot::getId, botId)
.setSql("install_num = install_num + 1");
botMapper.update(null, updateWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteInstallBot(DeleteInstallBotRequest deleteInstallBotRequest) throws BotException{