Skip to content

Commit 2898bb2

Browse files
committed
减少account返回的字段
修改查询实例时个人喜爱的实例无法表示的问题(example_id改为String类型即可)
1 parent 02bc175 commit 2898bb2

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

springboot-dubbo-api/src/main/java/com/lzq/api/dto/ExampleAccount.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class ExampleAccount implements Serializable {
5656
*/
5757
@TableId(value = "example_id")
5858
@JsonProperty("exampleId")
59-
private Long exampleId;
59+
private String exampleId;
6060
/**
6161
* 实列名称
6262
*/

springboot-dubbo-api/src/main/java/com/lzq/api/pojo/Account.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public class Account implements Serializable, UserDetails {
158158

159159

160160

161+
@JsonIgnore
161162
@Override
162163
public Collection<? extends GrantedAuthority> getAuthorities() {
163164
List<SimpleGrantedAuthority> list = new ArrayList();
@@ -166,22 +167,22 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
166167
}
167168

168169

169-
170+
@JsonIgnore
170171
@Override
171172
public boolean isAccountNonExpired() {
172173
return true;
173174
}
174-
175+
@JsonIgnore
175176
@Override
176177
public boolean isAccountNonLocked() {
177178
return true;
178179
}
179-
180+
@JsonIgnore
180181
@Override
181182
public boolean isCredentialsNonExpired() {
182183
return true;
183184
}
184-
185+
@JsonIgnore
185186
@Override
186187
public boolean isEnabled() {
187188
return true;

springboot-dubbo-service/src/main/resources/mapper/ExampleAccoutMapper.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
33
<mapper namespace="com.lzq.dubboservice.mapper.ExampleAccountMapper">
44
<sql id="Thebasic">
5-
a
6-
.
7-
example_id
8-
, example_name, ispublic, label, img, file_name, favorites, a.username
5+
a.example_id, example_name, ispublic, label, img, file_name, favorites, a.username
96
</sql>
107

118
<select id="queryByExampleName" resultType="com.lzq.api.dto.ExampleAccount">

springboot-dubbo-web/src/main/java/com/lzq/web/controller/IndexController.java

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

3-
import com.alibaba.fastjson.JSON;
4-
import com.alibaba.fastjson.JSONObject;
53
import com.auth0.jwt.interfaces.DecodedJWT;
64
import com.fasterxml.jackson.core.JsonProcessingException;
75
import com.lzq.api.pojo.*;

springboot-dubbo-web/src/main/java/com/lzq/web/controller/QueryController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.swagger.annotations.Api;
1212
import io.swagger.annotations.ApiOperation;
1313
import lombok.extern.slf4j.Slf4j;
14+
import org.apache.commons.lang.StringUtils;
1415
import org.apache.dubbo.config.annotation.Reference;
1516
import org.springframework.beans.factory.annotation.Autowired;
1617
import org.springframework.data.redis.core.RedisTemplate;
@@ -92,9 +93,10 @@ public Map<String, Object> queryByUsername(HttpSession session, String username)
9293
public Map<String, Object> getFollowList(HttpServletRequest request, AccountResult result, @RequestParam(defaultValue = "1") Integer currentPage) {
9394
String username = null;
9495
PageInfo<AccountResult> list = null;
96+
String token = request.getHeader("token");
9597
//判断用户是否登录
96-
if (request.getHeader("token") != null) {
97-
username = JWTUtils.verify(request.getHeader("token"))
98+
if (StringUtils.isNotBlank(token)){
99+
username = JWTUtils.verify(token)
98100
.getClaim("username").asString();
99101
}
100102
//登录的情况
@@ -238,7 +240,7 @@ public Map<String, Object> queryByExampleName(HttpServletRequest request, String
238240
*/
239241
@GetMapping("/getExample")
240242
@ApiOperation("查询个人全部实例")
241-
public Map<String, Object> getExample(HttpServletRequest request, Account account, @RequestParam(defaultValue = "1") Integer currentPage) {
243+
public Map<String, Object> getExample(HttpServletRequest request, Account account, @RequestParam(defaultValue = "1") Integer currentPage,@RequestParam(defaultValue = "0") Integer orderCondition) {
242244
String username = null;
243245
PageInfo<Example> list;
244246
if (request.getHeader("token") != null) {
@@ -307,19 +309,22 @@ public Map<String, Object> getFavorites(HttpServletRequest request, Account acco
307309
list.setList(exampleList);
308310
} else {
309311
//获取缓存中用户的喜爱实例id
310-
List<Integer> favoritesList = redisTemplate.opsForList().range(username + "fav", 0, -1);
312+
List<String> favoritesList = redisTemplate.opsForList().range(username + "fav", 0, -1);
313+
log.info("查询到的个人喜爱列表"+favoritesList);
311314
//获取缓存中用户的关注用户名
312315
List<String> followList = redisTemplate.opsForList().range(username, 0, -1);
313316
list = exampleAccountService.queryPersonFavorites(account.getUsername(), currentPage, orderCondition);
314317
List<ExampleAccount> exampleList = list.getList();
315318
for (ExampleAccount exampleAccount : exampleList) {
319+
log.info("遍历实例id:"+exampleAccount.getExampleId());
316320
//判断该用户是否被关注,该用户是否是自己
317321
if (followList.contains(exampleAccount.getUsername())) {
318322
exampleAccount.setMyFollow(true);
319323
} else if (username.equals(exampleAccount.getUsername())) {
320324
exampleAccount.setMyFollow(null);
321325
}
322326
if (favoritesList.contains(exampleAccount.getExampleId())) {
327+
log.info("我匹配正确了"+exampleAccount.getExampleId());
323328
exampleAccount.setMyFavorites(true);
324329
}
325330
}

springboot-dubbo-web/src/main/java/com/lzq/web/controller/UserController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public Map<String, Object> deleteAccount(Account account) {
155155
@PutMapping("/updateEmail")
156156
@ApiOperation("更新注册邮箱")
157157
public Map<String, Object> updatEmail(Account account) {
158+
//更新邮箱添加redis
158159
try {
159160
Boolean bol = accountService.update(account);
160161
return ResultMapUtils.ResultMapWithToken(bol, 0, null, null);

0 commit comments

Comments
 (0)