Browse Source

20220119

master
Ling Ang 4 years ago
parent
commit
fcd6b66523
  1. 9
      ptos_open/src/main/java/com/ccsens/ptos_open/api/BusinessController.java
  2. 8
      ptos_open/src/main/java/com/ccsens/ptos_open/bean/dto/BusinessDto.java
  3. 44
      ptos_open/src/main/java/com/ccsens/ptos_open/service/BusinessService.java
  4. 9
      ptos_open/src/main/java/com/ccsens/ptos_open/service/IBusinessService.java
  5. 2
      ptos_open/src/main/resources/mapper_dao/BusinessDao.xml

9
ptos_open/src/main/java/com/ccsens/ptos_open/api/BusinessController.java

@ -81,4 +81,13 @@ public class BusinessController {
log.info("修改业务下的插件配置信息成功");
return JsonResponse.newInstance().ok();
}
@MustLogin
@ApiOperation(value = "通过id查询业务信息", notes = "")
@RequestMapping(value = "/queryIdBusiness", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<BusinessVo.BusinessInfo> queryIdBusiness(@ApiParam @Validated @RequestBody QueryDto<BusinessDto.QueryIdBusiness> params) throws Exception{
log.info("通过id查询业务信息:{}",params);
BusinessVo.BusinessInfo businessInfos = businessService. queryIdBusiness(params.getParam(),params.getUserId());
log.info("返回业务信息");
return JsonResponse.newInstance().ok(businessInfos);
}
}

8
ptos_open/src/main/java/com/ccsens/ptos_open/bean/dto/BusinessDto.java

@ -76,4 +76,12 @@ public class BusinessDto {
@ApiModelProperty("是否开启debug模式 0不开启 1开启")
private Byte debug;
}
@Data
@ApiModel("通过id查询业务信息")
public static class QueryIdBusiness {
@ApiModelProperty("业务信息对应的id")
private Long businessId;
}
}

44
ptos_open/src/main/java/com/ccsens/ptos_open/service/BusinessService.java

@ -7,9 +7,7 @@ import com.ccsens.ptos_open.bean.dto.BusinessDto;
import com.ccsens.ptos_open.bean.po.OpenBusiness;
import com.ccsens.ptos_open.bean.po.OpenBusinessPlugin;
import com.ccsens.ptos_open.bean.po.OpenBusinessPluginExample;
import com.ccsens.ptos_open.bean.po.OpenPluginWithBLOBs;
import com.ccsens.ptos_open.bean.vo.BusinessVo;
import com.ccsens.ptos_open.bean.vo.PluginVo;
import com.ccsens.ptos_open.persist.dao.BusinessDao;
import com.ccsens.ptos_open.persist.dao.PluginDao;
import com.ccsens.ptos_open.persist.mapper.OpenBusinessPluginMapper;
@ -18,7 +16,6 @@ import com.ccsens.ptos_open.util.OpenCodeError;
import com.ccsens.util.exception.BaseException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -45,8 +42,8 @@ public class BusinessService implements IBusinessService {
@Override
public PageInfo<BusinessVo.BusinessInfo> queryBusiness(BusinessDto.QueryByPage param, Long userId) {
PageHelper.startPage(param.getPageNum(),param.getPageSize());
List<BusinessVo.BusinessInfo> pluginInfos = businessDao.queryBusinessList(param.getDepth(), param.getName(),param.getPub(),userId);
PageHelper.startPage(param.getPageNum(), param.getPageSize());
List<BusinessVo.BusinessInfo> pluginInfos = businessDao.queryBusinessList(param.getDepth(), param.getName(), param.getPub(), userId);
return new PageInfo<>(pluginInfos);
}
@ -78,19 +75,19 @@ public class BusinessService implements IBusinessService {
public void relevancePlugin(BusinessDto.RelevancePlugin param, Long userId) {
//判断插件是否存在
Boolean p = pluginDao.verifyById(param.getPluginId());
if(p == null || !p){
if (p == null || !p) {
throw new BaseException(OpenCodeError.NOT_PLUGIN);
}
//判断业务是否存在
Boolean b = businessDao.verifyById(param.getBusinessId());
if(b == null || !b){
if (b == null || !b) {
throw new BaseException(OpenCodeError.NOT_BUSINESS);
}
//验证业务下已经关联此插件,则提示
OpenBusinessPluginExample businessPluginExample = new OpenBusinessPluginExample();
businessPluginExample.createCriteria().andBusinessIdEqualTo(param.getBusinessId()).andPluginIdEqualTo(param.getPluginId());
List<OpenBusinessPlugin> openBusinessPlugins = businessPluginMapper.selectByExample(businessPluginExample);
if(CollectionUtil.isNotEmpty(openBusinessPlugins)){
if (CollectionUtil.isNotEmpty(openBusinessPlugins)) {
throw new BaseException(OpenCodeError.BUSINESS_PLUGIN);
}
//添加业务插件关联关系
@ -105,8 +102,8 @@ public class BusinessService implements IBusinessService {
@Override
public PageInfo<BusinessVo.BusinessPlugin> businessQueryPlugin(BusinessDto.BusinessQueryPlugin param, Long userId) {
PageHelper.startPage(param.getPageNum(),param.getPageSize());
List<BusinessVo.BusinessPlugin> businessPluginList = businessDao.businessQueryPlugin(param.getBusinessId(),userId);
PageHelper.startPage(param.getPageNum(), param.getPageSize());
List<BusinessVo.BusinessPlugin> businessPluginList = businessDao.businessQueryPlugin(param.getBusinessId(), userId);
return new PageInfo<>(businessPluginList);
}
@ -114,11 +111,11 @@ public class BusinessService implements IBusinessService {
public void updateConfig(BusinessDto.UpdateConfig param, Long userId) {
//检查关联的插件是否存在
OpenBusinessPlugin businessPlugin = businessPluginMapper.selectByPrimaryKey(param.getBusinessPluginId());
if(ObjectUtil.isNull(businessPlugin)){
if (ObjectUtil.isNull(businessPlugin)) {
throw new BaseException(OpenCodeError.NOT_PLUGIN);
}
Boolean p = pluginDao.verifyById(businessPlugin.getPluginId());
if(!p){
if (!p) {
throw new BaseException(OpenCodeError.NOT_PLUGIN);
}
//修改关联的信息
@ -126,4 +123,27 @@ public class BusinessService implements IBusinessService {
businessPlugin.setDebug(param.getDebug());
businessPluginMapper.updateByPrimaryKeySelective(businessPlugin);
}
@Override
public BusinessVo.BusinessInfo queryIdBusiness(BusinessDto.QueryIdBusiness param, Long userId) {
//检查该id业务是否存在
Boolean b = businessDao.verifyById(param.getBusinessId());
if (b == null || !b) {
throw new BaseException(OpenCodeError.NOT_BUSINESS);
}
//查询业务信息
OpenBusiness openBusiness = businessDao.selectByPrimaryKey(param.getBusinessId());
BusinessVo.BusinessInfo businessInfo = new BusinessVo.BusinessInfo();
businessInfo.setId(openBusiness.getId());
businessInfo.setName(openBusiness.getName());
businessInfo.setSecret(openBusiness.getSecret());
businessInfo.setPub(openBusiness.getPub());
businessInfo.setCreateTime(openBusiness.getCreatedAt().getTime());
businessInfo.setUpdateTime(openBusiness.getUpdatedAt().getTime());
businessInfo.setDescription(openBusiness.getDescription());
businessInfo.setStartUsing(openBusiness.getStartUsing());
businessInfo.setAppId(openBusiness.getAppId());
return businessInfo;
}
}

9
ptos_open/src/main/java/com/ccsens/ptos_open/service/IBusinessService.java

@ -2,7 +2,6 @@ package com.ccsens.ptos_open.service;
import com.ccsens.ptos_open.bean.dto.BusinessDto;
import com.ccsens.ptos_open.bean.vo.BusinessVo;
import com.ccsens.ptos_open.bean.vo.PluginVo;
import com.github.pagehelper.PageInfo;
/**
@ -46,4 +45,12 @@ public interface IBusinessService {
* @param userId userId
*/
void updateConfig(BusinessDto.UpdateConfig param, Long userId);
/**
* 通过id查找业务信息
* @param param 配置信息
* @param userId userId
*/
BusinessVo.BusinessInfo queryIdBusiness(BusinessDto.QueryIdBusiness param, Long userId);
}

2
ptos_open/src/main/resources/mapper_dao/BusinessDao.xml

@ -20,7 +20,7 @@
FROM
`t_open_business`
WHERE
creator_id = 2
creator_id = #{userId}
and rec_status = 0
<if test="pub != null">
and pub = 0

Loading…
Cancel
Save