|
|
@ -12,6 +12,8 @@ import com.ccsens.ptos_open.bean.po.OpenPluginWithBLOBs; |
|
|
|
import com.ccsens.ptos_open.bean.vo.PluginVo; |
|
|
|
import com.ccsens.ptos_open.persist.dao.PluginDao; |
|
|
|
import com.ccsens.ptos_open.persist.mapper.OpenPluginImgMapper; |
|
|
|
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.extern.slf4j.Slf4j; |
|
|
@ -39,22 +41,22 @@ public class PluginService implements IPluginService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<PluginVo.PluginInfo> queryPlugin(PluginDto.QueryByPage param, Long userId) { |
|
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
|
List<PluginVo.PluginInfo> pluginInfos = pluginDao.queryPluginList(param.getName(),param.getDepth(),userId); |
|
|
|
PageHelper.startPage(param.getPageNum(), param.getPageSize()); |
|
|
|
List<PluginVo.PluginInfo> pluginInfos = pluginDao.queryPluginList(param.getName(), param.getDepth(), userId); |
|
|
|
return new PageInfo<>(pluginInfos); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void savePlugin(PluginDto.SavePlugin param, Long userId) { |
|
|
|
public PluginVo.PluginReturn savePlugin(PluginDto.SavePlugin param, Long userId) { |
|
|
|
//TODO 验证用户权限
|
|
|
|
//添加插件
|
|
|
|
OpenPluginWithBLOBs openPlugin = new OpenPluginWithBLOBs(); |
|
|
|
BeanUtil.copyProperties(param,openPlugin); |
|
|
|
BeanUtil.copyProperties(param, openPlugin); |
|
|
|
openPlugin.setId(snowflake.nextId()); |
|
|
|
openPlugin.setCreatorId(userId); |
|
|
|
pluginDao.insertSelective(openPlugin); |
|
|
|
//保存预览图
|
|
|
|
if(StrUtil.isNotBlank(param.getPreview())){ |
|
|
|
if (StrUtil.isNotBlank(param.getPreview())) { |
|
|
|
OpenPluginImg pluginImg = new OpenPluginImg(); |
|
|
|
pluginImg.setId(snowflake.nextId()); |
|
|
|
pluginImg.setPluginId(openPlugin.getId()); |
|
|
@ -63,7 +65,7 @@ public class PluginService implements IPluginService { |
|
|
|
openPluginImgMapper.insertSelective(pluginImg); |
|
|
|
} |
|
|
|
//保存轮播图
|
|
|
|
if(CollectionUtil.isNotEmpty(param.getCarousel())){ |
|
|
|
if (CollectionUtil.isNotEmpty(param.getCarousel())) { |
|
|
|
param.getCarousel().forEach(path -> { |
|
|
|
OpenPluginImg pluginImg = new OpenPluginImg(); |
|
|
|
pluginImg.setId(snowflake.nextId()); |
|
|
@ -73,5 +75,62 @@ public class PluginService implements IPluginService { |
|
|
|
openPluginImgMapper.insertSelective(pluginImg); |
|
|
|
}); |
|
|
|
} |
|
|
|
//返回插件的id和name
|
|
|
|
PluginVo.PluginReturn pluginReturn = new PluginVo.PluginReturn(); |
|
|
|
pluginReturn.setId(openPlugin.getId()); |
|
|
|
pluginReturn.setName(openPlugin.getName()); |
|
|
|
return pluginReturn; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updatePlugin(PluginDto.UpdatePlugin param, Long userId) { |
|
|
|
//查询插件,判断插件是否存在
|
|
|
|
Boolean a = pluginDao.verifyById(param.getId()); |
|
|
|
if (a == null || !a) { |
|
|
|
throw new BaseException(OpenCodeError.NOT_PLUGIN); |
|
|
|
} |
|
|
|
//判断当前用户是否是插件的创建
|
|
|
|
OpenPluginWithBLOBs pluginWithBLOBs = new OpenPluginWithBLOBs(); |
|
|
|
pluginWithBLOBs.setId(param.getId()); |
|
|
|
//修改插件信息
|
|
|
|
if (param.getName() != null && !param.getName().equals("")) { |
|
|
|
pluginWithBLOBs.setName(param.getName()); |
|
|
|
} |
|
|
|
if (param.getVersions() != null && !param.getVersions().equals("")) { |
|
|
|
pluginWithBLOBs.setVersions(param.getVersions()); |
|
|
|
} |
|
|
|
if (param.getIntro() != null && !param.getIntro().equals("")) { |
|
|
|
pluginWithBLOBs.setIntro(param.getIntro()); |
|
|
|
} |
|
|
|
if (param.getDescription() != null && !param.getDescription().equals("")) { |
|
|
|
pluginWithBLOBs.setDescription(param.getDescription()); |
|
|
|
} |
|
|
|
if (param.getHtml() != null && !param.getHtml().equals("")) { |
|
|
|
pluginWithBLOBs.setHtml(param.getHtml()); |
|
|
|
} |
|
|
|
if (param.getCss() != null && !param.getCss().equals("")) { |
|
|
|
pluginWithBLOBs.setCss(param.getCss()); |
|
|
|
} |
|
|
|
if (param.getJs() != null && !param.getJs().equals("")) { |
|
|
|
pluginWithBLOBs.setJs(param.getJs()); |
|
|
|
} |
|
|
|
if (param.getConfig() != null && !param.getConfig().equals("")) { |
|
|
|
pluginWithBLOBs.setConfig(param.getConfig()); |
|
|
|
} |
|
|
|
pluginWithBLOBs.setPublish(param.getPublish()); |
|
|
|
//处理预览图和轮播图
|
|
|
|
if(param.getPreview() != null){ |
|
|
|
//删除之前的预览图,添加新的预览图
|
|
|
|
} |
|
|
|
pluginDao.updateByPrimaryKeySelective(pluginWithBLOBs); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|