1
0

4 Commits ae6ffc3f3c ... 39af94b51b

Autor SHA1 Mensaje Fecha
  reghao 39af94b51b update OpenApiClient hace 4 días
  reghao 5190768f15 update AccountAvatar hace 4 días
  reghao f1b8befbef update ApiKeyController hace 4 días
  reghao 158ff99062 update AdminFileController hace 4 días

+ 2 - 2
auth/auth-api/src/main/java/cn/reghao/tnb/auth/api/dto/AccountAvatar.java

@@ -13,12 +13,12 @@ public class AccountAvatar implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private String userIdStr;
-    private String username;
+    private String screenName;
     private String avatarUrl;
 
     public AccountAvatar(String userIdStr, AccountInfo accountInfo) {
         this.userIdStr = userIdStr;
-        this.username = accountInfo.getScreenName();
+        this.screenName = accountInfo.getScreenName();
         this.avatarUrl = accountInfo.getAvatarUrl();
     }
 }

+ 6 - 2
auth/auth-service/src/main/java/cn/reghao/tnb/auth/app/controller/ApiKeyController.java

@@ -3,6 +3,7 @@ package cn.reghao.tnb.auth.app.controller;
 import cn.reghao.tnb.auth.app.model.dto.ApiKeyDto;
 import cn.reghao.tnb.auth.app.model.po.ApiKey;
 import cn.reghao.tnb.auth.app.model.vo.ApiKeyCreateVO;
+import cn.reghao.tnb.auth.app.service.AccountTokenService;
 import cn.reghao.tnb.auth.app.service.ApiKeyService;
 import cn.reghao.tnb.common.web.WebResult;
 import org.springframework.http.ResponseEntity;
@@ -18,15 +19,18 @@ import java.util.List;
 @RestController
 @RequestMapping("/api/account/apikey")
 public class ApiKeyController {
+    private final AccountTokenService accountTokenService;
     private final ApiKeyService apiKeyService;
 
-    public ApiKeyController(ApiKeyService apiKeyService) {
+    public ApiKeyController(AccountTokenService accountTokenService, ApiKeyService apiKeyService) {
+        this.accountTokenService = accountTokenService;
         this.apiKeyService = apiKeyService;
     }
 
     @PostMapping
     public String createKey(@RequestBody @Validated ApiKeyDto apiKeyDto) {
-        ApiKeyCreateVO vo = apiKeyService.createApiKey(apiKeyDto);
+        long userId = accountTokenService.getAuthToken().getUserId();
+        ApiKeyCreateVO vo = apiKeyService.createApiKey(apiKeyDto, userId);
         return WebResult.success(vo);
     }
 

+ 2 - 7
auth/auth-service/src/main/java/cn/reghao/tnb/auth/app/service/ApiKeyService.java

@@ -21,15 +21,12 @@ import java.util.UUID;
  */
 @Service
 public class ApiKeyService {
-    private final AccountTokenService accountTokenService;
     private final StringRedisTemplate redisTemplate;
     private final ApiKeyMapper apiKeyMapper;
     private final ObjectMapper objectMapper = new ObjectMapper();
     private static final String REDIS_PREFIX = "open_api:ak:";
 
-    public ApiKeyService(AccountTokenService accountTokenService, StringRedisTemplate redisTemplate,
-                         ApiKeyMapper apiKeyMapper) {
-        this.accountTokenService = accountTokenService;
+    public ApiKeyService(StringRedisTemplate redisTemplate, ApiKeyMapper apiKeyMapper) {
         this.redisTemplate = redisTemplate;
         this.apiKeyMapper = apiKeyMapper;
     }
@@ -38,9 +35,7 @@ public class ApiKeyService {
      * 为用户创建新的 AK/SK
      */
     @Transactional(rollbackFor = Exception.class)
-    public ApiKeyCreateVO createApiKey(ApiKeyDto apiKeyDto) {
-        long userId = accountTokenService.getAuthToken().getUserId();
-
+    public ApiKeyCreateVO createApiKey(ApiKeyDto apiKeyDto, long userId) {
         String appName = apiKeyDto.getAppName();
         List<String> scopes =  apiKeyDto.getScopes();
 

+ 2 - 2
file/file-service/src/main/java/cn/reghao/tnb/file/app/controller/AdminFileController.java

@@ -2,7 +2,7 @@ package cn.reghao.tnb.file.app.controller;
 
 import cn.reghao.tnb.common.web.WebResult;
 import cn.reghao.tnb.file.app.model.dto.OssConfigDto;
-import cn.reghao.tnb.file.app.model.po.OssConfig;
+import cn.reghao.tnb.file.app.model.vo.OssConfigInfo;
 import cn.reghao.tnb.file.app.service.AdminFileService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -29,7 +29,7 @@ public class AdminFileController {
     @Operation(summary = "获取文件存储列表", description = "N")
     @GetMapping(value = "/file_store", produces = MediaType.APPLICATION_JSON_VALUE)
     public String getFileStores() {
-        List<OssConfig> list = adminFileService.getOssConfigList();
+        List<OssConfigInfo> list = adminFileService.getOssConfigList();
         return WebResult.success(list);
     }
 

+ 4 - 0
file/file-service/src/main/java/cn/reghao/tnb/file/app/db/mapper/OssConfigMapper.java

@@ -1,9 +1,12 @@
 package cn.reghao.tnb.file.app.db.mapper;
 
 import cn.reghao.jutil.jdk.web.db.BaseMapper;
+import cn.reghao.jutil.jdk.web.db.Page;
 import cn.reghao.tnb.file.app.model.po.OssConfig;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * @author reghao
  * @date 2026-03-02 21:48:46
@@ -11,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface OssConfigMapper extends BaseMapper<OssConfig> {
     OssConfig findByOssType(int ossType);
+    List<OssConfig> findByPage(Page page);
 }

+ 3 - 3
file/file-service/src/main/java/cn/reghao/tnb/file/app/model/constant/OssType.java

@@ -13,10 +13,10 @@ public enum OssType {
 
     private final int code;
     private final String desc;
-    private static Map<Integer, String> descMap = new HashMap<>();
+    private static Map<Integer, OssType> descMap = new HashMap<>();
     static {
         for (OssType type : OssType.values()) {
-            descMap.put(type.code, type.desc);
+            descMap.put(type.code, type);
         }
     }
 
@@ -48,7 +48,7 @@ public enum OssType {
         return desc;
     }
 
-    public static String getDescByCode(int code) {
+    public static OssType getByCode(int code) {
         return descMap.get(code);
     }
 }

+ 32 - 0
file/file-service/src/main/java/cn/reghao/tnb/file/app/model/vo/OssConfigInfo.java

@@ -0,0 +1,32 @@
+package cn.reghao.tnb.file.app.model.vo;
+
+import cn.reghao.jutil.jdk.web.db.BaseObject;
+import cn.reghao.tnb.file.app.model.constant.OssType;
+import cn.reghao.tnb.file.app.model.dto.OssConfigDto;
+import cn.reghao.tnb.file.app.model.po.OssConfig;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * @author reghao
+ * @date 2026-03-02 21:47:20
+ */
+@NoArgsConstructor
+@Data
+public class OssConfigInfo {
+    private String ossType;
+    private String endpoint;
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String bucketName;
+
+    public OssConfigInfo(OssConfig ossConfig) {
+        this.ossType = OssType.getByCode(ossConfig.getOssType()).name();
+        this.endpoint = ossConfig.getEndpoint();
+        this.accessKeyId = ossConfig.getAccessKeyId();
+        this.accessKeySecret = ossConfig.getAccessKeySecret();
+        this.bucketName = ossConfig.getBucketName();
+    }
+}

+ 8 - 8
file/file-service/src/main/java/cn/reghao/tnb/file/app/service/AdminFileService.java

@@ -1,8 +1,12 @@
 package cn.reghao.tnb.file.app.service;
 
+import cn.reghao.jutil.jdk.web.db.Page;
+import cn.reghao.tnb.common.util.ConstantId;
 import cn.reghao.tnb.file.app.db.mapper.OssConfigMapper;
+import cn.reghao.tnb.file.app.model.constant.OssType;
 import cn.reghao.tnb.file.app.model.dto.OssConfigDto;
 import cn.reghao.tnb.file.app.model.po.OssConfig;
+import cn.reghao.tnb.file.app.model.vo.OssConfigInfo;
 import org.springframework.stereotype.Service;
 
 import java.util.Collections;
@@ -25,13 +29,9 @@ public class AdminFileService {
         ossConfigMapper.save(ossConfig);
     }
 
-    public List<OssConfig> getOssConfigList() {
-        int ossType = 1;
-        OssConfig ossConfig = ossConfigMapper.findByOssType(ossType);
-        if (ossConfig != null) {
-            return List.of(ossConfig);
-        }
-
-        return Collections.emptyList();
+    public List<OssConfigInfo> getOssConfigList() {
+        Page page = new Page(1, ConstantId.PAGE_SIZE);
+        List<OssConfig> list = ossConfigMapper.findByPage(page);
+        return list.stream().map(OssConfigInfo::new).toList();
     }
 }

+ 2 - 8
file/file-service/src/main/java/cn/reghao/tnb/file/app/service/OpenApiClient.java

@@ -303,11 +303,7 @@ public class OpenApiClient {
         }
     }
 
-    public void publishVideoPost(File coverFile, File videoFile) throws Exception {
-        ServerInfo serverInfo1 = getServerInfo("image");
-        UploadFileRet uploadFileRet1 = putFile(serverInfo1.getOssUrl(), serverInfo1.getToken(), Path.of(coverFile.getPath()));
-        String coverFileId = uploadFileRet1.getUploadId();
-
+    public void publishVideoPost(int categoryPid, int categoryId, File coverFile, File videoFile) throws Exception {
         ServerInfo serverInfo2 = getServerInfo("video");
         int channelCode = serverInfo2.getChannelCode();
         UploadFileRet uploadFileRet2 = uploadFilePart(channelCode, serverInfo2.getOssUrl(), serverInfo2.getToken(), Path.of(videoFile.getPath()));
@@ -324,14 +320,12 @@ public class OpenApiClient {
             throw new RuntimeException("post failed: " + webResult.getMsg());
         }
         String videoId = webResult.getData();
+        updateVideoCover(videoId, coverFile);
 
-        int categoryPid = 11;
-        int categoryId = 19;
         int scope = 3;
         String title = videoFile.getName();
         Map<String, Object> map1 = new HashMap<>();
         map1.put("videoId", videoId);
-        map1.put("coverFileId", coverFileId);
         map1.put("title", title);
         map1.put("description", videoFile.getName());
         map1.put("categoryPid", categoryPid);

+ 2 - 2
file/file-service/src/main/java/cn/reghao/tnb/file/app/zdisk/service/CamService.java

@@ -94,8 +94,8 @@ public class CamService {
     private void setSharedCamName(CamDevice camDevice) {
         long createBy = camDevice.getAddBy();
         AccountAvatar accountAvatar = accountQuery.getAccountAvatar(createBy);
-        String username = accountAvatar.getUsername();
-        String albumName = String.format("%s(%s的分享)", camDevice.getCamName(), username);
+        String screenName = accountAvatar.getScreenName();
+        String albumName = String.format("%s(%s的分享)", camDevice.getCamName(), screenName);
         camDevice.setCamName(albumName);
     }
 

+ 4 - 0
file/file-service/src/main/resources/mapper/file/OssConfigMapper.xml

@@ -21,4 +21,8 @@
         where oss_type=#{ossType}
         limit 1
     </select>
+    <select id="findByPage" resultType="cn.reghao.tnb.file.app.model.po.OssConfig">
+        select *
+        from file_oss_config
+    </select>
 </mapper>