feat: 添加Category_attribute实体类和仓库接口

refactor(security): 限制文章更新仅限AUTHOR角色
修改ArticleController的updateArticle方法权限,移除ADMIN角色访问权限

chore: 更新application.properties中的Redis配置
取消注释Redis相关配置,包括缓存和连接池设置
This commit is contained in:
qingfeng1121
2025-10-16 16:12:19 +08:00
parent 2809837422
commit 8cc4c1da1d
5 changed files with 32 additions and 20 deletions

View File

@@ -2045,3 +2045,7 @@ This generated password is for development use only. Your security configuration
2025-10-12 14:20:56 [http-nio-8080-exec-4] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2] 2025-10-12 14:20:56 [http-nio-8080-exec-4] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2]
2025-10-12 14:21:20 [http-nio-8080-exec-6] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2] 2025-10-12 14:21:20 [http-nio-8080-exec-6] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2]
2025-10-12 14:21:26 [http-nio-8080-exec-8] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2] 2025-10-12 14:21:26 [http-nio-8080-exec-8] TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [2]
2025-10-12 18:34:45 [WebProjectHikariCP housekeeper] WARN com.zaxxer.hikari.pool.HikariPool - WebProjectHikariCP - Thread starvation or clock leap detected (housekeeper delta=30m35s799ms914µs800ns).
2025-10-12 20:00:33 [SpringApplicationShutdownHook] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2025-10-12 20:00:33 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - WebProjectHikariCP - Shutdown initiated...
2025-10-12 20:00:33 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - WebProjectHikariCP - Shutdown completed.

View File

@@ -57,13 +57,13 @@ public class ArticleController {
/** /**
* 更新现有文章 * 更新现有文章
* 仅限AUTHOR或ADMIN角色用户访问 * 仅限AUTHOR角色用户访问
* @param id 要更新的文章ID * @param id 要更新的文章ID
* @param articleDto 包含更新后文章数据的DTO对象 * @param articleDto 包含更新后文章数据的DTO对象
* @return 返回包含更新后文章信息的ResponseMessage对象 * @return 返回包含更新后文章信息的ResponseMessage对象
*/ */
@PutMapping("/{id}") @PutMapping("/{id}")
@PreAuthorize("hasRole('AUTHOR') or hasRole('ADMIN')") @PreAuthorize("hasRole('AUTHOR')")
public ResponseMessage<Article> updateArticle( public ResponseMessage<Article> updateArticle(
@PathVariable Integer id, @PathVariable Integer id,
@Valid @RequestBody ArticleDto articleDto) { @Valid @RequestBody ArticleDto articleDto) {

View File

@@ -0,0 +1,4 @@
package com.qf.myafterprojecy.pojo;
public class category_attribute {
}

View File

@@ -0,0 +1,4 @@
package com.qf.myafterprojecy.repository;
public interface Category_attribute {
}

View File

@@ -31,25 +31,25 @@ spring.jpa.properties.hibernate.order_updates=true
# spring.jpa.properties.hibernate.cache.use_second_level_cache=true # spring.jpa.properties.hibernate.cache.use_second_level_cache=true
# spring.jpa.properties.hibernate.cache.use_query_cache=true # spring.jpa.properties.hibernate.cache.use_query_cache=true
# 缓存配置 缓存配置
# spring.cache.type=redis spring.cache.type=redis
# spring.cache.redis.time-to-live=1800000 spring.cache.redis.time-to-live=1800000
# spring.cache.redis.key-prefix=CACHE_ spring.cache.redis.key-prefix=CACHE_
# spring.cache.redis.use-key-prefix=true spring.cache.redis.use-key-prefix=true
# spring.cache.redis.cache-null-values=false spring.cache.redis.cache-null-values=false
# Redis配置 Redis配置
# spring.redis.host=localhost spring.redis.host=localhost
# spring.redis.port=6379 spring.redis.port=6379
# spring.redis.password=123456 spring.redis.password=123456
# spring.redis.database=0 spring.redis.database=0
# spring.redis.timeout=10000ms spring.redis.timeout=10000ms
# Redis连接池优化配置 Redis连接池优化配置
#spring.redis.lettuce.pool.max-active=8 spring.redis.lettuce.pool.max-active=8
#spring.redis.lettuce.pool.max-wait=10000ms spring.redis.lettuce.pool.max-wait=10000ms
#spring.redis.lettuce.pool.max-idle=8 spring.redis.lettuce.pool.max-idle=8
#spring.redis.lettuce.pool.min-idle=2 spring.redis.lettuce.pool.min-idle=2
#spring.redis.lettuce.shutdown-timeout=100ms spring.redis.lettuce.shutdown-timeout=100ms
# 日志配置 # 日志配置
logging.level.root=INFO logging.level.root=INFO