forked from wanjia9506/soft_bot
getAllInstallBots接口:bot中已安装仓库返回仓库id
This commit is contained in:
parent
be845024ab
commit
cc40fb4823
|
|
@ -309,12 +309,12 @@ public class UserController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/getAllInstallBots")
|
||||
public Result<?> getAllInstallBots(@RequestParam("user_id") Integer userId, @RequestParam(value = "repos", required = false) String repos){
|
||||
public Result<?> getAllInstallBots(@RequestParam("user_id") Integer userId, @RequestParam(value = "repoIds", required = false) String repoIds){
|
||||
Result<GetAllInstallBotsResponse> result = new Result<>();
|
||||
if(userId == null && (repos == null || "".equals(repos))) {
|
||||
if(userId == null && (repoIds == null || "".equals(repoIds))) {
|
||||
return result.build("传入参数不能全空").build(500).build("fail!");
|
||||
}
|
||||
GetAllInstallBotsResponse getAllInstallBotsResponse = userService.getAllInstallBots(userId, repos);
|
||||
GetAllInstallBotsResponse getAllInstallBotsResponse = userService.getAllInstallBots(userId, repoIds);
|
||||
return result.
|
||||
build(getAllInstallBotsResponse).
|
||||
build(200).
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public interface IUserService {
|
|||
//判断是否安装过此bot
|
||||
JudgeIsInstallBotResponse judgeIsInstallBot(String repos, Integer botId);
|
||||
|
||||
GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repos);
|
||||
GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repoIds);
|
||||
|
||||
GetStoreAllInstallBotResponse getStoreAllInstallBots(Integer storeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1204,11 +1204,11 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
/**
|
||||
* 获取用户安装所有bot信息
|
||||
* @param userId
|
||||
* @param repos
|
||||
* @param repoIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repos) {
|
||||
public GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repoIds) {
|
||||
|
||||
List<InstallBot> installBots = new ArrayList<>();
|
||||
|
||||
|
|
@ -1216,22 +1216,22 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
installBots = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.eq(InstallBot::getInstallerId,userId));
|
||||
}
|
||||
if(repos != null) {
|
||||
List<String> repoList = Arrays.asList(repos.split(","));
|
||||
if(repoIds != null) {
|
||||
List<String> repoList = Arrays.asList(repoIds.split(","));
|
||||
installBots = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.in(InstallBot::getStoreRepo, repoList));
|
||||
.in(InstallBot::getStoreId, repoList));
|
||||
}
|
||||
|
||||
Map<Integer, StringJoiner> botAndAllRepoOwnerMap = new HashMap<>();
|
||||
Map<Integer, StringJoiner> botAndAllRepoIdMap = new HashMap<>();
|
||||
for(InstallBot installBot : installBots) {
|
||||
StringJoiner s = new StringJoiner(",");
|
||||
if(botAndAllRepoOwnerMap.containsKey(installBot.getBotId())){
|
||||
s = botAndAllRepoOwnerMap.get(installBot.getBotId());
|
||||
if(botAndAllRepoIdMap.containsKey(installBot.getBotId())){
|
||||
s = botAndAllRepoIdMap.get(installBot.getBotId());
|
||||
}
|
||||
if (installBot.getStoreRepo() == null || (s.length() > 0 && s.toString().contains(installBot.getStoreRepo()))){
|
||||
continue;
|
||||
}
|
||||
botAndAllRepoOwnerMap.put(installBot.getBotId(), s.add(installBot.getStoreRepo()));
|
||||
botAndAllRepoIdMap.put(installBot.getBotId(), s.add(installBot.getStoreId().toString()));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1247,7 +1247,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
installBotInfo.setLimitVO(limitVO);
|
||||
BeanUtils.copyProperties(bot,installBotInfo);
|
||||
BeanUtils.copyProperties(installBot,installBotInfo);
|
||||
installBotInfo.setStoreRepos(String.valueOf(botAndAllRepoOwnerMap.get(installBotInfo.getBotId())));
|
||||
installBotInfo.setStoreRepoIds(String.valueOf(botAndAllRepoIdMap.get(installBotInfo.getBotId())));
|
||||
installBotInfos.add(installBotInfo);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ public class InstallBotInfo {
|
|||
|
||||
LimitVO limitVO;
|
||||
|
||||
String storeRepos;
|
||||
String storeRepoIds;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue