src/main/java/com/xcong/farmer/cms/modules/core/controller/CmsCoreController.java
@@ -18,7 +18,7 @@ **/ @Slf4j @RestController @RequestMapping(value = "/cms") @RequestMapping(value = "/api") @Api(value = "CmsCoreController", tags = "CMS核心类") public class CmsCoreController { @@ -48,4 +48,6 @@ releaseService.releaseIndex(companyId); return Result.ok("success"); } } src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminWebSetController.java
@@ -2,6 +2,7 @@ import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.modules.system.dto.AdminUpdateWebSetDto; import com.xcong.farmer.cms.modules.system.service.IReleaseService; import com.xcong.farmer.cms.modules.system.service.IWebSetService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -20,6 +21,9 @@ @Resource private IWebSetService iWebSetService; @Resource private IReleaseService releaseService; @ApiOperation(value = "查看网页设置", notes = "查看网页设置") @GetMapping(value = "/seeWebSetInfo") public Result seeWebSetInfo() { @@ -31,4 +35,10 @@ public Result updateWebSet(@RequestBody @Valid AdminUpdateWebSetDto adminUpdateWebSetDto) { return iWebSetService.updateWebSet(adminUpdateWebSetDto); } @ApiOperation(value = "发布全站", notes = "发布全站") @PostMapping(value = "/releaseAll") public Result releaseAll() { return null; } } src/main/java/com/xcong/farmer/cms/modules/system/mapper/ArticleMapper.java
@@ -27,4 +27,6 @@ IPage<WebArticleVo> selectWebArticleInPage(Page<WebArticleVo> page, @Param("record") ArticleEntity articleEntity); List<Long> selectArticleIdsByColumnId(@Param("columnId") Long columnId, @Param("companyId") Long companyId, @Param("type") Integer type); List<ArticleEntity> selectArticleByColumnId(@Param("columnId") Long columnId, @Param("companyId") Long companyId, @Param("type") Integer type); } src/main/java/com/xcong/farmer/cms/modules/system/service/IReleaseService.java
@@ -7,5 +7,9 @@ void releaseColumn(Long id, int type, Long companyId); void releaseColumns(int type, Long companyId); void releaseIndex(Long companyId); void releaseAll(Long companyId); } src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.farmer.cms.common.contants.AppContants; import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.configurations.properties.CmsProperties; import com.xcong.farmer.cms.modules.system.dto.AdminAddColumnDto; import com.xcong.farmer.cms.modules.system.dto.AdminColumnDto; import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; @@ -41,6 +42,8 @@ private ArticleMapper articleMapper; @Autowired private CompanyMapper companyMapper; @Autowired private CmsProperties cmsProperties; @Override public Result getColumnInPage(AdminColumnDto adminColumnDto) { @@ -168,10 +171,14 @@ if (columnEntity.getTargetType() == 1) { ArticleEntity articleEntity = articleMapper.selectById(Long.parseLong(columnEntity.getTargetUrl())); adminSeeColumnInfoVo.setTargetName(articleEntity.getTitle()); adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + columnEntity.getPath() + "/" + columnEntity.getTargetUrl() + ".html"); } else if (columnEntity.getTargetType() == 2) { ColumnEntity column = this.baseMapper.selectByCodeAndCompanyId(columnEntity.getTargetUrl(), LoginUserUtil.getCompanyId()); adminSeeColumnInfoVo.setTargetName(column.getColumnName()); adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + column.getPath()); } } else { adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + columnEntity.getPath()); } adminSeeColumnInfoVo.setTargetUrl(columnEntity.getTargetUrl()); return Result.ok(adminSeeColumnInfoVo); src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java
@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; /** * @TODO 发布时,index存在重复发布的情况,可优化。用线程notify唤醒。 * @author wzy * @date 2022-07-05 **/ @@ -38,7 +39,7 @@ @Autowired private ICmsCoreService cmsCoreService; private final Executor executor = new ThreadPoolExecutor(5, 10, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); private final Executor executor = new ThreadPoolExecutor(5, 20, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); @Override public void releaseArticle(Long id, Long companyId) { @@ -85,11 +86,32 @@ } } List<Long> ids = articleMapper.selectArticleIdsByColumnId(columnEntity.getId(), companyId, type); cmsCoreService.articlesProcess(map, ids, columnEntity.getArticleTemplate(), columnEntity.getPath()); List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(columnEntity.getId(), companyId, type); if (CollUtil.isNotEmpty(articles)) { for (ArticleEntity article : articles) { if (article.getType() == 1) { map.put("id", article.getId()); cmsCoreService.articleProcess(map, columnEntity.getArticleTemplate(), columnEntity.getPath()); } } } releaseIndex(companyId); }); } } @Override public void releaseColumns(int type, Long companyId) { List<ColumnEntity> columns = columnMapper.selectColumnByParentId(0L, companyId, 2); if (CollUtil.isEmpty(columns)) { return; } for (ColumnEntity column : columns) { releaseColumn(column.getId(), type, companyId); } } @@ -116,4 +138,12 @@ cmsCoreService.indexProcess(map, null); } @Override public void releaseAll(Long companyId) { Map<String, Object> map = new HashMap<>(); map.put("companyId", companyId); releaseColumns(4, companyId); } } src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminSeeColumnInfoVo.java
@@ -52,4 +52,7 @@ @ApiModelProperty(value = "内容类型 1:文章 2:图片 3:文件 4:音频") private Integer contentType; @ApiModelProperty(value = "栏目地址") private String url; } src/main/resources/mapper/ArticleMapper.xml
@@ -119,6 +119,19 @@ </select> <select id="selectArticleIdsByColumnId" resultType="java.lang.Long"> select a.id from t_article a where a.column_id=#{columnId} and a.company_id=#{companyId} <if test="type != 4"> <if test="type == 2"> and release_status=1 </if> <if test="type == 3"> and release_status=0 </if> </if> </select> <select id="selectArticleByColumnId" resultType="com.xcong.farmer.cms.modules.system.entity.ArticleEntity"> select * from t_article a where a.column_id=#{columnId} and a.company_id=#{companyId} <if test="type != 4">