feat: 指定用户的统计查询

This commit is contained in:
xiaozzzi 2024-02-02 17:59:38 +08:00
parent e8d3691853
commit 88c01f5fbb
2 changed files with 33 additions and 1 deletions

View File

@ -2,12 +2,16 @@ package com.blossom.backend.server.article.stat;
import com.blossom.backend.base.auth.AuthContext;
import com.blossom.backend.base.auth.annotation.AuthIgnore;
import com.blossom.backend.base.auth.annotation.AuthUserType;
import com.blossom.backend.base.auth.exception.AuthException;
import com.blossom.backend.base.auth.exception.AuthRCode;
import com.blossom.backend.base.user.UserTypeEnum;
import com.blossom.backend.config.BlConstants;
import com.blossom.backend.server.article.draft.pojo.ArticleStatRes;
import com.blossom.backend.server.article.stat.pojo.ArticleHeatmapRes;
import com.blossom.backend.server.article.stat.pojo.ArticleLineRes;
import com.blossom.backend.server.article.stat.pojo.ArticleWordsSaveReq;
import com.blossom.backend.server.article.stat.pojo.ArticleWordsRes;
import com.blossom.backend.server.article.stat.pojo.ArticleWordsSaveReq;
import com.blossom.common.base.pojo.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -77,6 +81,21 @@ public class ArticleStatController {
return R.ok(statService.statCount(null, null, AuthContext.getUserId()));
}
/**
* 文章数和文章字数
*
* @apiNote 只有管理员可以查看
* @since 1.13.0
*/
@AuthUserType(UserTypeEnum.ADMIN)
@GetMapping("/words/user")
public R<ArticleStatRes> word(@RequestParam("id") Long id) {
if (!AuthContext.getType().equals(UserTypeEnum.ADMIN.getType())) {
throw new AuthException(AuthRCode.PERMISSION_DENIED);
}
return R.ok(statService.statCount(null, null, id));
}
/**
* 字数统计列表
*

View File

@ -2,6 +2,8 @@ package com.blossom.backend.server.picture;
import com.blossom.backend.base.auth.AuthContext;
import com.blossom.backend.base.auth.annotation.AuthIgnore;
import com.blossom.backend.base.auth.annotation.AuthUserType;
import com.blossom.backend.base.user.UserTypeEnum;
import com.blossom.backend.server.picture.pojo.*;
import com.blossom.common.base.exception.XzException400;
import com.blossom.common.base.pojo.PageRes;
@ -116,4 +118,15 @@ public class PictureController {
public R<PictureStatRes> stat(@RequestParam(value = "pid", required = false) Long pid) {
return R.ok(baseService.stat(AuthContext.getUserId(), pid));
}
/**
* 查询用户的图片统计
*
* @param userId 用户ID
*/
@AuthUserType(UserTypeEnum.ADMIN)
@GetMapping("/stat/user")
public R<PictureStatRes> statUser(@RequestParam(value = "id") Long userId) {
return R.ok(baseService.stat(userId, null));
}
}