| | |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <version>${mysql-driver.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 参数校验 start --> |
| | |
| | | <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> |
| | |
| | | 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; |
| | |
| | | * @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 { |
| | |
| | | |
| | | 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>()); |
| | | |
| | | |
| | | } |
| | |
| | | * @date 2022-07-01 |
| | | **/ |
| | | @Slf4j |
| | | public class TemplateConfiguration extends Configuration{ |
| | | public class TemplateConfiguration extends Configuration { |
| | | |
| | | private TemplateLoader templateLoader; |
| | | |
| | |
| | | } |
| | | map.put("apiUrl", API_URL); |
| | | |
| | | String companyCode = (String) map.get("companyCode"); |
| | | try { |
| | | String companyCode = (String) map.get("companyCode"); |
| | | |
| | | log.info("解析开始执行--#类型:{}#--#模板名称:{}#--#ID:{}#", map.get("templateType"), templateName, map.get("id")); |
| | | this.templateLoader.data(map); |
| | | Template template = template(FileUtils.path(templatePath, companyCode), templateName); |
| | | template.output(outputPath); |
| | | |
| | | // 判断是否有分页,有则执行。从第二页开始 |
| | | int i = 2; |
| | | while(Template.HAS_PAGING) { |
| | | map.put("page", i); |
| | | log.info("解析开始执行--#类型:{}#--#模板名称:{}#--#ID:{}#", map.get("templateType"), templateName, map.get("id")); |
| | | this.templateLoader.data(map); |
| | | Template pageTemplate = template(FileUtils.path(templatePath, companyCode), templateName); |
| | | pageTemplate.output(outputPath); |
| | | i++; |
| | | Template template = template(FileUtils.path(templatePath, companyCode), templateName); |
| | | template.output(outputPath); |
| | | |
| | | // 判断是否有分页,有则执行。从第二页开始 |
| | | int i = 2; |
| | | while (Template.HAS_PAGING) { |
| | | map.put("page", i); |
| | | this.templateLoader.data(map); |
| | | Template pageTemplate = template(FileUtils.path(templatePath, companyCode), templateName); |
| | | pageTemplate.output(outputPath); |
| | | i++; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("页面编译异常", e); |
| | | } |
| | | } |
| | | |
| | |
| | | **/ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(value = "/api") |
| | | @RequestMapping(value = "/cms") |
| | | @Api(value = "CmsCoreController", tags = "CMS核心类") |
| | | public class CmsCoreController { |
| | | |
| | |
| | | @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"); |
| | | } |
| | |
| | | @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("发布成功"); |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "内容类型 1:文章 2:图片 3:文件 4:音频") |
| | | private Integer contentType; |
| | | |
| | | @ApiModelProperty(value = "保存状态 1-仅保存 2-保存并发布") |
| | | private Integer saveState; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "内容类型 1:文章 2:图片 3:文件 4:音频") |
| | | private Integer contentType; |
| | | |
| | | @ApiModelProperty(value = "保存状态 1-仅保存 2-保存并发布") |
| | | private Integer saveState; |
| | | } |
| | |
| | | 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("添加成功"); |
| | | } |
| | | |
| | |
| | | String authorBelong = adminUpdateArticleDto.getAuthorBelong(); |
| | | articleEntity.setAuthorBelong(authorBelong); |
| | | this.baseMapper.updateById(articleEntity); |
| | | |
| | | if (adminUpdateArticleDto.getSaveState() == 2) { |
| | | releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId()); |
| | | } |
| | | return Result.ok("更新成功"); |
| | | } |
| | | |
| | |
| | | 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("删除成功"); |
| | |
| | | async: |
| | | request-timeout: 20s |
| | | datasource: |
| | | 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 |
| | | 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.cj.jdbc.Driver |
| | | druid: |
| | | initial-size: ${spring_datasource_druid_initial_size:10} |
| | | max-active: ${spring_datasource_druid_max_active:20} |
| | |
| | | async: |
| | | request-timeout: 20s |
| | | datasource: |
| | | # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗 |
| | | p6spy: true |
| | | 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 |
| | | 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 |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | druid: |
| | | initial-size: ${spring_datasource_druid_initial_size:10} |
| | | max-active: ${spring_datasource_druid_max_active:20} |