diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/article/IArticleCheckService.java b/basic-interface/src/main/java/ink/wgink/interfaces/article/IArticleCheckService.java new file mode 100644 index 00000000..74af2bae --- /dev/null +++ b/basic-interface/src/main/java/ink/wgink/interfaces/article/IArticleCheckService.java @@ -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 { +} diff --git a/module-article/pom.xml b/module-article/pom.xml new file mode 100644 index 00000000..7cf4594c --- /dev/null +++ b/module-article/pom.xml @@ -0,0 +1,33 @@ + + + + wg-basic + ink.wgink + 1.0-SNAPSHOT + + 4.0.0 + + module-article + 文章模块 + + + + ink.wgink + basic-exception + 1.0-SNAPSHOT + + + ink.wgink + basic-annotation + 1.0-SNAPSHOT + + + ink.wgink + common + 1.0-SNAPSHOT + + + + \ No newline at end of file diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/api/category/CategoryController.java b/module-article/src/main/java/ink/wgink/module/article/controller/api/category/CategoryController.java new file mode 100644 index 00000000..789ec544 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/api/category/CategoryController.java @@ -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 list() throws SearchException { + Map 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> listPage(ListPage page) throws SearchException { + Map params = requestParams(); + page.setParams(params); + return categoryService.listPage(page); + } + +} \ No newline at end of file diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentController.java b/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentController.java new file mode 100644 index 00000000..7e786af8 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentController.java @@ -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 list() { + Map 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> listPage(ListPage page) { + Map 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 count() { + Map params = requestParams(); + return new SuccessResultData<>(contentService.count(params)); + } + +} \ No newline at end of file diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/route/category/CategoryRouteController.java b/module-article/src/main/java/ink/wgink/module/article/controller/route/category/CategoryRouteController.java new file mode 100644 index 00000000..28c4a5c8 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/route/category/CategoryRouteController.java @@ -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"); + } + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentRouteController.java b/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentRouteController.java new file mode 100644 index 00000000..da626b25 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentRouteController.java @@ -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; + } + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/dao/category/ICategoryDao.java b/module-article/src/main/java/ink/wgink/module/article/dao/category/ICategoryDao.java new file mode 100644 index 00000000..12a6d062 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/dao/category/ICategoryDao.java @@ -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 params) throws SaveException; + + /** + * 删除文章类别 + * + * @param params + * @throws RemoveException + */ + void remove(Map params) throws RemoveException; + + /** + * 修改文章类别 + * + * @param params + * @throws UpdateException + */ + void update(Map params) throws UpdateException; + + /** + * 文章类别详情 + * + * @param params + * @return + * @throws SearchException + */ + CategoryDTO get(Map params) throws SearchException; + + /** + * 文章类别列表 + * + * @param params + * @return + * @throws SearchException + */ + List list(Map params) throws SearchException; + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/dao/content/IContentDao.java b/module-article/src/main/java/ink/wgink/module/article/dao/content/IContentDao.java new file mode 100644 index 00000000..2f6231ac --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/dao/content/IContentDao.java @@ -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 params) throws SaveException; + + /** + * 删除文章内容 + * + * @param params + * @throws RemoveException + */ + void remove(Map params) throws RemoveException; + + /** + * 修改文章内容 + * + * @param params + * @throws UpdateException + */ + void update(Map params) throws UpdateException; + + /** + * 文章内容详情 + * + * @param params + * @return + * @throws SearchException + */ + ContentDTO get(Map params) throws SearchException; + + /** + * 文章内容列表 + * + * @param params + * @return + * @throws SearchException + */ + List list(Map params) throws SearchException; + + /** + * 统计文章数量 + * + * @param params + * @return + * @throws SearchException + */ + Integer count(Map params) throws SearchException; + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/category/CategoryDTO.java b/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/category/CategoryDTO.java new file mode 100644 index 00000000..8120cd30 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/category/CategoryDTO.java @@ -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; + } +} diff --git a/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/content/ContentDTO.java b/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/content/ContentDTO.java new file mode 100644 index 00000000..a7eb6927 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/pojo/dtos/content/ContentDTO.java @@ -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; + } +} diff --git a/module-article/src/main/java/ink/wgink/module/article/pojo/vos/category/CategoryVO.java b/module-article/src/main/java/ink/wgink/module/article/pojo/vos/category/CategoryVO.java new file mode 100644 index 00000000..7c0ec45f --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/pojo/vos/category/CategoryVO.java @@ -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; + } + + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/pojo/vos/content/ContentVO.java b/module-article/src/main/java/ink/wgink/module/article/pojo/vos/content/ContentVO.java new file mode 100644 index 00000000..9ece5659 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/pojo/vos/content/ContentVO.java @@ -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; + } + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/service/category/ICategoryService.java b/module-article/src/main/java/ink/wgink/module/article/service/category/ICategoryService.java new file mode 100644 index 00000000..b6583653 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/category/ICategoryService.java @@ -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 ids); + + /** + * 删除文章类别(APP) + * + * @param token + * @param ids + * @return + */ + void removeByToken(String token, List 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 list(Map params); + + /** + * 文章类别分页列表 + * + * @param page + * @return + */ + SuccessResultList> listPage(ListPage page); + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/service/category/impl/CategoryServiceImpl.java b/module-article/src/main/java/ink/wgink/module/article/service/category/impl/CategoryServiceImpl.java new file mode 100644 index 00000000..721199e9 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/category/impl/CategoryServiceImpl.java @@ -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 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 ids) { + removeInfo(null, ids); + } + + @Override + public void removeByToken(String token, List ids) { + removeInfo(token, ids); + } + + /** + * 删除文章类别 + * + * @param token + * @param ids + */ + private void removeInfo(String token, List ids) { + Map 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 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 params = super.getHashMap(1); + params.put("categoryId", categoryId); + return categoryDao.get(params); + } + + @Override + public List list(Map params) throws SearchException { + return categoryDao.list(params); + } + + @Override + public SuccessResultList> listPage(ListPage page) throws SearchException { + PageHelper.startPage(page.getPage(), page.getRows()); + List articleCategoryDTOs = list(page.getParams()); + PageInfo pageInfo = new PageInfo<>(articleCategoryDTOs); + return new SuccessResultList<>(articleCategoryDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); + } + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/service/content/IContentService.java b/module-article/src/main/java/ink/wgink/module/article/service/content/IContentService.java new file mode 100644 index 00000000..7b729a93 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/content/IContentService.java @@ -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 ids); + + /** + * 删除文章内容(APP) + * + * @param token + * @param ids + * @return + */ + void removeByToken(String token, List 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 list(Map params); + + /** + * 文章内容分页列表 + * + * @param page + * @return + */ + SuccessResultList> listPage(ListPage page); + + /** + * 统计文章数量 + * + * @param params + * @return + */ + Integer count(Map params); + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentServiceImpl.java b/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentServiceImpl.java new file mode 100644 index 00000000..0a94f47f --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentServiceImpl.java @@ -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 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 ids) { + removeInfo(null, ids); + } + + @Override + public void removeByToken(String token, List ids) { + removeInfo(token, ids); + } + + /** + * 删除文章内容 + * + * @param token + * @param ids + */ + private void removeInfo(String token, List ids) { + Map 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 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 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 params = super.getHashMap(1); + params.put("contentId", contentId); + return contentDao.get(params); + } + + @Override + public List list(Map params) { + return contentDao.list(params); + } + + @Override + public SuccessResultList> listPage(ListPage page) { + PageHelper.startPage(page.getPage(), page.getRows()); + List articleContentDTOs = list(page.getParams()); + PageInfo pageInfo = new PageInfo<>(articleContentDTOs); + return new SuccessResultList<>(articleContentDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); + } + + @Override + public Integer count(Map params) { + Integer count = contentDao.count(params); + return count == null ? 0 : count; + } + +} diff --git a/module-article/src/main/java/ink/wgink/module/article/startup/ArticleStartUp.java b/module-article/src/main/java/ink/wgink/module/article/startup/ArticleStartUp.java new file mode 100644 index 00000000..9d5807cd --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/startup/ArticleStartUp.java @@ -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(); + } +} diff --git a/module-article/src/main/resources/mybatis/mapper/category/category-mapper.xml b/module-article/src/main/resources/mybatis/mapper/category/category-mapper.xml new file mode 100644 index 00000000..33dae801 --- /dev/null +++ b/module-article/src/main/resources/mybatis/mapper/category/category-mapper.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + 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; + + + + + 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} + ) + + + + + UPDATE + article_category + SET + is_delete = 1, + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + category_id IN + + #{categoryIds[${index}]} + + + + + + UPDATE + article_category + SET + + title = #{title}, + + + summary = #{summary}, + + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + category_id = #{categoryId} + + + + + + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/mybatis/mapper/content/content-mapper.xml b/module-article/src/main/resources/mybatis/mapper/content/content-mapper.xml new file mode 100644 index 00000000..6b845518 --- /dev/null +++ b/module-article/src/main/resources/mybatis/mapper/content/content-mapper.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 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; + + + + + 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} + ) + + + + + UPDATE + article_content + SET + is_delete = 1, + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + content_id IN + + #{contentIds[${index}]} + + + + + + UPDATE + article_content + SET + + title = #{title}, + + + sub_title = #{subTitle}, + + + summary = #{summary}, + + + link = #{link}, + + + source = #{source}, + + + author = #{author}, + + + publish_date = #{publishDate}, + + + is_publish = #{isPublish}, + + + content = #{content}, + + + category_id = #{categoryId}, + + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + content_id = #{contentId} + + + + + + + + + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/category/list.html b/module-article/src/main/resources/templates/category/list.html new file mode 100644 index 00000000..7ed664df --- /dev/null +++ b/module-article/src/main/resources/templates/category/list.html @@ -0,0 +1,246 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/category/save.html b/module-article/src/main/resources/templates/category/save.html new file mode 100644 index 00000000..d2f08b8d --- /dev/null +++ b/module-article/src/main/resources/templates/category/save.html @@ -0,0 +1,161 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/category/update.html b/module-article/src/main/resources/templates/category/update.html new file mode 100644 index 00000000..f123ff01 --- /dev/null +++ b/module-article/src/main/resources/templates/category/update.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/list-category.html b/module-article/src/main/resources/templates/content/list-category.html new file mode 100644 index 00000000..ff3204bf --- /dev/null +++ b/module-article/src/main/resources/templates/content/list-category.html @@ -0,0 +1,286 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/list.html b/module-article/src/main/resources/templates/content/list.html new file mode 100644 index 00000000..28c543ab --- /dev/null +++ b/module-article/src/main/resources/templates/content/list.html @@ -0,0 +1,314 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/save-category.html b/module-article/src/main/resources/templates/content/save-category.html new file mode 100644 index 00000000..1c8f15c7 --- /dev/null +++ b/module-article/src/main/resources/templates/content/save-category.html @@ -0,0 +1,253 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/save.html b/module-article/src/main/resources/templates/content/save.html new file mode 100644 index 00000000..4463c30c --- /dev/null +++ b/module-article/src/main/resources/templates/content/save.html @@ -0,0 +1,261 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/update-category.html b/module-article/src/main/resources/templates/content/update-category.html new file mode 100644 index 00000000..067d8b3b --- /dev/null +++ b/module-article/src/main/resources/templates/content/update-category.html @@ -0,0 +1,276 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/update.html b/module-article/src/main/resources/templates/content/update.html new file mode 100644 index 00000000..19de4b40 --- /dev/null +++ b/module-article/src/main/resources/templates/content/update.html @@ -0,0 +1,284 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index e88dd65e..9e5df7a3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ login-app login-wechat basic-properties + module-article pom diff --git a/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java b/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java index 5cdbce0a..46cf1187 100644 --- a/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java +++ b/service-menu/src/main/java/ink/wgink/module/menu/service/impl/MenuServiceImpl.java @@ -32,14 +32,6 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService @Autowired private IMenuDao menuDao; -// @Autowired -// private IRoleDao roleDao; -// @Autowired -// private IOauthClientService oauthClientService; -// @Autowired -// private SecurityComponent securityComponent; -// @Autowired -// private IUserService userService; @Override public MenuDTO get(Map params) { @@ -150,116 +142,12 @@ public class MenuServiceImpl extends DefaultBaseService implements IMenuService menuDao.update(params); return new SuccessResult(); } -// @Override -// public SuccessResultData> listMenuByClientId(Map 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 menuDTOs = listMenusAll(params); -// return new SuccessResultData<>(menuDTOs); -// } - -// @Override -// public List listUserMenuId() { -// List roleMenuBOs = listRoleMenu(); -// List menuIds = new ArrayList<>(); -// for (RoleMenuBO roleMenuBO : roleMenuBOs) { -// menuIds.add(roleMenuBO.getMenuId()); -// } -// return menuIds; -// } - -// @Override -// public SuccessResultData> listMenuByClientIdAndUserId(String clientId, String userId) { -// Map 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 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 menuDTOs = listMenusAll(params); -// return new SuccessResultData<>(menuDTOs); -// } @Override public List listMenuIdByUser(Map params) { return menuDao.listIdByUser(params); } - /** - * 获取角色菜单列表 - * - * @return - * @throws SearchException - */ -// private List listRoleMenu() { -// Map params = new HashMap<>(2); -// List listRoleIds = securityComponent.listRoleIds(); -// params.put("listRoleIds", listRoleIds); -// params.put("roleType", IRoleService.ROLE_MENU); -// List roleMenuBOs = roleDao.listRoleMenuInfo(params); -// return roleMenuBOs; -// } - - /** - * 管理员菜单列表 - * - * @return - * @throws SearchException - */ -// private List listAdminMenu() { -// Map params = new HashMap<>(4); -// params.put("listRoleIds", Arrays.asList(SecurityComponent.USERNAME_ADMIN)); -// params.put("roleType", IRoleService.ROLE_MENU); -// List roleMenuBOs = roleDao.listRoleMenuInfo(params); -// return roleMenuBOs; -// } - - /** - * 管理员菜单ID列表 - * - * @return - */ -// private List listAdminMenuId() { -// List roleMenuBOs = listAdminMenu(); -// List 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 menuDTOs, Map params, List 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 subMenuDTOs = new ArrayList<>(menuDao.listMenus(params)); -// menuDTO.setSubMenus(subMenuDTOs); -// if (!subMenuDTOs.isEmpty()) { -// menuDTO.setParent(true); -// } else { -// menuDTO.setParent(false); -// } -// listSubMenus(subMenuDTOs, params, roleMenuBOs); -// } -// } - /** * 获取code * diff --git a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java index 76def4bc..d4ad8d4b 100644 --- a/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java +++ b/service-menu/src/main/java/ink/wgink/module/menu/startup/ServiceMenuStartUp.java @@ -1,6 +1,7 @@ package ink.wgink.module.menu.startup; import ink.wgink.interfaces.app.IAppSignBaseService; +import ink.wgink.interfaces.article.IArticleCheckService; import ink.wgink.interfaces.config.ISystemConfigCheckService; import ink.wgink.interfaces.department.IDepartmentCheckService; import ink.wgink.interfaces.dictionary.IDictionaryCheckService; @@ -61,6 +62,8 @@ public class ServiceMenuStartUp implements ApplicationRunner { private IUserDetailCheckService userDetailCheckService; @Autowired(required = false) private IAppSignBaseService appSignBaseService; + @Autowired(required = false) + private IArticleCheckService articleCheckService; @Override public void run(ApplicationArguments args) throws Exception { @@ -105,6 +108,7 @@ public class ServiceMenuStartUp implements ApplicationRunner { initUserPermissionManage(params, menuId); initPermissionManage(params, menuId); initLogManage(params, menuId); + initArticleManage(params, menuId); } private void initSystemManage(Map params, String menuParentId) { @@ -769,5 +773,96 @@ public class ServiceMenuStartUp implements ApplicationRunner { } } + /** + * 文章管理 + * + * @param params + * @param menuParentId + */ + private void initArticleManage(Map 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 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 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); + } + } }