Skip to content

Commit de45ccc

Browse files
committed
新增用户区域分布统计
1 parent b281c35 commit de45ccc

File tree

21 files changed

+1897
-228
lines changed

21 files changed

+1897
-228
lines changed

blog-mysql8.sql

Lines changed: 136 additions & 153 deletions
Large diffs are not rendered by default.

blog-springboot/src/main/java/com/minzheng/blog/constant/CommonConst.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,24 @@ public class CommonConst {
6969
*/
7070
public static final String ARTICLE_PATH = "/articles/";
7171

72-
7372
/**
7473
* 友联页面路径
7574
*/
7675
public static final String LINK_PATH = "/links";
7776

77+
/**
78+
* 省
79+
*/
80+
public static final String PROVINCE = "省";
81+
82+
/**
83+
* 市
84+
*/
85+
public static final String CITY = "市";
86+
87+
/**
88+
* 未知的
89+
*/
90+
public static final String UNKNOWN = "未知";
91+
7892
}

blog-springboot/src/main/java/com/minzheng/blog/constant/RedisPrefixConst.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public class RedisPrefixConst {
5353
*/
5454
public static final String WEBSITE_CONFIG = "website_config";
5555

56+
/**
57+
* 用户地区
58+
*/
59+
public static final String USER_AREA = "user_area";
60+
61+
/**
62+
* 访客地区
63+
*/
64+
public static final String VISITOR_AREA = "visitor_area";
65+
5666
/**
5767
* 页面封面
5868
*/

blog-springboot/src/main/java/com/minzheng/blog/controller/BlogInfoController.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import javax.validation.Valid;
2424

25-
2625
import static com.minzheng.blog.constant.OptTypeConst.UPDATE;
2726

2827
/**
@@ -138,5 +137,16 @@ public Result<String> sendVoice(VoiceVO voiceVO) {
138137
return Result.ok();
139138
}
140139

140+
/**
141+
* 上传访客信息
142+
*
143+
* @return {@link Result}
144+
*/
145+
@PostMapping("/report")
146+
public Result<?> report() {
147+
blogInfoService.report();
148+
return Result.ok();
149+
}
150+
141151
}
142152

blog-springboot/src/main/java/com/minzheng/blog/controller/UserAuthController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.minzheng.blog.controller;
22

33

4+
import com.minzheng.blog.dto.UserAreaDTO;
45
import com.minzheng.blog.dto.UserInfoDTO;
56
import com.minzheng.blog.vo.PageResult;
67
import com.minzheng.blog.dto.UserBackDTO;
@@ -13,6 +14,7 @@
1314
import org.springframework.web.bind.annotation.*;
1415

1516
import javax.validation.Valid;
17+
import java.util.List;
1618

1719
/**
1820
* 用户账号控制器
@@ -40,6 +42,18 @@ public Result<?> sendCode(String username) {
4042
return Result.ok();
4143
}
4244

45+
/**
46+
* 获取用户区域分布
47+
*
48+
* @param conditionVO 条件
49+
* @return {@link Result<UserAreaDTO>} 用户区域分布
50+
*/
51+
@ApiOperation(value = "获取用户区域分布")
52+
@GetMapping("/admin/user/area")
53+
public Result<List<UserAreaDTO>> listUserAreas(ConditionVO conditionVO) {
54+
return Result.ok(userAuthService.listUserAreas(conditionVO));
55+
}
56+
4357
/**
4458
* 查询后台用户列表
4559
*

blog-springboot/src/main/java/com/minzheng/blog/dto/BlogBackInfoDTO.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public class BlogBackInfoDTO {
4444
*/
4545
private List<CategoryDTO> categoryDTOList;
4646

47+
/**
48+
* 标签列表
49+
*/
50+
private List<TagDTO> tagDTOList;
51+
4752
/**
4853
* 文章统计列表
4954
*/
@@ -59,6 +64,4 @@ public class BlogBackInfoDTO {
5964
*/
6065
private List<ArticleRankDTO> articleRankDTOList;
6166

62-
63-
6467
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.minzheng.blog.dto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
/**
9+
* 用户地区dto
10+
*
11+
* @author yezhiqiu
12+
* @date 2021/08/23
13+
*/
14+
@Data
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
@Builder
18+
public class UserAreaDTO {
19+
20+
/**
21+
* 地区名
22+
*/
23+
private String name;
24+
25+
/**
26+
* 数量
27+
*/
28+
private Long value;
29+
30+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.minzheng.blog.enums;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
6+
/**
7+
* 用户区域类型枚举
8+
*
9+
* @author yezhiqiu
10+
* @date 2021/08/24
11+
*/
12+
@Getter
13+
@AllArgsConstructor
14+
public enum UserAreaTypeEnum {
15+
/**
16+
* 用户
17+
*/
18+
USER(1, "用户"),
19+
/**
20+
* 游客
21+
*/
22+
VISITOR(2, "游客");
23+
24+
/**
25+
* 类型
26+
*/
27+
private final Integer type;
28+
29+
/**
30+
* 描述
31+
*/
32+
private final String desc;
33+
34+
/**
35+
* 获取用户区域类型
36+
*
37+
* @param type 类型
38+
* @return {@link UserAreaTypeEnum} 用户区域类型枚举
39+
*/
40+
public static UserAreaTypeEnum getUserAreaType(Integer type) {
41+
for (UserAreaTypeEnum value : UserAreaTypeEnum.values()) {
42+
if (value.getType().equals(type)) {
43+
return value;
44+
}
45+
}
46+
return null;
47+
}
48+
49+
}

blog-springboot/src/main/java/com/minzheng/blog/handler/ServletRequestListenerImpl.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

blog-springboot/src/main/java/com/minzheng/blog/service/BlogInfoService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,9 @@ public interface BlogInfoService {
5555
*/
5656
void updateAbout(BlogInfoVO blogInfoVO);
5757

58+
/**
59+
* 上传访客信息
60+
*/
61+
void report();
5862

5963
}

0 commit comments

Comments
 (0)