Commit 09ff0390 authored by tianbj's avatar tianbj
Browse files

Merge remote-tracking branch 'origin/5.0.0' into 5.0.0

# Conflicts:
#	README.md
#	doc/历史/4.6.5-to-4.7.0-mysql.sql
#	doc/历史/4.6.5-to-4.7.0-sqlserver.sql
#	doc/历史/db-mcms-mysql-4.7.0.sql
#	doc/历史/db-mcms-sqlserver-4.7.0.sql
#	pom.xml
#	src/main/java/net/mingsoft/cms/action/ArticleAction.java
#	src/main/java/net/mingsoft/cms/action/ColumnAction.java
#	src/main/java/net/mingsoft/cms/action/GeneraterAction.java
#	src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
#	src/main/java/net/mingsoft/cms/biz/IArticleBiz.java
#	src/main/java/net/mingsoft/cms/biz/impl/ArticleBizImpl.java
#	src/main/java/net/mingsoft/cms/dao/IArticleDao.java
#	src/main/java/net/mingsoft/cms/dao/IArticleDao.xml
#	src/main/java/net/mingsoft/cms/resources/resources_zh_CN.properties
#	src/main/java/net/mingsoft/config/WebConfig.java
#	src/main/resources/application.yml
#	src/main/webapp/WEB-INF/manager/cms/article/article_form.ftl
#	src/main/webapp/WEB-INF/manager/cms/article/article_main.ftl
#	src/main/webapp/WEB-INF/manager/cms/column/shiro-button.ftl
#	src/main/webapp/WEB-INF/manager/cms/column/shiro-update.ftl
#	src/main/webapp/html/1/index.html
#	src/main/webapp/html/1/m/index.html
#	src/main/webapp/static/plugins/ms/1.0.0/ms.util.js
#	src/main/webapp/static/plugins/tree-select/tree.js
#	src/main/webapp/static/plugins/vue-ueditor-wrap/vue-ueditor-wrap.min.js
#	src/main/webapp/templets/1/default/about.htm
#	src/main/webapp/templets/1/default/advice.htm
#	src/main/webapp/templets/1/default/case-list.htm
#	src/main/webapp/templets/1/default/index.htm
#	src/main/webapp/templets/1/default/m/about.htm
#	src/main/webapp/templets/1/default/m/advice.htm
#	src/main/webapp/templets/1/default/m/case-list.htm
#	src/main/webapp/templets/1/default/m/contact.htm
#	src/main/webapp/templets/1/default/m/news-list.htm
#	src/main/webapp/templets/1/default/m/news-show.htm
#	src/main/webapp/templets/1/default/news-show.htm
#	src/main/webapp/templets/1/default/search.htm
parents de640e65 96693c07
请使用master分支
<p align="center"> \ No newline at end of file
<a href="https://ms.mingsoft.net/"><img src="http://ms.mingsoft.net/templets/1/ms/images/logo-blue.png" ></a>
</p>
<p align="center">
<strong>价值源自分享</strong>
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=ms-mcms">
<img src="https://img.shields.io/maven-central/v/net.mingsoft/ms-mcms.svg?label=Maven%20Central" />
</a>
<a target="_blank" href="hhttps://baike.baidu.com/item/MIT%E8%AE%B8%E5%8F%AF%E8%AF%81/6671281?fr=aladdin">
<img src="https://img.shields.io/:license-MIT-blue.svg" />
</a>
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
<img src="https://img.shields.io/badge/JDK-8+-green.svg" />
</a>
<a target="_blank" href="https://gitee.com/mingSoft/MCMS/stargazers">
<img src="https://gitee.com/mingSoft/MCMS/badge/star.svg?theme=dark" alt='gitee star'/>
</a>
<a target="_blank" href='https://github.com/ming-soft/mcms'>
<img src="https://img.shields.io/github/stars/ming-soft/mcms.svg?style=social" alt="github star"/>
</a>
</p>
<p align="center">
铭飞平台:<a href="https://ms.mingsoft.net">https://ms.mingsoft.net/</a> <br/>
演示:<a href="http://demo.cms.mingsoft.net/ms/login.do">http://demo.cms.mingsoft.net/ms/login.do</a><br/>
<a href="http://file.mingsoft.net/ms-runner-4.7.2.zip">一键运行版本</a>
</p>
-------------------------------------------------------------------------------
很多人说铭飞是大天朝国唯一完整开源的J2EE系统!团队希望看到更多的优秀好用的开源系统,我们一直会努力下去!<br/>
QQ交流群号:[![加入QQ群](https://img.shields.io/badge/一群-231212174-blue.svg)](https://jq.qq.com/?_wv=1027&k=5zykX7V) [![加入QQ群](https://img.shields.io/badge/二群-221335098-blue.svg)](https://jq.qq.com/?_wv=1027&k=56BqFKu) [![加入QQ群](https://img.shields.io/badge/三群-242805203-blue.svg)](https://jq.qq.com/?_wv=1027&k=5oF19sl)
# 开源说明
* 系统100%开源
* 模块化开发模式,铭飞所开发的模块都发布到了maven中央库。 可以通过pom.xml文件的方式拉取源代码
```
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>模块</artifactId>
<version>版本号</version>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>
```
# 商用
基于[MIT](https://www.oschina.net/question/12_2829)开源协议,可直接商用无需授权,但请尊重开源精神不要去掉代码中铭飞的注释和版权信息
# 特点
* 免费完整开源:基于MIT协议,源代码完全开源,无商业限制,MS开发团队承诺将MCMS内容系统永久完整开源;<br/>
* 标签化建站:不需要专业的后台开发技能,只要使用系统提供的标签,就能轻松建设网站;<br/>
* html静态化:系统支持全站静态化;<br/>
* 跨终端:站点同时支持PC与移动端访问,同时会自动根据访问的终端切换到对应的界面,数据由系统统一管理;<br/>
* 海量模版:铭飞通过MStore(MS商城)分享更多免费、精美的企业网站模版,降低建站成本;<br/>
* 丰富插件:为了让MCms适应更多的业务场景,在MStore用户可以下载对应的插件,如:站群插件、微信插件、商城插件等;<br/>
* 每月更新:铭飞团队承诺每月28日为系统升级日,分享更多好用等模版与插件;<br/>
* 文档丰富:为了让用户更快速的使用MCms系统进行开发,铭飞团队持续更新开发相关文档,如标签文档、使用文档、视频教程等;<br/>
# 面向对象
* 企 业:帮助创立初期的公司或团队快速搭建产品的技术平台,加快公司项目开发进度;
* 开发者:帮助开发者快速完成承接外包的项目,避免从零搭建系统;
* 学习者:初学JAVA的同学可以下载源代码来进行学习交流;
# 开发环境
建议开发者使用以下环境,这样避免版本带来的问题
* Windows、Linux
* Eclipse、Idea
* Mysql≧5.7
* JDK≧8
* Tomcat≧8
# 快速体验(导入到 Eclipse 或 IDEA)
1、检出源代码:
git clone https://gitee.com/mingSoft/MCMS.git<br/>
2、导入项目<br/>
* Eclipse导入,菜单 File -> Import,然后选择 Maven -> Existing Maven Projects,点击 Next> 按钮,选择检出的项目MCMS文件夹,然后点击 Finish 按钮,即可成功导入
* IDEA导入,点击 Import Project,选择 pom.xml 文件,点击 Next 按钮,选择 Import Maven projects automatically 复选框,然后一直点击 Next 按钮,直到点击 Finish 按钮,即可成功导入<br/>
4、Eclipse(IDEA)会自动加载 Maven 依赖包,初次加载会比较慢(根据自身网络情况而定),若工程上有小叉号,请打开 Problems 窗口,查看具体错误内容,直到无错误为止<br/>
5、创建数据库db-mcms-open(数据库使用utf-8编码),导入doc/db-mcms-open-版本号.sql,如果升级现有系统请使用*-up-*.sql升级,如果导入了系统对应的完整版SQL,sql升级补丁不需要重复导入;<br/>
6、修改src\main\resources\application-dev.yml文件中的数据库设置参数;<br/>
7、运行MSApplication.java main方法<br/>
8、首先先访问后台地址:http://ip|域名/项目发布名/ms/login.do,管理员账号,用户名:msopen 密码:msopen,进入后台点击内容管理->静态化菜单,进行"生成主页","生成栏目","生成文章"操作一遍 (注意!!!是后台登录界面,不是会员中心登录界面)
# 技术选型
## 后端框架
| 技术 | 名称 | 官网 |
| :--- | :--- | :--- |
| Spring Framework | 容器 | [http://projects.spring.io/spring-framework](http://projects.spring.io/spring-framework/) |
| Spring Boot | MVC框架 | [https://spring.io/projects/spring-boot](https://spring.io/projects/spring-boot) |
| Apache Shiro | 安全框架 | [http://shiro.apache.org](http://shiro.apache.org/) |
| Spring session | 分布式Session管理 | [http://projects.spring.io/spring-session](http://projects.spring.io/spring-session) |
| MyBatis | ORM框架 | [http://www.mybatis.org](http://www.mybatis.org/mybatis-3/zh/index.html) |
| Freemarker | 视图框架 | [http://freemarker.foofun.cn](http://freemarker.foofun.cn/) |
| PageHelper | MyBatis分页插件 | [http://git.oschina.net/free/Mybatis\_PageHelper](http://git.oschina.net/free/Mybatis_PageHelper) |
| Log4J | 日志组件 | [http://logging.apache.org](http://logging.apache.org) |
| Maven | 项目构建 | [http://maven.apache.org](http://maven.apache.org/) |
| Elasticsearch | 分布式搜索引擎 | [https://www.elastic.co](https://www.elastic.co/) |
| Redis | 分布式缓存数据库 | [https://redis.io](https://redis.io) |
| hutool | 工具类 | [http://hutool.mydoc.io](http://hutool.mydoc.io) |
## 前端框架
| 技术 | 名称 | 官网 |
| :--- | :--- | :--- |
| vue| 函式库 | [https://cn.vuejs.org//](https://cn.vuejs.org//) |
| element ui| UI库 | [https://element.eleme.cn/2.0/#/zh-CN](https://element.eleme.cn/2.0/#/zh-CN) |
| jQuery | 函式库 | [http://jquery.com/](http://jquery.com/) |
| Bootstrap | 前端框架 | [http://getbootstrap.com/](http://getbootstrap.com/) |
| Bootstrap-table | Bootstrap数据表格 | [http://bootstrap-table.wenzhixin.net.cn/](http://bootstrap-table.wenzhixin.net.cn/) |
| BootstrapValidator | 表单验证 | [http://bootstrapvalidator.com/](http://bootstrapvalidator.com) |
| Font-awesome | 字体图标 | [http://fontawesome.io/](http://fontawesome.io/) |
| Waves | 点击效果插件 | [https://github.com/fians/Waves/](https://github.com/fians/Waves) |
| zTree | 树插件 | [http://www.treejs.cn/v3/](http://www.treejs.cn/v3/) |
| Select2 | 选择框插件 | [https://github.com/select2/select2](https://github.com/select2/select2) |
| Vue | MVVM框架 | [https://cn.vuejs.org/](https://cn.vuejs.org/) |
| AmazeUI | 移动端UI | [http://amazeui.org/](http://amazeui.org/) |
| Plupload | 上传控件 | [http://www.plupload.com/](http://www.plupload.com/) |
| freemarker | 模板引擎 | [http://freemarker.foofun.cn/toc.html](http://freemarker.foofun.cn/toc.html) |
| validator | 验证库 | [https://github.com/chriso/validator.js](https://github.com/chriso/validator.js) |
| animate | 动画 | [http://daneden.github.io/animate.css/](http://daneden.github.io/animate.css/) |
| icon | 矢量小图标\(待更新\) | [http://ms.mingsoft.net/html/86//6048/index.html](http://ms.mingsoft.net/html/86//6048/index.html) |
# 文件说明
* doc 项目文档文件夹,里面有数据库文件
* src/main/java java源代码
* src/main/resources 项目的资源配置文件
* src/main/webapp
* src/main/webapp/static 静态资源文件,如:js、css、image、等第三方前端插件库
* src/main/webapp/html 生成的静态页面,实际项目需要删除,只是提供给开发者快速预览生成后的静态页面
* src/main/webapp/templets 模版文件夹
* src/main/webapp/upload 上传资源文件夹
* src/main/webapp/WEB-INF/manager 后端视图页面
* LICENSE 项目协议说明
* README.md 项目说明文档
* pom.xml 依赖配置文件
# 文档
* MCms标签手册 http://doc.ms.mingsoft.net/mcms-tag-guide
* 快速开发手册 http://doc.ms.mingsoft.net/dev-guide/
# 软件截图
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121402_82521059_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/120836_8a943ad5_1795833.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/120927_8a3f93e3_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/120939_7e5281db_1795833.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/120951_9d3a50b2_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121003_9c68e090_1795833.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121020_34c8e0ab_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121033_b425e406_1795833.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121044_41cc0d00_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121059_48b4cd7b_1795833.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121112_8581de9a_1795833.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0523/121122_8b513dd1_1795833.png"/></td>
</tr>
</table>
# 铭飞平台
做开源我们是业余的,写代码我们是认真的。研发产品的路上我们一直在探索、一直在学习、一直在用心投入,希望能给更多的企业与开发者提供一些更有价值的服务。
## 项目管理
<table>
<tr>
<td><img src="http://ms.mingsoft.net/upload/1/article/1572421127803.gif"/></td>
</tr>
<tr>
<td><img src="http://ms.mingsoft.net/upload/1/article/1572421308885.gif"/></td>
</tr>
</table>
## 代码生成器
<table>
<tr>
<td><img src="http://ms.mingsoft.net/upload/1/article/1572419454270.gif"/></td>
</tr>
<tr>
<td><img src="http://ms.mingsoft.net/upload/1/article/1572419347761.gif"/></td>
</tr>
</table>
UPDATE cms_content
SET content_img = concat( '[{"path":"', content_img, '"}]' )
WHERE
content_img IS NOT NULL
AND trim( content_img ) != ''
\ No newline at end of file
INSERT INTO cms_content (
cms_content.id,
cms_content.app_id,
cms_content.content_url,
cms_content.content_details,
cms_content.content_keyword,
cms_content.content_description,
cms_content.content_img,
cms_content.content_sort,
cms_content.content_datetime,
cms_content.content_source,
cms_content.content_author,
cms_content.content_display,
cms_content.content_type,
cms_content.content_category_id,
cms_content.content_title,
cms_content.content_hit
)
SELECT
basic.basic_id,
cms_article.article_webid,
cms_article.article_url,
cms_article.article_content,
cms_article.article_keyword,
basic.basic_description,
basic.basic_thumbnails,
basic.basic_sort,
basic.basic_datetime,
cms_article.article_source,
cms_article.article_author,
basic.basic_display,
cms_article.article_type,
basic.basic_categoryid,
basic.basic_title,
basic.basic_hit
FROM
basic
INNER JOIN cms_article ON cms_article.article_basicid = basic.basic_id
INSERT INTO cms_category (
cms_category.id,
cms_category.category_title,
cms_category.category_sort,
cms_category.category_parent_id,
cms_category.category_path,
cms_category.category_flag,
cms_category.dict_id,
cms_category.app_id,
cms_category.category_manager_id,
cms_category.category_datetime,
cms_category.mdiy_model_id,
cms_category.category_diy_url,
cms_category.category_img,
cms_category.category_descrip,
cms_category.category_keyword,
cms_category.category_url,
cms_category.category_list_url,
cms_category.category_type,
cms_category.category_id
) SELECT
category.category_id,
category.category_title,
category.category_sort,
category.category_parent_id,
basic_column.column_path,
basic_column.column_flag,
category.category_dict_id,
category.category_appid,
category.category_managerid,
category.category_datetime,
basic_column.column_cm_id,
basic_column.column_diy_url,
category.category_smallimg,
basic_column.column_descrip,
basic_column.column_keyword,
basic_column.column_url,
basic_column.column_listurl,
basic_column.column_type,
category.category_categoryid
FROM
basic_column
INNER JOIN category ON basic_column.column_category_id = category.category_id
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>mcms</artifactId> <artifactId>mcms</artifactId>
<version>4.7.2</version> <version>5.0.0-SNAPSHOT</version>
<name>ms-mcms</name> <name>ms-mcms</name>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
...@@ -35,22 +35,12 @@ ...@@ -35,22 +35,12 @@
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-basic</artifactId>
<version>1.0.16</version>
</dependency>
<dependency> <dependency>
<groupId>net.mingsoft</groupId> <groupId>net.mingsoft</groupId>
<artifactId>ms-mpeople</artifactId> <artifactId>ms-mpeople</artifactId>
<version>1.0.11</version> <version>1.0.13-SNAPSHOT</version>
</dependency>
<!-- 此部分是铭飞平台MStroe的客户端(MStore不在铭飞开源产品范围),如果不需要使用MStore可以删除掉 -->
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-upgrader</artifactId>
<version>1.0.13</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>ms-mcms</finalName> <finalName>ms-mcms</finalName>
...@@ -78,27 +68,10 @@ ...@@ -78,27 +68,10 @@
<fork>true</fork> <fork>true</fork>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- 打包时候需需要启用,注意避免快照依赖的冗余jar包 -->
<!-- outputFileNameMapping>@{artifactId}@- @{baseVersion}@. @{extension}@</outputFileNameMapping -->
</configuration>
</plugin>
</plugins> </plugins>
<resources> <resources>
<resource> <resource>
<!-- 注释部分打包过滤,如果springboot项目 maven-jar-plugin插件排除无效 -->
<!-- <filtering>true</filtering> -->
<directory>src/main/webapp</directory> <directory>src/main/webapp</directory>
<!-- <excludes>
<exclude>static/**</exclude>
<exclude>html/**</exclude>
<exclude>upload/**</exclude>
<exclude>templets/**</exclude>
</excludes> -->
</resource> </resource>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
......
package net.mingsoft.cms.action;
import java.util.List;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import net.mingsoft.base.entity.ResultData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.BindingResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.ui.ModelMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.base.util.JSONObject;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.base.filter.DateValueFilter;
import net.mingsoft.base.filter.DoubleValueFilter;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/**
* 分类管理控制层
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
@Api(value = "分类接口")
@Controller("cmsCategoryAction")
@RequestMapping("/${ms.manager.path}/cms/category")
public class CategoryAction extends BaseAction{
/**
* 注入分类业务层
*/
@Autowired
private ICategoryBiz categoryBiz;
/**
* 返回主界面index
*/
@GetMapping("/index")
public String index(HttpServletResponse response,HttpServletRequest request){
return "/cms/category/index";
}
/**
* 查询分类列表
* @param category 分类实体
*/
@ApiOperation(value = "查询分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
category.setAppId(BasicUtil.getAppId());
BasicUtil.startPage();
List categoryList = categoryBiz.query(category);
return ResultData.build().success(new EUListBean(categoryList,(int)BasicUtil.endPage(categoryList).getTotal()));
}
/**
* 返回编辑界面category_form
*/
@GetMapping("/form")
public String form(@ModelAttribute CategoryEntity category,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(category.getId()!=null){
BaseEntity categoryEntity = categoryBiz.getEntity(Integer.parseInt(category.getId()));
model.addAttribute("categoryEntity",categoryEntity);
}
return "/cms/category/form";
}
/**
* 获取分类
* @param category 分类实体
*/
@ApiOperation(value = "获取分类列表接口")
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
if(category.getId()==null) {
return ResultData.build().error();
}
category.setAppId(BasicUtil.getAppId());
CategoryEntity _category = (CategoryEntity)categoryBiz.getEntity(Integer.parseInt(category.getId()));
return ResultData.build().success(_category);
}
@ApiOperation(value = "保存分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
/**
* 保存分类
* @param category 分类实体
*/
@PostMapping("/save")
@ResponseBody
@LogAnn(title = "保存分类", businessType = BusinessTypeEnum.INSERT)
@RequiresPermissions("cms:category:save")
public ResultData save(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request) {
//验证栏目管理名称的值是否合法
if(StringUtil.isBlank(category.getCategoryTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
}
if(!StringUtil.checkLength(category.getCategoryTitle()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryFlag()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.flag"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryPath()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
category.setAppId(BasicUtil.getAppId());
categoryBiz.saveEntity(category);
return ResultData.build().success(category);
}
/**
* @param category 分类实体
*/
@ApiOperation(value = "批量删除分类列表接口")
@PostMapping("/delete")
@ResponseBody
@LogAnn(title = "删除分类", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:category:del")
public ResultData delete(@RequestBody List<CategoryEntity> categorys,HttpServletResponse response, HttpServletRequest request) {
for(int i = 0;i<categorys.size();i++){
categoryBiz.delete(Integer.parseInt(categorys.get(i).getId()));
}
return ResultData.build().success();
}
/**
* 更新分类列表
* @param category 分类实体
*/
@ApiOperation(value = "更新分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@PostMapping("/update")
@ResponseBody
@LogAnn(title = "更新分类", businessType = BusinessTypeEnum.UPDATE)
@RequiresPermissions("cms:category:update")
public ResultData update(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response,
HttpServletRequest request) {
//验证栏目管理名称的值是否合法
if(StringUtil.isBlank(category.getCategoryTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
}
if(!StringUtil.checkLength(category.getCategoryTitle()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryFlag()+"", 0, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.flag"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryPath()+"", 0, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 0, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
//判断是否选择子级为所属栏目
CategoryEntity _category = new CategoryEntity();
_category.setCategoryParentId(category.getId());
_category.setAppId(BasicUtil.getAppId());
List<CategoryEntity> categoryList = categoryBiz.queryChilds(_category);
for(CategoryEntity item:categoryList){
if(item.getId().equals(category.getCategoryId())){
return ResultData.build().error(getResString("cannot.select.child"));
}
}
category.setAppId(BasicUtil.getAppId());
categoryBiz.updateEntity(category);
return ResultData.build().success(category);
}
}
\ No newline at end of file
package net.mingsoft.cms.action;
import java.io.File;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.mingsoft.basic.util.ArrysUtil;
import net.mingsoft.mdiy.util.DictUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import net.mingsoft.basic.action.BaseAction;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.biz.ICategoryBiz;
import net.mingsoft.basic.biz.IColumnBiz;
import net.mingsoft.basic.biz.IModelBiz;
import net.mingsoft.basic.constant.Const;
import net.mingsoft.basic.constant.ModelCode;
import net.mingsoft.basic.constant.e.SessionConstEnum;
import net.mingsoft.basic.entity.ColumnEntity;
import net.mingsoft.basic.entity.ManagerEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.FileUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.mdiy.util.ParserUtil;
/**
* 铭飞MS平台,通用栏目分类,为了区分文章栏目与其他栏目的权限,该类是从basic模块复制过来
* @author 铭飞开发团队
* @version
* 版本号:100-000-000<br/>
* 创建日期:2017年8月9日<br/>
* 历史修订:<br/>
*/
@Controller("articleColumnAction")
@RequestMapping("/${ms.manager.path}/cms/column")
public class ColumnAction extends BaseAction{
/**
* 栏目业务层
*/
@Autowired
private IColumnBiz columnBiz;
@Autowired
private ICategoryBiz categoryBiz;
/**
* 模块业务层注入
*/
@Autowired
private IModelBiz modelBiz;
/**
* 返回主界面index
*/
@RequestMapping("/index")
@RequiresPermissions("cms:column:view")
public String index(HttpServletResponse response,HttpServletRequest request,ModelMap model){
model.addAttribute("model", "cms");
return "/basic/column/index";
}
/**
* 栏目添加跳转页面
*
* @return
*/
@RequestMapping("/add")
public String add(HttpServletRequest request,ModelMap model) {
// 站点ID
int appId =BasicUtil.getAppId();
List<ColumnEntity> list = columnBiz.queryAll(appId, BasicUtil.getModelCodeId(net.mingsoft.cms.constant.ModelCode.CMS_COLUMN.toString()));
ColumnEntity columnSuper = new ColumnEntity();
// 栏目属性
model.addAttribute("columnFlag", DictUtil.list("栏目属性"));
model.addAttribute("appId",appId);
model.addAttribute("columnSuper", columnSuper);
model.addAttribute("column",new ColumnEntity());
model.addAttribute("listColumn", JSONArray.toJSONString(list));
model.addAttribute("model", "cms");
model.addAttribute("websiteId", appId);
return "/basic/column/form";
}
/**
* 后台验证填写的栏目信息是否合法
* @param column 栏目信息
* @param response
* @return false:不合法 true:合法
*/
private boolean checkForm(ColumnEntity column, HttpServletResponse response){
//栏目标题空值验证
if(StringUtils.isBlank(column.getCategoryTitle())){
this.outJson( response, ModelCode.COLUMN, false, getResString("err.empty", this.getResString("categoryTitle")));
return false;
}
//栏目标题长度验证
if(!StringUtil.checkLength(column.getCategoryTitle(), 1, 31)){
this.outJson( response, ModelCode.COLUMN, false, getResString("err.length", this.getResString("categoryTitle"), "1", "30"));
return false;
}
//栏目属性空值验证
if(StringUtils.isBlank(column.getColumnType()+"")){
this.outJson( response, ModelCode.COLUMN, false, getResString("err.empty", this.getResString("columnType")));
return false;
}
return true;
}
/**
* 组织栏目链接地址
* @param request
* @param column 栏目实体
*/
private void columnPath(HttpServletRequest request,ColumnEntity column){
StringBuffer columnPath = new StringBuffer();
String file = BasicUtil.getRealPath("")+ParserUtil.HTML+File.separator+ column.getAppId();
String delFile = "";
//修改栏目路径时,删除已存在的文件夹
column = (ColumnEntity) columnBiz.getEntity(column.getCategoryId());
delFile = file + column.getColumnPath();
if(!StringUtils.isBlank(delFile)){
File delFileName = new File(delFile);
delFileName.delete();
}
//若为顶级栏目,则路径为:/+栏目ID
if(column.getCategoryCategoryId() == 0){
column.setColumnPath(File.separator+column.getCategoryId());
file = file + File.separator + column.getCategoryId();
} else {
List<ColumnEntity> list = columnBiz.queryParentColumnByColumnId(column.getCategoryId());
if(list != null){
StringBuffer temp = new StringBuffer();
for(int i = list.size()-1; i>=0; i--){
ColumnEntity entity = list.get(i);
columnPath.append(File.separator).append(entity.getCategoryId());
temp.append(File.separator).append(entity.getCategoryId());
}
column.setColumnPath(columnPath.append(File.separator).append(column.getCategoryId()).toString());
file = file + temp.toString() + File.separator + column.getCategoryId();
}
}
columnBiz.updateEntity(column);
//生成文件夹
File fileName = new File(file);
fileName.mkdir();
}
/**
* @param column 栏目表实体
* <i>column参数包含字段信息参考:</i><br/>
* columnCategoryid:多个columnCategoryid直接用逗号隔开,例如columnCategoryid=1,2,3,4
* 批量删除栏目表
* <dt><span class="strong">返回</span></dt><br/>
* <dd>{code:"错误编码",<br/>
* result:"true|false",<br/>
* resultMsg:"错误信息"<br/>
* }</dd>
*/
@RequestMapping("/delete")
@ResponseBody
public void delete(HttpServletResponse response, HttpServletRequest request) {
int[] ids = BasicUtil.getInts("ids", ",");
ColumnEntity column =new ColumnEntity();
for(int i=0;i<ids.length;i++){
column = (ColumnEntity) columnBiz.getEntity(ids[i]);
columnBiz.deleteCategory(ids[i]);
FileUtil.del(column);
};
this.outJson(response, true);
}
/**
* 栏目更新页面跳转
* @param columnId 栏目ID
* @param request
* @param model
* @return 编辑栏目页
*/
@RequestMapping("/{columnId}/edit")
public String edit(@PathVariable int columnId, HttpServletRequest request,ModelMap model) {
// 获取管理实体
ManagerEntity managerSession = (ManagerEntity) BasicUtil.getSession( SessionConstEnum.MANAGER_SESSION);
// 站点ID
int appId = BasicUtil.getAppId();
List<ColumnEntity> list = new ArrayList<ColumnEntity>();
// 判断管理员权限,查询其管理的栏目集合
list = columnBiz.queryAll(appId, BasicUtil.getModelCodeId(net.mingsoft.cms.constant.ModelCode.CMS_COLUMN.toString()));
//查询当前栏目实体
ColumnEntity column = (ColumnEntity) columnBiz.getEntity(columnId);
// 栏目属性
model.addAttribute("columnFlag", DictUtil.list("栏目属性"));
model.addAttribute("appId",appId);
model.addAttribute("column", column);
model.addAttribute("columnc", column.getCategoryId());
ColumnEntity columnSuper = new ColumnEntity();
// 获取父栏目对象
if (column.getCategoryCategoryId() != Const.COLUMN_TOP_CATEGORY_ID) {
columnSuper = (ColumnEntity) columnBiz.getEntity(column.getCategoryCategoryId());
}
model.addAttribute("columnSuper", columnSuper);
model.addAttribute("listColumn", JSONArray.toJSONString(list));
model.addAttribute("model", "cms");
model.addAttribute("websiteId", appId);
return "/basic/column/form";
}
/**
* 栏目首页面列表显示
*/
@SuppressWarnings("deprecation")
@RequestMapping("/list")
public void list(@ModelAttribute ColumnEntity column,HttpServletResponse response, HttpServletRequest request,ModelMap model) {
// 站点ID有session获取
int websiteId = BasicUtil.getAppId();
// 需要打开的栏目节点树的栏目ID
List list = columnBiz.queryAll(websiteId, BasicUtil.getModelCodeId(net.mingsoft.cms.constant.ModelCode.CMS_COLUMN.toString()));
EUListBean _list = new EUListBean(list, list.size());
this.outJson(response, net.mingsoft.base.util.JSONArray.toJSONString(_list));
}
/**
* 栏目添加
*
* @param column
* 栏目对象
* @return 返回页面跳转
*/
@RequestMapping("/save")
public void save(@ModelAttribute ColumnEntity column,HttpServletRequest request,HttpServletResponse response) {
if(!checkForm(column,response)){
return;
}
column.setCategoryAppId( BasicUtil.getAppId());
column.setAppId(BasicUtil.getAppId());
column.setCategoryManagerId(getManagerBySession(request).getManagerId());
column.setCategoryDateTime(new Timestamp(System.currentTimeMillis()));
column.setCategoryModelId(BasicUtil.getModelCodeId(net.mingsoft.cms.constant.ModelCode.CMS_COLUMN.toString()));
String checkboxType = BasicUtil.getString("checkboxType");
//如果选择一个属性不做排序操作
if(!StringUtils.isEmpty(checkboxType) && checkboxType.length()>2){
column.setColumnFlag(ArrysUtil.sort(checkboxType, ",")+",");
}else{
column.setColumnFlag(checkboxType);
}
if(column.getColumnType()==ColumnEntity.ColumnTypeEnum.COLUMN_TYPE_COVER.toInt()){
column.setColumnListUrl(null);
}
columnBiz.saveCategory(column);
this.columnPath(request,column);
this.outJson(response, ModelCode.COLUMN, true,null,JSONArray.toJSONString(column.getCategoryId()));
}
/**
* 更新栏目
* @param column 栏目实体
* @param request
* @param response
*/
@RequestMapping("/update")
@ResponseBody
public void update(@ModelAttribute ColumnEntity column,HttpServletRequest request,HttpServletResponse response) {
//获取站点ID
int websiteId = BasicUtil.getAppId();
//检测栏目信息是否合法
if(!checkForm(column,response)){
return;
}
//若栏目管理属性为单页,则栏目的列表模板地址设为Null
if(column.getColumnType()==ColumnEntity.ColumnTypeEnum.COLUMN_TYPE_COVER.toInt()){
column.setColumnListUrl(null);
}
column.setCategoryManagerId(getManagerBySession(request).getManagerId());
column.setAppId(websiteId);
String checkboxType = BasicUtil.getString("checkboxType");
//如果选择一个属性不做排序操作
if(!StringUtils.isEmpty(checkboxType) && checkboxType.length()>2){
column.setColumnFlag(ArrysUtil.sort(checkboxType, ",")+",");
}else{
column.setColumnFlag(checkboxType);
}
columnBiz.updateCategory(column);
this.columnPath(request,column);
//查询当前栏目是否有子栏目,
List<ColumnEntity> childList = columnBiz.queryChild(column.getCategoryId(), websiteId,BasicUtil.getModelCodeId(net.mingsoft.cms.constant.ModelCode.CMS_COLUMN.toString()),null);
if(childList != null && childList.size()>0){
//改变子栏目的顶级栏目ID为当前栏目的父级栏目ID
for(int i=0;i<childList.size();i++){
childList.get(i).setCategoryCategoryId(column.getCategoryId());
childList.get(i).setCategoryManagerId(getManagerBySession(request).getManagerId());
childList.get(i).setAppId(websiteId);
columnBiz.updateCategory(childList.get(i));
//组织子栏目链接地址
this.columnPath(request, childList.get(i));
}
}
this.outJson(response, ModelCode.COLUMN, true,null,JSONArray.toJSONString(column.getCategoryId()));
}
}
\ No newline at end of file
package net.mingsoft.cms.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.mingsoft.base.entity.ResultData;
import org.springframework.validation.BindingResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.ui.ModelMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import net.mingsoft.cms.biz.IContentBiz;
import net.mingsoft.cms.entity.ContentEntity;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/**
* 文章管理控制层
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
@Api(value = "文章接口")
@Controller("cmsContentAction")
@RequestMapping("/${ms.manager.path}/cms/content")
public class ContentAction extends BaseAction{
/**
* 注入文章业务层
*/
@Autowired
private IContentBiz contentBiz;
/**
* 返回主界面index
*/
@GetMapping("/index")
public String index(HttpServletResponse response,HttpServletRequest request){
return "/cms/content/index";
}
/**
* 返回主界面main
*/
@GetMapping("/main")
public String main(HttpServletResponse response,HttpServletRequest request){
return "/cms/content/main";
}
/**
* 查询文章列表
* @param content 文章实体
*/
@ApiOperation(value = "查询文章列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "contentTitle", value = "文章标题", required =false,paramType="query"),
@ApiImplicitParam(name = "contentCategoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "contentType", value = "文章类型", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDisplay", value = "是否显示", required =false,paramType="query"),
@ApiImplicitParam(name = "contentAuthor", value = "文章作者", required =false,paramType="query"),
@ApiImplicitParam(name = "contentSource", value = "文章来源", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDatetime", value = "发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "contentSort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "contentImg", value = "文章缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDescription", value = "描述", required =false,paramType="query"),
@ApiImplicitParam(name = "contentKeyword", value = "关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDetails", value = "文章内容", required =false,paramType="query"),
@ApiImplicitParam(name = "contentUrl", value = "文章跳转链接地址", required =false,paramType="query"),
@ApiImplicitParam(name = "appid", value = "文章管理的应用id", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
content.setAppId(BasicUtil.getAppId());
BasicUtil.startPage();
List contentList = contentBiz.query(content);
return ResultData.build().success(new EUListBean(contentList,(int)BasicUtil.endPage(contentList).getTotal()));
}
/**
* 返回编辑界面content_form
*/
@GetMapping("/form")
public String form(@ModelAttribute ContentEntity content,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(content.getId()!=null){
BaseEntity contentEntity = contentBiz.getEntity(Integer.parseInt(content.getId()));
model.addAttribute("contentEntity",contentEntity);
}
return "/cms/content/form";
}
/**
* 获取文章
* @param content 文章实体
*/
@ApiOperation(value = "获取文章列表接口")
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore ContentEntity content,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
if(content.getId()==null) {
return ResultData.build().error();
}
content.setAppId(BasicUtil.getAppId());
ContentEntity _content = (ContentEntity)contentBiz.getEntity(Integer.parseInt(content.getId()));
return ResultData.build().success(_content);
}
@ApiOperation(value = "保存文章列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "contentTitle", value = "文章标题", required =true,paramType="query"),
@ApiImplicitParam(name = "contentCategoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "contentType", value = "文章类型", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDisplay", value = "是否显示", required =false,paramType="query"),
@ApiImplicitParam(name = "contentAuthor", value = "文章作者", required =false,paramType="query"),
@ApiImplicitParam(name = "contentSource", value = "文章来源", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDatetime", value = "发布时间", required =true,paramType="query"),
@ApiImplicitParam(name = "contentSort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "contentImg", value = "文章缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDescription", value = "描述", required =false,paramType="query"),
@ApiImplicitParam(name = "contentKeyword", value = "关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDetails", value = "文章内容", required =false,paramType="query"),
@ApiImplicitParam(name = "contentUrl", value = "文章跳转链接地址", required =false,paramType="query"),
@ApiImplicitParam(name = "appid", value = "文章管理的应用id", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
/**
* 保存文章
* @param content 文章实体
*/
@PostMapping("/save")
@ResponseBody
@LogAnn(title = "保存文章", businessType = BusinessTypeEnum.INSERT)
@RequiresPermissions("cms:content:save")
public ResultData save(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response, HttpServletRequest request) {
//验证文章标题的值是否合法
if(StringUtil.isBlank(content.getContentTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("content.title")));
}
if(!StringUtil.checkLength(content.getContentTitle()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.title"), "0", "200"));
}
if(!StringUtil.checkLength(content.getContentAuthor()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.author"), "0", "200"));
}
if(!StringUtil.checkLength(content.getContentSource()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.source"), "0", "200"));
}
//验证发布时间的值是否合法
if(StringUtil.isBlank(content.getContentDatetime())){
return ResultData.build().error(getResString("err.empty", this.getResString("content.datetime")));
}
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
}
content.setAppId(BasicUtil.getAppId());
contentBiz.saveEntity(content);
return ResultData.build().success(content);
}
/**
* @param content 文章实体
*/
@ApiOperation(value = "批量删除文章列表接口")
@PostMapping("/delete")
@ResponseBody
@LogAnn(title = "删除文章", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("cms:content:del")
public ResultData delete(@RequestBody List<ContentEntity> contents,HttpServletResponse response, HttpServletRequest request) {
int[] ids = new int[contents.size()];
for(int i = 0;i<contents.size();i++){
ids[i] =Integer.parseInt(contents.get(i).getId()) ;
}
contentBiz.delete(ids);
return ResultData.build().success();
}
/**
* 更新文章列表
* @param content 文章实体
*/
@ApiOperation(value = "更新文章列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query"),
@ApiImplicitParam(name = "contentTitle", value = "文章标题", required =true,paramType="query"),
@ApiImplicitParam(name = "contentCategoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "contentType", value = "文章类型", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDisplay", value = "是否显示", required =false,paramType="query"),
@ApiImplicitParam(name = "contentAuthor", value = "文章作者", required =false,paramType="query"),
@ApiImplicitParam(name = "contentSource", value = "文章来源", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDatetime", value = "发布时间", required =true,paramType="query"),
@ApiImplicitParam(name = "contentSort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "contentImg", value = "文章缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDescription", value = "描述", required =false,paramType="query"),
@ApiImplicitParam(name = "contentKeyword", value = "关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "contentDetails", value = "文章内容", required =false,paramType="query"),
@ApiImplicitParam(name = "contentUrl", value = "文章跳转链接地址", required =false,paramType="query"),
@ApiImplicitParam(name = "appid", value = "文章管理的应用id", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@PostMapping("/update")
@ResponseBody
@LogAnn(title = "更新文章", businessType = BusinessTypeEnum.UPDATE)
@RequiresPermissions("cms:content:update")
public ResultData update(@ModelAttribute @ApiIgnore ContentEntity content, HttpServletResponse response,
HttpServletRequest request) {
//验证文章标题的值是否合法
if(StringUtil.isBlank(content.getContentTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("content.title")));
}
if(!StringUtil.checkLength(content.getContentTitle()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.title"), "0", "200"));
}
if(!StringUtil.checkLength(content.getContentAuthor()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.author"), "0", "200"));
}
if(!StringUtil.checkLength(content.getContentSource()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.source"), "0", "200"));
}
//验证发布时间的值是否合法
if(StringUtil.isBlank(content.getContentDatetime())){
return ResultData.build().error(getResString("err.empty", this.getResString("content.datetime")));
}
if(!StringUtil.checkLength(content.getContentUrl()+"", 0, 200)){
return ResultData.build().error(getResString("err.length", this.getResString("content.url"), "0", "200"));
}
content.setAppId(BasicUtil.getAppId());
contentBiz.updateEntity(content);
return ResultData.build().success(content);
}
}
\ No newline at end of file
...@@ -24,7 +24,6 @@ package net.mingsoft.cms.action; ...@@ -24,7 +24,6 @@ package net.mingsoft.cms.action;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -32,6 +31,11 @@ import javax.servlet.http.HttpServletResponse; ...@@ -32,6 +31,11 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import net.mingsoft.cms.bean.ContentBean;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.biz.IContentBiz;
import net.mingsoft.cms.entity.CategoryEntity;
import org.apache.commons.lang3.StringUtils;
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.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -42,16 +46,10 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -42,16 +46,10 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import net.mingsoft.basic.action.BaseAction; import net.mingsoft.basic.action.BaseAction;
import net.mingsoft.basic.biz.IColumnBiz;
import net.mingsoft.basic.biz.IModelBiz; import net.mingsoft.basic.biz.IModelBiz;
import net.mingsoft.basic.entity.AppEntity; import net.mingsoft.basic.entity.AppEntity;
import net.mingsoft.basic.entity.CategoryEntity;
import net.mingsoft.basic.entity.ColumnEntity;
import net.mingsoft.cms.bean.ColumnArticleIdBean; import net.mingsoft.cms.bean.ColumnArticleIdBean;
import net.mingsoft.cms.biz.IArticleBiz;
import net.mingsoft.cms.constant.ModelCode;
import net.mingsoft.cms.util.CmsParserUtil; import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.biz.IContentModelBiz; import net.mingsoft.mdiy.biz.IContentModelBiz;
import net.mingsoft.mdiy.biz.IContentModelFieldBiz; import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
...@@ -78,13 +76,13 @@ public class GeneraterAction extends BaseAction { ...@@ -78,13 +76,13 @@ public class GeneraterAction extends BaseAction {
* 文章管理业务层 * 文章管理业务层
*/ */
@Autowired @Autowired
private IArticleBiz articleBiz; private IContentBiz contentBiz;
/** /**
* 栏目管理业务层 * 栏目管理业务层
*/ */
@Autowired @Autowired
private IColumnBiz columnBiz; private ICategoryBiz categoryBiz;
/** /**
* 模块管理业务层 * 模块管理业务层
...@@ -101,11 +99,6 @@ public class GeneraterAction extends BaseAction { ...@@ -101,11 +99,6 @@ public class GeneraterAction extends BaseAction {
@Autowired @Autowired
protected IContentModelFieldBiz fieldBiz; protected IContentModelFieldBiz fieldBiz;
/**
* 自定义模型业务层
*/
@Autowired
protected IContentModelBiz contentBiz;
/** /**
* 更新主页 * 更新主页
...@@ -114,13 +107,6 @@ public class GeneraterAction extends BaseAction { ...@@ -114,13 +107,6 @@ public class GeneraterAction extends BaseAction {
*/ */
@RequestMapping("/index") @RequestMapping("/index")
public String index(HttpServletRequest request, ModelMap model) { public String index(HttpServletRequest request, ModelMap model) {
// 该站点ID有session提供
int websiteId = BasicUtil.getAppId();
Integer modelId = modelBiz.getEntityByModelCode(ModelCode.CMS_COLUMN).getModelId(); // 查询当前模块编号
// 获取所有的内容管理栏目
List<ColumnEntity> list = columnBiz.queryAll(websiteId, modelId);
model.addAttribute("list", JSONArray.toJSONString(list));
model.addAttribute("now", new Date());
return "/cms/generate/index"; return "/cms/generate/index";
} }
...@@ -160,44 +146,46 @@ public class GeneraterAction extends BaseAction { ...@@ -160,44 +146,46 @@ public class GeneraterAction extends BaseAction {
* *
* @param request * @param request
* @param response * @param response
* @param columnId * @param CategoryId
*/ */
@RequestMapping("/{columnId}/genernateColumn") @RequestMapping("/{CategoryId}/genernateColumn")
@RequiresPermissions("cms:generate:column") @RequiresPermissions("cms:generate:column")
@ResponseBody @ResponseBody
public void genernateColumn(HttpServletRequest request, HttpServletResponse response, @PathVariable int columnId) { public void genernateColumn(HttpServletRequest request, HttpServletResponse response, @PathVariable int CategoryId) {
// 获取站点id // 获取站点id
AppEntity app = BasicUtil.getApp(); AppEntity app = BasicUtil.getApp();
List<ColumnEntity> columns = new ArrayList<ColumnEntity>(); List<CategoryEntity> columns = new ArrayList<CategoryEntity>();
// 如果栏目id小于0则更新所有的栏目,否则只更新选中的栏目 // 如果栏目id小于0则更新所有的栏目,否则只更新选中的栏目
int modelId = BasicUtil.getModelCodeId(ModelCode.CMS_COLUMN); // 查询当前模块编号 if (CategoryId>0) {
if (columnId > 0) { CategoryEntity categoryEntity = new CategoryEntity();
List<CategoryEntity> categorys = columnBiz.queryChildrenCategory(columnId, app.getAppId(), modelId); categoryEntity.setId(CategoryId+"");
for (CategoryEntity c : categorys) { categoryEntity.setAppId(app.getAppId());
columns.add((ColumnEntity) columnBiz.getEntity(c.getCategoryId())); columns = categoryBiz.queryChilds(categoryEntity);
}
} else { } else {
// 获取所有的内容管理栏目 // 获取所有的内容管理栏目
columns = columnBiz.queryAll(app.getAppId(), modelId); CategoryEntity categoryEntity=new CategoryEntity();
categoryEntity.setAppId(app.getAppId());
columns = categoryBiz.query(categoryEntity);
} }
List<ColumnArticleIdBean> articleIdList = null; List<ContentBean> articleIdList = null;
try { try {
// 1、设置模板文件夹路径 // 1、设置模板文件夹路径
// 获取栏目列表模版 // 获取栏目列表模版
for (ColumnEntity column : columns) { for (CategoryEntity column : columns) {
// 判断模板文件是否存在 // 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getColumnUrl()))) { if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryUrl()))) {
continue; continue;
} }
articleIdList = articleBiz.queryIdsByCategoryIdForParser(column.getCategoryId(), null, null); articleIdList = contentBiz.queryIdsByCategoryIdForParser(column.getId(), null, null);
// 判断列表类型 // 判断列表类型
switch (column.getColumnType()) { switch (column.getCategoryType()) {
case ColumnEntity.COLUMN_TYPE_LIST: // 列表 //TODO 暂时先用字符串代替
case "1": // 列表
CmsParserUtil.generateList(column, articleIdList.size()); CmsParserUtil.generateList(column, articleIdList.size());
break; break;
case ColumnEntity.COLUMN_TYPE_COVER:// 单页 case "2":// 单页
if(articleIdList.size()==0){ if(articleIdList.size()==0){
ColumnArticleIdBean columnArticleIdBean=new ColumnArticleIdBean(); ContentBean columnArticleIdBean=new ContentBean();
CopyOptions copyOptions=CopyOptions.create(); CopyOptions copyOptions=CopyOptions.create();
copyOptions.setIgnoreError(true); copyOptions.setIgnoreError(true);
BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions); BeanUtil.copyProperties(column,columnArticleIdBean,copyOptions);
...@@ -205,8 +193,6 @@ public class GeneraterAction extends BaseAction { ...@@ -205,8 +193,6 @@ public class GeneraterAction extends BaseAction {
} }
CmsParserUtil.generateBasic(articleIdList); CmsParserUtil.generateBasic(articleIdList);
break; break;
default:
throw new IllegalStateException("Unexpected value: " + column.getColumnType());
} }
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -226,13 +212,13 @@ public class GeneraterAction extends BaseAction { ...@@ -226,13 +212,13 @@ public class GeneraterAction extends BaseAction {
@RequestMapping("/{columnId}/generateArticle") @RequestMapping("/{columnId}/generateArticle")
@RequiresPermissions("cms:generate:article") @RequiresPermissions("cms:generate:article")
@ResponseBody @ResponseBody
public void generateArticle(HttpServletRequest request, HttpServletResponse response, @PathVariable int columnId) { public void generateArticle(HttpServletRequest request, HttpServletResponse response, @PathVariable String columnId) {
String dateTime = request.getParameter("dateTime"); String dateTime = request.getParameter("dateTime");
// 网站风格物理路径 // 网站风格物理路径
List<ColumnArticleIdBean> articleIdList = null; List<ContentBean> articleIdList = null;
try { try {
// 查出所有文章(根据选择栏目)包括子栏目 // 查出所有文章(根据选择栏目)包括子栏目
articleIdList = articleBiz.queryIdsByCategoryIdForParser(columnId, dateTime, null); articleIdList = contentBiz.queryIdsByCategoryIdForParser(columnId, dateTime, null);
// 有符合条件的新闻就更新 // 有符合条件的新闻就更新
if (articleIdList.size() > 0) { if (articleIdList.size() > 0) {
CmsParserUtil.generateBasic(articleIdList); CmsParserUtil.generateBasic(articleIdList);
......
/**
The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net)
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package net.mingsoft.cms.action.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.filter.DateValueFilter;
import net.mingsoft.basic.action.BaseAction;
import net.mingsoft.basic.bean.ListBean;
import net.mingsoft.basic.biz.IColumnBiz;
import net.mingsoft.basic.entity.ColumnEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.biz.IArticleBiz;
import net.mingsoft.cms.entity.ArticleEntity;
import net.mingsoft.mdiy.biz.IContentModelBiz;
import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
import net.mingsoft.mdiy.entity.ContentModelEntity;
import springfox.documentation.annotations.ApiIgnore;
/**
*
* @ClassName: ArticleAction
* @Description:TODO 前段文章控制,如果标签不能满足可以使用这个控制来满足用户的查询文章需求,主要是通过ajax返回json数据格式
* @author: 铭飞开发团队
* @date: 2018年1月31日 下午2:52:44
*
* @Copyright: 2018 www.mingsoft.net Inc. All rights reserved.
*/
@Controller("jsonApiArticle")
@RequestMapping("/mcms/article")
public class ArticleAction extends BaseAction {
/**
* 文章管理业务处理层
*/
@Autowired
private IArticleBiz articleBiz;
/**
* 栏目管理业务处理层
*/
@Autowired
private IColumnBiz columnBiz;
/**
* 内容模型管理业务处理层
*/
@Autowired
private IContentModelBiz contentModelBiz;
/**
* 自定义字段管理业务处理层
*/
@Autowired
private IContentModelFieldBiz fieldBiz;
/**
* 文章信息
*
* @param basicId
* 文章编号
* <dt><span class="strong">返回</span></dt><br/>
* {"basicCategoryId":分类编号,basicTitle
* :"标题",basicDescription:"描述",basicThumbnails:"缩略图",
* basicDateTime:"发布时间",basicUpdateTime:"更新时间","basicHit":点击数,
* "basicId":编号 articleContent:"文章内容","basicSort":排序,[自定义模型字段]}
*/
@GetMapping("/{basicId}/detail")
@ResponseBody
public void detail(@PathVariable int basicId, HttpServletRequest request, HttpServletResponse response) {
ArticleEntity article = articleBiz.getById(basicId);
if (article == null) {
this.outJson(response, "");
return;
}
// 获取文章栏目id获取栏目实体
ColumnEntity column = (ColumnEntity) columnBiz.getEntity(article.getBasicCategoryId());
ContentModelEntity contentModel = (ContentModelEntity) contentModelBiz
.getEntity(column.getColumnContentModelId());
// 判断内容模型的值
if (contentModel != null) {
Map where = new HashMap();
// 压入basicId字段的值
where.put("basicId", basicId);
// 遍历所有的字段实体,得到字段名列表信息
List<String> listFieldName = new ArrayList<String>();
listFieldName.add("basicId");
// 查询新增字段的信息
List fieldLists = fieldBiz.queryBySQL(contentModel.getCmTableName(), listFieldName, where);
if (fieldLists.size() > 0) {
Map map = (Map) fieldLists.get(0);
article.setExtendsFields(map);
}
}
this.outJson(response, JSONObject.toJSONStringWithDateFormat(article, "yyyy-MM-dd hh:mm:ss"));
}
/**
* 文章列表信息
*
* @param pageSize
* 一页显示数量
* @param pageNum
* 当前页码
* @param basicCategoryId
* 分类编号
* <dt><span class="strong">返回</span></dt><br/>
* {"list":"[{
* "basicTitle":"标题",
* "basicDescription":"描述",
* "basicThumbnails":"缩略图",
* "basicDateTime":"发布时间",
* "basicUpdateTime":"更新时间",
* "basicHit":点击数,
* "basicId":编号,
* "articleContent":文章内容,
* "articleAuthor":文章作者
* "articleType":文章属性,
* "articleSource":文章的来源,
* "articleUrl":文章跳转链接地址,
* "articleKeyword":文章关键字,
* "articleCategoryId":文章所属的分类Id,
* "articleTypeLinkURL":文章分类url地址,主要是用户生成html使用,
* "order":"排序方式",
* "orderBy":"排序字段
* }],
* "page":{"endRow": 2, 当前页面最后一个元素在数据库中的行号
* "firstPage": 1, 第一页页码
* "hasNextPage": true存在下一页false不存在,
* "hasPreviousPage": true存在上一页false不存在,
* "isFirstPage": true是第一页false不是第一页,
* "isLastPage": true是最后一页false不是最后一页,
* "lastPage": 最后一页的页码,
* "navigatePages": 导航数量,实现 1...5.6.7....10效果,
* "navigatepageNums": []导航页码集合,
* "nextPage": 下一页,
* "pageNum": 当前页码,
* "pageSize": 一页显示数量,
* "pages": 总页数,
* "prePage": 上一页,
* "size": 总记录,
* "startRow":当前页面第一个元素在数据库中的行号,
* "total":总记录数量
* }
*/
@RequestMapping(value = "/list",method= RequestMethod.GET)
@ApiOperation(value="文章列表信息")
@ResponseBody
public void list(@ModelAttribute @ApiIgnore ArticleEntity article, HttpServletRequest request, HttpServletResponse response) {
int appId = BasicUtil.getAppId();
int[] ids = null;
if (article.getBasicCategoryId()>0) {
ids = new int[]{article.getBasicCategoryId()};
}
//默认为desc排序
boolean isOrder = true;
if(!StringUtils.isBlank(article.getOrder())){
String basicOrder = article.getOrder();
if(basicOrder.equalsIgnoreCase("asc")){
isOrder = false;
}
}
BasicUtil.startPage();
List<ArticleEntity> list = articleBiz.query(appId, ids, null, null, article.getOrderBy(), isOrder, null, null, article);
for(ArticleEntity _article : list){
// 获取文章栏目id获取栏目实体
ColumnEntity column = (ColumnEntity) columnBiz.getEntity(_article.getBasicCategoryId());
ContentModelEntity contentModel = (ContentModelEntity) contentModelBiz
.getEntity(column.getColumnContentModelId());
// 判断内容模型的值
if (contentModel != null) {
Map where = new HashMap();
// 压入basicId字段的值
where.put("basicId", _article.getBasicId());
// 遍历所有的字段实体,得到字段名列表信息
List<String> listFieldName = new ArrayList<String>();
listFieldName.add("basicId");
// 查询新增字段的信息
List fieldLists = fieldBiz.queryBySQL(contentModel.getCmTableName(), listFieldName, where);
if (fieldLists.size() > 0) {
Map map = (Map) fieldLists.get(0);
_article.setExtendsFields(map);
}
}
}
this.outJson(response, JSONArray.toJSONString(new ListBean(list, BasicUtil.endPage(list)),new DateValueFilter("yyyy-MM-dd HH:mm:ss")));
}
}
\ No newline at end of file
package net.mingsoft.cms.action.web;
import java.util.List;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import net.mingsoft.base.entity.ResultData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.BindingResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.ui.ModelMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import net.mingsoft.cms.biz.ICategoryBiz;
import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.base.util.JSONObject;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.base.filter.DateValueFilter;
import net.mingsoft.base.filter.DoubleValueFilter;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.annotation.LogAnn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/**
* 分类管理控制层
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32<br/>
* 历史修订:<br/>
*/
@Api(value = "分类接口")
@Controller("WebcmsCategoryAction")
@RequestMapping("/cms/category")
public class CategoryAction extends net.mingsoft.cms.action.BaseAction{
/**
* 注入分类业务层
*/
@Autowired
private ICategoryBiz categoryBiz;
/**
* 返回主界面index
*/
@GetMapping("/index")
public String index(HttpServletResponse response,HttpServletRequest request){
return "/cms/category/index";
}
/**
* 查询分类列表
* @param category 分类实体
*/
@ApiOperation(value = "查询分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
BasicUtil.startPage();
List categoryList = categoryBiz.query(category);
return ResultData.build().success(new EUListBean(categoryList,(int)BasicUtil.endPage(categoryList).getTotal()));
}
/**
* 返回编辑界面category_form
*/
@GetMapping("/form")
public String form(@ModelAttribute CategoryEntity category,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(category.getId()!=null){
BaseEntity categoryEntity = categoryBiz.getEntity(Integer.parseInt(category.getId()));
model.addAttribute("categoryEntity",categoryEntity);
}
return "/cms/category/form";
}
/**
* 获取分类
* @param category 分类实体
*/
@ApiOperation(value = "获取分类列表接口")
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore CategoryEntity category,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
if(category.getId()==null) {
return ResultData.build().error();
}
CategoryEntity _category = (CategoryEntity)categoryBiz.getEntity(Integer.parseInt(category.getId()));
return ResultData.build().success(_category);
}
@ApiOperation(value = "保存分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
/**
* 保存分类
* @param category 分类实体
*/
@PostMapping("/save")
@ResponseBody
public ResultData save(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response, HttpServletRequest request) {
//验证栏目管理名称的值是否合法
if(StringUtil.isBlank(category.getCategoryTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
}
if(!StringUtil.checkLength(category.getCategoryTitle()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryFlag()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.flag"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryPath()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
categoryBiz.saveEntity(category);
return ResultData.build().success(category);
}
/**
* @param category 分类实体
*/
@ApiOperation(value = "批量删除分类列表接口")
@PostMapping("/delete")
@ResponseBody
public ResultData delete(@RequestBody List<CategoryEntity> categorys,HttpServletResponse response, HttpServletRequest request) {
int[] ids = new int[categorys.size()];
for(int i = 0;i<categorys.size();i++){
ids[i] =Integer.parseInt(categorys.get(i).getId()) ;
}
categoryBiz.delete(ids);
return ResultData.build().success();
}
/**
* 更新分类列表
* @param category 分类实体
*/
@ApiOperation(value = "更新分类列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryTitle", value = "栏目管理名称", required =true,paramType="query"),
@ApiImplicitParam(name = "categoryId", value = "所属栏目", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryType", value = "栏目管理属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categorySort", value = "自定义顺序", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryListUrl", value = "列表模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryUrl", value = "内容模板", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryKeyword", value = "栏目管理关键字", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDescrip", value = "栏目管理描述", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryImg", value = "缩略图", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDiyUrl", value = "自定义链接", required =false,paramType="query"),
@ApiImplicitParam(name = "mdiyModelId", value = "栏目管理的内容模型id", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryDatetime", value = "类别发布时间", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryManagerId", value = "发布用户id", required =false,paramType="query"),
@ApiImplicitParam(name = "appId", value = "应用编号", required =false,paramType="query"),
@ApiImplicitParam(name = "dictId", value = "字典对应编号", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryFlag", value = "栏目属性", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryPath", value = "栏目路径", required =false,paramType="query"),
@ApiImplicitParam(name = "categoryParentId", value = "父类型编号", required =false,paramType="query"),
@ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"),
@ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"),
@ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"),
@ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"),
@ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"),
@ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"),
})
@PostMapping("/update")
@ResponseBody
public ResultData update(@ModelAttribute @ApiIgnore CategoryEntity category, HttpServletResponse response,
HttpServletRequest request) {
//验证栏目管理名称的值是否合法
if(StringUtil.isBlank(category.getCategoryTitle())){
return ResultData.build().error(getResString("err.empty", this.getResString("category.title")));
}
if(!StringUtil.checkLength(category.getCategoryTitle()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.title"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryFlag()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.flag"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryPath()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.path"), "1", "100"));
}
if(!StringUtil.checkLength(category.getCategoryParentId()+"", 1, 100)){
return ResultData.build().error(getResString("err.length", this.getResString("category.parent.id"), "1", "100"));
}
categoryBiz.updateEntity(category);
return ResultData.build().success(category);
}
}
\ No newline at end of file
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