diff --git a/compose.yaml b/compose.yaml index 4d2047e..50c66bc 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,10 +1,9 @@ services: mysql: - image: 'mysql:latest' + image: 'mysql:8.0.35' environment: - - 'MYSQL_DATABASE=mydatabase' - - 'MYSQL_PASSWORD=secret' - - 'MYSQL_ROOT_PASSWORD=verysecret' - - 'MYSQL_USER=myuser' + - 'MYSQL_DATABASE=study' + - 'MYSQL_PASSWORD=123123' + - 'MYSQL_ROOT_PASSWORD=123123' ports: - - '3306' + - '3306:3306' diff --git a/src/main/java/com/zsc/edu/bill/framework/security/CustomAccessDeniedHandler.java b/src/main/java/com/zsc/edu/bill/framework/security/CustomAccessDeniedHandler.java index a375f5d..1554010 100644 --- a/src/main/java/com/zsc/edu/bill/framework/security/CustomAccessDeniedHandler.java +++ b/src/main/java/com/zsc/edu/bill/framework/security/CustomAccessDeniedHandler.java @@ -24,8 +24,6 @@ import java.time.LocalDateTime; @Component public class CustomAccessDeniedHandler implements AccessDeniedHandler { - private static final Logger logger = LoggerFactory.getLogger(CustomAccessDeniedHandler.class); - private final ObjectMapper objectMapper; @Override diff --git a/src/main/java/com/zsc/edu/bill/framework/security/JpaUserDetailsServiceImpl.java b/src/main/java/com/zsc/edu/bill/framework/security/JpaUserDetailsServiceImpl.java index 772affc..8f64cee 100644 --- a/src/main/java/com/zsc/edu/bill/framework/security/JpaUserDetailsServiceImpl.java +++ b/src/main/java/com/zsc/edu/bill/framework/security/JpaUserDetailsServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * @author harry_yao @@ -31,10 +32,10 @@ public class JpaUserDetailsServiceImpl implements UserDetailsService { public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepo.selectByUsername(username); - List authorities= roleAuthoritiesReposity.selectByRoleId(user.getRoleId()); - Set authorities1=new HashSet<>(); - authorities.stream().forEach(authority ->authorities1.add(Authority.valueOf(authority.getAuthority()))); - user.role.authorities=authorities1; + List roleAuthorities= roleAuthoritiesReposity.selectByRoleId(user.getRoleId()); + user.role.authorities=roleAuthorities.stream() + .map(i -> Authority.valueOf(i.getAuthority())) + .collect(Collectors.toSet()); @@ -42,7 +43,7 @@ public class JpaUserDetailsServiceImpl implements UserDetailsService { // new UsernameNotFoundException("用户 '" + username + "' 不存在!") // ); // user.getIdentities().stream().filter(identity -> identity.role.enableState == EnableState.启用) -// .forEach(identity -> Hibernate.initialize(identity.role.authorities)); +// .forEach(identity -> Hibernate.initialize(identity.role.roleAuthorities)); return UserDetailsImpl.from(user); } } diff --git a/src/main/java/com/zsc/edu/bill/framework/security/UserDetailsImpl.java b/src/main/java/com/zsc/edu/bill/framework/security/UserDetailsImpl.java index ba83852..52bc2f0 100644 --- a/src/main/java/com/zsc/edu/bill/framework/security/UserDetailsImpl.java +++ b/src/main/java/com/zsc/edu/bill/framework/security/UserDetailsImpl.java @@ -34,7 +34,6 @@ public class UserDetailsImpl implements UserDetails { public Set authorities; public static UserDetailsImpl from(User user) { - Set authorities = user.role.authorities; return new UserDetailsImpl( user.id, user.username, @@ -42,7 +41,7 @@ public class UserDetailsImpl implements UserDetails { user.enabled, user.dept, user.role, - authorities + user.role.authorities ); } diff --git a/src/main/java/com/zsc/edu/bill/modules/bills/query/BillQuery.java b/src/main/java/com/zsc/edu/bill/modules/bills/query/BillQuery.java index 8a12017..976aec9 100644 --- a/src/main/java/com/zsc/edu/bill/modules/bills/query/BillQuery.java +++ b/src/main/java/com/zsc/edu/bill/modules/bills/query/BillQuery.java @@ -11,6 +11,7 @@ import lombok.NoArgsConstructor; import org.springframework.util.StringUtils; import java.math.BigDecimal; +import java.util.Objects; /** * @author ftz @@ -56,16 +57,19 @@ public class BillQuery { */ private String companyName; - + /** + * 拼接查询条件 + * @return + */ public LambdaQueryWrapper wrapper() { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(StringUtils.hasText(this.uuid), Bill::getUuid, this.uuid); - queryWrapper.eq(StringUtils.hasText(String.valueOf(this.userId)), Bill::getUserId, this.userId); - queryWrapper.eq(StringUtils.hasText(this.title), Bill::getTitle, this.title); - queryWrapper.eq(StringUtils.hasText(String.valueOf(this.money)), Bill::getMoney, this.money); - queryWrapper.eq(StringUtils.hasText(String.valueOf(this.status)), Bill::getStatus, this.status); - queryWrapper.eq(StringUtils.hasText(String.valueOf(this.type)), Bill::getType, this.type); - queryWrapper.eq(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName); + queryWrapper.eq(Objects.nonNull(this.userId), Bill::getUserId, this.userId); + queryWrapper.like(StringUtils.hasText(this.title), Bill::getTitle, this.title); + queryWrapper.eq(Objects.nonNull(this.money), Bill::getMoney, this.money); + queryWrapper.eq(Objects.nonNull(this.status), Bill::getStatus, this.status); + queryWrapper.like(Objects.nonNull(this.type), Bill::getType, this.type); + queryWrapper.like(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName); return queryWrapper; } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4b7b289..2e1c2a1 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -9,7 +9,7 @@ mybatis-plus: spring: datasource: - url: jdbc:mysql://59.110.238.182:3306/study?useSSL=false&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true&characterEncoding=utf8&serverTimezone=Hongkong + url: jdbc:mysql://localhost:3306/study?useSSL=false&allowPublicKeyRetrieval=true&createDatabaseIfNotExist=true&characterEncoding=utf8&serverTimezone=Hongkong username: root - password: 2002 + password: 123123 driver-class-name: com.mysql.cj.jdbc.Driver \ No newline at end of file