新增文章管理模块
This commit is contained in:
parent
3de938dd2a
commit
037b0b7727
@ -0,0 +1,14 @@
|
|||||||
|
package ink.wgink.interfaces.article;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: IArticleCheckService
|
||||||
|
* @Description: 文章模块检查
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/4/14 9:24 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IArticleCheckService {
|
||||||
|
}
|
33
module-article/pom.xml
Normal file
33
module-article/pom.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>wg-basic</artifactId>
|
||||||
|
<groupId>ink.wgink</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>module-article</artifactId>
|
||||||
|
<description>文章模块</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ink.wgink</groupId>
|
||||||
|
<artifactId>basic-exception</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ink.wgink</groupId>
|
||||||
|
<artifactId>basic-annotation</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ink.wgink</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,104 @@
|
|||||||
|
package ink.wgink.module.article.controller.api.category;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.category.CategoryDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.category.CategoryVO;
|
||||||
|
import ink.wgink.module.article.service.category.ICategoryService;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.exceptions.RemoveException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleCategoryController
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "文章类别接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/category")
|
||||||
|
public class CategoryController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICategoryService categoryService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增文章类别", notes = "新增文章类别接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("save")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult saveArticleCategory(@RequestBody CategoryVO categoryVO) {
|
||||||
|
categoryService.save(categoryVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除文章类别(id列表)", notes = "删除文章类别(id列表)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@DeleteMapping("remove/{ids}")
|
||||||
|
public SuccessResult remove(@PathVariable("ids") String ids) throws RemoveException {
|
||||||
|
categoryService.remove(Arrays.asList(ids.split("\\_")));
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改文章类别", notes = "修改文章类别接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "categoryId", value = "文章类别ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update/{categoryId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult update(@PathVariable("categoryId") String categoryId, @RequestBody CategoryVO categoryVO) {
|
||||||
|
categoryService.update(categoryId, categoryVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章类别详情(通过ID)", notes = "文章类别详情(通过ID)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "categoryId", value = "文章类别ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("get/{categoryId}")
|
||||||
|
public CategoryDTO getArticleCategoryById(@PathVariable("categoryId") String categoryId) {
|
||||||
|
return categoryService.get(categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章类别列表", notes = "文章类别列表接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list")
|
||||||
|
public List<CategoryDTO> list() throws SearchException {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return categoryService.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章类别分页列表", notes = "文章类别分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<CategoryDTO>> listPage(ListPage page) throws SearchException {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return categoryService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,141 @@
|
|||||||
|
package ink.wgink.module.article.controller.api.content;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.exceptions.ParamsException;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.content.ContentDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.content.ContentVO;
|
||||||
|
import ink.wgink.module.article.service.content.IContentService;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.RegexUtil;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleContentController
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "文章内容接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/content")
|
||||||
|
public class ContentController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IContentService contentService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增文章内容", notes = "新增文章内容接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("save")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult saveArticleContent(@RequestBody ContentVO contentVO) {
|
||||||
|
if (!StringUtils.isBlank(contentVO.getLink()) && !RegexUtil.isUrl(contentVO.getLink())) {
|
||||||
|
throw new ParamsException("外链格式不正确");
|
||||||
|
}
|
||||||
|
contentService.save(contentVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除文章内容(id列表)", notes = "删除文章内容(id列表)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@DeleteMapping("remove/{ids}")
|
||||||
|
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||||
|
contentService.remove(Arrays.asList(ids.split("\\_")));
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改文章内容", notes = "修改文章内容接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "contentId", value = "文章内容ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update/{contentId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult update(@PathVariable("contentId") String contentId, @RequestBody ContentVO contentVO) {
|
||||||
|
if (!StringUtils.isBlank(contentVO.getLink()) && !RegexUtil.isUrl(contentVO.getLink())) {
|
||||||
|
throw new ParamsException("外链格式不正确");
|
||||||
|
}
|
||||||
|
contentService.update(contentId, contentVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改文章发布状态", notes = "修改文章发布状态接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "contentId", value = "文章内容ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-publish-status/{contentId}/{isPublish}")
|
||||||
|
public SuccessResult updatePublishStatus(@PathVariable("contentId") String contentId, @PathVariable("isPublish") Integer isPublish) {
|
||||||
|
if (isPublish != 0 && isPublish != 1) {
|
||||||
|
throw new ParamsException("发布状态类型错误");
|
||||||
|
}
|
||||||
|
contentService.updatePublishStatus(contentId, isPublish);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章内容详情(通过ID)", notes = "文章内容详情(通过ID)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "contentId", value = "文章内容ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("get/{contentId}")
|
||||||
|
public ContentDTO get(@PathVariable("contentId") String contentId) {
|
||||||
|
return contentService.get(contentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章内容列表", notes = "文章内容列表接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@GetMapping("list")
|
||||||
|
public List<ContentDTO> list() {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return contentService.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<ContentDTO>> listPage(ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return contentService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "统计文章数量", notes = "统计文章数量接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("count")
|
||||||
|
public SuccessResultData<Integer> count() {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return new SuccessResultData<>(contentService.count(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package ink.wgink.module.article.controller.route.category;
|
||||||
|
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: MenuRouteController
|
||||||
|
* @Description: 文章目录路由
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/2/10 1:43 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "文章目录路由接口")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/category")
|
||||||
|
public class CategoryRouteController {
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
public ModelAndView list() {
|
||||||
|
return new ModelAndView("category/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("save")
|
||||||
|
public ModelAndView save() {
|
||||||
|
return new ModelAndView("category/save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("update")
|
||||||
|
public ModelAndView update() {
|
||||||
|
return new ModelAndView("category/update");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package ink.wgink.module.article.controller.route.content;
|
||||||
|
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.category.CategoryDTO;
|
||||||
|
import ink.wgink.module.article.service.category.ICategoryService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
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.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: MenuRouteController
|
||||||
|
* @Description: 文章内容路由
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/2/10 1:43 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "文章内容路由接口")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/content")
|
||||||
|
public class ContentRouteController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICategoryService categoryService;
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
public ModelAndView list() {
|
||||||
|
return new ModelAndView("content/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("list/{categoryId}")
|
||||||
|
public ModelAndView listCategory(@PathVariable("categoryId") String categoryId) {
|
||||||
|
ModelAndView modelAndView = new ModelAndView("content/list-category");
|
||||||
|
modelAndView.addObject("categoryId", categoryId);
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("save")
|
||||||
|
public ModelAndView save() {
|
||||||
|
return new ModelAndView("content/save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("save/{categoryId}")
|
||||||
|
public ModelAndView save(@PathVariable("categoryId") String categoryId) {
|
||||||
|
ModelAndView modelAndView = new ModelAndView("content/save-category");
|
||||||
|
CategoryDTO categoryDTO = categoryService.get(categoryId);
|
||||||
|
modelAndView.addObject("categoryId", categoryId);
|
||||||
|
modelAndView.addObject("categoryTitle", categoryDTO.getTitle());
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("update")
|
||||||
|
public ModelAndView update() {
|
||||||
|
return new ModelAndView("content/update");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("update/{categoryId}")
|
||||||
|
public ModelAndView update(@PathVariable("categoryId") String categoryId) {
|
||||||
|
ModelAndView modelAndView = new ModelAndView("content/update-category");
|
||||||
|
CategoryDTO categoryDTO = categoryService.get(categoryId);
|
||||||
|
modelAndView.addObject("categoryId", categoryId);
|
||||||
|
modelAndView.addObject("categoryTitle", categoryDTO.getTitle());
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package ink.wgink.module.article.dao.category;
|
||||||
|
|
||||||
|
import ink.wgink.module.article.pojo.dtos.category.CategoryDTO;
|
||||||
|
import ink.wgink.exceptions.RemoveException;
|
||||||
|
import ink.wgink.exceptions.SaveException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IArticleCategoryDao
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Repository
|
||||||
|
public interface ICategoryDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建表
|
||||||
|
*
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void createTable() throws UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章类别
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws SaveException
|
||||||
|
*/
|
||||||
|
void save(Map<String, Object> params) throws SaveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章类别
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws RemoveException
|
||||||
|
*/
|
||||||
|
void remove(Map<String, Object> params) throws RemoveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章类别
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void update(Map<String, Object> params) throws UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类别详情
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
CategoryDTO get(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类别列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
List<CategoryDTO> list(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package ink.wgink.module.article.dao.content;
|
||||||
|
|
||||||
|
import ink.wgink.exceptions.RemoveException;
|
||||||
|
import ink.wgink.exceptions.SaveException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.content.ContentDTO;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IArticleContentDao
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Repository
|
||||||
|
public interface IContentDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建表
|
||||||
|
*
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void createTable() throws UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章内容
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws SaveException
|
||||||
|
*/
|
||||||
|
void save(Map<String, Object> params) throws SaveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章内容
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws RemoveException
|
||||||
|
*/
|
||||||
|
void remove(Map<String, Object> params) throws RemoveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章内容
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void update(Map<String, Object> params) throws UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章内容详情
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
ContentDTO get(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章内容列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
List<ContentDTO> list(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计文章数量
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
Integer count(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package ink.wgink.module.article.pojo.dtos.category;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName: ArticleCategoryDTO
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class CategoryDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2030651264235444348L;
|
||||||
|
@ApiModelProperty(name = "categoryId", value = "主键")
|
||||||
|
private String categoryId;
|
||||||
|
@ApiModelProperty(name = "title", value = "标题")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(name = "summary", value = "说明")
|
||||||
|
private String summary;
|
||||||
|
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
|
||||||
|
private String gmtCreate;
|
||||||
|
|
||||||
|
public String getCategoryId() {
|
||||||
|
return categoryId == null ? "" : categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(String categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
public String getTitle() {
|
||||||
|
return title == null ? "" : title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary == null ? "" : summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(String summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate == null ? "" : gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtCreate(String gmtCreate) {
|
||||||
|
this.gmtCreate = gmtCreate;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
package ink.wgink.module.article.pojo.dtos.content;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleContentDTO
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class ContentDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "contentId", value = "主键")
|
||||||
|
private String contentId;
|
||||||
|
@ApiModelProperty(name = "title", value = "标题")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(name = "subTitle", value = "子标题")
|
||||||
|
private String subTitle;
|
||||||
|
@ApiModelProperty(name = "summary", value = "概述")
|
||||||
|
private String summary;
|
||||||
|
@ApiModelProperty(name = "link", value = "外链地址")
|
||||||
|
private String link;
|
||||||
|
@ApiModelProperty(name = "source", value = "来源")
|
||||||
|
private String source;
|
||||||
|
@ApiModelProperty(name = "author", value = "作者")
|
||||||
|
private String author;
|
||||||
|
@ApiModelProperty(name = "publishDate", value = "发布时间")
|
||||||
|
private String publishDate;
|
||||||
|
@ApiModelProperty(name = "isPublish", value = "是否发布")
|
||||||
|
private Integer isPublish;
|
||||||
|
@ApiModelProperty(name = "content", value = "正文")
|
||||||
|
private String content;
|
||||||
|
@ApiModelProperty(name = "sort", value = "排序")
|
||||||
|
private String sort;
|
||||||
|
@ApiModelProperty(name = "categoryId", value = "文章类别")
|
||||||
|
private String categoryId;
|
||||||
|
@ApiModelProperty(name = "categoryTitle", value = "文章类别标题")
|
||||||
|
private String categoryTitle;
|
||||||
|
@ApiModelProperty(name = "categorySummary", value = "文章类别说明")
|
||||||
|
private String categorySummary;
|
||||||
|
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
|
||||||
|
private String gmtCreate;
|
||||||
|
|
||||||
|
public String getContentId() {
|
||||||
|
return contentId == null ? "" : contentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentId(String contentId) {
|
||||||
|
this.contentId = contentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title == null ? "" : title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubTitle() {
|
||||||
|
return subTitle == null ? "" : subTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTitle(String subTitle) {
|
||||||
|
this.subTitle = subTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary == null ? "" : summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(String summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link == null ? "" : link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source == null ? "" : source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author == null ? "" : author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublishDate() {
|
||||||
|
return publishDate == null ? "" : publishDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishDate(String publishDate) {
|
||||||
|
this.publishDate = publishDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsPublish() {
|
||||||
|
return isPublish == null ? 0 : isPublish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublish(Integer isPublish) {
|
||||||
|
this.isPublish = isPublish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content == null ? "" : content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSort() {
|
||||||
|
return sort == null ? "" : sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(String sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryId() {
|
||||||
|
return categoryId == null ? "" : categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(String categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryTitle() {
|
||||||
|
return categoryTitle == null ? "" : categoryTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryTitle(String categoryTitle) {
|
||||||
|
this.categoryTitle = categoryTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategorySummary() {
|
||||||
|
return categorySummary == null ? "" : categorySummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategorySummary(String categorySummary) {
|
||||||
|
this.categorySummary = categorySummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate == null ? "" : gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtCreate(String gmtCreate) {
|
||||||
|
this.gmtCreate = gmtCreate;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package ink.wgink.module.article.pojo.vos.category;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName: ArticleCategoryVO
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class CategoryVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "title", value = "标题")
|
||||||
|
@CheckEmptyAnnotation(name = "标题")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(name = "summary", value = "说明")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title == null ? "" : title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary == null ? "" : summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(String summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
package ink.wgink.module.article.pojo.vos.content;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||||
|
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleContentVO
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class ContentVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "title", value = "标题")
|
||||||
|
@CheckEmptyAnnotation(name = "标题")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(name = "subTitle", value = "子标题")
|
||||||
|
private String subTitle;
|
||||||
|
@ApiModelProperty(name = "summary", value = "概述")
|
||||||
|
private String summary;
|
||||||
|
@ApiModelProperty(name = "link", value = "外链地址")
|
||||||
|
private String link;
|
||||||
|
@ApiModelProperty(name = "source", value = "来源")
|
||||||
|
private String source;
|
||||||
|
@ApiModelProperty(name = "author", value = "作者")
|
||||||
|
private String author;
|
||||||
|
@ApiModelProperty(name = "publishDate", value = "发布时间")
|
||||||
|
@CheckEmptyAnnotation(name = "发布时间", verifyType = "date")
|
||||||
|
private String publishDate;
|
||||||
|
@ApiModelProperty(name = "isPublish", value = "是否发布")
|
||||||
|
@CheckNumberAnnotation(name = "是否发布")
|
||||||
|
private Integer isPublish;
|
||||||
|
@ApiModelProperty(name = "content", value = "正文")
|
||||||
|
private String content;
|
||||||
|
@ApiModelProperty(name = "sort", value = "排序")
|
||||||
|
private String sort;
|
||||||
|
@ApiModelProperty(name = "categoryId", value = "文章类别")
|
||||||
|
private String categoryId;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title == null ? "" : title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubTitle() {
|
||||||
|
return subTitle == null ? "" : subTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTitle(String subTitle) {
|
||||||
|
this.subTitle = subTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary == null ? "" : summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(String summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link == null ? "" : link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source == null ? "" : source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author == null ? "" : author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublishDate() {
|
||||||
|
return publishDate == null ? "" : publishDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishDate(String publishDate) {
|
||||||
|
this.publishDate = publishDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsPublish() {
|
||||||
|
return isPublish == null ? 0 : isPublish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPublish(Integer isPublish) {
|
||||||
|
this.isPublish = isPublish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content == null ? "" : content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSort() {
|
||||||
|
return sort == null ? "" : sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(String sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryId() {
|
||||||
|
return categoryId == null ? "" : categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(String categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package ink.wgink.module.article.service.category;
|
||||||
|
|
||||||
|
import ink.wgink.module.article.pojo.dtos.category.CategoryDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.category.CategoryVO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IArticleCategoryService
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
public interface ICategoryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章类别
|
||||||
|
*
|
||||||
|
* @param categoryVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void save(CategoryVO categoryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章类别(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param categoryVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void saveByToken(String token, CategoryVO categoryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章类别
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void remove(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章类别(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void removeByToken(String token, List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章类别
|
||||||
|
*
|
||||||
|
* @param categoryId
|
||||||
|
* @param categoryVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void update(String categoryId, CategoryVO categoryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章类别(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param categoryId
|
||||||
|
* @param categoryVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void updateByToken(String token, String categoryId, CategoryVO categoryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类别详情(通过ID)
|
||||||
|
*
|
||||||
|
* @param categoryId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CategoryDTO get(String categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类别列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CategoryDTO> list(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类别分页列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<CategoryDTO>> listPage(ListPage page);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package ink.wgink.module.article.service.category.impl;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import ink.wgink.module.article.dao.category.ICategoryDao;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.category.CategoryDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.category.CategoryVO;
|
||||||
|
import ink.wgink.module.article.service.category.ICategoryService;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.UUIDUtil;
|
||||||
|
import ink.wgink.util.map.HashMapUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleCategoryServiceImpl
|
||||||
|
* @Description: 文章类别
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class CategoryServiceImpl extends DefaultBaseService implements ICategoryService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICategoryDao categoryDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(CategoryVO categoryVO) {
|
||||||
|
saveInfo(null, categoryVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByToken(String token, CategoryVO categoryVO) {
|
||||||
|
saveInfo(token, categoryVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章类别
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param categoryVO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void saveInfo(String token, CategoryVO categoryVO) {
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(categoryVO);
|
||||||
|
params.put("categoryId", UUIDUtil.getUUID());
|
||||||
|
if (token != null) {
|
||||||
|
setAppSaveInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setSaveInfo(params);
|
||||||
|
}
|
||||||
|
categoryDao.save(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<String> ids) {
|
||||||
|
removeInfo(null, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByToken(String token, List<String> ids) {
|
||||||
|
removeInfo(token, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章类别
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
private void removeInfo(String token, List<String> ids) {
|
||||||
|
Map<String, Object> params = getHashMap(3);
|
||||||
|
params.put("categoryIds", ids);
|
||||||
|
if (token != null) {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
}
|
||||||
|
categoryDao.remove(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(String categoryId, CategoryVO categoryVO) {
|
||||||
|
updateInfo(null, categoryId, categoryVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateByToken(String token, String categoryId, CategoryVO categoryVO) {
|
||||||
|
updateInfo(token, categoryId, categoryVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章类别
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param categoryId
|
||||||
|
* @param categoryVO
|
||||||
|
*/
|
||||||
|
private void updateInfo(String token, String categoryId, CategoryVO categoryVO) {
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(categoryVO);
|
||||||
|
params.put("categoryId", categoryId);
|
||||||
|
if (token != null) {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
}
|
||||||
|
categoryDao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CategoryDTO get(String categoryId) throws SearchException {
|
||||||
|
Map<String, Object> params = super.getHashMap(1);
|
||||||
|
params.put("categoryId", categoryId);
|
||||||
|
return categoryDao.get(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CategoryDTO> list(Map<String, Object> params) throws SearchException {
|
||||||
|
return categoryDao.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<CategoryDTO>> listPage(ListPage page) throws SearchException {
|
||||||
|
PageHelper.startPage(page.getPage(), page.getRows());
|
||||||
|
List<CategoryDTO> articleCategoryDTOs = list(page.getParams());
|
||||||
|
PageInfo<CategoryDTO> pageInfo = new PageInfo<>(articleCategoryDTOs);
|
||||||
|
return new SuccessResultList<>(articleCategoryDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package ink.wgink.module.article.service.content;
|
||||||
|
|
||||||
|
import ink.wgink.interfaces.article.IArticleCheckService;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.content.ContentDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.content.ContentVO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IArticleContentService
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
public interface IContentService extends IArticleCheckService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章内容
|
||||||
|
*
|
||||||
|
* @param contentVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void save(ContentVO contentVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章内容(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param contentVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void saveByToken(String token, ContentVO contentVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章内容
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void remove(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章内容(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void removeByToken(String token, List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章内容
|
||||||
|
*
|
||||||
|
* @param contentId
|
||||||
|
* @param contentVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void update(String contentId, ContentVO contentVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章内容(APP)
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param contentId
|
||||||
|
* @param contentVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void updateByToken(String token, String contentId, ContentVO contentVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章发布状态
|
||||||
|
*
|
||||||
|
* @param contentId
|
||||||
|
* @param isPublish
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void updatePublishStatus(String contentId, Integer isPublish);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章内容详情(通过ID)
|
||||||
|
*
|
||||||
|
* @param contentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ContentDTO get(String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章内容列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ContentDTO> list(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章内容分页列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<ContentDTO>> listPage(ListPage page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计文章数量
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer count(Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
package ink.wgink.module.article.service.content.impl;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.module.article.dao.content.IContentDao;
|
||||||
|
import ink.wgink.module.article.pojo.dtos.content.ContentDTO;
|
||||||
|
import ink.wgink.module.article.pojo.vos.content.ContentVO;
|
||||||
|
import ink.wgink.module.article.service.content.IContentService;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.UUIDUtil;
|
||||||
|
import ink.wgink.util.map.HashMapUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ArticleContentServiceImpl
|
||||||
|
* @Description: 文章内容
|
||||||
|
* @Author: WenG
|
||||||
|
* @Date: 2020-04-03 15:37
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class ContentServiceImpl extends DefaultBaseService implements IContentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IContentDao contentDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(ContentVO contentVO) {
|
||||||
|
saveInfo(null, contentVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByToken(String token, ContentVO contentVO) {
|
||||||
|
saveInfo(token, contentVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文章内容
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param contentVO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void saveInfo(String token, ContentVO contentVO) {
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(contentVO);
|
||||||
|
params.put("contentId", UUIDUtil.getUUID());
|
||||||
|
if (token != null) {
|
||||||
|
setAppSaveInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setSaveInfo(params);
|
||||||
|
}
|
||||||
|
contentDao.save(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<String> ids) {
|
||||||
|
removeInfo(null, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByToken(String token, List<String> ids) {
|
||||||
|
removeInfo(token, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文章内容
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
private void removeInfo(String token, List<String> ids) {
|
||||||
|
Map<String, Object> params = getHashMap(3);
|
||||||
|
params.put("contentIds", ids);
|
||||||
|
if (token != null) {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
}
|
||||||
|
contentDao.remove(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(String contentId, ContentVO contentVO) {
|
||||||
|
updateArticleContentInfo(null, contentId, contentVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateByToken(String token, String contentId, ContentVO contentVO) {
|
||||||
|
updateArticleContentInfo(token, contentId, contentVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePublishStatus(String contentId, Integer isPublish) {
|
||||||
|
Map<String, Object> params = getHashMap(2);
|
||||||
|
params.put("contentId", contentId);
|
||||||
|
params.put("isPublish", isPublish);
|
||||||
|
setUpdateInfo(params);
|
||||||
|
contentDao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改文章内容
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param contentId
|
||||||
|
* @param contentVO
|
||||||
|
*/
|
||||||
|
private void updateArticleContentInfo(String token, String contentId, ContentVO contentVO) {
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(contentVO);
|
||||||
|
params.put("contentId", contentId);
|
||||||
|
if (token != null) {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
} else {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
}
|
||||||
|
contentDao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentDTO get(String contentId) {
|
||||||
|
Map<String, Object> params = super.getHashMap(1);
|
||||||
|
params.put("contentId", contentId);
|
||||||
|
return contentDao.get(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ContentDTO> list(Map<String, Object> params) {
|
||||||
|
return contentDao.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<ContentDTO>> listPage(ListPage page) {
|
||||||
|
PageHelper.startPage(page.getPage(), page.getRows());
|
||||||
|
List<ContentDTO> articleContentDTOs = list(page.getParams());
|
||||||
|
PageInfo<ContentDTO> pageInfo = new PageInfo<>(articleContentDTOs);
|
||||||
|
return new SuccessResultList<>(articleContentDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer count(Map<String, Object> params) {
|
||||||
|
Integer count = contentDao.count(params);
|
||||||
|
return count == null ? 0 : count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package ink.wgink.module.article.startup;
|
||||||
|
|
||||||
|
import ink.wgink.module.article.dao.category.ICategoryDao;
|
||||||
|
import ink.wgink.module.article.dao.content.IContentDao;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: ArticleStartUp
|
||||||
|
* @Description: 文章模块启动
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/4/14 9:20 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ArticleStartUp implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(ArticleStartUp.class);
|
||||||
|
@Autowired
|
||||||
|
private ICategoryDao categoryDao;
|
||||||
|
@Autowired
|
||||||
|
private IContentDao contentDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
initTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTable() {
|
||||||
|
LOG.debug("创建 article_category 表");
|
||||||
|
categoryDao.createTable();
|
||||||
|
|
||||||
|
LOG.debug("创建 article_content 表");
|
||||||
|
contentDao.createTable();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="ink.wgink.module.article.dao.category.ICategoryDao">
|
||||||
|
|
||||||
|
<cache flushInterval="3600000"/>
|
||||||
|
|
||||||
|
<resultMap id="categoryDTO" type="ink.wgink.module.article.pojo.dtos.category.CategoryDTO">
|
||||||
|
<id column="category_id" property="categoryId"/>
|
||||||
|
<result column="title" property="title"/>
|
||||||
|
<result column="summary" property="summary"/>
|
||||||
|
<result column="gmt_create" property="gmtCreate"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 建表 -->
|
||||||
|
<update id="createTable">
|
||||||
|
CREATE TABLE IF NOT EXISTS `article_category` (
|
||||||
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||||
|
`category_id` char(36) NOT NULL COMMENT '主键',
|
||||||
|
`title` varchar(255) DEFAULT NULL COMMENT '标题',
|
||||||
|
`summary` varchar(255) DEFAULT NULL COMMENT '说明',
|
||||||
|
`creator` char(36) DEFAULT NULL,
|
||||||
|
`gmt_create` datetime DEFAULT NULL,
|
||||||
|
`modifier` char(36) DEFAULT NULL,
|
||||||
|
`gmt_modified` datetime DEFAULT NULL,
|
||||||
|
`is_delete` int(1) DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`,`category_id`),
|
||||||
|
KEY `category_id` (`category_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 新增文章类别 -->
|
||||||
|
<insert id="save" parameterType="map" flushCache="true">
|
||||||
|
INSERT INTO article_category (
|
||||||
|
category_id,
|
||||||
|
title,
|
||||||
|
summary,
|
||||||
|
creator,
|
||||||
|
gmt_create,
|
||||||
|
modifier,
|
||||||
|
gmt_modified,
|
||||||
|
is_delete
|
||||||
|
) VALUES(
|
||||||
|
#{categoryId},
|
||||||
|
#{title},
|
||||||
|
#{summary},
|
||||||
|
#{creator},
|
||||||
|
#{gmtCreate},
|
||||||
|
#{modifier},
|
||||||
|
#{gmtModified},
|
||||||
|
#{isDelete}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 删除文章类别 -->
|
||||||
|
<update id="remove" parameterType="map" flushCache="true">
|
||||||
|
UPDATE
|
||||||
|
article_category
|
||||||
|
SET
|
||||||
|
is_delete = 1,
|
||||||
|
modifier = #{modifier},
|
||||||
|
gmt_modified = #{gmtModified}
|
||||||
|
WHERE
|
||||||
|
category_id IN
|
||||||
|
<foreach collection="categoryIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{categoryIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 修改文章类别 -->
|
||||||
|
<update id="update" parameterType="map" flushCache="true">
|
||||||
|
UPDATE
|
||||||
|
article_category
|
||||||
|
SET
|
||||||
|
<if test="title != null and title != ''">
|
||||||
|
title = #{title},
|
||||||
|
</if>
|
||||||
|
<if test="summary != null and summary != ''">
|
||||||
|
summary = #{summary},
|
||||||
|
</if>
|
||||||
|
modifier = #{modifier},
|
||||||
|
gmt_modified = #{gmtModified}
|
||||||
|
WHERE
|
||||||
|
category_id = #{categoryId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 文章类别详情 -->
|
||||||
|
<select id="get" parameterType="map" resultMap="categoryDTO" useCache="true">
|
||||||
|
SELECT
|
||||||
|
t1.title,
|
||||||
|
t1.summary,
|
||||||
|
t1.category_id
|
||||||
|
FROM
|
||||||
|
article_category t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
AND
|
||||||
|
t1.category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 文章类别列表 -->
|
||||||
|
<select id="list" parameterType="map" resultMap="categoryDTO">
|
||||||
|
SELECT
|
||||||
|
t1.title,
|
||||||
|
t1.summary,
|
||||||
|
LEFT(t1.gmt_create, 19) gmt_create,
|
||||||
|
t1.category_id
|
||||||
|
FROM
|
||||||
|
article_category t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="keywords != null and keywords != ''">
|
||||||
|
t1.title LIKE CONCAT('%', #{keywords}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="categoryIds != null and categoryIds.size > 0">
|
||||||
|
AND
|
||||||
|
t1.category_id IN
|
||||||
|
<foreach collection="categoryIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{categoryIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
ORDER BY
|
||||||
|
t1.gmt_create
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,281 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="ink.wgink.module.article.dao.content.IContentDao">
|
||||||
|
|
||||||
|
<cache flushInterval="3600000"/>
|
||||||
|
|
||||||
|
<resultMap id="contentDTO" type="ink.wgink.module.article.pojo.dtos.content.ContentDTO">
|
||||||
|
<id column="content_id" property="contentId"/>
|
||||||
|
<result column="title" property="title"/>
|
||||||
|
<result column="sub_title" property="subTitle"/>
|
||||||
|
<result column="summary" property="summary"/>
|
||||||
|
<result column="link" property="link"/>
|
||||||
|
<result column="source" property="source"/>
|
||||||
|
<result column="author" property="author"/>
|
||||||
|
<result column="publish_date" property="publishDate"/>
|
||||||
|
<result column="is_publish" property="isPublish"/>
|
||||||
|
<result column="content" property="content"/>
|
||||||
|
<result column="sort" property="sort"/>
|
||||||
|
<result column="category_id" property="categoryId"/>
|
||||||
|
<result column="category_title" property="categoryTitle"/>
|
||||||
|
<result column="category_summary" property="categorySummary"/>
|
||||||
|
<result column="gmt_create" property="gmtCreate"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 建表 -->
|
||||||
|
<update id="createTable">
|
||||||
|
CREATE TABLE IF NOT EXISTS `article_content` (
|
||||||
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||||
|
`content_id` char(36) NOT NULL COMMENT '主键',
|
||||||
|
`title` varchar(255) DEFAULT NULL COMMENT '标题',
|
||||||
|
`sub_title` varchar(255) DEFAULT NULL COMMENT '子标题',
|
||||||
|
`summary` varchar(255) DEFAULT NULL COMMENT '概述',
|
||||||
|
`link` varchar(255) DEFAULT NULL COMMENT '连接',
|
||||||
|
`source` varchar(255) DEFAULT NULL COMMENT '来源',
|
||||||
|
`author` varchar(255) DEFAULT NULL COMMENT '作者',
|
||||||
|
`publish_date` varchar(40) DEFAULT NULL COMMENT '发布时间',
|
||||||
|
`is_publish` int(11) DEFAULT NULL COMMENT '是否发布',
|
||||||
|
`content` longtext COMMENT '正文',
|
||||||
|
`category_id` char(36) DEFAULT NULL COMMENT '文章类别',
|
||||||
|
`sort` varchar(255) DEFAULT NULL COMMENT '文章排序',
|
||||||
|
`creator` char(36) DEFAULT NULL,
|
||||||
|
`gmt_create` datetime DEFAULT NULL,
|
||||||
|
`modifier` char(36) DEFAULT NULL,
|
||||||
|
`gmt_modified` datetime DEFAULT NULL,
|
||||||
|
`is_delete` int(1) DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`,`content_id`),
|
||||||
|
KEY `content_id` (`content_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 新增文章内容 -->
|
||||||
|
<insert id="save" parameterType="map" flushCache="true">
|
||||||
|
INSERT INTO article_content(
|
||||||
|
content_id,
|
||||||
|
title,
|
||||||
|
sub_title,
|
||||||
|
summary,
|
||||||
|
link,
|
||||||
|
source,
|
||||||
|
author,
|
||||||
|
publish_date,
|
||||||
|
is_publish,
|
||||||
|
content,
|
||||||
|
sort,
|
||||||
|
category_id,
|
||||||
|
creator,
|
||||||
|
gmt_create,
|
||||||
|
modifier,
|
||||||
|
gmt_modified,
|
||||||
|
is_delete
|
||||||
|
) VALUES(
|
||||||
|
#{contentId},
|
||||||
|
#{title},
|
||||||
|
#{subTitle},
|
||||||
|
#{summary},
|
||||||
|
#{link},
|
||||||
|
#{source},
|
||||||
|
#{author},
|
||||||
|
#{publishDate},
|
||||||
|
#{isPublish},
|
||||||
|
#{content},
|
||||||
|
#{sort},
|
||||||
|
#{categoryId},
|
||||||
|
#{creator},
|
||||||
|
#{gmtCreate},
|
||||||
|
#{modifier},
|
||||||
|
#{gmtModified},
|
||||||
|
#{isDelete}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 删除文章内容 -->
|
||||||
|
<update id="remove" parameterType="map" flushCache="true">
|
||||||
|
UPDATE
|
||||||
|
article_content
|
||||||
|
SET
|
||||||
|
is_delete = 1,
|
||||||
|
modifier = #{modifier},
|
||||||
|
gmt_modified = #{gmtModified}
|
||||||
|
WHERE
|
||||||
|
content_id IN
|
||||||
|
<foreach collection="contentIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{contentIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 修改文章内容 -->
|
||||||
|
<update id="update" parameterType="map" flushCache="true">
|
||||||
|
UPDATE
|
||||||
|
article_content
|
||||||
|
SET
|
||||||
|
<if test="title != null and title != ''">
|
||||||
|
title = #{title},
|
||||||
|
</if>
|
||||||
|
<if test="subTitle != null and subTitle != ''">
|
||||||
|
sub_title = #{subTitle},
|
||||||
|
</if>
|
||||||
|
<if test="summary != null and summary != ''">
|
||||||
|
summary = #{summary},
|
||||||
|
</if>
|
||||||
|
<if test="link != null and link != ''">
|
||||||
|
link = #{link},
|
||||||
|
</if>
|
||||||
|
<if test="source != null and source != ''">
|
||||||
|
source = #{source},
|
||||||
|
</if>
|
||||||
|
<if test="author != null and author != ''">
|
||||||
|
author = #{author},
|
||||||
|
</if>
|
||||||
|
<if test="publishDate != null and publishDate != ''">
|
||||||
|
publish_date = #{publishDate},
|
||||||
|
</if>
|
||||||
|
<if test="isPublish != null">
|
||||||
|
is_publish = #{isPublish},
|
||||||
|
</if>
|
||||||
|
<if test="content != null and content != ''">
|
||||||
|
content = #{content},
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
category_id = #{categoryId},
|
||||||
|
</if>
|
||||||
|
modifier = #{modifier},
|
||||||
|
gmt_modified = #{gmtModified}
|
||||||
|
WHERE
|
||||||
|
content_id = #{contentId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 文章内容详情 -->
|
||||||
|
<select id="get" parameterType="map" resultMap="contentDTO" useCache="true">
|
||||||
|
SELECT
|
||||||
|
t1.title,
|
||||||
|
t1.sub_title,
|
||||||
|
t1.summary,
|
||||||
|
t1.link,
|
||||||
|
t1.source,
|
||||||
|
t1.author,
|
||||||
|
t1.publish_date,
|
||||||
|
t1.is_publish,
|
||||||
|
t1.content,
|
||||||
|
t1.category_id,
|
||||||
|
t1.sort,
|
||||||
|
t1.content_id
|
||||||
|
FROM
|
||||||
|
article_content t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="contentId != null and contentId != ''">
|
||||||
|
AND
|
||||||
|
t1.content_id = #{contentId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 文章内容列表 -->
|
||||||
|
<select id="list" parameterType="map" resultMap="contentDTO" useCache="true">
|
||||||
|
SELECT
|
||||||
|
t1.title,
|
||||||
|
t1.sub_title,
|
||||||
|
t1.summary,
|
||||||
|
t1.source,
|
||||||
|
t1.author,
|
||||||
|
t1.publish_date,
|
||||||
|
t1.is_publish,
|
||||||
|
t1.content,
|
||||||
|
t1.category_id,
|
||||||
|
jt1.title category_title,
|
||||||
|
jt1.summary category_summary,
|
||||||
|
t1.sort,
|
||||||
|
LEFT(t1.gmt_create, 19) gmt_create,
|
||||||
|
t1.content_id
|
||||||
|
FROM
|
||||||
|
article_content t1
|
||||||
|
INNER JOIN
|
||||||
|
article_category jt1
|
||||||
|
ON
|
||||||
|
t1.category_id = jt1.category_id
|
||||||
|
AND
|
||||||
|
jt1.is_delete = 0
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="keywords != null and keywords != ''">
|
||||||
|
AND
|
||||||
|
t1.title LIKE CONCAT('%s', #{keywords}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="isPublish != null">
|
||||||
|
AND
|
||||||
|
t1.is_publish = #{isPublish}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
AND
|
||||||
|
t1.category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
<if test="contentIds != null and contentIds.size > 0">
|
||||||
|
AND
|
||||||
|
t1.content_id IN
|
||||||
|
<foreach collection="contentIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{contentIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="creator != null and creator != ''">
|
||||||
|
AND
|
||||||
|
t1.creator = #{creator}
|
||||||
|
</if>
|
||||||
|
<if test="creators != null and creators.size > 0">
|
||||||
|
AND
|
||||||
|
t1.creator IN
|
||||||
|
<foreach collection="creators" index="index" open="(" separator="," close=")">
|
||||||
|
#{creators[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
ORDER BY t1.publish_date DESC, t1.gmt_create DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 统计文章数量 -->
|
||||||
|
<select id="count" parameterType="map" resultType="Integer" useCache="true">
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
article_content
|
||||||
|
WHERE
|
||||||
|
is_delete = 0
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
AND
|
||||||
|
category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
<if test="isPublish != null">
|
||||||
|
AND
|
||||||
|
is_publish = #{isPublish}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
AND
|
||||||
|
category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
<if test="contentIds != null and contentIds.size > 0">
|
||||||
|
AND
|
||||||
|
content_id IN
|
||||||
|
<foreach collection="contentIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{contentIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="creator != null and creator != ''">
|
||||||
|
AND
|
||||||
|
creator = #{creator}
|
||||||
|
</if>
|
||||||
|
<if test="creators != null and creators.size > 0">
|
||||||
|
AND
|
||||||
|
creator IN
|
||||||
|
<foreach collection="creators" index="index" open="(" separator="," close=")">
|
||||||
|
#{creators[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
246
module-article/src/main/resources/templates/category/list.html
Normal file
246
module-article/src/main/resources/templates/category/list.html
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||||
|
<!-- 表头按钮组 -->
|
||||||
|
<script type="text/html" id="headerToolBar">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||||
|
<i class="fa fa-lg fa-plus"></i> 新增
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||||
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||||
|
<i class="fa fa-lg fa-trash"></i> 删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var table = layui.table;
|
||||||
|
var admin = layui.admin;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var common = layui.common;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var tableUrl = 'api/category/listpage';
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
function initTable() {
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{type:'checkbox', fixed: 'left'},
|
||||||
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
|
{field: 'categoryId', width: 300, title: '编码', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'title', width: 300, title: '标题', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'summary', width: 300, title: '说明', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 重载表格
|
||||||
|
function reloadTable(currentPage) {
|
||||||
|
table.reload('dataTable', {
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
where: {
|
||||||
|
keywords: $('#keywords').val(),
|
||||||
|
startTime: $('#startTime').val(),
|
||||||
|
endTime: $('#endTime').val()
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: currentPage
|
||||||
|
},
|
||||||
|
height: $win.height() - 90,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 初始化日期
|
||||||
|
function initDate() {
|
||||||
|
// 日期选择
|
||||||
|
laydate.render({
|
||||||
|
elem: '#startTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#endTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
function removeData(ids) {
|
||||||
|
top.dialog.msg(top.dataMessage.delete, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var layIndex;
|
||||||
|
top.restAjax.delete(top.restAjax.path('api/category/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||||
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(layIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initTable();
|
||||||
|
initDate();
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
reloadTable();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
// 事件 - 搜索
|
||||||
|
$(document).on('click', '#search', function() {
|
||||||
|
reloadTable(1);
|
||||||
|
});
|
||||||
|
// 事件 - 增删改
|
||||||
|
table.on('toolbar(dataTable)', function(obj) {
|
||||||
|
var layEvent = obj.event;
|
||||||
|
var checkStatus = table.checkStatus('dataTable');
|
||||||
|
var checkDatas = checkStatus.data;
|
||||||
|
if(layEvent === 'saveEvent') {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/category/save', []),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(layEvent === 'updateEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||||
|
} else if(checkDatas.length > 1) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/category/update?categoryId={categoryId}', [checkDatas[0].categoryId]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if(layEvent === 'removeEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||||
|
} else {
|
||||||
|
var ids = '';
|
||||||
|
for(var i = 0, item; item = checkDatas[i++];) {
|
||||||
|
if(i > 1) {
|
||||||
|
ids += '_';
|
||||||
|
}
|
||||||
|
ids += item['categoryId'];
|
||||||
|
}
|
||||||
|
removeData(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
161
module-article/src/main/resources/templates/category/save.html
Normal file
161
module-article/src/main/resources/templates/category/save.html
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">说明</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="summary" name="summary" class="layui-input" value="" placeholder="请输入说明" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var wangEditor = window.wangEditor;
|
||||||
|
var wangEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.post(top.restAjax.path('api/category/save', []), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
179
module-article/src/main/resources/templates/category/update.html
Normal file
179
module-article/src/main/resources/templates/category/update.html
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">说明</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="summary" name="summary" class="layui-input" value="" placeholder="请输入说明" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var categoryId = top.restAjax.params(window.location.href).categoryId;
|
||||||
|
|
||||||
|
var wangEditor = window.wangEditor;
|
||||||
|
var wangEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/get/{categoryId}', [categoryId]), {}, null, function(code, data) {
|
||||||
|
var dataFormData = {};
|
||||||
|
for(var i in data) {
|
||||||
|
dataFormData[i] = data[i];
|
||||||
|
}
|
||||||
|
form.val('dataForm', dataFormData);
|
||||||
|
form.render(null, 'dataForm');
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.put(top.restAjax.path('api/category/update/{categoryId}', [categoryId]), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,286 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<input type="hidden" id="categoryId" th:value="${categoryId}">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline layui-form search-item">
|
||||||
|
<select id="isPublish" name="isPublish">
|
||||||
|
<option value="">选择状态</option>
|
||||||
|
<option value="0">未发布</option>
|
||||||
|
<option value="1">已发布</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||||
|
<!-- 表头按钮组 -->
|
||||||
|
<script type="text/html" id="headerToolBar">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||||
|
<i class="fa fa-lg fa-plus"></i> 新增
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||||
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||||
|
<i class="fa fa-lg fa-trash"></i> 删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var table = layui.table;
|
||||||
|
var admin = layui.admin;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var common = layui.common;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var tableUrl = 'api/content/listpage';
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
function initTable() {
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{type:'checkbox', fixed: 'left'},
|
||||||
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
|
{field: 'title', width: 300, title: '标题', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'categorySummary', width: 200, title: '文章类别', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'publishDate', width: 150, title: '发布时间', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return common.formatDate('yyyy-MM-dd', new Date(rowData));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'isPublish', width: 100, title: '发布操作', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
if(rowData == 1) {
|
||||||
|
return '<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="unPublishEvent">取消发布</button>';
|
||||||
|
}
|
||||||
|
return '<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="publishEvent">确定发布</button>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 重载表格
|
||||||
|
function reloadTable(currentPage) {
|
||||||
|
table.reload('dataTable', {
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
where: {
|
||||||
|
keywords: $('#keywords').val(),
|
||||||
|
startTime: $('#startTime').val(),
|
||||||
|
endTime: $('#endTime').val(),
|
||||||
|
isPublish: $('#isPublish').val()
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: currentPage
|
||||||
|
},
|
||||||
|
height: $win.height() - 90,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 初始化日期
|
||||||
|
function initDate() {
|
||||||
|
// 日期选择
|
||||||
|
laydate.render({
|
||||||
|
elem: '#startTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#endTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
function removeData(ids) {
|
||||||
|
top.dialog.msg(top.dataMessage.delete, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var layIndex;
|
||||||
|
top.restAjax.delete(top.restAjax.path('api/content/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||||
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(layIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initTable();
|
||||||
|
initDate();
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
reloadTable();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
// 事件 - 搜索
|
||||||
|
$(document).on('click', '#search', function() {
|
||||||
|
reloadTable(1);
|
||||||
|
});
|
||||||
|
// 事件 - 增删改
|
||||||
|
table.on('toolbar(dataTable)', function(obj) {
|
||||||
|
var layEvent = obj.event;
|
||||||
|
var checkStatus = table.checkStatus('dataTable');
|
||||||
|
var checkDatas = checkStatus.data;
|
||||||
|
if(layEvent === 'saveEvent') {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/content/save/{categoryId}', [$('#categoryId').val()]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(layEvent === 'updateEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||||
|
} else if(checkDatas.length > 1) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/content/update/{categoryId}?contentId={contentId}', [checkDatas[0].contentId, $('#categoryId').val()]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if(layEvent === 'removeEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||||
|
} else {
|
||||||
|
var ids = '';
|
||||||
|
for(var i = 0, item; item = checkDatas[i++];) {
|
||||||
|
if(i > 1) {
|
||||||
|
ids += '_';
|
||||||
|
}
|
||||||
|
ids += item['contentId'];
|
||||||
|
}
|
||||||
|
removeData(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 修改发布状态
|
||||||
|
function updatePublishStatus(contentId, publishStatus) {
|
||||||
|
top.restAjax.put(top.restAjax.path('api/content/update-publish-status/{contentId}/{publishStatus}', [contentId, publishStatus]), {}, null, function(code, data) {
|
||||||
|
top.dialog.msg('发布状态修改成功', {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
table.on('tool(dataTable)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
var layEvent = obj.event;
|
||||||
|
if(layEvent === 'publishEvent') {
|
||||||
|
updatePublishStatus(data.contentId, 1);
|
||||||
|
} else if(layEvent === 'unPublishEvent') {
|
||||||
|
updatePublishStatus(data.contentId, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
314
module-article/src/main/resources/templates/content/list.html
Normal file
314
module-article/src/main/resources/templates/content/list.html
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline layui-form search-item" id="categoryIdTemplateBox" lay-filter="categoryIdTemplateBox"></div>
|
||||||
|
<script id="categoryIdTemplate" type="text/html">
|
||||||
|
<select id="categoryId" name="categoryId" lay-filter="categoryId" lay-search>
|
||||||
|
<option value="">选择类别</option>
|
||||||
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||||
|
<option value="{{item.categoryId}}">{{item.title}}</option>
|
||||||
|
{{# } }}
|
||||||
|
</select>
|
||||||
|
</script>
|
||||||
|
<div class="layui-inline layui-form search-item">
|
||||||
|
<select id="isPublish" name="isPublish">
|
||||||
|
<option value="">选择状态</option>
|
||||||
|
<option value="0">未发布</option>
|
||||||
|
<option value="1">已发布</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||||
|
<!-- 表头按钮组 -->
|
||||||
|
<script type="text/html" id="headerToolBar">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||||
|
<i class="fa fa-lg fa-plus"></i> 新增
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||||
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||||
|
<i class="fa fa-lg fa-trash"></i> 删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var table = layui.table;
|
||||||
|
var admin = layui.admin;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var form = layui.form;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var common = layui.common;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var tableUrl = 'api/content/listpage';
|
||||||
|
|
||||||
|
// 初始化选择框、单选、复选模板
|
||||||
|
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
|
||||||
|
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
|
||||||
|
document.getElementById(templateBoxId).innerHTML = html;
|
||||||
|
});
|
||||||
|
form.render('select', templateBoxId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化学校下拉选择
|
||||||
|
function initCategoryIdSelect() {
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/list', []), {}, null, function(code, data, args) {
|
||||||
|
initSelectRadioCheckboxTemplate('categoryIdTemplate', 'categoryIdTemplateBox', data);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initCategoryIdSelect();
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
function initTable() {
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{type:'checkbox', fixed: 'left'},
|
||||||
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
|
{field: 'title', width: 300, title: '标题', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'categorySummary', width: 200, title: '文章类别', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'publishDate', width: 150, title: '发布时间', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return common.formatDate('yyyy-MM-dd', new Date(rowData));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'isPublish', width: 100, title: '发布操作', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
if(rowData == 1) {
|
||||||
|
return '<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="unPublishEvent">取消发布</button>';
|
||||||
|
}
|
||||||
|
return '<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="publishEvent">确定发布</button>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 重载表格
|
||||||
|
function reloadTable(currentPage) {
|
||||||
|
table.reload('dataTable', {
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
where: {
|
||||||
|
keywords: $('#keywords').val(),
|
||||||
|
startTime: $('#startTime').val(),
|
||||||
|
endTime: $('#endTime').val(),
|
||||||
|
categoryId: $('#categoryId').val(),
|
||||||
|
isPublish: $('#isPublish').val()
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: currentPage
|
||||||
|
},
|
||||||
|
height: $win.height() - 90,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 初始化日期
|
||||||
|
function initDate() {
|
||||||
|
// 日期选择
|
||||||
|
laydate.render({
|
||||||
|
elem: '#startTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#endTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
function removeData(ids) {
|
||||||
|
top.dialog.msg(top.dataMessage.delete, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var layIndex;
|
||||||
|
top.restAjax.delete(top.restAjax.path('api/content/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||||
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(layIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initTable();
|
||||||
|
initDate();
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
reloadTable();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
// 事件 - 搜索
|
||||||
|
$(document).on('click', '#search', function() {
|
||||||
|
reloadTable(1);
|
||||||
|
});
|
||||||
|
// 事件 - 增删改
|
||||||
|
table.on('toolbar(dataTable)', function(obj) {
|
||||||
|
var layEvent = obj.event;
|
||||||
|
var checkStatus = table.checkStatus('dataTable');
|
||||||
|
var checkDatas = checkStatus.data;
|
||||||
|
if(layEvent === 'saveEvent') {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/content/save', []),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(layEvent === 'updateEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||||
|
} else if(checkDatas.length > 1) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/content/update?contentId={contentId}', [checkDatas[0].contentId]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if(layEvent === 'removeEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||||
|
} else {
|
||||||
|
var ids = '';
|
||||||
|
for(var i = 0, item; item = checkDatas[i++];) {
|
||||||
|
if(i > 1) {
|
||||||
|
ids += '_';
|
||||||
|
}
|
||||||
|
ids += item['contentId'];
|
||||||
|
}
|
||||||
|
removeData(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 修改发布状态
|
||||||
|
function updatePublishStatus(contentId, publishStatus) {
|
||||||
|
top.restAjax.put(top.restAjax.path('api/content/update-publish-status/{contentId}/{publishStatus}', [contentId, publishStatus]), {}, null, function(code, data) {
|
||||||
|
top.dialog.msg('发布状态修改成功', {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
table.on('tool(dataTable)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
var layEvent = obj.event;
|
||||||
|
if(layEvent === 'publishEvent') {
|
||||||
|
updatePublishStatus(data.contentId, 1);
|
||||||
|
} else if(layEvent === 'unPublishEvent') {
|
||||||
|
updatePublishStatus(data.contentId, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,253 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<input type="hidden" id="categoryId" name="categoryId" th:value="${categoryId}">
|
||||||
|
<blockquote class="layui-elem-quote" th:text="${categoryTitle}"></blockquote>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">子标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="subTitle" name="subTitle" class="layui-input" value="" placeholder="请输入子标题" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">概述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea id="summary" name="summary" class="layui-textarea" placeholder="请输入概述"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">外链地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="link" name="link" class="layui-input" value="" placeholder="请输入外链地址,http或https开头,列表点击跳转到对应页面。">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">来源</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="source" name="source" class="layui-input" value="" placeholder="请输入来源" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">作者</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="author" name="author" class="layui-input" value="" placeholder="请输入作者" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">发布时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="publishDate" name="publishDate" class="layui-input" value="" placeholder="请选择发布时间" readonly style="cursor: pointer;" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="isPublish" value="1" title="是" checked>
|
||||||
|
<input type="radio" name="isPublish" value="0" title="否">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<script id="content" name="content" type="text/plain"></script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.config.js"></script>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.all.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var ueEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化发布时间日期
|
||||||
|
function initPublishDateDate() {
|
||||||
|
laydate.render({
|
||||||
|
elem: '#publishDate',
|
||||||
|
type: 'date',
|
||||||
|
value: new Date(),
|
||||||
|
trigger: 'click'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化正文富文本
|
||||||
|
function initContentRichText() {
|
||||||
|
var editor = UE.getEditor('content');
|
||||||
|
editor.ready(function() {
|
||||||
|
editor.setHeight(400);
|
||||||
|
});
|
||||||
|
ueEditorObj['content'] = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文章类别联表
|
||||||
|
function initCategory(){
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/list', []), {}, null, function(code, data, args) {
|
||||||
|
laytpl(document.getElementById('categoryIdTemplate').innerHTML).render(data, function(html) {
|
||||||
|
document.getElementById('categoryIdTemplateBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
form.render('select', 'categoryIdTemplateBox');
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
initPublishDateDate();
|
||||||
|
initContentRichText();
|
||||||
|
initCategory();
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
formData.field['content'] = ueEditorObj['content'].getContent();
|
||||||
|
top.restAjax.post(top.restAjax.path('api/content/save', []), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
261
module-article/src/main/resources/templates/content/save.html
Normal file
261
module-article/src/main/resources/templates/content/save.html
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">文章类别</label>
|
||||||
|
<div class="layui-input-block layui-form" id="categoryIdTemplateBox" lay-filter="categoryIdTemplateBox"></div>
|
||||||
|
<script id="categoryIdTemplate" type="text/html">
|
||||||
|
<select name="categoryId" lay-verify="required" lay-search>
|
||||||
|
<option value="">选择文章类别</option>
|
||||||
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||||
|
<option value="{{item.categoryId}}">{{item.title}}</option>
|
||||||
|
{{# } }}
|
||||||
|
</select>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">子标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="subTitle" name="subTitle" class="layui-input" value="" placeholder="请输入子标题" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">概述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea id="summary" name="summary" class="layui-textarea" placeholder="请输入概述"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">外链地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="link" name="link" class="layui-input" value="" placeholder="请输入外链地址,http或https开头,列表点击跳转到对应页面。">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">来源</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="source" name="source" class="layui-input" value="" placeholder="请输入来源" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">作者</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="author" name="author" class="layui-input" value="" placeholder="请输入作者" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">发布时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="publishDate" name="publishDate" class="layui-input" value="" placeholder="请选择发布时间" readonly style="cursor: pointer;" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="isPublish" value="1" title="是" checked>
|
||||||
|
<input type="radio" name="isPublish" value="0" title="否">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<script id="content" name="content" type="text/plain"></script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.config.js"></script>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.all.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var ueEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化发布时间日期
|
||||||
|
function initPublishDateDate() {
|
||||||
|
laydate.render({
|
||||||
|
elem: '#publishDate',
|
||||||
|
type: 'date',
|
||||||
|
value: new Date(),
|
||||||
|
trigger: 'click'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化正文富文本
|
||||||
|
function initContentRichText() {
|
||||||
|
var editor = UE.getEditor('content');
|
||||||
|
editor.ready(function() {
|
||||||
|
editor.setHeight(400);
|
||||||
|
});
|
||||||
|
ueEditorObj['content'] = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文章类别联表
|
||||||
|
function initCategory(){
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/list', []), {}, null, function(code, data, args) {
|
||||||
|
laytpl(document.getElementById('categoryIdTemplate').innerHTML).render(data, function(html) {
|
||||||
|
document.getElementById('categoryIdTemplateBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
form.render('select', 'categoryIdTemplateBox');
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
initPublishDateDate();
|
||||||
|
initContentRichText();
|
||||||
|
initCategory();
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
formData.field['content'] = ueEditorObj['content'].getContent();
|
||||||
|
top.restAjax.post(top.restAjax.path('api/content/save', []), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,276 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<input type="hidden" id="categoryId" name="categoryId" th:value="${categoryId}">
|
||||||
|
<blockquote class="layui-elem-quote" th:text="${categoryTitle}"></blockquote>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">子标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="subTitle" name="subTitle" class="layui-input" value="" placeholder="请输入子标题" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">概述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea id="summary" name="summary" class="layui-textarea" placeholder="请输入概述"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">外链地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="link" name="link" class="layui-input" value="" placeholder="请输入外链地址,http或https开头,列表点击跳转到对应页面。">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">来源</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="source" name="source" class="layui-input" value="" placeholder="请输入来源" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">作者</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="author" name="author" class="layui-input" value="" placeholder="请输入作者" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">发布时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="publishDate" name="publishDate" class="layui-input" value="" placeholder="请选择发布时间" readonly style="cursor: pointer;" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="isPublish" value="1" title="是">
|
||||||
|
<input type="radio" name="isPublish" value="0" title="否">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<script id="content" name="content" type="text/plain"></script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.config.js"></script>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.all.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var contentId = top.restAjax.params(window.location.href).contentId;
|
||||||
|
|
||||||
|
var ueEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化发布时间日期
|
||||||
|
function initPublishDateDate() {
|
||||||
|
laydate.render({
|
||||||
|
elem: '#publishDate',
|
||||||
|
type: 'date',
|
||||||
|
value: new Date(),
|
||||||
|
trigger: 'click'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化正文富文本
|
||||||
|
function initContentRichText(value) {
|
||||||
|
var editor = UE.getEditor('content');
|
||||||
|
editor.ready(function() {
|
||||||
|
editor.setHeight(400);
|
||||||
|
editor.setContent(value);
|
||||||
|
});
|
||||||
|
ueEditorObj['content'] = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文章类别联表
|
||||||
|
function initArticleCategoryIdJoinTable(joinValue){
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/list', []), {}, null, function(code, data) {
|
||||||
|
laytpl(document.getElementById('categoryIdJoinTemplate').innerHTML).render(data, function(html) {
|
||||||
|
document.getElementById('categoryIdJoinTemplateBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
form.render('select', 'categoryIdJoinTemplateBox');
|
||||||
|
|
||||||
|
// 初始化选择
|
||||||
|
var formSelectData = {};
|
||||||
|
formSelectData['categoryId'] = joinValue;
|
||||||
|
form.val('dataForm', formSelectData);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/content/get/{contentId}', [contentId]), {}, null, function(code, data) {
|
||||||
|
var dataFormData = {};
|
||||||
|
for(var i in data) {
|
||||||
|
dataFormData[i] = data[i] +'';
|
||||||
|
}
|
||||||
|
form.val('dataForm', dataFormData);
|
||||||
|
form.render(null, 'dataForm');
|
||||||
|
initPublishDateDate();
|
||||||
|
initContentRichText(data['content']);
|
||||||
|
initArticleCategoryIdJoinTable(data['categoryId']);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
formData.field['content'] = ueEditorObj['content'].getContent();
|
||||||
|
top.restAjax.put(top.restAjax.path('api/content/update/{contentId}', [contentId]), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
284
module-article/src/main/resources/templates/content/update.html
Normal file
284
module-article/src/main/resources/templates/content/update.html
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">文章类别</label>
|
||||||
|
<div class="layui-input-block layui-form" id="categoryIdJoinTemplateBox" lay-filter="categoryIdJoinTemplateBox"></div>
|
||||||
|
<script id="categoryIdJoinTemplate" type="text/html">
|
||||||
|
<select name="categoryId" lay-verify="required" lay-search>
|
||||||
|
<option value="">选择文章类别</option>
|
||||||
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||||
|
<option value="{{item.categoryId}}">{{item.title}}</option>
|
||||||
|
{{# } }}
|
||||||
|
</select>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入标题" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">子标题</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="subTitle" name="subTitle" class="layui-input" value="" placeholder="请输入子标题" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<label class="layui-form-label">概述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea id="summary" name="summary" class="layui-textarea" placeholder="请输入概述"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">外链地址</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="link" name="link" class="layui-input" value="" placeholder="请输入外链地址,http或https开头,列表点击跳转到对应页面。">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">来源</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="source" name="source" class="layui-input" value="" placeholder="请输入来源" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">作者</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="author" name="author" class="layui-input" value="" placeholder="请输入作者" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">发布时间</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="publishDate" name="publishDate" class="layui-input" value="" placeholder="请选择发布时间" readonly style="cursor: pointer;" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
|
||||||
|
<div class="layui-form-item" pane>
|
||||||
|
<label class="layui-form-label">是否发布</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="isPublish" value="1" title="是">
|
||||||
|
<input type="radio" name="isPublish" value="0" title="否">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<script id="content" name="content" type="text/plain"></script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.config.js"></script>
|
||||||
|
<script src="assets/js/vendor/ueditor/ueditor.all.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var contentId = top.restAjax.params(window.location.href).contentId;
|
||||||
|
|
||||||
|
var ueEditorObj = {};
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshDownloadTemplet(fileName, file) {
|
||||||
|
var dataRander = {};
|
||||||
|
dataRander[fileName] = file;
|
||||||
|
|
||||||
|
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||||
|
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文件列表
|
||||||
|
function initFileList(fileName, ids, callback) {
|
||||||
|
var dataForm = {};
|
||||||
|
dataForm[fileName] = ids;
|
||||||
|
form.val('dataForm', dataForm);
|
||||||
|
|
||||||
|
if(!ids) {
|
||||||
|
refreshDownloadTemplet(fileName, []);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, []);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top.restAjax.get(top.restAjax.path('api/file/list', []), {
|
||||||
|
ids: ids
|
||||||
|
}, null, function(code, data) {
|
||||||
|
refreshDownloadTemplet(fileName, data);
|
||||||
|
if(callback) {
|
||||||
|
callback(fileName, data);
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化视频
|
||||||
|
function initVideo(fileName, data) {
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
var player = new ckplayer({
|
||||||
|
container: '#'+ fileName + i,
|
||||||
|
variable: 'player',
|
||||||
|
flashplayer: false,
|
||||||
|
video: {
|
||||||
|
file: 'route/file/download/true/'+ item.fileId,
|
||||||
|
type: 'video/mp4'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化发布时间日期
|
||||||
|
function initPublishDateDate() {
|
||||||
|
laydate.render({
|
||||||
|
elem: '#publishDate',
|
||||||
|
type: 'date',
|
||||||
|
value: new Date(),
|
||||||
|
trigger: 'click'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化正文富文本
|
||||||
|
function initContentRichText(value) {
|
||||||
|
var editor = UE.getEditor('content');
|
||||||
|
editor.ready(function() {
|
||||||
|
editor.setHeight(400);
|
||||||
|
editor.setContent(value);
|
||||||
|
});
|
||||||
|
ueEditorObj['content'] = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化文章类别联表
|
||||||
|
function initArticleCategoryIdJoinTable(joinValue){
|
||||||
|
top.restAjax.get(top.restAjax.path('api/category/list', []), {}, null, function(code, data) {
|
||||||
|
laytpl(document.getElementById('categoryIdJoinTemplate').innerHTML).render(data, function(html) {
|
||||||
|
document.getElementById('categoryIdJoinTemplateBox').innerHTML = html;
|
||||||
|
});
|
||||||
|
form.render('select', 'categoryIdJoinTemplateBox');
|
||||||
|
|
||||||
|
// 初始化选择
|
||||||
|
var formSelectData = {};
|
||||||
|
formSelectData['categoryId'] = joinValue;
|
||||||
|
form.val('dataForm', formSelectData);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/content/get/{contentId}', [contentId]), {}, null, function(code, data) {
|
||||||
|
var dataFormData = {};
|
||||||
|
for(var i in data) {
|
||||||
|
dataFormData[i] = data[i] +'';
|
||||||
|
}
|
||||||
|
form.val('dataForm', dataFormData);
|
||||||
|
form.render(null, 'dataForm');
|
||||||
|
initPublishDateDate();
|
||||||
|
initContentRichText(data['content']);
|
||||||
|
initArticleCategoryIdJoinTable(data['categoryId']);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
formData.field['content'] = ueEditorObj['content'].getContent();
|
||||||
|
top.restAjax.put(top.restAjax.path('api/content/update/{contentId}', [contentId]), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
pom.xml
1
pom.xml
@ -29,6 +29,7 @@
|
|||||||
<module>login-app</module>
|
<module>login-app</module>
|
||||||
<module>login-wechat</module>
|
<module>login-wechat</module>
|
||||||
<module>basic-properties</module>
|
<module>basic-properties</module>
|
||||||
|
<module>module-article</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@ -32,14 +32,6 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMenuDao menuDao;
|
private IMenuDao menuDao;
|
||||||
// @Autowired
|
|
||||||
// private IRoleDao roleDao;
|
|
||||||
// @Autowired
|
|
||||||
// private IOauthClientService oauthClientService;
|
|
||||||
// @Autowired
|
|
||||||
// private SecurityComponent securityComponent;
|
|
||||||
// @Autowired
|
|
||||||
// private IUserService userService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MenuDTO get(Map<String, Object> params) {
|
public MenuDTO get(Map<String, Object> params) {
|
||||||
@ -150,116 +142,12 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService
|
|||||||
menuDao.update(params);
|
menuDao.update(params);
|
||||||
return new SuccessResult();
|
return new SuccessResult();
|
||||||
}
|
}
|
||||||
// @Override
|
|
||||||
// public SuccessResultData<List<MenuDTO>> listMenuByClientId(Map<String, Object> params) {
|
|
||||||
// OauthClientDTO oauthClientDTO = oauthClientService.getOauthClient(params);
|
|
||||||
// if (oauthClientDTO == null) {
|
|
||||||
// throw new SearchException("客户端不存在");
|
|
||||||
// }
|
|
||||||
// String menuId = oauthClientDTO.getMenuId();
|
|
||||||
// if (StringUtils.isBlank(menuId)) {
|
|
||||||
// return new SuccessResultData<>(new ArrayList<>());
|
|
||||||
// }
|
|
||||||
// // 获取全部菜单
|
|
||||||
// params.clear();
|
|
||||||
// params.put("menuParentId", menuId);
|
|
||||||
// params.put("menuStatus", 0);
|
|
||||||
// if (!SecurityComponent.USERNAME_ADMIN.equals(securityComponent.getCurrentUsername())) {
|
|
||||||
// log.debug("非管理员第三方查询菜单");
|
|
||||||
// params.put("menuIds", listUserMenuId());
|
|
||||||
// }
|
|
||||||
// List<MenuDTO> menuDTOs = listMenusAll(params);
|
|
||||||
// return new SuccessResultData<>(menuDTOs);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<String> listUserMenuId() {
|
|
||||||
// List<RoleMenuBO> roleMenuBOs = listRoleMenu();
|
|
||||||
// List<String> menuIds = new ArrayList<>();
|
|
||||||
// for (RoleMenuBO roleMenuBO : roleMenuBOs) {
|
|
||||||
// menuIds.add(roleMenuBO.getMenuId());
|
|
||||||
// }
|
|
||||||
// return menuIds;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public SuccessResultData<List<MenuDTO>> listMenuByClientIdAndUserId(String clientId, String userId) {
|
|
||||||
// Map<String, Object> params = new HashMap<>(1);
|
|
||||||
// params.put("clientId", clientId);
|
|
||||||
// OauthClientDTO oauthClientDTO = oauthClientService.getOauthClient(params);
|
|
||||||
// if (oauthClientDTO == null) {
|
|
||||||
// throw new SearchException("客户端不存在");
|
|
||||||
// }
|
|
||||||
// String menuId = oauthClientDTO.getMenuId();
|
|
||||||
// if (StringUtils.isBlank(menuId)) {
|
|
||||||
// return new SuccessResultData<>(new ArrayList<>());
|
|
||||||
// }
|
|
||||||
// List<String> userMenuIds;
|
|
||||||
// // 如果是管理员获取管理员配置的菜单,管理员的ID是1
|
|
||||||
// if (StringUtils.equalsIgnoreCase(userId, "1")) {
|
|
||||||
// userMenuIds = listAdminMenuId();
|
|
||||||
// } else {
|
|
||||||
// params.put("userId", userId);
|
|
||||||
// params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_MENU);
|
|
||||||
// userMenuIds = listMenuIdByUser(params);
|
|
||||||
// }
|
|
||||||
// // 获取全部菜单
|
|
||||||
// params.clear();
|
|
||||||
// params.put("menuParentId", menuId);
|
|
||||||
// params.put("menuStatus", 0);
|
|
||||||
// params.put("menuIds", userMenuIds);
|
|
||||||
// List<MenuDTO> menuDTOs = listMenusAll(params);
|
|
||||||
// return new SuccessResultData<>(menuDTOs);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> listMenuIdByUser(Map<String, Object> params) {
|
public List<String> listMenuIdByUser(Map<String, Object> params) {
|
||||||
return menuDao.listIdByUser(params);
|
return menuDao.listIdByUser(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色菜单列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @throws SearchException
|
|
||||||
*/
|
|
||||||
// private List<RoleMenuBO> listRoleMenu() {
|
|
||||||
// Map<String, Object> params = new HashMap<>(2);
|
|
||||||
// List<String> listRoleIds = securityComponent.listRoleIds();
|
|
||||||
// params.put("listRoleIds", listRoleIds);
|
|
||||||
// params.put("roleType", IRoleService.ROLE_MENU);
|
|
||||||
// List<RoleMenuBO> roleMenuBOs = roleDao.listRoleMenuInfo(params);
|
|
||||||
// return roleMenuBOs;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理员菜单列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @throws SearchException
|
|
||||||
*/
|
|
||||||
// private List<RoleMenuBO> listAdminMenu() {
|
|
||||||
// Map<String, Object> params = new HashMap<>(4);
|
|
||||||
// params.put("listRoleIds", Arrays.asList(SecurityComponent.USERNAME_ADMIN));
|
|
||||||
// params.put("roleType", IRoleService.ROLE_MENU);
|
|
||||||
// List<RoleMenuBO> roleMenuBOs = roleDao.listRoleMenuInfo(params);
|
|
||||||
// return roleMenuBOs;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理员菜单ID列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// private List<String> listAdminMenuId() {
|
|
||||||
// List<RoleMenuBO> roleMenuBOs = listAdminMenu();
|
|
||||||
// List<String> menuIds = new ArrayList<>();
|
|
||||||
// for (RoleMenuBO roleMenuBO : roleMenuBOs) {
|
|
||||||
// menuIds.add(roleMenuBO.getMenuId());
|
|
||||||
// }
|
|
||||||
// return menuIds;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归查询子菜单
|
* 递归查询子菜单
|
||||||
*
|
*
|
||||||
@ -293,38 +181,6 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 子菜单权限
|
|
||||||
*
|
|
||||||
* @param menuDTOs
|
|
||||||
* @param params
|
|
||||||
* @param roleMenuBOs
|
|
||||||
* @throws SearchException
|
|
||||||
*/
|
|
||||||
// private void listSubMenus(List<MenuDTO> menuDTOs, Map<String, Object> params, List<RoleMenuBO> roleMenuBOs) {
|
|
||||||
// for (MenuDTO menuDTO : menuDTOs) {
|
|
||||||
// if (roleMenuBOs != null) {
|
|
||||||
// boolean hasRight = false;
|
|
||||||
// for (RoleMenuBO roleMenuBO : roleMenuBOs) {
|
|
||||||
// if (menuDTO.getMenuId().equals(roleMenuBO.getMenuId())) {
|
|
||||||
// hasRight = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// menuDTO.setRight(hasRight);
|
|
||||||
// }
|
|
||||||
// params.put("menuParentId", menuDTO.getMenuId());
|
|
||||||
// List<MenuDTO> subMenuDTOs = new ArrayList<>(menuDao.listMenus(params));
|
|
||||||
// menuDTO.setSubMenus(subMenuDTOs);
|
|
||||||
// if (!subMenuDTOs.isEmpty()) {
|
|
||||||
// menuDTO.setParent(true);
|
|
||||||
// } else {
|
|
||||||
// menuDTO.setParent(false);
|
|
||||||
// }
|
|
||||||
// listSubMenus(subMenuDTOs, params, roleMenuBOs);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取code
|
* 获取code
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ink.wgink.module.menu.startup;
|
package ink.wgink.module.menu.startup;
|
||||||
|
|
||||||
import ink.wgink.interfaces.app.IAppSignBaseService;
|
import ink.wgink.interfaces.app.IAppSignBaseService;
|
||||||
|
import ink.wgink.interfaces.article.IArticleCheckService;
|
||||||
import ink.wgink.interfaces.config.ISystemConfigCheckService;
|
import ink.wgink.interfaces.config.ISystemConfigCheckService;
|
||||||
import ink.wgink.interfaces.department.IDepartmentCheckService;
|
import ink.wgink.interfaces.department.IDepartmentCheckService;
|
||||||
import ink.wgink.interfaces.dictionary.IDictionaryCheckService;
|
import ink.wgink.interfaces.dictionary.IDictionaryCheckService;
|
||||||
@ -61,6 +62,8 @@ public class ServiceMenuStartUp implements ApplicationRunner {
|
|||||||
private IUserDetailCheckService userDetailCheckService;
|
private IUserDetailCheckService userDetailCheckService;
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private IAppSignBaseService appSignBaseService;
|
private IAppSignBaseService appSignBaseService;
|
||||||
|
@Autowired(required = false)
|
||||||
|
private IArticleCheckService articleCheckService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
@ -105,6 +108,7 @@ public class ServiceMenuStartUp implements ApplicationRunner {
|
|||||||
initUserPermissionManage(params, menuId);
|
initUserPermissionManage(params, menuId);
|
||||||
initPermissionManage(params, menuId);
|
initPermissionManage(params, menuId);
|
||||||
initLogManage(params, menuId);
|
initLogManage(params, menuId);
|
||||||
|
initArticleManage(params, menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSystemManage(Map<String, Object> params, String menuParentId) {
|
private void initSystemManage(Map<String, Object> params, String menuParentId) {
|
||||||
@ -769,5 +773,96 @@ public class ServiceMenuStartUp implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章管理
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @param menuParentId
|
||||||
|
*/
|
||||||
|
private void initArticleManage(Map<String, Object> params, String menuParentId) {
|
||||||
|
if (articleCheckService == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG.debug("初始化菜单:文章管理");
|
||||||
|
params.remove("menuId");
|
||||||
|
params.put("menuCode", "00010100");
|
||||||
|
MenuDTO menuDTO = menuDao.getSimple(params);
|
||||||
|
String menuId;
|
||||||
|
if (menuDTO == null) {
|
||||||
|
menuId = UUIDUtil.getUUID();
|
||||||
|
params.put("menuId", menuId);
|
||||||
|
params.put("menuParentId", menuParentId);
|
||||||
|
params.put("menuName", "文章管理");
|
||||||
|
params.put("menuSummary", "文章管理");
|
||||||
|
params.put("menuUrl", "javascript:void(0);");
|
||||||
|
params.put("menuType", "1");
|
||||||
|
params.put("menuIcon", "fa-icon-color-white fa fa-newspaper-o");
|
||||||
|
params.put("menuOrder", "100");
|
||||||
|
params.put("menuStatus", "0");
|
||||||
|
params.put("openType", "1");
|
||||||
|
menuDao.save(params);
|
||||||
|
} else {
|
||||||
|
menuId = menuDTO.getMenuId();
|
||||||
|
}
|
||||||
|
|
||||||
|
initCategoryManage(params, menuId);
|
||||||
|
initContentManage(params, menuId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门用户调整
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @param menuParentId
|
||||||
|
*/
|
||||||
|
private void initCategoryManage(Map<String, Object> params, String menuParentId) {
|
||||||
|
LOG.debug("初始化菜单:目录管理");
|
||||||
|
params.remove("menuId");
|
||||||
|
params.put("menuCode", "000101000001");
|
||||||
|
MenuDTO menuDTO = menuDao.getSimple(params);
|
||||||
|
String menuId;
|
||||||
|
if (menuDTO == null) {
|
||||||
|
menuId = UUIDUtil.getUUID();
|
||||||
|
params.put("menuId", menuId);
|
||||||
|
params.put("menuParentId", menuParentId);
|
||||||
|
params.put("menuName", "目录管理");
|
||||||
|
params.put("menuSummary", "目录管理");
|
||||||
|
params.put("menuUrl", "/route/category/list");
|
||||||
|
params.put("menuType", "1");
|
||||||
|
params.put("menuIcon", "fa-icon-color-white fa fa-newspaper-o");
|
||||||
|
params.put("menuOrder", "1");
|
||||||
|
params.put("menuStatus", "0");
|
||||||
|
params.put("openType", "1");
|
||||||
|
menuDao.save(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门用户调整
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @param menuParentId
|
||||||
|
*/
|
||||||
|
private void initContentManage(Map<String, Object> params, String menuParentId) {
|
||||||
|
LOG.debug("初始化菜单:内容管理");
|
||||||
|
params.remove("menuId");
|
||||||
|
params.put("menuCode", "000101000002");
|
||||||
|
MenuDTO menuDTO = menuDao.getSimple(params);
|
||||||
|
String menuId;
|
||||||
|
if (menuDTO == null) {
|
||||||
|
menuId = UUIDUtil.getUUID();
|
||||||
|
params.put("menuId", menuId);
|
||||||
|
params.put("menuParentId", menuParentId);
|
||||||
|
params.put("menuName", "内容管理");
|
||||||
|
params.put("menuSummary", "内容管理");
|
||||||
|
params.put("menuUrl", "/route/content/list");
|
||||||
|
params.put("menuType", "1");
|
||||||
|
params.put("menuIcon", "fa-icon-color-white fa fa-newspaper-o");
|
||||||
|
params.put("menuOrder", "2");
|
||||||
|
params.put("menuStatus", "0");
|
||||||
|
params.put("openType", "1");
|
||||||
|
menuDao.save(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user