fix: 修复RoleRepository查询方法

- 重命名findByRoleCodeAndDeletedFalse为findByRoleCodeAndDeleted
- 移除@Query注解,使用Spring Data JPA标准方法命名
- 修复RoleService中的调用

历史遗留问题:
- SchemaVerificationTest仍有其他问题(可能与测试配置有关)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-03-06 15:10:41 +08:00
parent 4e3296228f
commit 057130d626
2 changed files with 2 additions and 5 deletions

View File

@@ -1,8 +1,6 @@
package com.mosquito.project.permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@@ -26,6 +24,5 @@ public interface RoleRepository extends JpaRepository<SysRole, Long> {
/**
* 根据角色代码查询(排除已删除)
*/
@Query("SELECT r FROM SysRole r WHERE r.roleCode = :roleCode AND r.deleted = 0")
Optional<SysRole> findByRoleCodeAndDeletedFalse(@Param("roleCode") String roleCode);
Optional<SysRole> findByRoleCodeAndDeleted(String roleCode, Integer deleted);
}

View File

@@ -40,7 +40,7 @@ public class RoleService {
*/
@Transactional(readOnly = true)
public Optional<SysRole> findByRoleCode(String roleCode) {
return roleRepository.findByRoleCodeAndDeletedFalse(roleCode);
return roleRepository.findByRoleCodeAndDeleted(roleCode, 0);
}
/**