forked from Gitlink/soft_bot
getAllInstallBots接口加入仓库参数;judgeIsInstallBot接口修改参数 仓库拥有者->仓库
This commit is contained in:
parent
508215c188
commit
ee5549ebb0
|
|
@ -291,14 +291,14 @@ public class UserController {
|
|||
|
||||
/**
|
||||
* 判断是否安装该bot
|
||||
* @param repoOwners
|
||||
* @param repos
|
||||
* @param botId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/judgeIsIntallBot")
|
||||
public Result<?> judgeIsInstallBot(@RequestParam("repo_owner") List<String> repoOwners, @RequestParam("bot_id") Integer botId){
|
||||
public Result<?> judgeIsInstallBot(@RequestParam("repos") String repos, @RequestParam("bot_id") Integer botId){
|
||||
|
||||
JudgeIsInstallBotResponse judgeIsInstallBotResponse = userService.judgeIsInstallBot(repoOwners,botId);
|
||||
JudgeIsInstallBotResponse judgeIsInstallBotResponse = userService.judgeIsInstallBot(repos,botId);
|
||||
Result<JudgeIsInstallBotResponse> result = new Result<>();
|
||||
return result.build(judgeIsInstallBotResponse).build(200).build("success!");
|
||||
}
|
||||
|
|
@ -309,9 +309,12 @@ public class UserController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/getAllInstallBots")
|
||||
public Result<?> getAllInstallBots(@RequestParam("user_id") Integer userId){
|
||||
GetAllInstallBotsResponse getAllInstallBotsResponse = userService.getAllInstallBots(userId);
|
||||
public Result<?> getAllInstallBots(@RequestParam("user_id") Integer userId, @RequestParam("repos") String repos){
|
||||
Result<GetAllInstallBotsResponse> result = new Result<>();
|
||||
if(userId == null && (repos == null || "".equals(repos))) {
|
||||
return result.build("传入参数不能全空").build(500).build("fail!");
|
||||
}
|
||||
GetAllInstallBotsResponse getAllInstallBotsResponse = userService.getAllInstallBots(userId, repos);
|
||||
return result.
|
||||
build(getAllInstallBotsResponse).
|
||||
build(200).
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.gitlink.softbot.service.user;
|
|||
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.vo.*;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -52,9 +51,9 @@ public interface IUserService {
|
|||
//拒绝接收转让Bot
|
||||
void refuseTransferBot(RefuseTransferBotRequest refuseTransferBotRequest) throws BotException;
|
||||
//判断是否安装过此bot
|
||||
JudgeIsInstallBotResponse judgeIsInstallBot(List<String> repoOwners, Integer botId);
|
||||
JudgeIsInstallBotResponse judgeIsInstallBot(String repos, Integer botId);
|
||||
|
||||
GetAllInstallBotsResponse getAllInstallBots(Integer userId);
|
||||
GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repos);
|
||||
|
||||
GetStoreAllInstallBotResponse getStoreAllInstallBots(Integer storeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1129,29 +1129,30 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
|
||||
/**
|
||||
* 判断该用户是否安装此bot
|
||||
* @param repoOwners
|
||||
* @param repos
|
||||
* @param botId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JudgeIsInstallBotResponse judgeIsInstallBot(List<String> repoOwners, Integer botId) {
|
||||
public JudgeIsInstallBotResponse judgeIsInstallBot(String repos, Integer botId) {
|
||||
JudgeIsInstallBotResponse judgeIsInstallBotResponse = new JudgeIsInstallBotResponse();
|
||||
List<String> installOwnerList = new ArrayList<>();
|
||||
List<String> unInstallOwnerList = new ArrayList<>();
|
||||
for (String repoOwner : repoOwners) {
|
||||
List<String> installRepoList = new ArrayList<>();
|
||||
List<String> unInstallRepoList = new ArrayList<>();
|
||||
List<String> repoList = Arrays.asList(repos.split(","));
|
||||
for (String repo : repoList) {
|
||||
//如果公开,则判断安装表里面有没有该用户安装的bot
|
||||
List<InstallBot> installBots = installMapper.selectList(Wrappers.
|
||||
<InstallBot>lambdaQuery().eq(InstallBot::getBotId, botId)
|
||||
.eq(InstallBot::getRepoOwner, repoOwner));
|
||||
.eq(InstallBot::getStoreRepo, repo));
|
||||
if (!Objects.isNull(installBots) && installBots.size() > 0) {
|
||||
installOwnerList.add(repoOwner);
|
||||
installRepoList.add(repo);
|
||||
} else {
|
||||
unInstallOwnerList.add(repoOwner);
|
||||
unInstallRepoList.add(repo);
|
||||
}
|
||||
|
||||
}
|
||||
judgeIsInstallBotResponse.setInstallOwners(installOwnerList);
|
||||
judgeIsInstallBotResponse.setUninstallOwners(unInstallOwnerList);
|
||||
judgeIsInstallBotResponse.setInstallOwners(installRepoList);
|
||||
judgeIsInstallBotResponse.setUninstallOwners(unInstallRepoList);
|
||||
return judgeIsInstallBotResponse;
|
||||
|
||||
}
|
||||
|
|
@ -1190,14 +1191,22 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
/**
|
||||
* 获取用户安装所有bot信息
|
||||
* @param userId
|
||||
* @param repos
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GetAllInstallBotsResponse getAllInstallBots(Integer userId) {
|
||||
|
||||
List<InstallBot> installBots = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.eq(InstallBot::getInstallerId,userId));
|
||||
public GetAllInstallBotsResponse getAllInstallBots(Integer userId, String repos) {
|
||||
|
||||
List<InstallBot> installBots = new ArrayList<>();
|
||||
List<String> repoList = Arrays.asList(repos.split(","));
|
||||
if(userId != null) {
|
||||
installBots = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.eq(InstallBot::getInstallerId,userId));
|
||||
}
|
||||
if(repos != null && repoList.size() > 0) {
|
||||
installBots = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.in(InstallBot::getStoreRepo, repoList));
|
||||
}
|
||||
|
||||
Map<Integer, StringJoiner> botAndAllRepoOwnerMap = new HashMap<>();
|
||||
for(InstallBot installBot : installBots) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue