reghao 6 месяцев назад
Родитель
Сommit
9b5f5d0851

+ 0 - 39
user/user-service/src/main/java/cn/reghao/tnb/user/app/controller/CrawledUserController.java

@@ -1,39 +0,0 @@
-package cn.reghao.tnb.user.app.controller;
-
-import cn.reghao.jutil.web.WebResult;
-import cn.reghao.tnb.account.api.dto.CrawledUser;
-import cn.reghao.tnb.user.app.service.CrawledUserService;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.Operation;
-import org.springframework.http.MediaType;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @author reghao
- * @date 2024-09-27 15:15:50
- */
-@Tag(name = "爬取的用户资料接口")
-@RestController
-@RequestMapping("/api/user")
-public class CrawledUserController {
-    private final CrawledUserService crawledUserService;
-
-    public CrawledUserController(CrawledUserService crawledUserService) {
-        this.crawledUserService = crawledUserService;
-    }
-
-    @Operation(summary = "创建 bilibili 用户帐号", description = "N")
-    @PostMapping("/create/bili")
-    public String updateUserProfile(@RequestBody @Validated CrawledUser crawledUser) {
-        Long userId = crawledUserService.createAccount(crawledUser);
-        return WebResult.success(userId);
-    }
-
-    @Operation(summary = "查找 bilibili 用户", description = "N")
-    @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String searchUser(@RequestParam("username") String username) {
-        Long userId = crawledUserService.getUserId(username);
-        return WebResult.success(userId);
-    }
-}

+ 24 - 0
user/user-service/src/main/java/cn/reghao/tnb/user/app/rpc/AdminUserServiceImpl.java

@@ -2,6 +2,7 @@ package cn.reghao.tnb.user.app.rpc;
 
 import cn.reghao.jutil.jdk.db.PageList;
 import cn.reghao.tnb.account.api.dto.AccountInfo;
+import cn.reghao.tnb.account.api.dto.CrawledUser;
 import cn.reghao.tnb.account.api.iface.AccountQuery;
 import cn.reghao.tnb.content.api.iface.UserContentService;
 import cn.reghao.tnb.user.api.dto.UserInfo;
@@ -87,4 +88,27 @@ public class AdminUserServiceImpl implements AdminUserService {
         int duration = vipPlan.getDuration();
         return new VipPlanInfo(planId, name, price, duration);
     }
+
+    public Long getUserId(String username) {
+        AccountInfo accountInfo = accountQuery.getByUsername(username);
+        if (accountInfo != null) {
+            long userId = accountInfo.getUserId();
+            return userId;
+        }
+
+        return null;
+    }
+
+    public synchronized Long createAccount(CrawledUser crawledUser) {
+        Long userId = accountQuery.createCrawledAccount(crawledUser);
+        UserProfile userProfile = userProfileMapper.findByUserId(userId);
+        if (userProfile == null) {
+            int gender = crawledUser.getGender();
+            String signature = crawledUser.getSignature();
+            userProfile = new UserProfile(userId, gender, signature);
+            userProfileMapper.save(userProfile);
+        }
+
+        return userId;
+    }
 }

+ 0 - 47
user/user-service/src/main/java/cn/reghao/tnb/user/app/service/CrawledUserService.java

@@ -1,47 +0,0 @@
-package cn.reghao.tnb.user.app.service;
-
-import cn.reghao.tnb.account.api.dto.AccountInfo;
-import cn.reghao.tnb.account.api.dto.CrawledUser;
-import cn.reghao.tnb.account.api.iface.AccountQuery;
-import cn.reghao.tnb.user.app.db.mapper.UserProfileMapper;
-import cn.reghao.tnb.user.app.model.po.UserProfile;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.stereotype.Service;
-
-/**
- * @author reghao
- * @date 2023-05-31 11:12:08
- */
-@Service
-public class CrawledUserService {
-    @DubboReference(check = false, retries = 0, timeout = 60_000)
-    private AccountQuery accountQuery;
-    private final UserProfileMapper userProfileMapper;
-
-    public CrawledUserService(UserProfileMapper userProfileMapper) {
-        this.userProfileMapper = userProfileMapper;
-    }
-
-    public Long getUserId(String username) {
-        AccountInfo accountInfo = accountQuery.getByUsername(username);
-        if (accountInfo != null) {
-            long userId = accountInfo.getUserId();
-            return userId;
-        }
-
-        return null;
-    }
-
-    public synchronized Long createAccount(CrawledUser crawledUser) {
-        Long userId = accountQuery.createCrawledAccount(crawledUser);
-        UserProfile userProfile = userProfileMapper.findByUserId(userId);
-        if (userProfile == null) {
-            int gender = crawledUser.getGender();
-            String signature = crawledUser.getSignature();
-            userProfile = new UserProfile(userId, gender, signature);
-            userProfileMapper.save(userProfile);
-        }
-
-        return userId;
-    }
-}