更新bot

This commit is contained in:
tonglin 2023-01-09 11:23:59 +08:00
parent 532185a679
commit ff50cdce0f
2 changed files with 29 additions and 15 deletions

View File

@ -14,8 +14,9 @@ public class GlobalExceptionAdvice {
public Result<String> handleCouponException(
HttpServletRequest request, BotException exception
){
Result<String> response = new Result<>(-1,"business error!");
Result<String> response = new Result<>(500,"server error!");
response.setData(exception.getMessage());
response.setMessage(exception.getMessage());
return response;
}
}

View File

@ -121,14 +121,17 @@ public class UserService extends AbstractUserBot implements IUserService {
Bot updateBot = shiftObject(botInputVO);
Integer id = botInputVO.getBotId();
updateBot.setId(id);
MarketBot marketBot = marketBotMapper.selectById(id);
marketBot.setMarketIntro(updateBot.getBotDes());
marketBot.setLogo(updateBot.getLogo());
try {
marketBotMapper.updateById(marketBot);
MarketBot marketBot = marketBotMapper.selectById(id);
if (marketBot!=null){
marketBot.setMarketIntro(updateBot.getBotDes());
marketBot.setLogo(updateBot.getLogo());
marketBot.setMarketName(updateBot.getBotName());
marketBotMapper.updateById(marketBot);
}
botMapper.updateById(updateBot);
}catch (DuplicateKeyException e){
throw new BotException("Bot名称已经存在");
throw new BotException("Bot更新失败");
}
boolean flag = false;
@ -421,12 +424,18 @@ public class UserService extends AbstractUserBot implements IUserService {
MarketBot marketBot = getDBMarketBot(botToMarketRequest);
//更新市场bot的安装次数bot在上市前可能通过详情页面被安装过
marketBot.setInstallNum(bot.getInstallNum());
//更新bot表中详细信息
bot.setBotDes(marketBot.getMarketIntro());
bot.setBotName(marketBot.getMarketName());
bot.setLogo(marketBot.getLogo());
botMapper.updateById(bot);
marketBotMapper.insert(marketBot);
// //2.es添加数据
// com.gitlink.softbot.entity.es.MarketBot marketBot1 = getESMarketBot(botToMarketRequest);
// marketService.saveMarketBot(marketBot1);
}catch (DuplicateKeyException e){
throw new BotException("bot已经上市");
throw new BotException("上市失败");
}
log.info("Bot上市成功{}",botToMarketRequest);
}
@ -905,14 +914,18 @@ public class UserService extends AbstractUserBot implements IUserService {
try {
MarketBot marketBot = marketBotMapper.selectOne(Wrappers
.<MarketBot>lambdaQuery().eq(MarketBot::getBotId,botToMarketRequest.getBotId()));
MarketBot updateMarketBot = getDBMarketBot(botToMarketRequest);
updateMarketBot.setId(marketBot.getId());
marketBotMapper.updateById(updateMarketBot);
//同步更新bot表信息
Bot bot = botMapper.selectById(marketBot.getId());
bot.setBotDes(updateMarketBot.getMarketIntro());
bot.setLogo(updateMarketBot.getLogo());
botMapper.updateById(bot);
if (marketBot!=null){
MarketBot updateMarketBot = getDBMarketBot(botToMarketRequest);
updateMarketBot.setId(marketBot.getId());
marketBotMapper.updateById(updateMarketBot);
//同步更新bot表信息
Bot bot = botMapper.selectById(marketBot.getId());
bot.setBotDes(updateMarketBot.getMarketIntro());
bot.setLogo(updateMarketBot.getLogo());
bot.setBotName(updateMarketBot.getMarketName());
botMapper.updateById(bot);
}
}catch (Exception e){
throw new BotException("更新失败!");
}