Skip to content

Commit d06987e

Browse files
committed
feat(FlowUserController): 更新api地址、收藏同步任务不在同步image
1 parent 29b7e4e commit d06987e

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

flow-client/src/main/java/com/ligg/flowclient/controller/AccountController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public Result<FlowUserVo> bindEmail(
170170
* 提交 Bangumi 收藏同步任务(异步执行,立即返回任务状态)。
171171
* 从 user_oauth 读取 Bangumi token 拉取收藏并写入 user_bgm_collection。
172172
*/
173+
@Deprecated
173174
@PostMapping("/oauth/bangumi/collections/sync")
174175
@IpEndpointRateLimit(keyPrefix = "animeflow:account:sync-bgm-collection:ip:", seconds = 60, maxRequests = 5)
175176
public Result<UserBgmCollectionSyncStatusVo> syncBangumiCollections(

flow-client/src/main/java/com/ligg/flowclient/controller/FlowUserController.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@
66
package com.ligg.flowclient.controller;
77

88
import com.ligg.common.entity.UserOauthEntity;
9-
import com.ligg.common.exception.LoginExpiredException;
109
import com.ligg.common.response.Result;
1110
import com.ligg.common.statuenum.ResponseCode;
11+
import com.ligg.flowclient.annotation.IpEndpointRateLimit;
1212
import com.ligg.flowclient.interceptor.AuthorizationInterceptor;
1313
import com.ligg.flowclient.module.dto.UpdateUserCollectionDto;
1414
import com.ligg.flowclient.module.dto.UpdateUserDto;
1515
import com.ligg.flowclient.module.vo.FlowUserVo;
1616
import com.ligg.common.vo.bangumi.UserCollectionsVo;
17-
import com.ligg.flowclient.service.BangumiOAuthTokenService;
18-
import com.ligg.flowclient.service.JwtTokenService;
19-
import com.ligg.flowclient.service.UserBgmCollectionService;
20-
import com.ligg.flowclient.service.UserService;
17+
import com.ligg.flowclient.module.vo.UserBgmCollectionSyncStatusVo;
18+
import com.ligg.flowclient.service.*;
2119
import jakarta.validation.Valid;
2220
import lombok.RequiredArgsConstructor;
23-
import org.springframework.util.StringUtils;
2421
import org.springframework.web.bind.annotation.*;
2522
import org.springframework.web.multipart.MultipartFile;
2623

@@ -35,6 +32,8 @@ public class FlowUserController {
3532

3633
private final BangumiOAuthTokenService bangumiOAuthTokenService;
3734

35+
private final UserBgmCollectionSyncService userBgmCollectionSyncService;
36+
3837
private final JwtTokenService jwtTokenService;
3938

4039
/**
@@ -104,4 +103,29 @@ public Result<Void> updateCollection(
104103
userBgmCollectionService.updateCollection(accessToken, subjectId, body);
105104
return Result.success();
106105
}
106+
107+
/**
108+
* 提交 Bangumi 收藏同步任务(异步执行,立即返回任务状态)。
109+
* 从 user_oauth 读取 Bangumi token 拉取收藏并写入 user_bgm_collection。
110+
*/
111+
@PostMapping("/collections/sync")
112+
@IpEndpointRateLimit(keyPrefix = "animeflow:account:sync-bgm-collection:ip:", seconds = 60, maxRequests = 5)
113+
public Result<UserBgmCollectionSyncStatusVo> syncBangumiCollections(
114+
@RequestAttribute(AuthorizationInterceptor.ACCESS_TOKEN_REQUEST_ATTRIBUTE) String accessToken,
115+
@RequestParam(defaultValue = "2") int subjectType) {
116+
Long userId = jwtTokenService.validateAccessToken(accessToken);
117+
UserBgmCollectionSyncStatusVo status = userBgmCollectionSyncService.triggerSync(userId, subjectType);
118+
return Result.success(ResponseCode.SUCCESS, status);
119+
}
120+
121+
/**
122+
* 查询 Bangumi 收藏同步任务状态。
123+
*/
124+
@GetMapping("/collections/sync")
125+
public Result<UserBgmCollectionSyncStatusVo> getBangumiCollectionSyncStatus(
126+
@RequestAttribute(AuthorizationInterceptor.ACCESS_TOKEN_REQUEST_ATTRIBUTE) String accessToken) {
127+
Long userId = jwtTokenService.validateAccessToken(accessToken);
128+
UserBgmCollectionSyncStatusVo status = userBgmCollectionSyncService.getSyncStatus(userId);
129+
return Result.success(ResponseCode.SUCCESS, status);
130+
}
107131
}

flow-client/src/main/java/com/ligg/flowclient/service/UserBgmCollectionSyncRunner.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ private void upsertCollection(Long userId, UserCollectionsDto.Item item) {
139139
row.setUserId(userId);
140140
row.setSubjectId(item.getId());
141141
row.setSubjectType(item.getType() != null ? item.getType() : 2);
142-
row.setImages(toJson(item.getImages()));
143142
row.setBgmInterestId(interest.getId());
144143
row.setRate(interest.getRate() != null ? interest.getRate() : 0);
145144
row.setType(interest.getType());

0 commit comments

Comments
 (0)