From ee99654e7cb5070f1ebd16a4880c947c2d2816bb Mon Sep 17 00:00:00 2001 From: Hanserwei <2628273921@qq.com> Date: Wed, 15 Oct 2025 19:31:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core):=E4=BC=98=E5=8C=96=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=AE=9E=E7=8E=B0=E7=B1=BB=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整了多个服务实现类中的 import 语句顺序- 移除了未使用的注解和依赖注入相关导入 - 统一了 MyBatis 注解的导入方式-优化了数据源配置类中的 DataSource 导入位置 - 移除了过滤器中不必要的 Component 注解- 简化了部分重复的代码结构以提升可读性 --- .../hannote/count/biz/service/NoteCountDOService.java | 2 +- .../hannote/count/biz/service/UserCountDOService.java | 2 +- .../count/biz/service/impl/NoteCountDOServiceImpl.java | 4 +--- .../count/biz/service/impl/UserCountDOServiceImpl.java | 6 ++---- .../generator/biz/config/LeafDataSourceConfiguration.java | 3 ++- .../id/generator/biz/core/segment/dao/IDAllocMapper.java | 7 +------ .../note/biz/service/impl/NoteCollectionDOServiceImpl.java | 7 +++---- .../hannote/user/relation/biz/service/FansDOService.java | 2 +- .../user/relation/biz/service/FollowingDOService.java | 2 +- .../user/relation/biz/service/impl/FansDOServiceImpl.java | 4 +--- .../relation/biz/service/impl/FollowingDOServiceImpl.java | 6 ++---- .../biz/context/filter/HeaderUserId2ContextFilter.java | 1 - 12 files changed, 16 insertions(+), 30 deletions(-) diff --git a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/NoteCountDOService.java b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/NoteCountDOService.java index a94df71..669dc98 100644 --- a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/NoteCountDOService.java +++ b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/NoteCountDOService.java @@ -1,7 +1,7 @@ package com.hanserwei.hannote.count.biz.service; -import com.hanserwei.hannote.count.biz.domain.dataobject.NoteCountDO; import com.baomidou.mybatisplus.extension.service.IService; +import com.hanserwei.hannote.count.biz.domain.dataobject.NoteCountDO; public interface NoteCountDOService extends IService{ diff --git a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/UserCountDOService.java b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/UserCountDOService.java index d98c596..c2165fa 100644 --- a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/UserCountDOService.java +++ b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/UserCountDOService.java @@ -1,7 +1,7 @@ package com.hanserwei.hannote.count.biz.service; -import com.hanserwei.hannote.count.biz.domain.dataobject.UserCountDO; import com.baomidou.mybatisplus.extension.service.IService; +import com.hanserwei.hannote.count.biz.domain.dataobject.UserCountDO; public interface UserCountDOService extends IService{ diff --git a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/NoteCountDOServiceImpl.java b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/NoteCountDOServiceImpl.java index 778005e..c686dc8 100644 --- a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/NoteCountDOServiceImpl.java +++ b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/NoteCountDOServiceImpl.java @@ -1,12 +1,10 @@ package com.hanserwei.hannote.count.biz.service.impl; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hanserwei.hannote.count.biz.domain.dataobject.NoteCountDO; import com.hanserwei.hannote.count.biz.domain.mapper.NoteCountDOMapper; import com.hanserwei.hannote.count.biz.service.NoteCountDOService; +import org.springframework.stereotype.Service; @Service public class NoteCountDOServiceImpl extends ServiceImpl implements NoteCountDOService{ diff --git a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/UserCountDOServiceImpl.java b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/UserCountDOServiceImpl.java index 0473a46..08fc3ce 100644 --- a/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/UserCountDOServiceImpl.java +++ b/han-note-count/han-note-count-biz/src/main/java/com/hanserwei/hannote/count/biz/service/impl/UserCountDOServiceImpl.java @@ -1,12 +1,10 @@ package com.hanserwei.hannote.count.biz.service.impl; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hanserwei.hannote.count.biz.domain.mapper.UserCountDOMapper; import com.hanserwei.hannote.count.biz.domain.dataobject.UserCountDO; +import com.hanserwei.hannote.count.biz.domain.mapper.UserCountDOMapper; import com.hanserwei.hannote.count.biz.service.UserCountDOService; +import org.springframework.stereotype.Service; @Service public class UserCountDOServiceImpl extends ServiceImpl implements UserCountDOService{ diff --git a/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/config/LeafDataSourceConfiguration.java b/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/config/LeafDataSourceConfiguration.java index 0adf6c4..5cf254d 100644 --- a/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/config/LeafDataSourceConfiguration.java +++ b/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/config/LeafDataSourceConfiguration.java @@ -2,7 +2,6 @@ package com.hanserwei.hannote.distributed.id.generator.biz.config; import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceBuilder; import jakarta.annotation.PostConstruct; -import javax.sql.DataSource; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -11,6 +10,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.util.StringUtils; +import javax.sql.DataSource; + @Slf4j @Configuration @RequiredArgsConstructor diff --git a/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/core/segment/dao/IDAllocMapper.java b/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/core/segment/dao/IDAllocMapper.java index cd66df2..f2c57d6 100644 --- a/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/core/segment/dao/IDAllocMapper.java +++ b/han-note-distributed-id-generator/han-note-distributed-id-generator-biz/src/main/java/com/hanserwei/hannote/distributed/id/generator/biz/core/segment/dao/IDAllocMapper.java @@ -1,12 +1,7 @@ package com.hanserwei.hannote.distributed.id.generator.biz.core.segment.dao; import com.hanserwei.hannote.distributed.id.generator.biz.core.segment.model.LeafAlloc; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Result; -import org.apache.ibatis.annotations.Results; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.*; import java.util.List; diff --git a/han-note-note/han-note-note-biz/src/main/java/com/hanserwei/hannote/note/biz/service/impl/NoteCollectionDOServiceImpl.java b/han-note-note/han-note-note-biz/src/main/java/com/hanserwei/hannote/note/biz/service/impl/NoteCollectionDOServiceImpl.java index 77c8f04..95fc0bc 100644 --- a/han-note-note/han-note-note-biz/src/main/java/com/hanserwei/hannote/note/biz/service/impl/NoteCollectionDOServiceImpl.java +++ b/han-note-note/han-note-note-biz/src/main/java/com/hanserwei/hannote/note/biz/service/impl/NoteCollectionDOServiceImpl.java @@ -1,13 +1,12 @@ package com.hanserwei.hannote.note.biz.service.impl; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hanserwei.hannote.note.biz.domain.dataobject.NoteCollectionDO; import com.hanserwei.hannote.note.biz.domain.mapper.NoteCollectionDOMapper; import com.hanserwei.hannote.note.biz.service.NoteCollectionDOService; +import org.springframework.stereotype.Service; + @Service -public class NoteCollectionDOServiceImpl extends ServiceImpl implements NoteCollectionDOService{ +public class NoteCollectionDOServiceImpl extends ServiceImpl implements NoteCollectionDOService { } diff --git a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FansDOService.java b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FansDOService.java index c54aaa7..bfddabb 100644 --- a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FansDOService.java +++ b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FansDOService.java @@ -1,7 +1,7 @@ package com.hanserwei.hannote.user.relation.biz.service; -import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FansDO; import com.baomidou.mybatisplus.extension.service.IService; +import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FansDO; public interface FansDOService extends IService{ diff --git a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FollowingDOService.java b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FollowingDOService.java index 9fa027f..e145039 100644 --- a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FollowingDOService.java +++ b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/FollowingDOService.java @@ -1,7 +1,7 @@ package com.hanserwei.hannote.user.relation.biz.service; -import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FollowingDO; import com.baomidou.mybatisplus.extension.service.IService; +import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FollowingDO; public interface FollowingDOService extends IService{ diff --git a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FansDOServiceImpl.java b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FansDOServiceImpl.java index 8a33a69..ba25744 100644 --- a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FansDOServiceImpl.java +++ b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FansDOServiceImpl.java @@ -1,12 +1,10 @@ package com.hanserwei.hannote.user.relation.biz.service.impl; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FansDO; import com.hanserwei.hannote.user.relation.biz.domain.mapper.FansDOMapper; import com.hanserwei.hannote.user.relation.biz.service.FansDOService; +import org.springframework.stereotype.Service; @Service public class FansDOServiceImpl extends ServiceImpl implements FansDOService{ diff --git a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FollowingDOServiceImpl.java b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FollowingDOServiceImpl.java index d9b15df..164702b 100644 --- a/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FollowingDOServiceImpl.java +++ b/han-note-user-relation/han-note-user-relation-biz/src/main/java/com/hanserwei/hannote/user/relation/biz/service/impl/FollowingDOServiceImpl.java @@ -1,12 +1,10 @@ package com.hanserwei.hannote.user.relation.biz.service.impl; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hanserwei.hannote.user.relation.biz.domain.mapper.FollowingDOMapper; import com.hanserwei.hannote.user.relation.biz.domain.dataobject.FollowingDO; +import com.hanserwei.hannote.user.relation.biz.domain.mapper.FollowingDOMapper; import com.hanserwei.hannote.user.relation.biz.service.FollowingDOService; +import org.springframework.stereotype.Service; @Service public class FollowingDOServiceImpl extends ServiceImpl implements FollowingDOService{ diff --git a/hanserwei-framework/hanserwei-spring-boot-starter-biz-context/src/main/java/com/hanserwei/framework/biz/context/filter/HeaderUserId2ContextFilter.java b/hanserwei-framework/hanserwei-spring-boot-starter-biz-context/src/main/java/com/hanserwei/framework/biz/context/filter/HeaderUserId2ContextFilter.java index fcfe06f..6f6bcaa 100644 --- a/hanserwei-framework/hanserwei-spring-boot-starter-biz-context/src/main/java/com/hanserwei/framework/biz/context/filter/HeaderUserId2ContextFilter.java +++ b/hanserwei-framework/hanserwei-spring-boot-starter-biz-context/src/main/java/com/hanserwei/framework/biz/context/filter/HeaderUserId2ContextFilter.java @@ -8,7 +8,6 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; import java.io.IOException;