Commit c1b81d0d authored by wujj's avatar wujj
Browse files

Merge remote-tracking branch 'origin/5.2'

# Conflicts:
#	doc/mcms-5.1.sql
#	pom.xml
parents c791bf40 1a95a697
This diff is collapsed.
...@@ -2,11 +2,15 @@ ...@@ -2,11 +2,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>net.mingsoft</groupId>
<artifactId>ms-pom</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>ms-mcms</artifactId> <artifactId>ms-mcms</artifactId>
<version>5.1</version> <version>5.2-SNAPSHOT</version>
<name>ms-mcms</name> <name>ms-mcms</name>
<!-- 打包jar包 --> <!-- 打包jar包 -->
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -16,25 +20,22 @@ ...@@ -16,25 +20,22 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency>
<groupId>dm</groupId>
<artifactId>dm.jdbc.driver</artifactId>
<version>8.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>ms-mpeople</artifactId> <artifactId>ms-mpeople</artifactId>
<version>1.0.28</version> </dependency>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-db</artifactId>
</dependency> </dependency>
<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 --> <!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
...@@ -61,24 +62,97 @@ ...@@ -61,24 +62,97 @@
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration> <configuration>
<source>${java.version}</source> <excludes>
<target>${java.version}</target> <exclude>**/static/plugins/</exclude>
<exclude>**/static/skin/</exclude>
<exclude>**/*.yml</exclude>
<exclude>**/Dockerfile</exclude>
<exclude>**/ehcache.xml</exclude>
<exclude>**/upgrade/</exclude>
<exclude>**/MSApplication.*</exclude>
<exclude>**/MSServletInitializer.*</exclude>
</excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<excludes>
<exclude>**/static/plugins/</exclude>
<exclude>**/static/skin/</exclude>
<exclude>**/*.yml</exclude>
<exclude>**/Dockerfile</exclude>
<exclude>**/ehcache.xml</exclude>
<exclude>**/upgrade/</exclude>
<exclude>**/config/</exclude>
<exclude>**/MSApplication.java</exclude>
<exclude>**/MSServletInitializer.java</exclude>
</excludes>
</configuration>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id>
<goals> <goals>
<goal>repackage</goal> <goal>jar-no-fork</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration> <configuration>
<fork>true</fork> <charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration> </configuration>
</plugin> </plugin>
...@@ -95,7 +169,7 @@ ...@@ -95,7 +169,7 @@
</plugins> </plugins>
<resources> <resources>
<resource> <resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory> <directory>src/main/webapp</directory>
<excludes> <excludes>
<!--打包生产 --> <!--打包生产 -->
...@@ -103,6 +177,13 @@ ...@@ -103,6 +177,13 @@
<!-- <exclude>html/</exclude> --> <!-- <exclude>html/</exclude> -->
<!-- <exclude>upload/</exclude> --> <!-- <exclude>upload/</exclude> -->
<!-- <exclude>templets/</exclude> --> <!-- <exclude>templets/</exclude> -->
</excludes>
<excludes>
<!--打包生产 -->
<exclude>static/</exclude>
<exclude>html/</exclude>
<exclude>upload/</exclude>
<exclude>template/</exclude>
</excludes> </excludes>
</resource> </resource>
<resource> <resource>
...@@ -110,6 +191,9 @@ ...@@ -110,6 +191,9 @@
</resource> </resource>
<resource> <resource>
<directory>src/main/java</directory> <directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource> </resource>
</resources> </resources>
<defaultGoal>compile</defaultGoal> <defaultGoal>compile</defaultGoal>
......
...@@ -13,7 +13,7 @@ import java.util.Locale; ...@@ -13,7 +13,7 @@ import java.util.Locale;
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = {"net.mingsoft"}) @ComponentScan(basePackages = {"net.mingsoft"})
@MapperScan(basePackages={"**.dao"}) @MapperScan(basePackages={"**.dao","**.mapper"})
@ServletComponentScan(basePackages = {"net.mingsoft"}) @ServletComponentScan(basePackages = {"net.mingsoft"})
public class MSApplication { public class MSApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
package net.mingsoft.cms.action; package net.mingsoft.cms.action;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.base.entity.ResultData; import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn; import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean; import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.constant.e.BusinessTypeEnum; import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import net.mingsoft.basic.util.BasicUtil; import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.PinYinUtil;
import net.mingsoft.basic.util.StringUtil; import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.cms.biz.ICategoryBiz; import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.entity.CategoryEntity; import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.basic.util.PinYinUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -25,6 +25,7 @@ import springfox.documentation.annotations.ApiIgnore; ...@@ -25,6 +25,7 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
* 分类管理控制层 * 分类管理控制层
* @author 铭飞开发团队 * @author 铭飞开发团队
...@@ -34,7 +35,7 @@ import java.util.List; ...@@ -34,7 +35,7 @@ import java.util.List;
@Api(value = "分类接口") @Api(value = "分类接口")
@Controller("cmsCategoryAction") @Controller("cmsCategoryAction")
@RequestMapping("/${ms.manager.path}/cms/category") @RequestMapping("/${ms.manager.path}/cms/category")
public class CategoryAction extends BaseAction{ public class CategoryAction extends BaseAction {
/** /**
...@@ -84,23 +85,18 @@ public class CategoryAction extends BaseAction{ ...@@ -84,23 +85,18 @@ public class CategoryAction extends BaseAction{
}) })
@RequestMapping("/list") @RequestMapping("/list")
@ResponseBody @ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) { public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model, BindingResult result) {
category.setAppId(BasicUtil.getAppId());
BasicUtil.startPage(); BasicUtil.startPage();
List categoryList = categoryBiz.query(category); List categoryList = categoryBiz.query(category);
return ResultData.build().success(new EUListBean(categoryList,(int)BasicUtil.endPage(categoryList).getTotal())); return ResultData.build().success(new EUListBean(categoryList,(int) BasicUtil.endPage(categoryList).getTotal()));
} }
/** /**
* 返回编辑界面category_form * 返回编辑界面category_form
*/ */
@GetMapping("/form") @GetMapping("/form")
public String form(@ModelAttribute CategoryEntity category,HttpServletResponse response,HttpServletRequest request,ModelMap model){ public String form(@ModelAttribute CategoryEntity category, HttpServletResponse response, HttpServletRequest request, ModelMap model){
if(category.getId()!=null){ model.addAttribute("appId", BasicUtil.getAppId());
BaseEntity categoryEntity = categoryBiz.getEntity(Integer.parseInt(category.getId()));
model.addAttribute("categoryEntity",categoryEntity);
}
model.addAttribute("appId",BasicUtil.getAppId());
return "/cms/category/form"; return "/cms/category/form";
} }
...@@ -112,12 +108,11 @@ public class CategoryAction extends BaseAction{ ...@@ -112,12 +108,11 @@ public class CategoryAction extends BaseAction{
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query") @ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get") @GetMapping("/get")
@ResponseBody @ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){ public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){
if(category.getId()==null) { if(category.getId()==null) {
return ResultData.build().error(); return ResultData.build().error();
} }
category.setAppId(BasicUtil.getAppId()); CategoryEntity _category = (CategoryEntity)categoryBiz.getById(category.getId());
CategoryEntity _category = (CategoryEntity)categoryBiz.getEntity(Integer.parseInt(category.getId()));
return ResultData.build().success(_category); return ResultData.build().success(_category);
} }
...@@ -172,9 +167,16 @@ public class CategoryAction extends BaseAction{ ...@@ -172,9 +167,16 @@ public class CategoryAction extends BaseAction{
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){ if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100")); return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
} }
//获取拼音 //判断拼音是否重复
if(StrUtil.isNotBlank(category.getCategoryPinyin())) {
CategoryEntity _category = new CategoryEntity();
_category.setCategoryPinyin(category.getCategoryPinyin());
List<CategoryEntity> query = categoryBiz.query(_category);
if (query.size() > 0) {
return ResultData.build().error(getResString("err.exist", this.getResString("category.pinyin")));
}
}
category.setAppId(BasicUtil.getAppId());
categoryBiz.saveEntity(category); categoryBiz.saveEntity(category);
return ResultData.build().success(category); return ResultData.build().success(category);
} }
...@@ -187,9 +189,9 @@ public class CategoryAction extends BaseAction{ ...@@ -187,9 +189,9 @@ public class CategoryAction extends BaseAction{
@ResponseBody @ResponseBody
@LogAnn(title = "删除分类", businessType = BusinessTypeEnum.DELETE) @LogAnn(title = "删除分类", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:category:del") @RequiresPermissions("cms:category:del")
public ResultData delete(@RequestBody List<CategoryEntity> categorys,HttpServletResponse response, HttpServletRequest request) { public ResultData delete(@RequestBody List<CategoryEntity> categorys, HttpServletResponse response, HttpServletRequest request) {
for(int i = 0;i<categorys.size();i++){ for(int i = 0;i<categorys.size();i++){
categoryBiz.delete(Integer.parseInt(categorys.get(i).getId())); categoryBiz.delete(categorys.get(i).getId());
} }
return ResultData.build().success(); return ResultData.build().success();
} }
...@@ -244,11 +246,23 @@ public class CategoryAction extends BaseAction{ ...@@ -244,11 +246,23 @@ public class CategoryAction extends BaseAction{
} }
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 0, 100)){ if(!StringUtil.checkLength(category.getCategoryParentId()+"", 0, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100")); return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
//判断拼音是否重复并且是否和原拼音相同
if(StrUtil.isNotBlank(category.getCategoryPinyin()) && !categoryBiz.getById(category.getId()).getCategoryPinyin().equals(category.getCategoryPinyin())) {
CategoryEntity _category = new CategoryEntity();
_category.setCategoryPinyin(category.getCategoryPinyin());
List<CategoryEntity> query = categoryBiz.query(_category);
if (query.size() > 0) {
return ResultData.build().error(getResString("err.exist", this.getResString("category.pinyin")));
}
} }
String pingYin = PinYinUtil.getPingYin(category.getCategoryTitle()); String pingYin = PinYinUtil.getPingYin(category.getCategoryTitle());
//如果用户填写了拼音则使用用户填写的
if (StrUtil.isNotBlank(category.getCategoryPinyin())) {
pingYin = category.getCategoryPinyin();
}
CategoryEntity categoryEntity=new CategoryEntity(); CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setCategoryPinyin(pingYin); categoryEntity.setCategoryPinyin(pingYin);
categoryEntity.setAppId(BasicUtil.getAppId());
CategoryEntity categoryBizEntity = (CategoryEntity)categoryBiz.getEntity(categoryEntity); CategoryEntity categoryBizEntity = (CategoryEntity)categoryBiz.getEntity(categoryEntity);
category.setCategoryPinyin(pingYin); category.setCategoryPinyin(pingYin);
//如果存在此拼音栏目则拼接上id //如果存在此拼音栏目则拼接上id
...@@ -258,14 +272,12 @@ public class CategoryAction extends BaseAction{ ...@@ -258,14 +272,12 @@ public class CategoryAction extends BaseAction{
//判断是否选择子级为所属栏目 //判断是否选择子级为所属栏目
CategoryEntity _category = new CategoryEntity(); CategoryEntity _category = new CategoryEntity();
_category.setCategoryParentId(category.getId()); _category.setCategoryParentId(category.getId());
_category.setAppId(BasicUtil.getAppId());
List<CategoryEntity> categoryList = categoryBiz.queryChilds(_category); List<CategoryEntity> categoryList = categoryBiz.queryChilds(_category);
for(CategoryEntity item:categoryList){ for(CategoryEntity item:categoryList){
if(item.getId().equals(category.getCategoryId())){ if(item.getId().equals(category.getCategoryId())){
return ResultData.build().error(getResString("cannot.select.child")); return ResultData.build().error(getResString("cannot.select.child"));
} }
} }
category.setAppId(BasicUtil.getAppId());
categoryBiz.updateEntity(category); categoryBiz.updateEntity(category);
return ResultData.build().success(category); return ResultData.build().success(category);
} }
......
...@@ -4,7 +4,6 @@ import io.swagger.annotations.Api; ...@@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.base.entity.ResultData; import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn; import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean; import net.mingsoft.basic.bean.EUListBean;
...@@ -23,7 +22,9 @@ import springfox.documentation.annotations.ApiIgnore; ...@@ -23,7 +22,9 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 文章管理控制层 * 文章管理控制层
* @author 铭飞开发团队 * @author 铭飞开发团队
...@@ -33,7 +34,7 @@ import java.util.List; ...@@ -33,7 +34,7 @@ import java.util.List;
@Api(value = "文章接口") @Api(value = "文章接口")
@Controller("cmsContentAction") @Controller("cmsContentAction")
@RequestMapping("/${ms.manager.path}/cms/content") @RequestMapping("/${ms.manager.path}/cms/content")
public class ContentAction extends BaseAction{ public class ContentAction extends BaseAction {
/** /**
...@@ -86,23 +87,18 @@ public class ContentAction extends BaseAction{ ...@@ -86,23 +87,18 @@ public class ContentAction extends BaseAction{
}) })
@RequestMapping("/list") @RequestMapping("/list")
@ResponseBody @ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) { public ResultData list(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model, BindingResult result) {
content.setAppId(BasicUtil.getAppId());
BasicUtil.startPage(); BasicUtil.startPage();
List contentList = contentBiz.query(content); List contentList = contentBiz.query(content);
return ResultData.build().success(new EUListBean(contentList,(int)BasicUtil.endPage(contentList).getTotal())); return ResultData.build().success(new EUListBean(contentList,(int) BasicUtil.endPage(contentList).getTotal()));
} }
/** /**
* 返回编辑界面content_form * 返回编辑界面content_form
*/ */
@GetMapping("/form") @GetMapping("/form")
public String form(@ModelAttribute ContentEntity content,HttpServletResponse response,HttpServletRequest request,ModelMap model){ public String form(@ModelAttribute ContentEntity content, HttpServletResponse response, HttpServletRequest request, ModelMap model){
if(content.getId()!=null){ model.addAttribute("appId", BasicUtil.getAppId());
BaseEntity contentEntity = contentBiz.getEntity(Integer.parseInt(content.getId()));
model.addAttribute("contentEntity",contentEntity);
}
model.addAttribute("appId",BasicUtil.getAppId());
return "/cms/content/form"; return "/cms/content/form";
} }
...@@ -114,12 +110,11 @@ public class ContentAction extends BaseAction{ ...@@ -114,12 +110,11 @@ public class ContentAction extends BaseAction{
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query") @ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get") @GetMapping("/get")
@ResponseBody @ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){ public ResultData get(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response, HttpServletRequest request, @ApiIgnore ModelMap model){
if(content.getId()==null) { if(content.getId()==null) {
return ResultData.build().error(); return ResultData.build().error();
} }
content.setAppId(BasicUtil.getAppId()); ContentEntity _content = contentBiz.getById(content.getId());
ContentEntity _content = (ContentEntity)contentBiz.getEntity(Integer.parseInt(content.getId()));
return ResultData.build().success(_content); return ResultData.build().success(_content);
} }
...@@ -176,8 +171,7 @@ public class ContentAction extends BaseAction{ ...@@ -176,8 +171,7 @@ public class ContentAction extends BaseAction{
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){ if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200")); return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
} }
content.setAppId(BasicUtil.getAppId()); contentBiz.save(content);
contentBiz.saveEntity(content);
return ResultData.build().success(content); return ResultData.build().success(content);
} }
...@@ -189,12 +183,12 @@ public class ContentAction extends BaseAction{ ...@@ -189,12 +183,12 @@ public class ContentAction extends BaseAction{
@ResponseBody @ResponseBody
@LogAnn(title = "删除文章", businessType = BusinessTypeEnum.DELETE) @LogAnn(title = "删除文章", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:content:del") @RequiresPermissions("cms:content:del")
public ResultData delete(@RequestBody List<ContentEntity> contents,HttpServletResponse response, HttpServletRequest request) { public ResultData delete(@RequestBody List<ContentEntity> contents, HttpServletResponse response, HttpServletRequest request) {
int[] ids = new int[contents.size()]; List<String> ids = new ArrayList<>();
for(int i = 0;i<contents.size();i++){ for(int i = 0;i<contents.size();i++){
ids[i] =Integer.parseInt(contents.get(i).getId()) ; ids.add(contents.get(i).getId());
} }
contentBiz.delete(ids); contentBiz.removeByIds(ids);
return ResultData.build().success(); return ResultData.build().success();
} }
/** /**
...@@ -251,7 +245,6 @@ public class ContentAction extends BaseAction{ ...@@ -251,7 +245,6 @@ public class ContentAction extends BaseAction{
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){ if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200")); return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
} }
content.setAppId(BasicUtil.getAppId());
contentBiz.updateEntity(content); contentBiz.updateEntity(content);
return ResultData.build().success(content); return ResultData.build().success(content);
} }
......
...@@ -161,12 +161,10 @@ public class GeneraterAction extends BaseAction { ...@@ -161,12 +161,10 @@ public class GeneraterAction extends BaseAction {
if (CategoryId>0) { if (CategoryId>0) {
CategoryEntity categoryEntity = new CategoryEntity(); CategoryEntity categoryEntity = new CategoryEntity();
categoryEntity.setId(CategoryId+""); categoryEntity.setId(CategoryId+"");
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.queryChilds(categoryEntity); columns = categoryBiz.queryChilds(categoryEntity);
} else { } else {
// 获取所有的内容管理栏目 // 获取所有的内容管理栏目
CategoryEntity categoryEntity=new CategoryEntity(); CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.query(categoryEntity); columns = categoryBiz.query(categoryEntity);
} }
List<CategoryBean> articleIdList = null; List<CategoryBean> articleIdList = null;
......
package net.mingsoft.cms.action.web; package net.mingsoft.cms.action.web;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -103,10 +104,9 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ ...@@ -103,10 +104,9 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
@ApiImplicitParam(name = "contentId", value = "文章编号", required = true,paramType="path") @ApiImplicitParam(name = "contentId", value = "文章编号", required = true,paramType="path")
@GetMapping(value = "/{contentId}/hit") @GetMapping(value = "/{contentId}/hit")
@ResponseBody @ResponseBody
public void hit(@PathVariable @ApiIgnore int contentId, HttpServletRequest request, HttpServletResponse response){ public String hit(@PathVariable @ApiIgnore int contentId, HttpServletRequest request, HttpServletResponse response){
if(contentId<=0){ if(contentId<=0){
this.outString(response, "document.write(0)"); return "document.write(0)";
return;
} }
//获取ip //获取ip
String ip = BasicUtil.getIp(); String ip = BasicUtil.getIp();
...@@ -114,11 +114,17 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ ...@@ -114,11 +114,17 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
boolean isMobileDevice = BasicUtil.isMobileDevice(); boolean isMobileDevice = BasicUtil.isMobileDevice();
ContentEntity content = (ContentEntity)contentBiz.getEntity(contentId); ContentEntity content = (ContentEntity)contentBiz.getEntity(contentId);
if(content == null){
return "document.write(0)";
}
//浏览数+1 //浏览数+1
if(ObjectUtil.isNotEmpty(content.getContentHit())){
content.setContentHit(content.getContentHit()+1); content.setContentHit(content.getContentHit()+1);
}else {
content.setContentHit(1);
}
contentBiz.updateEntity(content); contentBiz.updateEntity(content);
// cms_history 增加相应记录 // cms_history 增加相应记录
HistoryLogEntity entity = new HistoryLogEntity(); HistoryLogEntity entity = new HistoryLogEntity();
entity.setHlIsMobile(isMobileDevice); entity.setHlIsMobile(isMobileDevice);
...@@ -126,17 +132,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{ ...@@ -126,17 +132,10 @@ public class ContentAction extends net.mingsoft.cms.action.BaseAction{
entity.setContentId(content.getId()); entity.setContentId(content.getId());
entity.setCreateDate(new Date()); entity.setCreateDate(new Date());
historyLogBiz.saveEntity(entity); historyLogBiz.saveEntity(entity);
if(content == null){
this.outString(response, "document.write(0)");
return;
}
if(content.getAppId() == null || content.getAppId() != BasicUtil.getAppId()){ if(content.getAppId() == null || content.getAppId() != BasicUtil.getAppId()){
this.outString(response, "document.write(0)"); return "document.write(0)";
return;
} }
this.outString(response, "document.write(" + content.getContentHit() + ")"); return "document.write(" + content.getContentHit() + ")";
return;
} }
} }
...@@ -26,7 +26,9 @@ import cn.hutool.core.util.PageUtil; ...@@ -26,7 +26,9 @@ import cn.hutool.core.util.PageUtil;
import freemarker.core.ParseException; import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException; import freemarker.template.MalformedTemplateNameException;
import freemarker.template.TemplateNotFoundException; import freemarker.template.TemplateNotFoundException;
import net.bytebuddy.implementation.bytecode.Throw;
import net.mingsoft.base.constant.Const; import net.mingsoft.base.constant.Const;
import net.mingsoft.basic.exception.BusinessException;
import net.mingsoft.basic.util.BasicUtil; import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil; import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.cms.bean.CategoryBean; import net.mingsoft.cms.bean.CategoryBean;
...@@ -105,7 +107,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -105,7 +107,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* 动态列表页 * 动态列表页
*/ */
@GetMapping("/index.do") @GetMapping("/index.do")
public void index(HttpServletRequest req, HttpServletResponse resp) { @ResponseBody
public String index(HttpServletRequest req, HttpServletResponse resp) {
Map map = BasicUtil.assemblyRequestMap(); Map map = BasicUtil.assemblyRequestMap();
map.forEach((k,v)->{ map.forEach((k,v)->{
map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1")); map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1"));
...@@ -129,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -129,7 +132,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.outString(resp, content); return content;
} }
/** /**
...@@ -137,8 +140,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -137,8 +140,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param req * @param req
* @param resp * @param resp
*/ */
@ResponseBody
@GetMapping("/list.do") @GetMapping("/list.do")
public void list(HttpServletRequest req, HttpServletResponse resp) { public String list(HttpServletRequest req, HttpServletResponse resp) {
Map map = BasicUtil.assemblyRequestMap(); Map map = BasicUtil.assemblyRequestMap();
map.forEach((k,v)->{ map.forEach((k,v)->{
map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1")); map.put(k,v.toString().replaceAll("('|\"|\\\\)","\\\\$1"));
...@@ -152,7 +156,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -152,7 +156,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
List<CategoryBean> columnArticles = contentBiz.queryIdsByCategoryIdForParser(contentBean); List<CategoryBean> columnArticles = contentBiz.queryIdsByCategoryIdForParser(contentBean);
//判断栏目下是否有文章 //判断栏目下是否有文章
if(columnArticles.size()==0){ if(columnArticles.size()==0){
this.outJson(resp, false); return "";
} }
//设置分页类 //设置分页类
PageBean page = new PageBean(); PageBean page = new PageBean();
...@@ -185,7 +189,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -185,7 +189,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.outString(resp, content); return content;
} }
/** /**
...@@ -193,18 +197,17 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -193,18 +197,17 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
* @param id 文章编号 * @param id 文章编号
*/ */
@GetMapping("/view.do") @GetMapping("/view.do")
public void view(String orderby,String order,HttpServletRequest req, HttpServletResponse resp) { @ResponseBody
public String view(String orderby,String order,HttpServletRequest req, HttpServletResponse resp) {
//参数文章编号 //参数文章编号
ContentEntity article = (ContentEntity) contentBiz.getEntity(BasicUtil.getInt(ParserUtil.ID)); ContentEntity article = (ContentEntity) contentBiz.getEntity(BasicUtil.getInt(ParserUtil.ID));
if(ObjectUtil.isNull(article)){ if(ObjectUtil.isNull(article)){
this.outJson(resp, null,false,getResString("err.empty", this.getResString("id"))); throw new BusinessException(this.getResString("err.empty", this.getResString("id"))) ;
return;
} }
if(StringUtils.isNotBlank(order)){ if(StringUtils.isNotBlank(order)){
//防注入 //防注入
if(!order.toLowerCase().equals("asc")&&!order.toLowerCase().equals("desc")){ if(!order.toLowerCase().equals("asc")&&!order.toLowerCase().equals("desc")){
this.outJson(resp, null,false,getResString("err.error", this.getResString("order"))); throw new BusinessException(this.getResString("err.error", this.getResString("order")));
return;
} }
} }
...@@ -239,7 +242,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -239,7 +242,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
ModelEntity contentModel = null; ModelEntity contentModel = null;
for (int artId = 0; artId < articleIdList.size();) { for (int artId = 0; artId < articleIdList.size();) {
//如果不是当前文章则跳过 //如果不是当前文章则跳过
if(articleIdList.get(artId).getArticleId() != Integer.parseInt(article.getId())){ if(articleIdList.get(artId).getArticleId().equals(article.getId())){
artId++; artId++;
continue; continue;
} }
...@@ -289,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -289,7 +292,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.outString(resp, content); return content;
} }
...@@ -303,7 +306,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -303,7 +306,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
*/ */
@RequestMapping(value = "search") @RequestMapping(value = "search")
@ResponseBody @ResponseBody
public void search(HttpServletRequest request, HttpServletResponse response) throws IOException { public String search(HttpServletRequest request, HttpServletResponse response) throws IOException {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 读取请求字段 // 读取请求字段
...@@ -447,7 +450,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction { ...@@ -447,7 +450,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.outString(response, content); return content;
} }
// 清除路径中的转义字符 // 清除路径中的转义字符
......
...@@ -13,16 +13,16 @@ public class CategoryBean extends CategoryEntity { ...@@ -13,16 +13,16 @@ public class CategoryBean extends CategoryEntity {
/** /**
* 文章编号 * 文章编号
*/ */
private int articleId; private String articleId;
public int getArticleId() { public String getArticleId() {
return articleId; return articleId;
} }
public void setArticleId(int articleId) { public void setArticleId(String articleId) {
this.articleId = articleId; this.articleId = articleId;
} }
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
* 创建日期:2019-11-28 15:12:32<br/> * 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
public interface ICategoryBiz extends IBaseBiz { public interface ICategoryBiz extends IBaseBiz<CategoryEntity> {
/** /**
* 查询当前分类下的所有子分类 * 查询当前分类下的所有子分类
...@@ -33,5 +33,5 @@ public interface ICategoryBiz extends IBaseBiz { ...@@ -33,5 +33,5 @@ public interface ICategoryBiz extends IBaseBiz {
*/ */
void update(CategoryEntity entity); void update(CategoryEntity entity);
void delete(int categoryId); void delete(String categoryId);
} }
...@@ -3,6 +3,7 @@ package net.mingsoft.cms.biz; ...@@ -3,6 +3,7 @@ package net.mingsoft.cms.biz;
import net.mingsoft.base.biz.IBaseBiz; import net.mingsoft.base.biz.IBaseBiz;
import net.mingsoft.cms.bean.CategoryBean; import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean; import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.mdiy.entity.ModelEntity; import net.mingsoft.mdiy.entity.ModelEntity;
import java.util.List; import java.util.List;
...@@ -15,7 +16,7 @@ import java.util.Map; ...@@ -15,7 +16,7 @@ import java.util.Map;
* 创建日期:2019-11-28 15:12:32<br/> * 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
public interface IContentBiz extends IBaseBiz { public interface IContentBiz extends IBaseBiz<ContentEntity> {
/** /**
* 根据文章属性查询 * 根据文章属性查询
......
...@@ -21,19 +21,23 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技 ...@@ -21,19 +21,23 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl; package net.mingsoft.cms.biz.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.mingsoft.base.biz.impl.BaseBizImpl; import net.mingsoft.base.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.base.dao.IBaseDao;
import net.mingsoft.basic.util.BasicUtil; import net.mingsoft.basic.util.PinYinUtil;
import net.mingsoft.cms.biz.ICategoryBiz; import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.dao.ICategoryDao; import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.dao.IContentDao; import net.mingsoft.cms.dao.IContentDao;
import net.mingsoft.cms.entity.CategoryEntity; import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.basic.util.PinYinUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -43,7 +47,8 @@ import java.util.List; ...@@ -43,7 +47,8 @@ import java.util.List;
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@Service("cmscategoryBizImpl") @Service("cmscategoryBizImpl")
public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { @Transactional(rollbackFor = RuntimeException.class)
public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> implements ICategoryBiz {
@Autowired @Autowired
...@@ -68,31 +73,49 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { ...@@ -68,31 +73,49 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
public void saveEntity(CategoryEntity categoryEntity) { public void saveEntity(CategoryEntity categoryEntity) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
String pingYin = PinYinUtil.getPingYin(categoryEntity.getCategoryTitle()); String pingYin = PinYinUtil.getPingYin(categoryEntity.getCategoryTitle());
//如果用户自己填入了拼音则使用用户的
if (StrUtil.isNotBlank(categoryEntity.getCategoryPinyin())) {
pingYin = categoryEntity.getCategoryPinyin();
}
CategoryEntity category=new CategoryEntity(); CategoryEntity category=new CategoryEntity();
category.setCategoryPinyin(pingYin); category.setCategoryPinyin(pingYin);
category.setAppId(BasicUtil.getAppId());
Object categoryBizEntity = getEntity(category); Object categoryBizEntity = getEntity(category);
setParentId(categoryEntity); setParentId(categoryEntity);
categoryEntity.setCategoryPinyin(pingYin); categoryEntity.setCategoryPinyin(pingYin);
super.saveEntity(categoryEntity); //更新新的父级
if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){
CategoryEntity parent = getById(categoryEntity.getCategoryId());
//如果之前是叶子节点就更新
if(parent.getLeaf()){
parent.setLeaf(false);
updateById(parent);
}
}
categoryEntity.setLeaf(false);
//如果是新增栏目一定是叶子节点
if (StrUtil.isEmpty(categoryEntity.getId())) {
categoryEntity.setLeaf(true);
}
super.save(categoryEntity);
//拼音存在则拼接id //拼音存在则拼接id
if(categoryBizEntity!=null){ if(categoryBizEntity!=null){
categoryEntity.setCategoryPinyin(pingYin+categoryEntity.getId()); categoryEntity.setCategoryPinyin(pingYin+categoryEntity.getId());
} }
CategoryEntity parentCategory = null; CategoryEntity parentCategory = null;
if (StringUtils.isNotBlank(categoryEntity.getCategoryId())) { if (StringUtils.isNotBlank(categoryEntity.getCategoryId())) {
parentCategory = (CategoryEntity)categoryDao.getEntity(Integer.parseInt(categoryEntity.getCategoryId())); parentCategory = (CategoryEntity)getById(categoryEntity.getCategoryId());
} }
//保存链接地址 //保存链接地址
String path=ObjectUtil.isNotNull(parentCategory)?parentCategory.getCategoryPath():""; String path=ObjectUtil.isNotNull(parentCategory)?parentCategory.getCategoryPath():"";
categoryEntity.setCategoryPath( path+"/" + categoryEntity.getCategoryPinyin()); categoryEntity.setCategoryPath( path+"/" + categoryEntity.getCategoryPinyin());
super.updateEntity(categoryEntity); setTopId(categoryEntity);
super.updateById(categoryEntity);
} }
private void setParentId(CategoryEntity categoryEntity) { private void setParentId(CategoryEntity categoryEntity) {
String path = ""; String path = "";
if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Integer.parseInt(categoryEntity.getCategoryId())>0) { if(StringUtils.isNotEmpty(categoryEntity.getCategoryId())&&Long.parseLong(categoryEntity.getCategoryId())>0) {
CategoryEntity category = (CategoryEntity)categoryDao.getEntity(Integer.parseInt(categoryEntity.getCategoryId())); CategoryEntity category = (CategoryEntity)getById(categoryEntity.getCategoryId());
path = category.getCategoryPath(); path = category.getCategoryPath();
if(StringUtils.isEmpty(category.getCategoryParentId())) { if(StringUtils.isEmpty(category.getCategoryParentId())) {
categoryEntity.setCategoryParentId(category.getId()); categoryEntity.setCategoryParentId(category.getId());
...@@ -132,13 +155,14 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { ...@@ -132,13 +155,14 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
String pingYin = PinYinUtil.getPingYin(entity.getCategoryTitle()); String pingYin = PinYinUtil.getPingYin(entity.getCategoryTitle());
CategoryEntity category=new CategoryEntity(); CategoryEntity category=new CategoryEntity();
category.setCategoryPinyin(pingYin); category.setCategoryPinyin(pingYin);
category.setAppId(BasicUtil.getAppId());
CategoryEntity categoryBizEntity = (CategoryEntity)getEntity(category); CategoryEntity categoryBizEntity = (CategoryEntity)getEntity(category);
//拼音存在则拼接id //拼音存在则拼接id
if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(entity.getId())){ if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(entity.getId())){
entity.setCategoryPinyin(pingYin+entity.getId()); entity.setCategoryPinyin(pingYin+entity.getId());
} }
super.updateEntity(entity); setParentLeaf(entity);
setTopId(entity);
super.updateById(entity);
setChildParentId(entity); setChildParentId(entity);
} }
...@@ -148,21 +172,72 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz { ...@@ -148,21 +172,72 @@ public class CategoryBizImpl extends BaseBizImpl implements ICategoryBiz {
} }
@Override @Override
public void delete(int categoryId) { public void delete(String categoryId) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
CategoryEntity category = (CategoryEntity) categoryDao.getEntity(categoryId); CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId);
//删除父类 //删除父类
if(category != null){ if(category != null){
category.setCategoryParentId(null); category.setCategoryParentId(null);
List<CategoryEntity> childrenList = categoryDao.queryChildren(category); List<CategoryEntity> childrenList = categoryDao.queryChildren(category);
int[] ids = new int[childrenList.size()]; List<String> ids = new ArrayList<>();
for(int i = 0; i < childrenList.size(); i++){ for(int i = 0; i < childrenList.size(); i++){
//删除子类 //删除子类
ids[i] = Integer.parseInt(childrenList.get(i).getId()); ids.add(childrenList.get(i).getId());
} }
categoryDao.delete(ids); categoryDao.deleteBatchIds(ids);
// 删除文章 // 删除文章
contentDao.deleteEntityByCategoryIds(ids); contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()]));
}
}
/**
* 设置父级叶子节点
* @param entity
*/
private void setParentLeaf(CategoryEntity entity){
Assert.notNull(entity);
CategoryEntity categoryEntity = getById(entity.getId());
//如果父级不为空并且修改了父级则需要更新父级
if(!entity.getCategoryId().equals(categoryEntity.getCategoryId())){
//更新旧的父级
if(StrUtil.isNotBlank(categoryEntity.getCategoryId())&&!"0".equals(categoryEntity.getCategoryId())){
CategoryEntity parent = getById(categoryEntity.getCategoryId());
//如果修改了父级则需要判断父级是否还有子节点
boolean leaf = parent.getLeaf();
//查找不等于当前更新的分类子集,有则不是叶子节点
QueryWrapper<CategoryEntity> queryWrapper = new QueryWrapper<>();
parent.setLeaf(count(queryWrapper.eq("category_id",parent.getId()).ne("id",entity.getId()))==0);
if(leaf!=parent.getLeaf()){
updateById(parent);
}
}
//更新新的父级
if(StrUtil.isNotBlank(entity.getCategoryId())&&!"0".equals(entity.getCategoryId())){
CategoryEntity parent = getById(entity.getCategoryId());
//如果之前是叶子节点就更新
if(parent.getLeaf()){
parent.setLeaf(false);
updateById(parent);
}
}
}
}
/**
* 设置顶级id
* @param entity
*/
private void setTopId(CategoryEntity entity){
String categoryParentId = entity.getCategoryParentId();
if(StrUtil.isNotBlank(categoryParentId)){
String[] ids = categoryParentId.split(",");
//如果有ParentId就取第一个
if(ids.length>0){
entity.setTopId(ids[0]);
return;
}
} }
entity.setTopId("0");
} }
} }
...@@ -21,14 +21,32 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技 ...@@ -21,14 +21,32 @@ The MIT License (MIT) * Copyright (c) 2019 铭飞科技
package net.mingsoft.cms.biz.impl; package net.mingsoft.cms.biz.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import net.mingsoft.basic.constant.Const;
import net.mingsoft.basic.holder.DataHolder;
import net.mingsoft.basic.util.BasicUtil; import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.bean.CategoryBean; import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean; import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.dao.ICategoryDao;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.bean.AttributeBean;
import net.mingsoft.mdiy.bean.PageBean;
import net.mingsoft.mdiy.entity.ModelEntity; import net.mingsoft.mdiy.entity.ModelEntity;
import net.mingsoft.mdiy.util.ParserUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import net.mingsoft.base.biz.impl.BaseBizImpl; import net.mingsoft.base.biz.impl.BaseBizImpl;
import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.base.dao.IBaseDao;
import java.io.IOException;
import java.util.*; import java.util.*;
import net.mingsoft.cms.biz.IContentBiz; import net.mingsoft.cms.biz.IContentBiz;
...@@ -41,11 +59,20 @@ import net.mingsoft.cms.dao.IContentDao; ...@@ -41,11 +59,20 @@ import net.mingsoft.cms.dao.IContentDao;
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@Service("cmscontentBizImpl") @Service("cmscontentBizImpl")
public class ContentBizImpl extends BaseBizImpl implements IContentBiz { public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> implements IContentBiz {
/*
* log4j日志记录
*/
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Autowired @Autowired
private IContentDao contentDao; private IContentDao contentDao;
/**
* 栏目管理业务层
*/
@Autowired
private ICategoryDao categoryDao;
@Override @Override
...@@ -67,4 +94,152 @@ public class ContentBizImpl extends BaseBizImpl implements IContentBiz { ...@@ -67,4 +94,152 @@ public class ContentBizImpl extends BaseBizImpl implements IContentBiz {
} }
return contentDao.getSearchCount(null,null,whereMap, appId,categoryIds); return contentDao.getSearchCount(null,null,whereMap, appId,categoryIds);
} }
/*
* 任务调度静态化任务
*/
public void staticizeTask(Integer appId, String tmpFileName, String generateFileName) {
LOG.info("定时静态化任务", new Date());
try {
//将任务采集传过来的appId导入到线程变量中
//当前线程使用appId时优先使用此数据
DataHolder.set(net.mingsoft.basic.constant.Const.APP_ID, appId);
//调用三种静态化
genernateColumn();
generaterIndex(tmpFileName, generateFileName);
//生成文章日期默认为执行日期的上一天
generateArticle(DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
LOG.info("静态化完成", new Date());
} catch (IOException e) {
LOG.info("静态化失败", new Date());
e.printStackTrace();
}
}
/*
* 生成文章逻辑
*/
private void generateArticle(String dateTime) throws IOException {
// 网站风格物理路径
List<CategoryBean> articleIdList = null;
List<CategoryEntity> categoryList = null;
AttributeBean attributeBean = new AttributeBean();
ContentBean contentBean = new ContentBean();
contentBean.setBeginTime(dateTime);
Map<String, Object> map = new HashMap<>();
map.put(net.mingsoft.basic.constant.Const.APP_ID, BasicUtil.getAppId());
PageBean page = new PageBean();
map.put(ParserUtil.HTML, ParserUtil.HTML);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page);
CategoryEntity categoryEntity = new CategoryEntity();
categoryList = categoryDao.query(categoryEntity);
for(CategoryEntity category : categoryList){
contentBean.setContentCategoryId(category.getId());
// 分类是列表
if(category.getCategoryType().equals("1")){
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(category.getCategoryListUrl())) || StringUtils.isEmpty(category.getCategoryListUrl())) {
LOG.error("模板不存在:{}",category.getCategoryUrl());
continue;
}
// 获取文章列表表属性
ParserUtil.read(category.getCategoryListUrl(),map, page,attributeBean);
contentBean.setFlag(attributeBean.getFlag());
contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = queryIdsByCategoryIdForParser(contentBean);
// 有符合条件的就更新
if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList);
}
}
}
/*
* 生成栏目逻辑
*/
private void genernateColumn() throws IOException {
List<CategoryEntity> columns = new ArrayList<>();
// 获取所有的内容管理栏目
CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setAppId(BasicUtil.getAppId());
columns = categoryDao.query(categoryEntity);
List<CategoryBean> articleIdList = null;
// 1、设置模板文件夹路径
// 获取栏目列表模版
for (CategoryEntity column : columns) {
ContentBean contentBean = new ContentBean();
contentBean.setContentCategoryId(column.getId());
// 分类是列表
if(column.getCategoryType().equals("1")) {
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryListUrl()))) {
LOG.error("模板不存在:{}", column.getCategoryUrl());
continue;
}
//获取模板中列表标签中的条件
Map<String, Object> map = new HashMap<>();
map.put(net.mingsoft.basic.constant.Const.APP_ID, BasicUtil.getAppId());
PageBean page = new PageBean();
map.put(ParserUtil.HTML, ParserUtil.HTML);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page);
AttributeBean attributeBean = new AttributeBean();
// 获取文章列表模板标签属性
ParserUtil.read(column.getCategoryListUrl(), map, page, attributeBean);
contentBean.setFlag(attributeBean.getFlag());
contentBean.setNoflag(attributeBean.getNoflag());
contentBean.setOrder(attributeBean.getOrder());
contentBean.setOrderBy(attributeBean.getOrderby());
}
articleIdList = contentDao.queryIdsByCategoryIdForParser(contentBean);
// 判断列表类型
switch (column.getCategoryType()) {
//TODO 暂时先用字符串代替
case "1": // 列表
CmsParserUtil.generateList(column, articleIdList.size());
break;
case "2":// 单页
if(articleIdList.size()==0){
CategoryBean columnArticleIdBean=new CategoryBean();
CopyOptions copyOptions=CopyOptions.create();
copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions);
articleIdList.add(columnArticleIdBean);
}
CmsParserUtil.generateBasic(articleIdList);
break;
}
}
}
/*
* 生成主页逻辑
*/
private void generaterIndex(String templatePath, String targetPath) throws IOException {
if (!FileUtil.exist(ParserUtil.buildTempletPath())) {
LOG.info("模板文件不存在");
return;
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(ParserUtil.IS_DO, false);
CategoryEntity column = new CategoryEntity();
//内容管理栏目编码
map.put(ParserUtil.COLUMN, column);
//如果单站点,就废弃站点地址
if (ParserUtil.IS_SINGLE) {
map.put(ParserUtil.URL, BasicUtil.getUrl());
}
//设置生成的路径
map.put(ParserUtil.HTML, ParserUtil.HTML);
//设置站点编号
map.put(Const.APP_ID, BasicUtil.getAppId());
String read = ParserUtil.read(templatePath, map);
FileUtil.writeString(read, ParserUtil.buildHtmlPath(targetPath), net.mingsoft.base.constant.Const.UTF8);
}
} }
\ No newline at end of file
package net.mingsoft.cms.dao; package net.mingsoft.cms.dao;
import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.base.dao.IBaseDao;
import java.util.*;
import net.mingsoft.cms.entity.CategoryEntity; import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* 分类持久层 * 分类持久层
* @author 铭飞开发团队 * @author 铭飞开发团队
...@@ -14,13 +13,13 @@ import org.springframework.stereotype.Component; ...@@ -14,13 +13,13 @@ import org.springframework.stereotype.Component;
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@Component("cmsCategoryDao") @Component("cmsCategoryDao")
public interface ICategoryDao extends IBaseDao { public interface ICategoryDao extends IBaseDao<CategoryEntity> {
/** /**
* 查询当前分类下面的所有子分类 * 查询当前分类下面的所有子分类
* @param category 必须存在categoryId categoryParentId * @param category 必须存在categoryId categoryParentId
* @return * @return
*/ */
public List<net.mingsoft.cms.entity.CategoryEntity> queryChildren(CategoryEntity category); public List<CategoryEntity> queryChildren(CategoryEntity category);
} }
\ No newline at end of file
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id,</if> <if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id,</if>
<if test="categoryDatetime != null">category_datetime,</if> <if test="categoryDatetime != null">category_datetime,</if>
<if test="categoryManagerId != null">category_manager_id,</if> <if test="categoryManagerId != null">category_manager_id,</if>
<if test="appId != null">app_id,</if>
<if test="dictId != null">dict_id,</if> <if test="dictId != null">dict_id,</if>
<if test="categoryFlag != null">category_flag,</if> <if test="categoryFlag != null">category_flag,</if>
<if test="categoryPath != null and categoryPath != ''">category_path,</if> <if test="categoryPath != null and categoryPath != ''">category_path,</if>
...@@ -75,7 +74,6 @@ ...@@ -75,7 +74,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">#{mdiyModelId},</if> <if test="mdiyModelId != null and mdiyModelId != ''">#{mdiyModelId},</if>
<if test="categoryDatetime != null">#{categoryDatetime},</if> <if test="categoryDatetime != null">#{categoryDatetime},</if>
<if test="categoryManagerId != null">#{categoryManagerId},</if> <if test="categoryManagerId != null">#{categoryManagerId},</if>
<if test="appId != null">#{appId},</if>
<if test="dictId != null">#{dictId},</if> <if test="dictId != null">#{dictId},</if>
<if test="categoryFlag != null ">#{categoryFlag},</if> <if test="categoryFlag != null ">#{categoryFlag},</if>
<if test="categoryPath != null and categoryPath != ''">#{categoryPath},</if> <if test="categoryPath != null and categoryPath != ''">#{categoryPath},</if>
...@@ -107,7 +105,6 @@ ...@@ -107,7 +105,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id=#{mdiyModelId},</if> <if test="mdiyModelId != null and mdiyModelId != ''">mdiy_model_id=#{mdiyModelId},</if>
<if test="categoryDatetime != null">category_datetime=#{categoryDatetime},</if> <if test="categoryDatetime != null">category_datetime=#{categoryDatetime},</if>
<if test="categoryManagerId != null">category_manager_id=#{categoryManagerId},</if> <if test="categoryManagerId != null">category_manager_id=#{categoryManagerId},</if>
<if test="appId != null">app_id=#{appId},</if>
<if test="dictId != null">dict_id=#{dictId},</if> <if test="dictId != null">dict_id=#{dictId},</if>
<if test="categoryFlag != null ">category_flag=#{categoryFlag},</if> <if test="categoryFlag != null ">category_flag=#{categoryFlag},</if>
<if test="categoryPath != null and categoryPath != ''">category_path=#{categoryPath},</if> <if test="categoryPath != null and categoryPath != ''">category_path=#{categoryPath},</if>
...@@ -143,7 +140,6 @@ ...@@ -143,7 +140,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''">and mdiy_model_id=#{mdiyModelId}</if> <if test="mdiyModelId != null and mdiyModelId != ''">and mdiy_model_id=#{mdiyModelId}</if>
<if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if> <if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if>
<if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if> <if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="dictId != null"> and dict_id=#{dictId} </if> <if test="dictId != null"> and dict_id=#{dictId} </if>
<if test="categoryFlag != null and categoryFlag != ''">and category_flag=#{categoryFlag}</if> <if test="categoryFlag != null and categoryFlag != ''">and category_flag=#{categoryFlag}</if>
<if test="categoryPath != null and categoryPath != ''">and category_path=#{categoryPath}</if> <if test="categoryPath != null and categoryPath != ''">and category_path=#{categoryPath}</if>
...@@ -170,9 +166,7 @@ ...@@ -170,9 +166,7 @@
<select id="queryChildren" resultMap="resultMap"> <select id="queryChildren" resultMap="resultMap">
select * from cms_category select * from cms_category
<where> <where>
<if test="appId &gt; 0">
and app_id=#{appId}
</if>
<if test="dictId &gt; 0"> <if test="dictId &gt; 0">
and dict_id=#{dictId} and dict_id=#{dictId}
</if> </if>
...@@ -228,7 +222,6 @@ ...@@ -228,7 +222,6 @@
<if test="mdiyModelId != null and mdiyModelId != ''"> and mdiy_model_id=#{mdiyModelId}</if> <if test="mdiyModelId != null and mdiyModelId != ''"> and mdiy_model_id=#{mdiyModelId}</if>
<if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if> <if test="categoryDatetime != null"> and category_datetime=#{categoryDatetime} </if>
<if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if> <if test="categoryManagerId != null"> and category_manager_id=#{categoryManagerId} </if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="dictId != null"> and dict_id=#{dictId} </if> <if test="dictId != null"> and dict_id=#{dictId} </if>
<if test="categoryFlag != null and categoryFlag != ''"> and category_flag=#{categoryFlag}</if> <if test="categoryFlag != null and categoryFlag != ''"> and category_flag=#{categoryFlag}</if>
<if test="categoryPath != null and categoryPath != ''"> and category_path=#{categoryPath}</if> <if test="categoryPath != null and categoryPath != ''"> and category_path=#{categoryPath}</if>
...@@ -240,7 +233,6 @@ ...@@ -240,7 +233,6 @@
<if test="del != null"> and del=#{del} </if> <if test="del != null"> and del=#{del} </if>
<include refid="net.mingsoft.base.dao.IBaseDao.sqlWhere"></include> <include refid="net.mingsoft.base.dao.IBaseDao.sqlWhere"></include>
</where> </where>
order by id desc
</select> </select>
</mapper> </mapper>
package net.mingsoft.cms.dao; package net.mingsoft.cms.dao;
import net.mingsoft.base.dao.IBaseDao; import net.mingsoft.base.dao.IBaseDao;
import java.util.*;
import net.mingsoft.cms.bean.CategoryBean; import net.mingsoft.cms.bean.CategoryBean;
import net.mingsoft.cms.bean.ContentBean; import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.entity.ContentEntity;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/** /**
* 文章持久层 * 文章持久层
* @author 铭飞开发团队 * @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/> * 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
public interface IContentDao extends IBaseDao { public interface IContentDao extends IBaseDao<ContentEntity> {
/** /**
* 查询文章编号集合 * 查询文章编号集合
...@@ -32,12 +34,12 @@ public interface IContentDao extends IBaseDao { ...@@ -32,12 +34,12 @@ public interface IContentDao extends IBaseDao {
* list[2]:是否是等值查询 list[3]:字段的值 * list[2]:是否是等值查询 list[3]:字段的值
* @return 文章实体总数 * @return 文章实体总数
*/ */
int getSearchCount(@Param("tableName") String tableName, @Param("diyList") List diyList,@Param("map") Map<String, Object> map, int getSearchCount(@Param("tableName") String tableName, @Param("diyList") List diyList, @Param("map") Map<String, Object> map,
@Param("websiteId") int websiteId, @Param("ids") String ids); @Param("websiteId") int websiteId, @Param("ids") String ids);
/** /**
* 分类编号删除文章 * 分类编号删除文章
* @param ids * @param ids
*/ */
void deleteEntityByCategoryIds(@Param("ids") int[] ids); void deleteEntityByCategoryIds(@Param("ids") String[] ids);
} }
\ No newline at end of file
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
<result column="content_url" property="contentUrl" /><!--文章跳转链接地址 --> <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
<result column="static_url" property="staticUrl" /><!--静态地址 --> <result column="static_url" property="staticUrl" /><!--静态地址 -->
<result column="content_hit" property="contentHit" /><!--点击次数 --> <result column="content_hit" property="contentHit" /><!--点击次数 -->
<result column="app_id" property="appId" /><!--文章管理的应用id -->
<result column="create_by" property="createBy" /><!--创建人 --> <result column="create_by" property="createBy" /><!--创建人 -->
<result column="create_date" property="createDate" /><!--创建时间 --> <result column="create_date" property="createDate" /><!--创建时间 -->
<result column="update_by" property="updateBy" /><!--修改人 --> <result column="update_by" property="updateBy" /><!--修改人 -->
...@@ -67,7 +66,6 @@ ...@@ -67,7 +66,6 @@
<result column="mdiy_model_id" property="mdiyModelId" /><!--栏目管理的内容模型id --> <result column="mdiy_model_id" property="mdiyModelId" /><!--栏目管理的内容模型id -->
<result column="category_datetime" property="categoryDatetime" /><!--类别发布时间 --> <result column="category_datetime" property="categoryDatetime" /><!--类别发布时间 -->
<result column="category_manager_id" property="categoryManagerId" /><!--发布用户id --> <result column="category_manager_id" property="categoryManagerId" /><!--发布用户id -->
<result column="app_id" property="appId" /><!--应用编号 -->
<result column="dict_id" property="dictId" /><!--字典对应编号 --> <result column="dict_id" property="dictId" /><!--字典对应编号 -->
<result column="category_flag" property="categoryFlag" /><!--栏目属性 --> <result column="category_flag" property="categoryFlag" /><!--栏目属性 -->
<result column="category_path" property="categoryPath" /><!--栏目路径 --> <result column="category_path" property="categoryPath" /><!--栏目路径 -->
...@@ -98,7 +96,6 @@ ...@@ -98,7 +96,6 @@
<if test="contentDetails != null and contentDetails != ''">content_details,</if> <if test="contentDetails != null and contentDetails != ''">content_details,</if>
<if test="contentUrl != null and contentUrl != ''">content_url,</if> <if test="contentUrl != null and contentUrl != ''">content_url,</if>
<if test="contentHit != null">content_hit,</if> <if test="contentHit != null">content_hit,</if>
<if test="appId != null">app_id,</if>
<if test="createBy &gt; 0">create_by,</if> <if test="createBy &gt; 0">create_by,</if>
<if test="createDate != null">create_date,</if> <if test="createDate != null">create_date,</if>
<if test="updateBy &gt; 0">update_by,</if> <if test="updateBy &gt; 0">update_by,</if>
...@@ -120,7 +117,6 @@ ...@@ -120,7 +117,6 @@
<if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if> <if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if>
<if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if> <if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if>
<if test="contentHit != null">#{contentHit},</if> <if test="contentHit != null">#{contentHit},</if>
<if test="appId != null">#{appId},</if>
<if test="createBy &gt; 0">#{createBy},</if> <if test="createBy &gt; 0">#{createBy},</if>
<if test="createDate != null">#{createDate},</if> <if test="createDate != null">#{createDate},</if>
<if test="updateBy &gt; 0">#{updateBy},</if> <if test="updateBy &gt; 0">#{updateBy},</if>
...@@ -147,7 +143,6 @@ ...@@ -147,7 +143,6 @@
<if test="contentDetails != null ">content_details=#{contentDetails},</if> <if test="contentDetails != null ">content_details=#{contentDetails},</if>
<if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if> <if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if>
<if test="contentHit != null">content_hit=#{contentHit},</if> <if test="contentHit != null">content_hit=#{contentHit},</if>
<if test="appId != null">app_id=#{appId},</if>
<if test="createBy &gt; 0">create_by=#{createBy},</if> <if test="createBy &gt; 0">create_by=#{createBy},</if>
<if test="createDate != null">create_date=#{createDate},</if> <if test="createDate != null">create_date=#{createDate},</if>
<if test="updateBy &gt; 0">update_by=#{updateBy},</if> <if test="updateBy &gt; 0">update_by=#{updateBy},</if>
...@@ -181,7 +176,6 @@ ...@@ -181,7 +176,6 @@
<if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if> <if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if>
<if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if> <if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if>
<if test="contentHit != null">and content_hit=#{contentHit}</if> <if test="contentHit != null">and content_hit=#{contentHit}</if>
<if test="appId != null"> and app_id=#{appId} </if>
<if test="createBy &gt; 0"> and create_by=#{createBy} </if> <if test="createBy &gt; 0"> and create_by=#{createBy} </if>
<if test="createDate != null"> and create_date=#{createDate} </if> <if test="createDate != null"> and create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and update_by=#{updateBy} </if> <if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
...@@ -219,7 +213,7 @@ ...@@ -219,7 +213,7 @@
</select> </select>
<!--条件查询--> <!--条件查询-->
<select id="query" resultMap="resultContentMap"> <select id="query" resultMap="resultContentMap">
select ct.*,CONCAT("/html/",ct.app_id,category_path,"/",ct.id,".html") AS static_url from ( select ct.*,CONCAT('/html/',ct.app_id,category_path,'/',ct.id,'.html') AS static_url from (
select ct.*,cc.category_path from cms_content ct select ct.*,cc.category_path from cms_content ct
join cms_category cc on ct.content_category_id=cc.id join cms_category cc on ct.content_category_id=cc.id
<where> <where>
...@@ -239,13 +233,12 @@ ...@@ -239,13 +233,12 @@
<if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if> <if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if>
<if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if> <if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if>
<if test="contentHit != null"> and content_hit=#{contentHit}</if> <if test="contentHit != null"> and content_hit=#{contentHit}</if>
<if test="appId != null"> and ct.app_id=#{appId} </if>
<if test="createBy &gt; 0"> and ct.create_by=#{createBy} </if> <if test="createBy &gt; 0"> and ct.create_by=#{createBy} </if>
<if test="createDate != null"> and ct.create_date=#{createDate} </if> <if test="createDate != null"> and ct.create_date=#{createDate} </if>
<if test="updateBy &gt; 0"> and ct.update_by=#{updateBy} </if> <if test="updateBy &gt; 0"> and ct.update_by=#{updateBy} </if>
<if test="updateDate != null"> and update_date=#{updateDate} </if> <if test="updateDate != null"> and update_date=#{updateDate} </if>
</where> </where>
)ct ORDER BY date_format(ct.content_datetime,'%Y-%m-%d') desc,content_sort desc )ct ORDER BY ct.content_datetime desc,content_sort desc
</select> </select>
<sql id="queryWhereCategoryId" databaseId="mysql"> <sql id="queryWhereCategoryId" databaseId="mysql">
...@@ -261,13 +254,11 @@ ...@@ -261,13 +254,11 @@
<!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 --> <!-- 根据站点编号、开始、结束时间和栏目编号查询文章编号集合 -->
<select id="queryIdsByCategoryIdForParser" resultMap="resultBean" > <select id="queryIdsByCategoryIdForParser" resultMap="resultBean" >
select select
cms_content.id article_id,c.* ct.id article_id,c.*
FROM cms_content FROM cms_content ct
LEFT JOIN cms_category c ON content_category_id = c.id LEFT JOIN cms_category c ON content_category_id = c.id
where cms_content.del=0 where ct.del=0
<if test="appId &gt; 0">
and cms_content.app_id = #{appId}
</if>
<!-- 查询子栏目数据 --> <!-- 查询子栏目数据 -->
<if test="contentCategoryId &gt; 0"> <if test="contentCategoryId &gt; 0">
and (content_category_id=#{contentCategoryId} or content_category_id in and (content_category_id=#{contentCategoryId} or content_category_id in
...@@ -280,17 +271,17 @@ ...@@ -280,17 +271,17 @@
and content_datetime &gt;= #{endTime} and content_datetime &gt;= #{endTime}
</if> </if>
<if test="flag!=null and flag!=''"> <if test="flag!=null and flag!=''">
and cms_content.content_type in ( #{flag}) and ct.content_type in ( #{flag})
</if> </if>
<if test="noflag!=null and noflag!=''"> <if test="noflag!=null and noflag!=''">
and (cms_content.content_type not in ( #{noflag} ) or cms_content.content_type is null) and (ct.content_type not in ( #{noflag} ) or ct.content_type is null)
</if> </if>
<if test="orderBy!=null and orderBy!='' "> <if test="orderBy!=null and orderBy!='' ">
<if test="orderBy=='date'">ORDER BY content_datetime</if> <if test="orderBy=='date'">ORDER BY content_datetime</if>
<if test="orderBy=='hit'">ORDER BY content_hit</if> <if test="orderBy=='hit'">ORDER BY content_hit</if>
<if test="orderBy=='sort'">ORDER BY content_sort</if> <if test="orderBy=='sort'">ORDER BY content_sort</if>
<if test="orderBy!='date' and orderBy!='hit' and orderBy!='sort'"> <if test="orderBy!='date' and orderBy!='hit' and orderBy!='sort'">
ORDER BY cms_content.id ORDER BY ct.id
</if> </if>
<choose> <choose>
<when test="order!=null and order!=''"> <when test="order!=null and order!=''">
...@@ -312,7 +303,7 @@ ...@@ -312,7 +303,7 @@
<if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id <if test="tableName!=null and tableName!='' and diyMap!=null">left join ${tableName} d on d.link_id=a.id
</if> </if>
<where> <where>
a.del=0 and a.app_id = #{websiteId} a.del=0
<if test="ids!=null and ids!=''"> <if test="ids!=null and ids!=''">
and FIND_IN_SET(content_category_id,#{ids}) and FIND_IN_SET(content_category_id,#{ids})
</if> </if>
......
...@@ -4,16 +4,21 @@ import cn.hutool.core.util.StrUtil; ...@@ -4,16 +4,21 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import net.mingsoft.base.entity.BaseEntity; import net.mingsoft.base.entity.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
/** /**
* 分类实体 * 分类实体
* @author 铭飞开发团队 * @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/> * 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@TableName("cms_category")
public class CategoryEntity extends BaseEntity { public class CategoryEntity extends BaseEntity {
private static final long serialVersionUID = 1574925152750L; private static final long serialVersionUID = 1574925152750L;
...@@ -80,6 +85,7 @@ private static final long serialVersionUID = 1574925152750L; ...@@ -80,6 +85,7 @@ private static final long serialVersionUID = 1574925152750L;
/** /**
* 应用编号 * 应用编号
*/ */
@TableField(exist = false)
private Integer appId; private Integer appId;
/** /**
* 字典对应编号 * 字典对应编号
...@@ -98,6 +104,31 @@ private static final long serialVersionUID = 1574925152750L; ...@@ -98,6 +104,31 @@ private static final long serialVersionUID = 1574925152750L;
*/ */
private String categoryParentId; private String categoryParentId;
/**
* 叶子节点
*/
private Boolean leaf;
/**
* 顶级id
*/
private String topId;
public Boolean getLeaf() {
return leaf;
}
public void setLeaf(Boolean leaf) {
this.leaf = leaf;
}
public String getTopId() {
return topId;
}
public void setTopId(String topId) {
this.topId = topId;
}
/** /**
* 设置栏目管理名称 * 设置栏目管理名称
......
package net.mingsoft.cms.entity; package net.mingsoft.cms.entity;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import net.mingsoft.base.entity.BaseEntity; import net.mingsoft.base.entity.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
/** /**
* 文章实体 * 文章实体
* @author 铭飞开发团队 * @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/> * 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@TableName("cms_content")
public class ContentEntity extends BaseEntity { public class ContentEntity extends BaseEntity {
private static final long serialVersionUID = 1574925152617L; private static final long serialVersionUID = 1574925152617L;
...@@ -73,6 +78,7 @@ private static final long serialVersionUID = 1574925152617L; ...@@ -73,6 +78,7 @@ private static final long serialVersionUID = 1574925152617L;
/** /**
* 文章管理的应用id * 文章管理的应用id
*/ */
@TableField(exist = false)
private Integer appId; private Integer appId;
/** /**
* 点击次数 * 点击次数
......
...@@ -34,3 +34,4 @@ content.sort=\u81EA\u5B9A\u4E49\u987A\u5E8F ...@@ -34,3 +34,4 @@ content.sort=\u81EA\u5B9A\u4E49\u987A\u5E8F
category.diy.url=\u81EA\u5B9A\u4E49\u94FE\u63A5 category.diy.url=\u81EA\u5B9A\u4E49\u94FE\u63A5
content.keyword=\u5173\u952E\u5B57 content.keyword=\u5173\u952E\u5B57
templet.file=\u672A\u627E\u5230\u6A21\u677F\u6587\u4EF6 templet.file=\u672A\u627E\u5230\u6A21\u677F\u6587\u4EF6
category.pinyin=\u62FC\u97F3
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment