|
|
@ -8,11 +8,14 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.ptos_open.bean.dto.PluginDto; |
|
|
|
import com.ccsens.ptos_open.bean.po.OpenPlugin; |
|
|
|
import com.ccsens.ptos_open.bean.po.OpenPluginImg; |
|
|
|
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.persist.dao.PluginDao; |
|
|
|
import com.ccsens.ptos_open.persist.mapper.OpenPluginImgMapper; |
|
|
|
import com.ccsens.ptos_open.util.OpenCodeError; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.CodeError; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -89,45 +92,83 @@ public class PluginService implements IPluginService { |
|
|
|
if (a == null || !a) { |
|
|
|
throw new BaseException(OpenCodeError.NOT_PLUGIN); |
|
|
|
} |
|
|
|
//判断当前用户是否是插件的创建
|
|
|
|
OpenPluginWithBLOBs pluginWithBLOBs = new OpenPluginWithBLOBs(); |
|
|
|
pluginWithBLOBs.setId(param.getId()); |
|
|
|
//查询插件的创建者id,判断当前用户是否是插件的创建
|
|
|
|
Long creatorId = pluginDao.getPluginCreatorId(param.getId()); |
|
|
|
if(!userId.equals(creatorId)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
|
} |
|
|
|
//新建插件
|
|
|
|
OpenPluginWithBLOBs plugin = new OpenPluginWithBLOBs(); |
|
|
|
plugin.setId(param.getId()); |
|
|
|
//修改插件信息
|
|
|
|
if (param.getName() != null && !param.getName().equals("")) { |
|
|
|
pluginWithBLOBs.setName(param.getName()); |
|
|
|
if (StrUtil.isNotBlank(param.getName())) { |
|
|
|
plugin.setName(param.getName()); |
|
|
|
} |
|
|
|
if (param.getVersions() != null && !param.getVersions().equals("")) { |
|
|
|
pluginWithBLOBs.setVersions(param.getVersions()); |
|
|
|
if (StrUtil.isNotBlank(param.getVersions())) { |
|
|
|
plugin.setVersions(param.getVersions()); |
|
|
|
} |
|
|
|
if (param.getIntro() != null && !param.getIntro().equals("")) { |
|
|
|
pluginWithBLOBs.setIntro(param.getIntro()); |
|
|
|
if (StrUtil.isNotBlank(param.getIntro())) { |
|
|
|
plugin.setIntro(param.getIntro()); |
|
|
|
} |
|
|
|
if (param.getDescription() != null && !param.getDescription().equals("")) { |
|
|
|
pluginWithBLOBs.setDescription(param.getDescription()); |
|
|
|
if (StrUtil.isNotBlank(param.getDescription())) { |
|
|
|
plugin.setDescription(param.getDescription()); |
|
|
|
} |
|
|
|
if (param.getHtml() != null && !param.getHtml().equals("")) { |
|
|
|
pluginWithBLOBs.setHtml(param.getHtml()); |
|
|
|
if (StrUtil.isNotBlank(param.getHtml())) { |
|
|
|
plugin.setHtml(param.getHtml()); |
|
|
|
} |
|
|
|
if (param.getCss() != null && !param.getCss().equals("")) { |
|
|
|
pluginWithBLOBs.setCss(param.getCss()); |
|
|
|
if (StrUtil.isNotBlank(param.getCss())) { |
|
|
|
plugin.setCss(param.getCss()); |
|
|
|
} |
|
|
|
if (param.getJs() != null && !param.getJs().equals("")) { |
|
|
|
pluginWithBLOBs.setJs(param.getJs()); |
|
|
|
if (StrUtil.isNotBlank(param.getJs())) { |
|
|
|
plugin.setJs(param.getJs()); |
|
|
|
} |
|
|
|
if (param.getConfig() != null && !param.getConfig().equals("")) { |
|
|
|
pluginWithBLOBs.setConfig(param.getConfig()); |
|
|
|
if (StrUtil.isNotBlank(param.getConfig())) { |
|
|
|
plugin.setConfig(param.getConfig()); |
|
|
|
} |
|
|
|
pluginWithBLOBs.setPublish(param.getPublish()); |
|
|
|
//处理预览图和轮播图
|
|
|
|
if(param.getPreview() != null){ |
|
|
|
//删除之前的预览图,添加新的预览图
|
|
|
|
plugin.setPublish(param.getPublish()); |
|
|
|
//TODO 处理预览图和轮播图
|
|
|
|
OpenPluginImgExample pluginImgExample = new OpenPluginImgExample(); |
|
|
|
|
|
|
|
if(StrUtil.isNotBlank(param.getPreview())){ |
|
|
|
pluginImgExample.createCriteria().andPluginIdEqualTo(param.getId()).andTypeEqualTo((byte) 0); |
|
|
|
//删除之前的预览图
|
|
|
|
List<OpenPluginImg> openPluginImgs = openPluginImgMapper.selectByExample(pluginImgExample); |
|
|
|
if(CollectionUtil.isNotEmpty(openPluginImgs)){ |
|
|
|
openPluginImgs.forEach(openPluginImg -> { |
|
|
|
openPluginImg.setRecStatus((byte) 2); |
|
|
|
openPluginImgMapper.updateByPrimaryKeySelective(openPluginImg); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
//添加新的预览图
|
|
|
|
OpenPluginImg pluginImg = new OpenPluginImg(); |
|
|
|
pluginImg.setId(snowflake.nextId()); |
|
|
|
pluginImg.setPluginId(param.getId()); |
|
|
|
pluginImg.setType((byte) 0); |
|
|
|
pluginImg.setFilePath(param.getPreview()); |
|
|
|
openPluginImgMapper.insertSelective(pluginImg); |
|
|
|
} |
|
|
|
pluginDao.updateByPrimaryKeySelective(pluginWithBLOBs); |
|
|
|
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(param.getCarousel())){ |
|
|
|
pluginImgExample.createCriteria().andPluginIdEqualTo(param.getId()).andTypeEqualTo((byte) 1); |
|
|
|
List<OpenPluginImg> openPluginImgs = openPluginImgMapper.selectByExample(pluginImgExample); |
|
|
|
openPluginImgs.forEach(openPluginImg -> { |
|
|
|
openPluginImg.setRecStatus((byte) 2); |
|
|
|
openPluginImgMapper.updateByPrimaryKeySelective(openPluginImg); |
|
|
|
}); |
|
|
|
//如果轮播图不为空,则删除旧数据,重新添加
|
|
|
|
param.getCarousel().forEach(carousel -> { |
|
|
|
OpenPluginImg pluginImg = new OpenPluginImg(); |
|
|
|
pluginImg.setId(snowflake.nextId()); |
|
|
|
pluginImg.setPluginId(param.getId()); |
|
|
|
pluginImg.setType((byte) 1); |
|
|
|
pluginImg.setFilePath(carousel); |
|
|
|
openPluginImgMapper.insertSelective(pluginImg); |
|
|
|
}); |
|
|
|
} |
|
|
|
//修改插件信息
|
|
|
|
pluginDao.updateByPrimaryKeySelective(plugin); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|