Browse Source

Merge branch 'master' of ssh://101.201.226.163:50022/ccsens_wiki/ccsens_ptos

master
zy_Java 4 years ago
parent
commit
23cf6dcba7
  1. 10
      ptos_open/src/main/java/com/ccsens/ptos_open/api/PluginController.java
  2. 7
      ptos_open/src/main/java/com/ccsens/ptos_open/bean/dto/PluginDto.java
  3. 7
      ptos_open/src/main/java/com/ccsens/ptos_open/persist/dao/UserDao.java
  4. 12
      ptos_open/src/main/java/com/ccsens/ptos_open/service/BusinessService.java
  5. 6
      ptos_open/src/main/java/com/ccsens/ptos_open/service/IPluginService.java
  6. 56
      ptos_open/src/main/java/com/ccsens/ptos_open/service/PluginService.java
  7. 17
      ptos_open/src/main/resources/mapper_dao/UserDao.xml

10
ptos_open/src/main/java/com/ccsens/ptos_open/api/PluginController.java

@ -59,9 +59,17 @@ public class PluginController {
public JsonResponse updatePlugin(@ApiParam @Validated @RequestBody QueryDto<PluginDto.UpdatePlugin> params) throws Exception{ public JsonResponse updatePlugin(@ApiParam @Validated @RequestBody QueryDto<PluginDto.UpdatePlugin> params) throws Exception{
log.info("修改插件:{}",params); log.info("修改插件:{}",params);
pluginService.updatePlugin(params.getParam(),params.getUserId()); pluginService.updatePlugin(params.getParam(),params.getUserId());
log.info("修改插件成功"); log.info("修改插件成功");
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok();
} }
@MustLogin
@ApiOperation(value = "根据id查询插件", notes = "")
@RequestMapping(value = "/queryIdPlugin", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse <PluginVo.PluginInfo> queryIdPlugin(@ApiParam @Validated @RequestBody QueryDto<PluginDto.QueryIdPlugin> params) throws Exception{
log.info("根据id查询插件:{}",params);
PluginVo.PluginInfo pluginInfo = pluginService. queryIdPlugin(params.getParam(),params.getUserId());
log.info("返回插件信息");
return JsonResponse.newInstance().ok(pluginInfo);
}
} }

7
ptos_open/src/main/java/com/ccsens/ptos_open/bean/dto/PluginDto.java

@ -82,4 +82,11 @@ public class PluginDto {
private byte publish; private byte publish;
} }
@Data
@ApiModel("根据id查找插件")
public static class QueryIdPlugin {
@ApiModelProperty("插件id")
private Long id;
}
} }

7
ptos_open/src/main/java/com/ccsens/ptos_open/persist/dao/UserDao.java

@ -0,0 +1,7 @@
package com.ccsens.ptos_open.persist.dao;
public interface UserDao {
String getUserNameById(Long userId);
}

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

@ -115,7 +115,7 @@ public class BusinessService implements IBusinessService {
} }
Boolean p = pluginDao.verifyById(businessPlugin.getPluginId()); Boolean p = pluginDao.verifyById(businessPlugin.getPluginId());
if (!p) { if (!p) {
throw new BaseException(OpenCodeError.NOT_PLUGIN); throw new BaseException(OpenCodeError.NOT_BUSINESS);
} }
//修改关联的信息 //修改关联的信息
businessPlugin.setConfig(param.getConfig()); businessPlugin.setConfig(param.getConfig());
@ -125,13 +125,13 @@ public class BusinessService implements IBusinessService {
@Override @Override
public BusinessVo.BusinessInfo queryIdBusiness(BusinessDto.QueryIdBusiness param, Long userId) { 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()); OpenBusiness openBusiness = businessDao.selectByPrimaryKey(param.getBusinessId());
if(ObjectUtil.isNull(openBusiness)){
throw new BaseException(OpenCodeError.NOT_BUSINESS);
}
//返回业务信息
BusinessVo.BusinessInfo businessInfo = new BusinessVo.BusinessInfo(); BusinessVo.BusinessInfo businessInfo = new BusinessVo.BusinessInfo();
businessInfo.setId(openBusiness.getId()); businessInfo.setId(openBusiness.getId());
businessInfo.setName(openBusiness.getName()); businessInfo.setName(openBusiness.getName());

6
ptos_open/src/main/java/com/ccsens/ptos_open/service/IPluginService.java

@ -31,4 +31,10 @@ public interface IPluginService {
*/ */
void updatePlugin(PluginDto.UpdatePlugin param, Long userId); void updatePlugin(PluginDto.UpdatePlugin param, Long userId);
/**
* 根据id查询插件
* @param param 插件信息
* @param userId userId
*/
PluginVo.PluginInfo queryIdPlugin(PluginDto.QueryIdPlugin param, Long userId);
} }

56
ptos_open/src/main/java/com/ccsens/ptos_open/service/PluginService.java

@ -5,13 +5,13 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.ccsens.ptos_open.bean.dto.BusinessDto;
import com.ccsens.ptos_open.bean.dto.PluginDto; import com.ccsens.ptos_open.bean.dto.PluginDto;
import com.ccsens.ptos_open.bean.po.OpenPlugin; import com.ccsens.ptos_open.bean.po.*;
import com.ccsens.ptos_open.bean.po.OpenPluginImg; import com.ccsens.ptos_open.bean.vo.BusinessVo;
import com.ccsens.ptos_open.bean.po.OpenPluginImgExample;
import com.ccsens.ptos_open.bean.po.OpenPluginWithBLOBs;
import com.ccsens.ptos_open.bean.vo.PluginVo; import com.ccsens.ptos_open.bean.vo.PluginVo;
import com.ccsens.ptos_open.persist.dao.PluginDao; import com.ccsens.ptos_open.persist.dao.PluginDao;
import com.ccsens.ptos_open.persist.dao.UserDao;
import com.ccsens.ptos_open.persist.mapper.OpenPluginImgMapper; import com.ccsens.ptos_open.persist.mapper.OpenPluginImgMapper;
import com.ccsens.ptos_open.util.OpenCodeError; import com.ccsens.ptos_open.util.OpenCodeError;
import com.ccsens.util.CodeEnum; import com.ccsens.util.CodeEnum;
@ -34,7 +34,10 @@ import java.util.List;
@Service @Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class PluginService implements IPluginService { public class PluginService implements IPluginService {
@Resource
private OpenPluginImgMapper imgMapper;
@Resource
private UserDao userDao;
@Resource @Resource
private PluginDao pluginDao; private PluginDao pluginDao;
@Resource @Resource
@ -169,6 +172,49 @@ public class PluginService implements IPluginService {
pluginDao.updateByPrimaryKeySelective(plugin); pluginDao.updateByPrimaryKeySelective(plugin);
} }
@Override
public PluginVo.PluginInfo queryIdPlugin(PluginDto.QueryIdPlugin param, Long userId) {
//查询插件信息
OpenPluginWithBLOBs openPlugin = pluginDao.selectByPrimaryKey(param.getId());
if(ObjectUtil.isNull(openPlugin)){
throw new BaseException(OpenCodeError.NOT_PLUGIN);
}
//返回插件信息
PluginVo.PluginInfo pluginInfo = new PluginVo.PluginInfo();
pluginInfo.setId(openPlugin.getId());
pluginInfo.setName(openPlugin.getName());
pluginInfo.setVersions(openPlugin.getVersions());
pluginInfo.setIntro(openPlugin.getIntro());
pluginInfo.setUpdatedTime(openPlugin.getUpdatedAt().getTime());
pluginInfo.setAuthorId(openPlugin.getCreatorId());
//作者id查user表
String userName = userDao.getUserNameById(openPlugin.getCreatorId());
pluginInfo.setAuthorName(userName);
//通过id查询预览图
OpenPluginImgExample imgExample = new OpenPluginImgExample();
imgExample.createCriteria().andPluginIdEqualTo(openPlugin.getId()).andTypeEqualTo((byte)0);
List<OpenPluginImg> Img =imgMapper.selectByExample(imgExample);
String path = null;
if(Img != null && Img.size() != 0){
Img.get(0);
path = Img.get(0).getFilePath();
}
pluginInfo.setPreview(path);
if(openPlugin.getCreatorId() == userId) {
Byte main = 1;
pluginInfo.setMine(main);
} else {
Byte main = 0;
pluginInfo.setMine(main);
}
pluginInfo.setHtml(openPlugin.getHtml());
pluginInfo.setCss(openPlugin.getCss());
pluginInfo.setJs(openPlugin.getJs());
pluginInfo.setConfig(openPlugin.getConfig());
return pluginInfo;
}
} }

17
ptos_open/src/main/resources/mapper_dao/UserDao.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.ptos_open.persist.dao.UserDao">
<select id="getUserNameById" resultType="java.lang.String">
SELECT
`name`
FROM
t_sys_user
WHERE
id = #{userId}
and rec_status = 0
</select>
</mapper>
Loading…
Cancel
Save