fix
Helius
2022-08-16 f75fac3aaaf1e3783f2edb4d4e3261ffda7f9499
fix
10 files modified
62 ■■■■ changed files
pom.xml 7 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/FarmerCmsApplication.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/common/contants/AppContants.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/core/controller/CmsCoreController.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddArticleDto.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateArticleDto.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java 15 ●●●● patch | view | raw | blame | history
src/main/resources/application-test.yml 10 ●●●● patch | view | raw | blame | history
src/main/resources/application.yml 5 ●●●●● patch | view | raw | blame | history
pom.xml
@@ -107,7 +107,6 @@
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-driver.version}</version>
        </dependency>
        <!-- 参数校验 start -->
@@ -280,6 +279,12 @@
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
        <!-- 控制台 SQL日志打印插件 -->
        <dependency>
            <groupId>p6spy</groupId>
src/main/java/com/xcong/farmer/cms/FarmerCmsApplication.java
@@ -1,5 +1,6 @@
package com.xcong.farmer.cms;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.xcong.farmer.cms.netty.server.WebSocketServer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +13,7 @@
 * @author helius
 */
@EnableSwagger2
@SpringBootApplication
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@MapperScan("com.xcong.farmer.cms.modules.*.mapper")
@MapperScan("com.xcong.farmer.cms.modules.*.dao")
public class FarmerCmsApplication implements CommandLineRunner {
src/main/java/com/xcong/farmer/cms/common/contants/AppContants.java
@@ -33,7 +33,7 @@
    public static final String PICTURE_PATH = "D:\\Tools\\";
    public static final Executor EXECUTOR = new ThreadPoolExecutor(15, 30, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
    public static final Executor EXECUTOR = new ThreadPoolExecutor(10, 30, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
}
src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java
@@ -36,6 +36,7 @@
        }
        map.put("apiUrl", API_URL);
        try {
        String companyCode = (String) map.get("companyCode");
        log.info("解析开始执行--#类型:{}#--#模板名称:{}#--#ID:{}#", map.get("templateType"), templateName, map.get("id"));
@@ -52,6 +53,9 @@
            pageTemplate.output(outputPath);
            i++;
        }
        } catch (Exception e) {
            log.error("页面编译异常", e);
        }
    }
    public Template template(String templatePath, String templateName) {
src/main/java/com/xcong/farmer/cms/modules/core/controller/CmsCoreController.java
@@ -18,7 +18,7 @@
 **/
@Slf4j
@RestController
@RequestMapping(value = "/api")
@RequestMapping(value = "/cms")
@Api(value = "CmsCoreController", tags = "CMS核心类")
public class CmsCoreController {
@@ -28,8 +28,8 @@
    @ApiOperation(value = "发布文章", notes = "发布文章")
    @PostMapping(value = "releaseArticle/{id}")
    public Result releaseArticle(@PathVariable("id") Long id) {
        Long companyId = LoginUserUtil.getCompanyId();
//        Long companyId = 24L;
//        Long companyId = LoginUserUtil.getCompanyId();
        Long companyId = 26L;
        releaseService.releaseArticle(id, companyId);
        return Result.ok("success");
    }
@@ -55,8 +55,8 @@
    @ApiOperation(value = "发布全站", notes = "发布全站")
    @PostMapping(value = "/releaseAll")
    public Result releaseAll() {
        Long companyId = LoginUserUtil.getCompanyId();
//        Long companyId = 24L;
//        Long companyId = LoginUserUtil.getCompanyId();
        Long companyId = 26L;
        releaseService.releaseAll(companyId);
        return Result.ok("发布成功");
    }
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddArticleDto.java
@@ -68,4 +68,7 @@
    @ApiModelProperty(value = "内容类型 1:文章 2:图片 3:文件 4:音频")
    private Integer contentType;
    @ApiModelProperty(value = "保存状态 1-仅保存 2-保存并发布")
    private Integer saveState;
}
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminUpdateArticleDto.java
@@ -70,4 +70,7 @@
    @ApiModelProperty(value = "内容类型 1:文章 2:图片 3:文件 4:音频")
    private Integer contentType;
    @ApiModelProperty(value = "保存状态 1-仅保存 2-保存并发布")
    private Integer saveState;
}
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -132,6 +132,10 @@
        articleEntity.setType(adminAddArticleDto.getType());
        articleEntity.setContentType(adminAddArticleDto.getContentType());
        this.baseMapper.insert(articleEntity);
        if (adminAddArticleDto.getSaveState() == 2) {
            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
        }
        return Result.ok("添加成功");
    }
@@ -211,6 +215,10 @@
        String authorBelong = adminUpdateArticleDto.getAuthorBelong();
        articleEntity.setAuthorBelong(authorBelong);
        this.baseMapper.updateById(articleEntity);
        if (adminUpdateArticleDto.getSaveState() == 2) {
            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
        }
        return Result.ok("更新成功");
    }
@@ -223,8 +231,11 @@
                Long articleId = Long.valueOf(articleIdStr);
                ArticleEntity articleEntity = this.baseMapper.selectById(articleId);
                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
                this.baseMapper.updateById(articleEntity);
//                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
//                this.baseMapper.updateById(articleEntity);
                if (articleEntity != null) {
                    this.baseMapper.deleteById(articleId);
                }
            }
        }
        return Result.ok("删除成功");
src/main/resources/application-test.yml
@@ -10,11 +10,17 @@
    async:
      request-timeout: 20s
  datasource:
    dynamic:
      # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗
      p6spy: false
      # 配置默认数据源
      primary: base
      datasource:
        base:
    url: jdbc:mysql://120.27.238.55:3306/farmer_cms?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
    username: ct_test
    password: 123456
    driver-class-name: com.mysql.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
          driver-class-name: com.mysql.cj.jdbc.Driver
    druid:
      initial-size: ${spring_datasource_druid_initial_size:10}
      max-active: ${spring_datasource_druid_max_active:20}
src/main/resources/application.yml
@@ -10,8 +10,13 @@
    async:
      request-timeout: 20s
  datasource:
    dynamic:
    # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗
    p6spy: true
      # 配置默认数据源
      primary: base
      datasource:
        base:
    url: jdbc:mysql://120.27.238.55:3306/farmer_cms?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
    username: ct_test
    password: 123456