Helius
2022-07-07 ea4120a80f7ef6188a745d9b27238cde1a3f7d74
modify release
1 files added
5 files modified
83 ■■■■ changed files
src/main/java/com/xcong/farmer/cms/modules/core/service/ICmsCoreService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java 28 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminColumnController.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/ReleaseColumnDto.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java 23 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/core/service/ICmsCoreService.java
@@ -10,7 +10,7 @@
     * @param id
     * @param templateName
     */
    void articleProcess(Long id, String templateName, String templatPath);
    void articleProcess(Map<String, Object> data, String templateName, String templatePath);
    /**
     * 栏目编译
@@ -18,7 +18,7 @@
     * @param templateName 模板名称
     * @param columnOnly 是否只编译当前栏目列表页(如果false,则会编译栏目下所有子栏目或者所有文章)
     */
    void columnProcess(Map<String, Object> map, String templateName, boolean columnOnly);
    void columnProcess(Map<String, Object> map, String templateName);
    void indexProcess(Map<String, Object> map, String templateName);
src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java
@@ -10,6 +10,10 @@
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
 * @author wzy
@@ -21,30 +25,32 @@
    @Autowired
    private TemplateConfiguration cfg;
    private final Executor executor = new ThreadPoolExecutor(5, 10, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
    @Override
    public void articleProcess(Long id, String templateName, String templatePath) {
        Map<String, Object> data = new HashMap<>();
        data.put("id", id);
        data.put("companyId", 23L);
    public void articleProcess(Map<String, Object> data, String templateName, String templatePath) {
        data.put("templateType", "article");
        data.put("templatePath", templatePath);
        data.put("templateName", id);
        data.put("templateName", data.get("id"));
        if (StrUtil.isEmpty(templateName)) {
            templateName = "defualt.artile.html";
        }
        cfg.process(data, templateName);
        String finalTemplateName = templateName;
        executor.execute(() -> cfg.process(data, finalTemplateName));
    }
    @Override
    public void columnProcess(Map<String, Object> data, String templateName, boolean article) {
        data.put("companyId", 23L);
    public void columnProcess(Map<String, Object> data, String templateName) {
        data.put("templateType", "column");
        data.put("page", 1);
        if (StrUtil.isEmpty(templateName)) {
            templateName = "defualt.list.html";
        }
        cfg.process(data, templateName);
        String finalTemplateName = templateName;
        executor.execute(() -> cfg.process(data, finalTemplateName));
    }
    @Override
@@ -53,7 +59,7 @@
            templateName = "index.html";
        }
        data.put("companyId", 23L);
        cfg.process(data, templateName);
        String finalTemplateName = templateName;
        executor.execute(() -> cfg.process(data, finalTemplateName));
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminColumnController.java
@@ -10,6 +10,7 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -65,4 +66,10 @@
        return iColumnService.delObjs(adminDeleteDto);
    }
    @ApiOperation(value = "发布栏目", notes = "发布栏目")
    @PostMapping(value = "/release")
    public Result release(@RequestBody ReleaseColumnDto releaseColumnDto) {
        return Result.ok("发布成功");
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/dto/ReleaseColumnDto.java
New file
@@ -0,0 +1,20 @@
package com.xcong.farmer.cms.modules.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @author wzy
 * @date 2022-07-07
 **/
@Data
@ApiModel(value = "ReleaseColumnDto", description = "发布栏目接收参数类")
public class ReleaseColumnDto {
    @ApiModelProperty(value = "栏目ID", example = "1")
    private Long id;
    @ApiModelProperty(value = "是否编译子栏目和栏目下所有文章 1-是 ,2-否", example = "1")
    private Integer type;
}
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -46,6 +46,7 @@
    @Autowired
    private ICmsCoreService cmsCoreService;
    @Override
    public Result getArticleInPage(AdminArticleDto adminArticleDto) {
        UserEntity userlogin = LoginUserUtil.getLoginUser();
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java
@@ -6,6 +6,7 @@
import com.xcong.farmer.cms.modules.system.mapper.ArticleMapper;
import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper;
import com.xcong.farmer.cms.modules.system.service.IReleaseService;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -32,14 +33,25 @@
    @Override
    public void releaseArticle(Long id) {
        Long companyId = LoginUserUtil.getCompanyId();
        ArticleEntity article = articleMapper.selectById(id);
        ColumnEntity column = columnMapper.selectById(article.getColumnId());
        cmsCoreService.articleProcess(article.getId(), column.getArticleTemplate(), column.getPath());
        Map<String, Object> data = new HashMap<>();
        data.put("id", article.getId());
        data.put("companyId", companyId);
        cmsCoreService.articleProcess(data, column.getArticleTemplate(), column.getPath());
        this.releaseColumn(column.getId(), false);
        if (column.getParentId() != 0L) {
            releaseColumn(column.getParentId(), false);
        }
        this.releaseIndex();
    }
    @Override
    public void releaseColumn(Long id, boolean article) {
        Long companyId = LoginUserUtil.getCompanyId();
        ColumnEntity columnEntity = columnMapper.selectById(id);
        Map<String, Object> map = new HashMap<>();
        map.put("id", columnEntity.getId());
@@ -51,12 +63,17 @@
            map.put("parentCode", parent.getColumnCode());
        }
        map.put("templatePath", columnEntity.getPath());
        cmsCoreService.columnProcess(map, columnEntity.getListTemplate(), article);
        map.put("companyId", companyId);
        cmsCoreService.columnProcess(map, columnEntity.getListTemplate());
    }
    @Override
    public void releaseIndex() {
        Map<String, Object> map = new HashMap<>();
        Long companyId = LoginUserUtil.getCompanyId();
        map.put("companyId", companyId);
        cmsCoreService.indexProcess(map, null);
    }
}