feat: 开发中...
This commit is contained in:
@@ -35,6 +35,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
}
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
context.setAuthentication(authentication);
|
||||
log.info("set authentication info to security context: {}", authentication);
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
|
@@ -40,8 +40,9 @@ public class BlogExceptionHandler {
|
||||
|
||||
@ExceptionHandler(NestedRuntimeException.class)
|
||||
public ResponseVO<String> onNestedRuntimeException(NestedRuntimeException e) {
|
||||
if (e.getRootCause() != null) {
|
||||
if (e.getRootCause() instanceof ConstraintViolationException ve) {
|
||||
Throwable rootCause = e.getRootCause();
|
||||
if (rootCause != null) {
|
||||
if (rootCause instanceof ConstraintViolationException ve) {
|
||||
return ResponseVO.failed(ve.getConstraintViolations()
|
||||
.stream()
|
||||
.findFirst()
|
||||
@@ -49,7 +50,7 @@ public class BlogExceptionHandler {
|
||||
.orElse("未知错误!")
|
||||
);
|
||||
}
|
||||
return ResponseVO.failed(e.getRootCause().getMessage());
|
||||
return ResponseVO.failed(rootCause.getMessage());
|
||||
}
|
||||
return ResponseVO.failed(e.getMessage());
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import cn.hamster3.application.blog.entity.UserEntity;
|
||||
import cn.hamster3.application.blog.entity.repo.UserRepository;
|
||||
import cn.hamster3.application.blog.util.BlogUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -12,7 +11,6 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class UserAuditorAware implements AuditorAware<UserEntity> {
|
||||
@Resource
|
||||
|
@@ -3,6 +3,8 @@ package cn.hamster3.application.blog.entity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -33,6 +35,7 @@ public class AttachEntity {
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
@Column(name = "data")
|
||||
@JdbcTypeCode(SqlTypes.LONG32VARBINARY)
|
||||
private byte[] data;
|
||||
|
||||
@CreatedBy
|
||||
|
@@ -2,6 +2,9 @@ package cn.hamster3.application.blog.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -20,9 +23,19 @@ public class BlogAttachEntity {
|
||||
@Column(name = "id", nullable = false, updatable = false)
|
||||
private Long id;
|
||||
|
||||
@Setter
|
||||
@Column(name = "name", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Setter
|
||||
@Column(name = "content_type", nullable = false)
|
||||
private String contentType;
|
||||
|
||||
@Setter
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
@Column(name = "data", nullable = false)
|
||||
@Column(name = "data")
|
||||
@JdbcTypeCode(SqlTypes.LONG32VARBINARY)
|
||||
private byte[] data;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
|
@@ -13,6 +13,7 @@ import java.util.UUID;
|
||||
|
||||
public interface AttachRepository extends JpaRepository<AttachEntity, Long>, JpaSpecificationExecutor<AttachEntity> {
|
||||
boolean existsByIdAndCreator_Id(Long id, UUID id1);
|
||||
|
||||
@Query("select a from AttachEntity a where a.id = ?1")
|
||||
AttachEntity findByIdWithContent(Long id);
|
||||
|
||||
|
@@ -45,10 +45,7 @@ public class SettingService implements ISettingService {
|
||||
|
||||
@Override
|
||||
public @NotNull ResponseVO<PageableVO<SettingInfoResponseVO>> getSettingInfoList(@NotNull Pageable pageable) {
|
||||
return PageableVO.success(
|
||||
settingRepo.findAll(pageable)
|
||||
.map(o -> settingMapper.entityToInfoVO(o))
|
||||
);
|
||||
return PageableVO.success(settingRepo.findAll(pageable).map(o -> settingMapper.entityToInfoVO(o)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +72,7 @@ public class SettingService implements ISettingService {
|
||||
if (check != null) {
|
||||
return check;
|
||||
}
|
||||
log.info("prepare update setting: {}", data);
|
||||
for (Map.Entry<String, String> entry : data.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
String content = entry.getValue();
|
||||
@@ -99,6 +97,7 @@ public class SettingService implements ISettingService {
|
||||
if (!settingRepo.existsByIdIgnoreCase(id)) {
|
||||
return ResponseVO.notFound();
|
||||
}
|
||||
log.info("prepare delete setting by id: {}", id);
|
||||
settingRepo.deleteByIdIgnoreCase(id);
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.hamster3.application.blog.vo.blog;
|
||||
|
||||
import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
@@ -5,7 +5,6 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@Data
|
||||
|
Reference in New Issue
Block a user