getRegisterBot,getBotDetail接口:返回数据中添加issue权限及事件
This commit is contained in:
parent
7dec7afc23
commit
a39cfa21b5
|
|
@ -29,6 +29,8 @@ public class BotLimitEvent {
|
|||
|
||||
private Integer readWritePr;
|
||||
|
||||
private Integer readWriteIssue;
|
||||
|
||||
private Integer authCategory;
|
||||
|
||||
private Integer event;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.gitlink.softbot.dao.db.BotLimitMapper;
|
|||
import com.gitlink.softbot.entity.db.*;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.service.market.IMarketService;
|
||||
import com.gitlink.softbot.service.user.impl.UserService;
|
||||
import com.gitlink.softbot.utils.GitLinkApi;
|
||||
import com.gitlink.softbot.vo.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -53,6 +54,9 @@ public class MarketService implements IMarketService {
|
|||
@Autowired
|
||||
GitLinkApi api;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Override
|
||||
public MarketBotPagesVO getMarketBotByNameLike(String keyword,Integer pageIndex,Integer pageSize){
|
||||
log.info("执行Bot通过上市名称模糊查询,keyword:{},pageIndex:{},pageSize:{}",keyword,pageIndex,pageSize);
|
||||
|
|
@ -235,7 +239,7 @@ public class MarketService implements IMarketService {
|
|||
// 设置开发者名称
|
||||
getBotDetailResponse.setDeveloperName(api.getUserNameByUid(registerBot.getDeveloperId().toString()));
|
||||
getBotDetailResponse.setDeveloperLogin(registerBot.getDeveloperLogin());
|
||||
getBotDetailResponse.setLimitAndEvents(getLimitFromLimitEvents(botLimitEvents));
|
||||
getBotDetailResponse.setLimitAndEvents(userService.getLimitFromLimitEvents(botLimitEvents));
|
||||
return getBotDetailResponse;
|
||||
}
|
||||
|
||||
|
|
@ -293,46 +297,4 @@ public class MarketService implements IMarketService {
|
|||
marketBotPagesVO1.setPageSize(pageSize);
|
||||
return marketBotPagesVO1;
|
||||
}
|
||||
|
||||
private LimitVO getLimitFromLimitEvents(List<BotLimitEvent> botLimitEvents){
|
||||
LimitVO limitVO = new LimitVO();
|
||||
//无权限情况下
|
||||
if (botLimitEvents.size()==1&&botLimitEvents.get(0).getEvent()==5){
|
||||
limitVO.setEventPr("");
|
||||
limitVO.setEventCode("");
|
||||
limitVO.setJurisDictionCode(2);
|
||||
limitVO.setJurisDictionPr(2);
|
||||
}
|
||||
StringBuffer codeStr = new StringBuffer();
|
||||
StringBuffer prStr = new StringBuffer();
|
||||
|
||||
botLimitEvents.forEach(botLimitEvent -> {
|
||||
if (botLimitEvent.getEvent()>=3){
|
||||
prStr.append(botLimitEvent.getEvent());
|
||||
prStr.append(",");
|
||||
limitVO.setJurisDictionPr(botLimitEvent.getReadWritePr());
|
||||
}else {
|
||||
codeStr.append(botLimitEvent.getEvent());
|
||||
codeStr.append(",");
|
||||
limitVO.setJurisDictionCode(botLimitEvent.getReadWriteCode());
|
||||
}
|
||||
});
|
||||
|
||||
if (codeStr.length()>1){
|
||||
codeStr.deleteCharAt(codeStr.length()-1);
|
||||
}else {
|
||||
limitVO.setJurisDictionCode(2);
|
||||
}
|
||||
if (prStr.length()>1){
|
||||
prStr.deleteCharAt(prStr.length()-1);
|
||||
}else {
|
||||
limitVO.setJurisDictionPr(2);
|
||||
}
|
||||
|
||||
limitVO.setEventPr(prStr.toString());
|
||||
limitVO.setEventCode(codeStr.toString());
|
||||
|
||||
log.info("limitVO:{}",limitVO);
|
||||
return limitVO;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.gitlink.softbot.dao.db.*;
|
||||
import com.gitlink.softbot.entity.db.*;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
|
|
@ -415,46 +416,51 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
botOutputVO.setIsPublic(bot.getIsPublic());
|
||||
return botOutputVO;
|
||||
}
|
||||
private LimitVO getLimitFromLimitEvents(List<BotLimitEvent> botLimitEvents){
|
||||
public LimitVO getLimitFromLimitEvents(List<BotLimitEvent> botLimitEvents){
|
||||
LimitVO limitVO = new LimitVO();
|
||||
//无权限情况下
|
||||
if (botLimitEvents.size()==1&&botLimitEvents.get(0).getEvent()==5){
|
||||
limitVO.setEventPr("");
|
||||
limitVO.setEventCode("");
|
||||
limitVO.setEventIssue("");
|
||||
limitVO.setJurisDictionCode(2);
|
||||
limitVO.setJurisDictionPr(2);
|
||||
limitVO.setJurisDictionIssue(2);
|
||||
}
|
||||
StringBuffer codeStr = new StringBuffer();
|
||||
StringBuffer prStr = new StringBuffer();
|
||||
StringJoiner codeStr = new StringJoiner(",");
|
||||
StringJoiner prStr = new StringJoiner(",");
|
||||
StringJoiner issueStr = new StringJoiner(",");
|
||||
|
||||
botLimitEvents.forEach(botLimitEvent -> {
|
||||
if (botLimitEvent.getEvent()>=3){
|
||||
prStr.append(botLimitEvent.getEvent());
|
||||
prStr.append(",");
|
||||
limitVO.setJurisDictionPr(botLimitEvent.getReadWritePr());
|
||||
}else {
|
||||
codeStr.append(botLimitEvent.getEvent());
|
||||
codeStr.append(",");
|
||||
limitVO.setJurisDictionCode(botLimitEvent.getReadWriteCode());
|
||||
}
|
||||
});
|
||||
botLimitEvents.forEach(botLimitEvent -> {
|
||||
|
||||
if (codeStr.length()>1){
|
||||
codeStr.deleteCharAt(codeStr.length()-1);
|
||||
}else {
|
||||
limitVO.setJurisDictionCode(2);
|
||||
}
|
||||
if (prStr.length()>1){
|
||||
prStr.deleteCharAt(prStr.length()-1);
|
||||
}else {
|
||||
limitVO.setJurisDictionPr(2);
|
||||
}
|
||||
switch (botLimitEvent.getEvent()) {
|
||||
case (0 | 1 | 2):
|
||||
codeStr.add(botLimitEvent.getEvent().toString());
|
||||
limitVO.setJurisDictionCode(botLimitEvent.getReadWriteCode());
|
||||
case (3 | 4 | 6):
|
||||
prStr.add(botLimitEvent.getEvent().toString());
|
||||
limitVO.setJurisDictionPr(botLimitEvent.getReadWritePr());
|
||||
case (7 | 8 | 9 | 10):
|
||||
issueStr.add(botLimitEvent.getEvent().toString());
|
||||
limitVO.setJurisDictionIssue(botLimitEvent.getReadWriteIssue());
|
||||
}
|
||||
});
|
||||
|
||||
limitVO.setEventPr(prStr.toString());
|
||||
limitVO.setEventCode(codeStr.toString());
|
||||
if (codeStr.length()==0) {
|
||||
limitVO.setJurisDictionCode(2);
|
||||
}
|
||||
if (prStr.length()==0) {
|
||||
limitVO.setJurisDictionPr(2);
|
||||
}
|
||||
if (issueStr.length() == 0) {
|
||||
limitVO.setJurisDictionIssue(2);
|
||||
}
|
||||
|
||||
log.info("limitVO:{}",limitVO);
|
||||
return limitVO;
|
||||
limitVO.setEventPr(prStr.toString());
|
||||
limitVO.setEventCode(codeStr.toString());
|
||||
|
||||
log.info("limitVO:{}",limitVO);
|
||||
return limitVO;
|
||||
}
|
||||
@Override
|
||||
public Bot shiftObject(BotInputVO botVO) {
|
||||
|
|
@ -474,15 +480,16 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
LimitVO limitVO = botInputVO.getLimitAndEvents();
|
||||
List<Limit> limitList = limitVOToLimit(limitVO);
|
||||
List<BotLimitEvent> botLimitEvents = new ArrayList<>();
|
||||
limitList.forEach(limit -> {
|
||||
BotLimitEvent botLimitEvent = new BotLimitEvent();
|
||||
botLimitEvent.setBotId(bot.getId());
|
||||
botLimitEvent.setAuthCategory(limit.getAuthCategory());
|
||||
botLimitEvent.setReadWriteCode(limit.getReadWriteCode());
|
||||
botLimitEvent.setReadWritePr(limit.getReadWritePr());
|
||||
botLimitEvent.setEvent(limit.getEvent());
|
||||
botLimitEvents.add(botLimitEvent);
|
||||
});
|
||||
limitList.forEach(limit -> {
|
||||
BotLimitEvent botLimitEvent = new BotLimitEvent();
|
||||
botLimitEvent.setBotId(bot.getId());
|
||||
botLimitEvent.setAuthCategory(limit.getAuthCategory());
|
||||
botLimitEvent.setReadWriteCode(limit.getReadWriteCode());
|
||||
botLimitEvent.setReadWritePr(limit.getReadWritePr());
|
||||
botLimitEvent.setReadWriteIssue(limit.getReadWriteIssue());
|
||||
botLimitEvent.setEvent(limit.getEvent());
|
||||
botLimitEvents.add(botLimitEvent);
|
||||
});
|
||||
return botLimitEvents;
|
||||
}
|
||||
public RegisterBot shiftBotToRegisterBot(BotInputVO botInputVO,Bot bot){
|
||||
|
|
@ -567,7 +574,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void botToMarket(BotToMarketRequest botToMarketRequest) throws BotException{
|
||||
log.info("Bot上市{}",botToMarketRequest);
|
||||
//先校验是否公开,不是公开,则判断
|
||||
//先校验是否公开,不是公开,则判断
|
||||
Bot bot = botMapper.selectById(botToMarketRequest.getBotId());
|
||||
if (bot==null){
|
||||
throw new BotException("该Bot不存在!");
|
||||
|
|
@ -651,9 +658,9 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
System.out.println(registerBot.getBotId());
|
||||
MarketBot marketBot = marketBotMapper.selectOne(new QueryWrapper<MarketBot>()
|
||||
.eq("bot_id",registerBot.getBotId()));
|
||||
if (Objects.isNull(marketBot)){
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(marketBot)){
|
||||
return;
|
||||
}
|
||||
botList.add(getMarketBotsResponse.getMarketBot(
|
||||
marketBot
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in New Issue