diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentDataAuthController.java b/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentDataAuthController.java new file mode 100644 index 00000000..9b8069b2 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/api/content/ContentDataAuthController.java @@ -0,0 +1,69 @@ +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.IContentDataAuthService; +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/data-auth") +public class ContentDataAuthController extends DefaultBaseController { + + @Autowired + private IContentDataAuthService contentDataAuthService; + + @ApiOperation(value = "文章内容列表", notes = "文章内容列表接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @ApiImplicitParams({ + @ApiImplicitParam(name = "categoryId", value = "文章目录", paramType = "query", dataType = "String") + }) + @GetMapping("list") + public List list() { + Map params = requestParams(); + return contentDataAuthService.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 = "categoryId", 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 contentDataAuthService.listPage(page); + } + +} \ No newline at end of file diff --git a/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentDataAuthRouteController.java b/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentDataAuthRouteController.java new file mode 100644 index 00000000..d8ddcfda --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/controller/route/content/ContentDataAuthRouteController.java @@ -0,0 +1,41 @@ +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/data-auth") +public class ContentDataAuthRouteController { + + @GetMapping("list") + public ModelAndView list() { + return new ModelAndView("content/data-auth/list"); + } + + @GetMapping("list/{categoryId}") + public ModelAndView listCategory(@PathVariable("categoryId") String categoryId) { + ModelAndView modelAndView = new ModelAndView("content/data-auth/list-category"); + modelAndView.addObject("categoryId", categoryId); + return modelAndView; + } + +} 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 index 3b70005e..efc91b8c 100644 --- 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 @@ -39,6 +39,11 @@ public class ContentRouteController { return new ModelAndView("content/list"); } + @GetMapping("list-data-auth") + public ModelAndView listDataAuth() { + return new ModelAndView("category/list-data-auth"); + } + @GetMapping("list/{categoryId}") public ModelAndView listCategory(@PathVariable("categoryId") String categoryId) { ModelAndView modelAndView = new ModelAndView("content/list-category"); diff --git a/module-article/src/main/java/ink/wgink/module/article/service/content/IContentDataAuthService.java b/module-article/src/main/java/ink/wgink/module/article/service/content/IContentDataAuthService.java new file mode 100644 index 00000000..41c31933 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/content/IContentDataAuthService.java @@ -0,0 +1,108 @@ +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 IContentDataAuthService extends IArticleCheckService { + + /** + * 文章内容列表 + * + * @param params + * @return + */ + List list(Map params); + + /** + * 文章内容列表 + * + * @param categoryId 目录ID + * @return + */ + List list(String categoryId); + + /** + * 文章列表 + * + * @param userId 用户ID + * @return + */ + List listByUserId(String userId); + + /** + * 文章列表 + * + * @param userIds 用户ID列表 + * @return + */ + List listByUserIds(List userIds); + + /** + * 文章列表 + * + * @param categoryId 目录ID + * @param userId 用户ID + * @return + */ + List listByUserId(String categoryId, String userId); + + /** + * 文章列表 + * + * @param categoryId 目录ID + * @param userIds 用户ID列表 + * @return + */ + List listByUserIds(String categoryId, List userIds); + + /** + * 文章内容分页列表 + * + * @param page + * @return + */ + SuccessResultList> listPage(ListPage page); + + /** + * 文章内容分页 + * + * @param categoryId + * @param page + * @return + */ + SuccessResultList> listPage(String categoryId, ListPage page); + + /** + * 文章内容分页 + * + * @param categoryId + * @param userId + * @param page + * @return + */ + SuccessResultList> listPageByUserId(String categoryId, String userId, ListPage page); + + /** + * 文章内容分页 + * + * @param categoryId + * @param userIds + * @param page + * @return + */ + SuccessResultList> listPageByUserIds(String categoryId, List userIds, ListPage page); + +} 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 index a0d867e7..b17d73a8 100644 --- 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 @@ -194,30 +194,6 @@ public interface IContentService extends IArticleCheckService { */ SuccessResultList> listPageByUserIds(String categoryId, List userIds, ListPage page); - /** - * 文章内容列表(带数据权限) - * - * @param params - * @return - */ - List listWithDataAuth(Map params); - - /** - * 文章内容列表(带数据权限) - * - * @param categoryId 目录ID - * @return - */ - List listWithDataAuth(String categoryId); - - /** - * 文章内容分页列表(带数据权限) - * - * @param page - * @return - */ - SuccessResultList> listPageWithDataAuth(ListPage page); - /** * 统计文章数量 * diff --git a/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentDataAuthService.java b/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentDataAuthService.java new file mode 100644 index 00000000..a8ab8141 --- /dev/null +++ b/module-article/src/main/java/ink/wgink/module/article/service/content/impl/ContentDataAuthService.java @@ -0,0 +1,138 @@ +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.pojo.dtos.content.ContentDTO; +import ink.wgink.module.article.service.content.IContentDataAuthService; +import ink.wgink.module.article.service.content.IContentService; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResultList; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: ContentDataAuthService + * @Description: 文章内容数据权限 + * @Author: wanggeng + * @Date: 2021/6/11 10:17 上午 + * @Version: 1.0 + */ +@Service +public class ContentDataAuthService extends DefaultBaseService implements IContentDataAuthService { + + @Autowired + private IContentService contentService; + + @Override + public List list(Map params) { + setDataAuthorityInfo(params); + return contentService.list(params); + } + + @Override + public List list(String categoryId) { + if (StringUtils.isBlank(categoryId)) { + return new ArrayList<>(); + } + Map params = getHashMap(2); + params.put("categoryId", categoryId); + return list(params); + } + + @Override + public List listByUserId(String userId) { + if (StringUtils.isBlank(userId)) { + return new ArrayList<>(); + } + Map params = getHashMap(2); + params.put("creator", userId); + return list(params); + } + + @Override + public List listByUserIds(List userIds) { + if (userIds == null || userIds.isEmpty()) { + return new ArrayList<>(); + } + Map params = getHashMap(2); + params.put("creators", userIds); + return list(params); + } + + @Override + public List listByUserId(String categoryId, String userId) { + if (StringUtils.isBlank(userId)) { + return new ArrayList<>(); + } + Map params = getHashMap(4); + params.put("categoryId", categoryId); + params.put("creator", userId); + return list(params); + } + + @Override + public List listByUserIds(String categoryId, List userIds) { + if (StringUtils.isBlank(categoryId)) { + return new ArrayList<>(); + } + if (userIds == null || userIds.isEmpty()) { + return new ArrayList<>(); + } + Map params = getHashMap(4); + params.put("categoryId", categoryId); + params.put("creators", userIds); + return 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 SuccessResultList> listPage(String categoryId, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + page.getParams().put("categoryId", categoryId); + return listPage(page); + } + + @Override + public SuccessResultList> listPageByUserId(String categoryId, String userId, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + if (StringUtils.isBlank(userId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + page.getParams().put("categoryId", categoryId); + page.getParams().put("creator", userId); + return listPage(page); + } + + @Override + public SuccessResultList> listPageByUserIds(String categoryId, List userIds, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + if (userIds == null || userIds.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + page.getParams().put("categoryId", categoryId); + page.getParams().put("creators", userIds); + return listPage(page); + } +} 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 index f514f71c..1dd5ddbb 100644 --- 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 @@ -3,6 +3,7 @@ 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.exceptions.ParamsException; 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; @@ -11,9 +12,11 @@ import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.util.UUIDUtil; import ink.wgink.util.map.HashMapUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -137,6 +140,9 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public List list(String categoryId) { + if (StringUtils.isBlank(categoryId)) { + return new ArrayList<>(); + } Map params = getHashMap(2); params.put("categoryId", categoryId); return list(params); @@ -144,6 +150,9 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public List listByUserId(String userId) { + if (StringUtils.isBlank(userId)) { + return new ArrayList<>(); + } Map params = getHashMap(2); params.put("creator", userId); return list(params); @@ -151,6 +160,9 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public List listByUserIds(List userIds) { + if (userIds == null || userIds.isEmpty()) { + return new ArrayList<>(); + } Map params = getHashMap(2); params.put("creators", userIds); return list(params); @@ -158,6 +170,9 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public List listByUserId(String categoryId, String userId) { + if (StringUtils.isBlank(userId)) { + return new ArrayList<>(); + } Map params = getHashMap(4); params.put("categoryId", categoryId); params.put("creator", userId); @@ -166,6 +181,12 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public List listByUserIds(String categoryId, List userIds) { + if (StringUtils.isBlank(categoryId)) { + return new ArrayList<>(); + } + if (userIds == null || userIds.isEmpty()) { + return new ArrayList<>(); + } Map params = getHashMap(4); params.put("categoryId", categoryId); params.put("creators", userIds); @@ -182,12 +203,21 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public SuccessResultList> listPage(String categoryId, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } page.getParams().put("categoryId", categoryId); return listPage(page); } @Override public SuccessResultList> listPageByUserId(String categoryId, String userId, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + if (StringUtils.isBlank(userId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } page.getParams().put("categoryId", categoryId); page.getParams().put("creator", userId); return listPage(page); @@ -195,34 +225,17 @@ public class ContentServiceImpl extends DefaultBaseService implements IContentSe @Override public SuccessResultList> listPageByUserIds(String categoryId, List userIds, ListPage page) { + if (StringUtils.isBlank(categoryId)) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + if (userIds == null || userIds.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } page.getParams().put("categoryId", categoryId); page.getParams().put("creators", userIds); return listPage(page); } - @Override - public List listWithDataAuth(Map params) { - setDataAuthorityInfo(params); - return list(params); - } - - @Override - public List listWithDataAuth(String categoryId) { - Map params = getHashMap(16); - params.put("categoryId", categoryId); - setDataAuthorityInfo(params); - return list(params); - } - - @Override - public SuccessResultList> listPageWithDataAuth(ListPage page) { - PageHelper.startPage(page.getPage(), page.getRows()); - setDataAuthorityInfo(page.getParams()); - 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); diff --git a/module-article/src/main/resources/templates/content/data-auth/list-category.html b/module-article/src/main/resources/templates/content/data-auth/list-category.html new file mode 100644 index 00000000..53d75537 --- /dev/null +++ b/module-article/src/main/resources/templates/content/data-auth/list-category.html @@ -0,0 +1,299 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ + +
+
+
+
+ +
+ + + + + \ No newline at end of file diff --git a/module-article/src/main/resources/templates/content/data-auth/list.html b/module-article/src/main/resources/templates/content/data-auth/list.html new file mode 100644 index 00000000..687c9f26 --- /dev/null +++ b/module-article/src/main/resources/templates/content/data-auth/list.html @@ -0,0 +1,327 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file