新增文章统计

This commit is contained in:
wenc000 2020-04-17 17:32:58 +08:00
parent 5cf2eeffe7
commit 841af683f3
7 changed files with 104 additions and 18 deletions

View File

@ -11,6 +11,7 @@ import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO; import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO; import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO;
import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO; import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO;
@ -102,6 +103,9 @@ public class ArticleContentController extends AbstractController {
@ApiOperation(value = "文章内容列表", notes = "文章内容列表接口") @ApiOperation(value = "文章内容列表", notes = "文章内容列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@ApiImplicitParams({
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "form", dataType = "String")
})
@GetMapping("listarticlecontent") @GetMapping("listarticlecontent")
public List<ArticleContentDTO> listArticleContent() throws SearchException { public List<ArticleContentDTO> listArticleContent() throws SearchException {
Map<String, Object> params = requestParams(); Map<String, Object> params = requestParams();
@ -110,11 +114,12 @@ public class ArticleContentController extends AbstractController {
@ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口") @ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"), @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"), @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", 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)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagearticlecontent") @GetMapping("listpagearticlecontent")
@ -131,4 +136,15 @@ public class ArticleContentController extends AbstractController {
return securityComponent.getCurrentUserIdInfo(); return securityComponent.getCurrentUserIdInfo();
} }
@ApiOperation(value = "统计文章数量", notes = "统计文章数量接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("countarticlecount")
public SuccessResultData<Integer> countArticleCount() {
Map<String, Object> params = requestParams();
return articleContentService.countArticleCount(params);
}
} }

View File

@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO; import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO;
import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO; import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO;
@ -82,7 +83,8 @@ public class ArticleContentAppController extends AbstractController {
@ApiOperation(value = "文章内容列表", notes = "文章内容列表接口") @ApiOperation(value = "文章内容列表", notes = "文章内容列表接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header") @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "query", dataType = "String")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listarticlecontent") @GetMapping("listarticlecontent")
@ -94,11 +96,12 @@ public class ArticleContentAppController extends AbstractController {
@ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口") @ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"), @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"), @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"), @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", 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)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagearticlecontent") @GetMapping("listpagearticlecontent")
@ -108,4 +111,16 @@ public class ArticleContentAppController extends AbstractController {
return articleContentService.listPageArticleContent(page); return articleContentService.listPageArticleContent(page);
} }
@ApiOperation(value = "统计文章数量", notes = "统计文章数量接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("countarticlecount")
public SuccessResultData<Integer> countArticleCount() {
Map<String, Object> params = requestParams();
return articleContentService.countArticleCount(params);
}
} }

View File

@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO; import com.cm.common.article.pojo.dtos.articlecontent.ArticleContentDTO;
import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO; import com.cm.common.article.pojo.vos.articlecontent.ArticleContentVO;
@ -82,7 +83,8 @@ public class ArticleContentResourceController extends AbstractController {
@ApiOperation(value = "文章内容列表", notes = "文章内容列表接口") @ApiOperation(value = "文章内容列表", notes = "文章内容列表接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"),
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "query", dataType = "String")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listarticlecontent") @GetMapping("listarticlecontent")
@ -94,11 +96,12 @@ public class ArticleContentResourceController extends AbstractController {
@ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口") @ApiOperation(value = "文章内容分页列表", notes = "文章内容分页列表接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"), @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"), @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"), @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", 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)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagearticlecontent") @GetMapping("listpagearticlecontent")
@ -108,4 +111,16 @@ public class ArticleContentResourceController extends AbstractController {
return articleContentService.listPageArticleContent(page); return articleContentService.listPageArticleContent(page);
} }
@ApiOperation(value = "统计文章数量", notes = "统计文章数量接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"),
@ApiImplicitParam(name = "articleCategoryId", value = "文章目录", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("countarticlecount")
public SuccessResultData<Integer> countArticleCount() {
Map<String, Object> params = requestParams();
return articleContentService.countArticleCount(params);
}
} }

View File

@ -62,5 +62,13 @@ public interface IArticleContentDao {
* @throws SearchException * @throws SearchException
*/ */
List<ArticleContentDTO> listArticleContent(Map<String, Object> params) throws SearchException; List<ArticleContentDTO> listArticleContent(Map<String, Object> params) throws SearchException;
/**
* 统计文章数量
*
* @param params
* @return
* @throws SearchException
*/
Integer countArticleCount(Map<String, Object> params) throws SearchException;
} }

View File

@ -119,4 +119,12 @@ public interface IArticleContentService {
*/ */
SuccessResultList<List<ArticleContentDTO>> listPageArticleContent(ListPage page) throws SearchException; SuccessResultList<List<ArticleContentDTO>> listPageArticleContent(ListPage page) throws SearchException;
/**
* 统计文章数量
*
* @param params
* @return
* @throws SearchException
*/
SuccessResultData<Integer> countArticleCount(Map<String, Object> params) throws SearchException;
} }

View File

@ -10,6 +10,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException; import com.cm.common.exception.UpdateException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil; import com.cm.common.utils.UUIDUtil;
@ -154,4 +155,9 @@ public class ArticleContentServiceImpl extends AbstractService implements IArtic
return new SuccessResultList<>(articleContentDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); return new SuccessResultList<>(articleContentDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
} }
@Override
public SuccessResultData<Integer> countArticleCount(Map<String, Object> params) throws SearchException {
Integer countArticleCount = articleContentDao.countArticleCount(params);
return new SuccessResultData<>(countArticleCount == null ? 0 : countArticleCount);
}
} }

View File

@ -191,4 +191,22 @@
</if> </if>
</select> </select>
<!-- 统计文章数量 -->
<select id="countArticleCount" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
article_content
WHERE
is_delete = 0
<if test="articleCategoryId != null and articleCategoryId != ''">
AND
article_category_id = #{articleCategoryId}
</if>
<if test="isPublish != null">
AND
is_publish = #{isPublish}
</if>
</select>
</mapper> </mapper>