增加Bot注册与配置功能
This commit is contained in:
parent
192c0f4286
commit
1a1df9f493
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
5
pom.xml
5
pom.xml
|
@ -45,6 +45,11 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.gitlink.softbot;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.gitlink.softbot.dao")
|
||||
public class SoftBotApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.gitlink.softbot.controller;
|
||||
package com.gitlink.softbot.controller.market;
|
||||
|
||||
|
||||
import com.gitlink.softbot.entity.es.MarketBot;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.global.vo.Result;
|
||||
import com.gitlink.softbot.service.market.IMarketService;
|
||||
|
@ -11,9 +11,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController()
|
||||
|
||||
@RestController
|
||||
public class MarketController {
|
||||
|
||||
@Resource
|
|
@ -0,0 +1,37 @@
|
|||
package com.gitlink.softbot.controller.user;
|
||||
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.global.vo.Result;
|
||||
import com.gitlink.softbot.service.user.IUserService;
|
||||
import com.gitlink.softbot.vo.BotInputVO;
|
||||
import com.gitlink.softbot.vo.BotOutputVO;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
@PostMapping("/registerBot")
|
||||
public Result<BotOutputVO> registerBot(@RequestBody BotInputVO botInputVO) throws BotException {
|
||||
Result<BotOutputVO> result = new Result<>();
|
||||
BotOutputVO botOutputVO = userService.registerBot(botInputVO);
|
||||
result.setCode(200);
|
||||
result.setMessage("register success!");
|
||||
result.setData(botOutputVO);
|
||||
return result;
|
||||
}
|
||||
@PostMapping("/updateBot")
|
||||
public Result<BotOutputVO> updateBot(@RequestBody BotInputVO botInputVO) throws BotException{
|
||||
Result<BotOutputVO> result = new Result<>();
|
||||
BotOutputVO botOutputVO = userService.updateBot(botInputVO);
|
||||
result.setCode(200);
|
||||
result.setMessage("update success!");
|
||||
result.setData(botOutputVO);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.gitlink.softbot.dao.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitlink.softbot.entity.db.BotLimitEvent;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface BotLimitMapper extends BaseMapper<BotLimitEvent> {
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.gitlink.softbot.dao.db;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitlink.softbot.entity.db.Bot;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface BotMapper extends BaseMapper<Bot> {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.gitlink.softbot.dao.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitlink.softbot.entity.db.InstallBot;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface InstallMapper extends BaseMapper<InstallBot> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.gitlink.softbot.dao.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitlink.softbot.entity.db.RegisterBot;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface RegisterMapper extends BaseMapper<RegisterBot> {
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.gitlink.softbot.entity.db;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -14,10 +15,8 @@ import java.util.Date;
|
|||
@TableName("bot")
|
||||
public class Bot {
|
||||
|
||||
@TableId
|
||||
private int id;
|
||||
|
||||
private String botId;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String botName;
|
||||
|
||||
|
@ -37,6 +36,8 @@ public class Bot {
|
|||
|
||||
private String webUrl;
|
||||
|
||||
private Integer installNum;
|
||||
|
||||
private int category;
|
||||
|
||||
private Date updateTime;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.gitlink.softbot.entity.db;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("bot_limit_event")
|
||||
public class BotLimitEvent {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer botId;
|
||||
|
||||
private Integer installId;
|
||||
|
||||
private Integer storeId;
|
||||
|
||||
private Integer readWriteCode;
|
||||
|
||||
private Integer readWritePr;
|
||||
|
||||
private Integer authCategory;
|
||||
|
||||
private Integer event;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.gitlink.softbot.entity.db;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("install_bot")
|
||||
public class InstallBot {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer botId;
|
||||
|
||||
private Integer installerId;
|
||||
|
||||
private Integer storeId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.gitlink.softbot.entity.db;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("register_bot")
|
||||
public class RegisterBot {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer botId;
|
||||
|
||||
private Integer developerId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
}
|
|
@ -19,10 +19,10 @@ public class MarketBot {
|
|||
|
||||
/** 主键**/
|
||||
@Id
|
||||
private int id;
|
||||
private Integer id;
|
||||
|
||||
/** botid**/
|
||||
private String botId;
|
||||
private Integer botId;
|
||||
|
||||
/** 上市名称**/
|
||||
@Field(type = FieldType.Text)
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.gitlink.softbot.service.market.IMarketService;
|
|||
import com.gitlink.softbot.vo.MarketBotPagesVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.lucene.search.TotalHits;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.gitlink.softbot.service.user;
|
||||
|
||||
import com.gitlink.softbot.entity.db.Bot;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.vo.BotInputVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public abstract class AbstractUserBot {
|
||||
|
||||
//1.校验必填信息
|
||||
public abstract void checkInfo(BotInputVO botVO) throws BotException;
|
||||
|
||||
//2.生成clientid和clientsecret
|
||||
public abstract String getClientId();
|
||||
public abstract String getClientSecret();
|
||||
|
||||
//3.生成BotWeburl
|
||||
public abstract String getBotUrl(String botName);
|
||||
|
||||
//4.生成Bot完整信息
|
||||
public abstract Bot shiftObject(BotInputVO botVO);
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.gitlink.softbot.service.user;
|
||||
|
||||
import com.gitlink.softbot.entity.db.Bot;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.vo.BotInputVO;
|
||||
import com.gitlink.softbot.vo.BotOutputVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
public interface IUserService {
|
||||
//1.Bot注冊
|
||||
public BotOutputVO registerBot(BotInputVO botVO) throws BotException;
|
||||
//2.修改配置信息
|
||||
public BotOutputVO updateBot(BotInputVO botInputVO) throws BotException;
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
package com.gitlink.softbot.service.user.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gitlink.softbot.dao.db.BotLimitMapper;
|
||||
import com.gitlink.softbot.dao.db.BotMapper;
|
||||
import com.gitlink.softbot.dao.db.InstallMapper;
|
||||
import com.gitlink.softbot.dao.db.RegisterMapper;
|
||||
import com.gitlink.softbot.entity.db.Bot;
|
||||
import com.gitlink.softbot.entity.db.BotLimitEvent;
|
||||
import com.gitlink.softbot.entity.db.InstallBot;
|
||||
import com.gitlink.softbot.entity.db.RegisterBot;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.service.user.AbstractUserBot;
|
||||
import com.gitlink.softbot.service.user.IUserService;
|
||||
import com.gitlink.softbot.vo.BotInputVO;
|
||||
import com.gitlink.softbot.vo.BotOutputVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class UserService extends AbstractUserBot implements IUserService {
|
||||
|
||||
@Autowired
|
||||
BotMapper botMapper;
|
||||
@Autowired
|
||||
InstallMapper installMapper;
|
||||
@Autowired
|
||||
RegisterMapper registerMapper;
|
||||
@Autowired
|
||||
BotLimitMapper botLimitMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public BotOutputVO registerBot(BotInputVO botVO) throws BotException {
|
||||
//校验必填信息信息
|
||||
checkInfo(botVO);
|
||||
//插入Bot表
|
||||
botMapper.insert(shiftObject(botVO));
|
||||
Bot insertBot = botMapper.selectOne(new QueryWrapper<Bot>().eq("bot_name",botVO.getBotName()));
|
||||
|
||||
for (Integer storeId : botVO.getStoreLit()){
|
||||
//插入安装表
|
||||
installMapper.insert( shiftBotToInstallBot(botVO,insertBot,storeId));
|
||||
InstallBot installBot = installMapper.selectOne(new QueryWrapper<InstallBot>().
|
||||
eq("bot_id",insertBot.getId()).
|
||||
eq("installer_id",botVO.getUserId())
|
||||
.eq("store_id",storeId));
|
||||
//插入权限表
|
||||
BotLimitEvent botLimitEvent = shiftBotToLimit(botVO,insertBot,storeId,installBot.getId());
|
||||
botLimitMapper.insert(botLimitEvent);
|
||||
}
|
||||
//插入注册表
|
||||
RegisterBot registerBot = shiftBotToRegisterBot(botVO,insertBot);
|
||||
registerMapper.insert(registerBot);
|
||||
|
||||
return shiftBotToBotOutputVo(botVO,insertBot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public BotOutputVO updateBot(BotInputVO botInputVO) throws BotException {
|
||||
//先更新Bot
|
||||
Bot updateBot = shiftObject(botInputVO);
|
||||
Integer id = botMapper.selectOne(new QueryWrapper<Bot>().eq("bot_name",botInputVO.getBotName())).getId();
|
||||
updateBot.setId(id);
|
||||
botMapper.updateById(updateBot);
|
||||
//先判断权限这一块有没有更新
|
||||
boolean flag=false; //true是有更新
|
||||
List<InstallBot> installBots = installMapper.selectList(new QueryWrapper<InstallBot>()
|
||||
.eq("bot_id",id));
|
||||
List<BotLimitEvent> limitEventList = new ArrayList<>();
|
||||
List<Integer> oldStoreIdList = new ArrayList<>();
|
||||
installBots.forEach(installBot -> {
|
||||
BotLimitEvent botLimitEvent = botLimitMapper.selectOne(new QueryWrapper<BotLimitEvent>()
|
||||
.eq("store_id",installBot.getStoreId())
|
||||
.eq("bot_id",installBot.getBotId())
|
||||
.eq("install_id",installBot.getId()));
|
||||
limitEventList.add(botLimitEvent);
|
||||
oldStoreIdList.add(installBot.getStoreId());
|
||||
});
|
||||
List<Integer> newStoreIdList = botInputVO.getStoreLit();
|
||||
Collections.sort(newStoreIdList);
|
||||
Collections.sort(oldStoreIdList);
|
||||
if (newStoreIdList.size()!= oldStoreIdList.size()){
|
||||
flag=true;
|
||||
}else {
|
||||
for (int i = 0; i < newStoreIdList.size(); i++) {
|
||||
if (newStoreIdList.get(i)!=oldStoreIdList.get(i)){
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (limitEventList.size()>0){
|
||||
BotLimitEvent botLimitEvent = limitEventList.get(0);
|
||||
System.out.println(botLimitEvent.getEvent());
|
||||
System.out.println(botInputVO.getEvent());
|
||||
if (botLimitEvent.getReadWriteCode()!=botInputVO.getReadWriteCode()
|
||||
||botLimitEvent.getReadWritePr()!=botInputVO.getReadWritePr()
|
||||
||botLimitEvent.getAuthCategory()!=botInputVO.getAuthCategory()
|
||||
||botLimitEvent.getEvent()!=botInputVO.getEvent()){
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
//有变化需要更新
|
||||
if (flag) {
|
||||
//更新权限表(更新逻辑:先删除,再插入)
|
||||
installBots.forEach(installBot -> {
|
||||
//删除install表
|
||||
installMapper.deleteById(installBot.getId());
|
||||
//删除limit表
|
||||
botLimitMapper.delete(new QueryWrapper<BotLimitEvent>()
|
||||
.eq("bot_id", id)
|
||||
.eq("store_id", installBot.getStoreId()));
|
||||
});
|
||||
//插入install表
|
||||
for (Integer storeId : botInputVO.getStoreLit()){
|
||||
InstallBot installBot = shiftBotToInstallBot(botInputVO,updateBot,storeId);
|
||||
installMapper.insert(installBot);
|
||||
InstallBot bot = installMapper.selectOne(new QueryWrapper<InstallBot>()
|
||||
.eq("store_id",storeId)
|
||||
.eq("bot_id",installBot.getBotId()));
|
||||
BotLimitEvent botLimitEvent = shiftBotToLimit(botInputVO,updateBot,storeId,bot.getId());
|
||||
botLimitMapper.insert(botLimitEvent);
|
||||
}
|
||||
}
|
||||
return shiftBotToBotOutputVo(botInputVO,updateBot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkInfo(BotInputVO botVO) throws BotException {
|
||||
{
|
||||
|
||||
if (botVO.getUserId()==null){
|
||||
throw new BotException("userId is null!");
|
||||
}
|
||||
if (StringUtils.isBlank(botVO.getBotDes())){
|
||||
throw new BotException("botDes is null!");
|
||||
}
|
||||
if (StringUtils.isBlank(botVO.getBotName())){
|
||||
throw new BotException("botName is null!");
|
||||
}
|
||||
if (StringUtils.isBlank(botVO.getWebhook())){
|
||||
throw new BotException("webhook is null!");
|
||||
}
|
||||
}
|
||||
QueryWrapper<Bot> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("bot_name",botVO.getBotName());
|
||||
List<Bot> botList = botMapper.selectList(wrapper);
|
||||
if (botList.size()>0){
|
||||
throw new BotException("该名称已经被使用!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bot shiftObject(BotInputVO botVO) {
|
||||
Bot bot = new Bot();
|
||||
bot.setBotDes(botVO.getBotDes());
|
||||
bot.setBotName(botVO.getBotName());
|
||||
bot.setIsPublic(botVO.getIsPublic());
|
||||
bot.setWebhook(botVO.getWebhook());
|
||||
bot.setClientSecret(getClientSecret());
|
||||
bot.setClientId(getClientId());
|
||||
bot.setWebUrl(getBotUrl(botVO.getBotName()));
|
||||
bot.setLogo(botVO.getLogo());
|
||||
bot.setCreateTime(new Date());
|
||||
bot.setUpdateTime(new Date());
|
||||
bot.setState(0);
|
||||
bot.setInstallNum(1);
|
||||
return bot;
|
||||
}
|
||||
public BotLimitEvent shiftBotToLimit(BotInputVO botInputVO,Bot bot,Integer storeId,Integer installId){
|
||||
BotLimitEvent botLimitEvent = new BotLimitEvent();
|
||||
botLimitEvent.setBotId(bot.getId());
|
||||
botLimitEvent.setAuthCategory(botInputVO.getAuthCategory());
|
||||
botLimitEvent.setReadWriteCode(botInputVO.getReadWriteCode());
|
||||
botLimitEvent.setReadWritePr(botInputVO.getReadWritePr());
|
||||
botLimitEvent.setEvent(botInputVO.getEvent());
|
||||
botLimitEvent.setStoreId(storeId);
|
||||
botLimitEvent.setInstallId(installId);
|
||||
botLimitEvent.setCreateTime(new Date());
|
||||
botLimitEvent.setUpdateTime(new Date());
|
||||
return botLimitEvent;
|
||||
}
|
||||
public InstallBot shiftBotToInstallBot(BotInputVO botInputVO,Bot bot,Integer storeId){
|
||||
InstallBot installBot = new InstallBot();
|
||||
installBot.setBotId(bot.getId());
|
||||
installBot.setInstallerId(botInputVO.getUserId());
|
||||
installBot.setStoreId(storeId);
|
||||
installBot.setCreateTime(new Date());
|
||||
installBot.setUpdateTime(new Date());
|
||||
return installBot;
|
||||
}
|
||||
public RegisterBot shiftBotToRegisterBot(BotInputVO botInputVO,Bot bot){
|
||||
RegisterBot registerBot = new RegisterBot();
|
||||
registerBot.setBotId(bot.getId());
|
||||
registerBot.setDeveloperId(botInputVO.getUserId());
|
||||
registerBot.setCreateTime(new Date());
|
||||
registerBot.setUpdateTime(new Date());
|
||||
return registerBot;
|
||||
}
|
||||
public BotOutputVO shiftBotToBotOutputVo(BotInputVO botInputVO,Bot bot){
|
||||
BotOutputVO botOutputVO = new BotOutputVO();
|
||||
botOutputVO.setBotId(bot.getId());
|
||||
botOutputVO.setBotDes(bot.getBotDes());
|
||||
botOutputVO.setBotName(bot.getBotName());
|
||||
botOutputVO.setAuthCategory(botInputVO.getAuthCategory());
|
||||
botOutputVO.setClientId(bot.getClientId());
|
||||
botOutputVO.setClientSecret(bot.getClientSecret());
|
||||
botOutputVO.setIsPublic(bot.getIsPublic());
|
||||
botOutputVO.setWebhook(bot.getWebhook());
|
||||
botOutputVO.setUserId(botOutputVO.getUserId());
|
||||
botOutputVO.setWebUrl(bot.getWebUrl());
|
||||
botOutputVO.setStoreLit(botInputVO.getStoreLit());
|
||||
botOutputVO.setEvent(botInputVO.getEvent());
|
||||
botOutputVO.setReadWriteCode(botInputVO.getReadWriteCode());
|
||||
botOutputVO.setReadWritePr(botInputVO.getReadWritePr());
|
||||
botOutputVO.setLogo(bot.getLogo());
|
||||
return botOutputVO;
|
||||
}
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return "qwer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientSecret() {
|
||||
return "ert";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBotUrl(String botName) {
|
||||
return botName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.gitlink.softbot.vo;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BotInputVO implements Serializable {
|
||||
|
||||
//用户id
|
||||
private Integer userId;
|
||||
|
||||
//bot名称
|
||||
private String botName;
|
||||
|
||||
//bot详细介绍
|
||||
private String botDes;
|
||||
|
||||
//webhook地址
|
||||
private String webhook;
|
||||
|
||||
//头像
|
||||
private String logo;
|
||||
|
||||
//监管仓库的ids
|
||||
private List<Integer> storeLit;
|
||||
|
||||
//是否公开
|
||||
private Integer isPublic;
|
||||
|
||||
//代码读写权限(0:只读1:读写2:无权限)
|
||||
private Integer readWriteCode;
|
||||
|
||||
//请求读写权限(0:只读1:读写2:无权限)
|
||||
private Integer readWritePr;
|
||||
|
||||
//权限类型(0:代码仓库权限1:合并请求权限)
|
||||
private Integer authCategory;
|
||||
|
||||
//0:git推送到存储库1:创建分支或标签2:删除分支或标签3:合并请求被打开4:合并请求被分配
|
||||
private Integer event;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.gitlink.softbot.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BotOutputVO implements Serializable {
|
||||
|
||||
private Integer botId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
//bot名称
|
||||
private String botName;
|
||||
|
||||
//bot详细介绍
|
||||
private String botDes;
|
||||
|
||||
//webhook地址
|
||||
private String webhook;
|
||||
|
||||
//监管仓库的ids
|
||||
private List<Integer> storeLit;
|
||||
|
||||
//是否公开
|
||||
private Integer isPublic;
|
||||
|
||||
//代码读写权限(0:只读1:读写2:无权限)
|
||||
private Integer readWriteCode;
|
||||
|
||||
//请求读写权限(0:只读1:读写2:无权限)
|
||||
private Integer readWritePr;
|
||||
|
||||
//权限类型(0:代码仓库权限1:合并请求权限)
|
||||
private Integer authCategory;
|
||||
|
||||
//0:git推送到存储库1:创建分支或标签2:删除分支或标签3:合并请求被打开4:合并请求被分配
|
||||
private Integer event;
|
||||
|
||||
private String logo;
|
||||
|
||||
private String clientId;
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
private String webUrl;
|
||||
}
|
|
@ -5,12 +5,13 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class MarketBotPagesVO {
|
||||
public class MarketBotPagesVO implements Serializable {
|
||||
private int pageIndex;
|
||||
private int pageSize;
|
||||
private long total;
|
||||
|
|
|
@ -5,7 +5,7 @@ es-url:
|
|||
spring:
|
||||
datasource:
|
||||
username: root
|
||||
password: 123456
|
||||
password: tonglin0711
|
||||
url: jdbc:mysql://localhost:3306/soft_bot?useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
elasticsearch:
|
||||
|
|
|
@ -3,16 +3,18 @@ package com.gitlink.softbot.service.market;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.gitlink.softbot.entity.es.MarketBot;
|
||||
import com.gitlink.softbot.global.exception.BotException;
|
||||
import com.gitlink.softbot.service.user.IUserService;
|
||||
import com.gitlink.softbot.vo.BotInputVO;
|
||||
import com.gitlink.softbot.vo.MarketBotPagesVO;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@SpringBootTest
|
||||
|
@ -21,12 +23,14 @@ public class MarketServiceTest {
|
|||
|
||||
@Autowired
|
||||
IMarketService service;
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
@Test
|
||||
public void test() throws BotException {
|
||||
for (int i = 60; i < 80; i++) {
|
||||
MarketBot marketBot = new MarketBot();
|
||||
marketBot.setBotId("asd"+i);
|
||||
marketBot.setBotId(i);
|
||||
marketBot.setMarketDesc("童asdasdas林");
|
||||
marketBot.setMarketName("qqq");
|
||||
marketBot.setId(i);
|
||||
|
@ -52,4 +56,38 @@ public class MarketServiceTest {
|
|||
MarketBotPagesVO marketBotPagesVO1 = service.getMarketBotByNameLike("童",3,12);
|
||||
System.out.println(JSON.toJSONString(marketBotPagesVO1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void register() throws BotException{
|
||||
BotInputVO botInputVO = new BotInputVO();
|
||||
botInputVO.setBotDes("wqeqwe");
|
||||
botInputVO.setBotName("botqwertop");
|
||||
botInputVO.setWebhook("adadad");
|
||||
botInputVO.setEvent(3);
|
||||
botInputVO.setAuthCategory(1);
|
||||
botInputVO.setIsPublic(1);
|
||||
botInputVO.setReadWriteCode(1);
|
||||
botInputVO.setReadWritePr(1);
|
||||
botInputVO.setStoreLit(Arrays.asList(1,2,3,4));
|
||||
botInputVO.setUserId(12);
|
||||
botInputVO.setLogo("sada");
|
||||
userService.registerBot(botInputVO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update()throws BotException{
|
||||
BotInputVO botInputVO = new BotInputVO();
|
||||
botInputVO.setBotDes("wqeqwetonglinoooo");
|
||||
botInputVO.setBotName("botqwertop");
|
||||
botInputVO.setWebhook("adadad");
|
||||
botInputVO.setEvent(2);
|
||||
botInputVO.setAuthCategory(2);
|
||||
botInputVO.setIsPublic(1);
|
||||
botInputVO.setReadWriteCode(1);
|
||||
botInputVO.setReadWritePr(1);
|
||||
botInputVO.setStoreLit(Arrays.asList(1,2,3,4));
|
||||
botInputVO.setUserId(12);
|
||||
botInputVO.setLogo("sada");
|
||||
userService.updateBot(botInputVO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ es-url:
|
|||
spring:
|
||||
datasource:
|
||||
username: root
|
||||
password: 123456
|
||||
password: tonglin0711
|
||||
url: jdbc:mysql://localhost:3306/soft_bot?useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
elasticsearch:
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue