feat(backend): Improve tag management and media resource access
This commit is contained in:
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authorization.AuthorizationDecision;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
@@ -53,6 +54,18 @@ public class SecurityConfig {
|
||||
"/content/category/admin/**"
|
||||
).access((authentication, context) ->
|
||||
new AuthorizationDecision(isInternalRequest(context.getRequest().getHeader("X-Internal-Token"))))
|
||||
.requestMatchers(
|
||||
HttpMethod.POST, "/content/tag"
|
||||
).access((authentication, context) ->
|
||||
new AuthorizationDecision(isInternalRequest(context.getRequest().getHeader("X-Internal-Token"))))
|
||||
.requestMatchers(
|
||||
HttpMethod.PUT, "/content/tag"
|
||||
).access((authentication, context) ->
|
||||
new AuthorizationDecision(isInternalRequest(context.getRequest().getHeader("X-Internal-Token"))))
|
||||
.requestMatchers(
|
||||
HttpMethod.DELETE, "/content/tag/*"
|
||||
).access((authentication, context) ->
|
||||
new AuthorizationDecision(isInternalRequest(context.getRequest().getHeader("X-Internal-Token"))))
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
+8
-1
@@ -88,6 +88,13 @@ public class TagController {
|
||||
if (userIdObj instanceof Long) {
|
||||
return (Long) userIdObj;
|
||||
}
|
||||
String userIdHeader = request.getHeader("userId");
|
||||
if (userIdHeader != null && !userIdHeader.isBlank()) {
|
||||
try {
|
||||
return Long.parseLong(userIdHeader);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -62,7 +62,14 @@ public class VideoController {
|
||||
@GetMapping("/public/{id}")
|
||||
public Result<VideoInfoVO> getVideoInfoPublic(@PathVariable Long id, HttpServletRequest request) {
|
||||
Long userId = getUserIdFromRequest(request);
|
||||
return videoService.getVideoInfo(id, userId);
|
||||
Result<VideoInfoVO> result = videoService.getVideoInfo(id, userId);
|
||||
if (result.getData() == null) {
|
||||
return result;
|
||||
}
|
||||
if (result.getData().getPublishTime() == null) {
|
||||
return Result.error("视频暂未公开");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,6 +53,11 @@ public class VideoListVO implements Serializable {
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 视频状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@@ -82,4 +87,4 @@ public class VideoListVO implements Serializable {
|
||||
* 发布时间
|
||||
*/
|
||||
private LocalDateTime publishTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user