Skip to content

Commit f5c9df9

Browse files
committed
添加相关注释和一对一、一对多关系增加关联ID
1 parent 6501064 commit f5c9df9

File tree

9 files changed

+155
-8
lines changed

9 files changed

+155
-8
lines changed

blog-api/blog-api.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.10" level="project" />
7373
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" />
7474
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.20" level="project" />
75-
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" />
75+
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
7676
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
7777
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.4" level="project" />
7878
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.4" level="project" />

blog-api/src/main/java/com/rawchen/controller/admin/ScheduleJobController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public Result saveJob(@RequestBody ScheduleJob scheduleJob) {
5757
scheduleJob.setStatus(false);
5858
scheduleJob.setCreateTime(new Date());
5959
ValidatorUtils.validateEntity(scheduleJob);
60+
//保存任务配置并以此创建定时任务
6061
scheduleJobService.saveJob(scheduleJob);
6162
return Result.ok("添加成功");
6263
}

blog-api/src/main/java/com/rawchen/model/vo/BlogInfo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.rawchen.model.vo;
22

3-
import lombok.Getter;
4-
import lombok.NoArgsConstructor;
5-
import lombok.Setter;
6-
import lombok.ToString;
3+
import lombok.*;
74
import com.rawchen.entity.Category;
85
import com.rawchen.entity.Tag;
96

blog-api/src/main/java/com/rawchen/service/RedisService.java

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,181 @@
77
import java.util.Map;
88

99
public interface RedisService {
10+
11+
/**
12+
* 根据hash值获取博客页面信息
13+
*
14+
* @param hash
15+
* @param pageNum
16+
* @return
17+
*/
1018
PageResult<BlogInfo> getBlogInfoPageResultByHash(String hash, Integer pageNum);
1119

20+
/**
21+
* 保存键值到hash中
22+
*
23+
* @param hash
24+
* @param key
25+
* @param value
26+
*/
1227
void saveKVToHash(String hash, Object key, Object value);
1328

29+
/**
30+
* 保存map到hash中
31+
*
32+
* @param hash
33+
* @param map
34+
*/
1435
void saveMapToHash(String hash, Map map);
1536

37+
/**
38+
* 根据hash值获取map
39+
*
40+
* @param hash
41+
* @return
42+
*/
1643
Map getMapByHash(String hash);
1744

45+
/**
46+
* 根据hashKey获取value
47+
*
48+
* @param hash
49+
* @param key
50+
* @return
51+
*/
1852
Object getValueByHashKey(String hash, Object key);
1953

54+
/**
55+
* 根据hashkey新增
56+
* @param hash
57+
* @param key
58+
* @param increment
59+
*/
2060
void incrementByHashKey(String hash, Object key, int increment);
2161

62+
/**
63+
* 根据hashkey删除
64+
*
65+
* @param hash
66+
* @param key
67+
*/
2268
void deleteByHashKey(String hash, Object key);
2369

70+
/**
71+
* 根据值获取list
72+
*
73+
* @param key
74+
* @param <T>
75+
* @return
76+
*/
2477
<T> List<T> getListByValue(String key);
2578

79+
/**
80+
* 保存list到value
81+
*
82+
* @param key
83+
* @param list
84+
* @param <T>
85+
*/
2686
<T> void saveListToValue(String key, List<T> list);
2787

88+
/**
89+
* 根据值获取map
90+
*
91+
* @param key
92+
* @param <T>
93+
* @return
94+
*/
2895
<T> Map<String, T> getMapByValue(String key);
2996

97+
/**
98+
* 保存map到value
99+
*
100+
* @param key
101+
* @param map
102+
* @param <T>
103+
*/
30104
<T> void saveMapToValue(String key, Map<String, T> map);
31105

106+
/**
107+
* 根据value获取Object
108+
*
109+
* @param key
110+
* @param t
111+
* @param <T>
112+
* @return
113+
*/
32114
<T> T getObjectByValue(String key, Class t);
33115

116+
/**
117+
* 根据key插入信息
118+
*
119+
* @param key
120+
* @param increment
121+
*/
34122
void incrementByKey(String key, int increment);
35123

124+
/**
125+
* 保存object到value
126+
*
127+
* @param key
128+
* @param object
129+
*/
36130
void saveObjectToValue(String key, Object object);
37131

132+
/**
133+
* 保存value到set
134+
*
135+
* @param key
136+
* @param value
137+
*/
38138
void saveValueToSet(String key, Object value);
39139

140+
/**
141+
* 根据set获取总数
142+
*
143+
* @param key
144+
* @return
145+
*/
40146
int countBySet(String key);
41147

148+
/**
149+
* 根据set删除值
150+
*
151+
* @param key
152+
* @param value
153+
*/
42154
void deleteValueBySet(String key, Object value);
43155

156+
/**
157+
* 校验Redis中是否存在uuid
158+
*
159+
* @param key
160+
* @param value
161+
* @return
162+
*/
44163
boolean hasValueInSet(String key, Object value);
45164

165+
/**
166+
* 删除友链页面缓存
167+
*
168+
* @param key
169+
*/
46170
void deleteCacheByKey(String key);
47171

172+
/**
173+
* 校验key是否存在
174+
*
175+
* @param key
176+
* @return
177+
*/
48178
boolean hasKey(String key);
49179

180+
/**
181+
* 设置key的过期时间
182+
*
183+
* @param key
184+
* @param time
185+
*/
50186
void expire(String key, long time);
51187
}

blog-api/src/main/java/com/rawchen/service/impl/BlogServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public PageResult<BlogInfo> getBlogInfoListByIsPublished(Integer pageNum) {
122122
}
123123
//redis没有缓存,从数据库查询,并添加缓存
124124
PageHelper.startPage(pageNum, pageSize, orderBy);
125+
//处理查询Tag并处理带密码的文章
125126
List<BlogInfo> blogInfos = processBlogInfosPassword(blogMapper.getBlogInfoListByIsPublished());
126127
PageInfo<BlogInfo> pageInfo = new PageInfo<>(blogInfos);
127128
PageResult<BlogInfo> pageResult = new PageResult<>(pageInfo.getPages(), pageInfo.getList());

blog-api/src/main/java/com/rawchen/task/VisitorSyncScheduleTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import java.util.Set;
2323

2424
/**
25-
* @Description: 访客统计相关定时任务
25+
* <p>@Description: 存放访客统计相关定时任务方法的Bean</p>
26+
* <p>@Component默认值为该类首字母小写的类名</p>
27+
* <p>example:VisitorSyncScheduleTask -> visitorSyncScheduleTask</p>
28+
*
2629
* @Date: 2021-02-05
2730
*/
2831
@Component

blog-api/src/main/resources/mapper/BlogMapper.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<result property="firstPicture" column="first_picture"/>
108108
<association property="category" javaType="com.rawchen.entity.Category">
109109
<result property="name" column="category_name"/>
110+
<result property="id" column="category_id"/>
110111
</association>
111112
</resultMap>
112113

@@ -120,7 +121,8 @@
120121
b.views,
121122
b.password,
122123
b.first_picture,
123-
c.category_name
124+
c.category_name,
125+
c.id as category_id
124126
from blog as b
125127
left join category as c on b.category_id = c.id
126128
where b.is_published = true

blog-api/src/main/resources/mapper/TagMapper.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<!--按博客id查询List-->
2626
<select id="getTagListByBlogId" resultMap="tag">
27-
select t.tag_name, t.color
27+
select t.id, t.tag_name, t.color
2828
from blog_tag as bt
2929
left join tag as t on bt.tag_id = t.id
3030
where bt.blog_id = #{blogId}

blog-api/src/test/java/com/rawchen/BlogApiApplicationTests.java

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

3+
import com.rawchen.util.IpAddressUtils;
34
import org.junit.jupiter.api.Test;
45
import org.springframework.boot.test.context.SpringBootTest;
56
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -24,4 +25,10 @@ void test02() {
2425
System.out.println(ClassUtils.getShortNameAsProperty(String.class));
2526
System.out.println(ClassUtils.getMethod(String.class, "valueOf", String.class));
2627
}
28+
29+
@Test
30+
void test03() {
31+
String cityInfo = IpAddressUtils.getCityInfo("119.23.60.193");
32+
System.out.println(cityInfo);
33+
}
2734
}

0 commit comments

Comments
 (0)