添加getInstallBot/getBotDetail开发者用户名信息
This commit is contained in:
parent
fb57d71111
commit
651c08bbef
|
|
@ -47,7 +47,7 @@ public class Bot {
|
|||
|
||||
private String privateKey;
|
||||
|
||||
private Integer owerId;
|
||||
private Integer ownerId;
|
||||
|
||||
private Integer uid;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,13 @@ 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.utils.GitLinkApi;
|
||||
import com.gitlink.softbot.vo.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -46,6 +49,9 @@ public class MarketService implements IMarketService {
|
|||
@Resource
|
||||
BotLimitMapper botLimitMapper;
|
||||
|
||||
@Autowired
|
||||
GitLinkApi api;
|
||||
|
||||
@Override
|
||||
public MarketBotPagesVO getMarketBotByNameLike(String keyword,Integer pageIndex,Integer pageSize){
|
||||
log.info("执行Bot通过上市名称模糊查询,keyword:{},pageIndex:{},pageSize:{}",keyword,pageIndex,pageSize);
|
||||
|
|
@ -206,6 +212,7 @@ public class MarketService implements IMarketService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public GetBotDetailResponse getBotDetail(Integer userId, Integer botId) {
|
||||
Bot bot = botMapper.selectOne(Wrappers.<Bot>lambdaQuery()
|
||||
.eq(Bot::getId,botId));
|
||||
|
|
@ -221,6 +228,8 @@ public class MarketService implements IMarketService {
|
|||
BeanUtils.copyProperties(marketBot,getBotDetailResponse);
|
||||
}
|
||||
BeanUtils.copyProperties(registerBot,getBotDetailResponse);
|
||||
// 设置开发者名称
|
||||
getBotDetailResponse.setDeveloperName(api.getUserNameByUid(bot.getOwnerId().toString()));
|
||||
getBotDetailResponse.setLimitAndEvents(getLimitFromLimitEvents(botLimitEvents));
|
||||
return getBotDetailResponse;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
.eq(InstallBot::getBotId,deleteBotRequest.getBotId()));
|
||||
if (installBots!=null&&installBots.size()>0){
|
||||
|
||||
//批量插入installBot表,添加webhook
|
||||
//批量删除webhook
|
||||
for (InstallBot installBot : installBots) {
|
||||
|
||||
//构造接口参数
|
||||
|
|
@ -760,6 +760,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public GetInstallBotResponse getInstallBot(GetInstallBotRequest getInstallBotRequest) throws BotException{
|
||||
GetInstallBotResponse getInstallBotResponse = new GetInstallBotResponse();
|
||||
//1.到bot表中查看name
|
||||
|
|
@ -792,6 +793,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
.eq(RegisterBot::getBotId,getInstallBotRequest.getBotId()));
|
||||
if (registerBot!=null){
|
||||
getInstallBotResponse.setRegisterId(registerBot.getDeveloperId());
|
||||
getInstallBotResponse.setRegisterName(api.getUserNameByUid(registerBot.getDeveloperId().toString()));
|
||||
}
|
||||
//获取所有权限
|
||||
List<BotLimitEvent> botLimitEvents = botLimitMapper.selectList(Wrappers.<BotLimitEvent>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package com.gitlink.softbot.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.gitlink.softbot.global.vo.Response;
|
||||
import com.gitlink.softbot.utils.response.UserResponse;
|
||||
import com.gitlink.softbot.vo.Webhook;
|
||||
import org.mapstruct.BeforeMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
|
@ -61,6 +61,16 @@ public class GitLinkApi {
|
|||
return response;
|
||||
}
|
||||
|
||||
public String getUserNameByUid(String uid){
|
||||
Map<String, String> inputParams = new HashMap<>();
|
||||
inputParams.put("uid", uid.toString());
|
||||
Response response = RestTemplateUtil.httpRequest(restTemplate, HttpMethod.GET, URL+"/api", null, "/users/get_user_info.json", inputParams, null ,getHeader());
|
||||
if("ok".equals(response.getCode())){
|
||||
return JSON.parseObject(response.getData().toString(), UserResponse.class).getUsername();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Response getWebhookById(Integer uid, Object[] params,Integer webhookId) throws JsonProcessingException {
|
||||
Map<String, String> inputParams = new HashMap<>();
|
||||
inputParams.put("uid", uid.toString());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.gitlink.softbot.utils.response;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wxj
|
||||
*/
|
||||
@Data
|
||||
public class UserResponse {
|
||||
private Integer userID;
|
||||
private String login;
|
||||
private String username;
|
||||
private String realName;
|
||||
private String nickName;
|
||||
private String imageUrl;
|
||||
private String userIdentity;
|
||||
}
|
||||
|
|
@ -46,6 +46,11 @@ public class GetBotDetailResponse {
|
|||
*/
|
||||
private Integer developerId;
|
||||
|
||||
/**
|
||||
* 开发者用户名
|
||||
*/
|
||||
private String developerName;
|
||||
|
||||
/**
|
||||
* 主要功能
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class GetInstallBotResponse implements Serializable {
|
|||
private Integer state;
|
||||
private String logo;
|
||||
private Integer registerId;
|
||||
private String registerName;
|
||||
private Date createTime;
|
||||
private LimitVO limitVO;
|
||||
private List<Integer> storeIdList;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.gitlink.softbot.service.market;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.gitlink.softbot.global.vo.Response;
|
||||
import com.gitlink.softbot.utils.GitLinkApi;
|
||||
import com.gitlink.softbot.utils.response.UserResponse;
|
||||
import com.gitlink.softbot.vo.Webhook;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -24,7 +26,8 @@ public class GitLinkApiTest {
|
|||
@Test
|
||||
public void getUserTest(){
|
||||
Response response = api.getUserByUid(uid);
|
||||
System.out.println(response.getData());
|
||||
UserResponse userResponse = JSON.parseObject(response.getData().toString(),UserResponse.class);
|
||||
System.out.println(userResponse.getUsername());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue