fix(feature/bill): 修复分页查询错误
This commit is contained in:
parent
f0b1b1bfe6
commit
21e6a1c05e
11
compose.yaml
11
compose.yaml
@ -1,10 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: 'mysql:latest'
|
image: 'mysql:8.0.35'
|
||||||
environment:
|
environment:
|
||||||
- 'MYSQL_DATABASE=mydatabase'
|
- 'MYSQL_DATABASE=study'
|
||||||
- 'MYSQL_PASSWORD=secret'
|
- 'MYSQL_PASSWORD=123123'
|
||||||
- 'MYSQL_ROOT_PASSWORD=verysecret'
|
- 'MYSQL_ROOT_PASSWORD=123123'
|
||||||
- 'MYSQL_USER=myuser'
|
|
||||||
ports:
|
ports:
|
||||||
- '3306'
|
- '3306:3306'
|
||||||
|
@ -24,8 +24,6 @@ import java.time.LocalDateTime;
|
|||||||
@Component
|
@Component
|
||||||
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
|
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CustomAccessDeniedHandler.class);
|
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author harry_yao
|
* @author harry_yao
|
||||||
@ -31,10 +32,10 @@ public class JpaUserDetailsServiceImpl implements UserDetailsService {
|
|||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
User user = userRepo.selectByUsername(username);
|
User user = userRepo.selectByUsername(username);
|
||||||
|
|
||||||
List<RoleAuthority> authorities= roleAuthoritiesReposity.selectByRoleId(user.getRoleId());
|
List<RoleAuthority> roleAuthorities= roleAuthoritiesReposity.selectByRoleId(user.getRoleId());
|
||||||
Set<Authority> authorities1=new HashSet<>();
|
user.role.authorities=roleAuthorities.stream()
|
||||||
authorities.stream().forEach(authority ->authorities1.add(Authority.valueOf(authority.getAuthority())));
|
.map(i -> Authority.valueOf(i.getAuthority()))
|
||||||
user.role.authorities=authorities1;
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class JpaUserDetailsServiceImpl implements UserDetailsService {
|
|||||||
// new UsernameNotFoundException("用户 '" + username + "' 不存在!")
|
// new UsernameNotFoundException("用户 '" + username + "' 不存在!")
|
||||||
// );
|
// );
|
||||||
// user.getIdentities().stream().filter(identity -> identity.role.enableState == EnableState.启用)
|
// 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);
|
return UserDetailsImpl.from(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ public class UserDetailsImpl implements UserDetails {
|
|||||||
public Set<Authority> authorities;
|
public Set<Authority> authorities;
|
||||||
|
|
||||||
public static UserDetailsImpl from(User user) {
|
public static UserDetailsImpl from(User user) {
|
||||||
Set<Authority> authorities = user.role.authorities;
|
|
||||||
return new UserDetailsImpl(
|
return new UserDetailsImpl(
|
||||||
user.id,
|
user.id,
|
||||||
user.username,
|
user.username,
|
||||||
@ -42,7 +41,7 @@ public class UserDetailsImpl implements UserDetails {
|
|||||||
user.enabled,
|
user.enabled,
|
||||||
user.dept,
|
user.dept,
|
||||||
user.role,
|
user.role,
|
||||||
authorities
|
user.role.authorities
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ftz
|
* @author ftz
|
||||||
@ -56,16 +57,19 @@ public class BillQuery {
|
|||||||
*/
|
*/
|
||||||
private String companyName;
|
private String companyName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼接查询条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public LambdaQueryWrapper<Bill> wrapper() {
|
public LambdaQueryWrapper<Bill> wrapper() {
|
||||||
LambdaQueryWrapper<Bill> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Bill> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(StringUtils.hasText(this.uuid), Bill::getUuid, this.uuid);
|
queryWrapper.eq(StringUtils.hasText(this.uuid), Bill::getUuid, this.uuid);
|
||||||
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.userId)), Bill::getUserId, this.userId);
|
queryWrapper.eq(Objects.nonNull(this.userId), Bill::getUserId, this.userId);
|
||||||
queryWrapper.eq(StringUtils.hasText(this.title), Bill::getTitle, this.title);
|
queryWrapper.like(StringUtils.hasText(this.title), Bill::getTitle, this.title);
|
||||||
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.money)), Bill::getMoney, this.money);
|
queryWrapper.eq(Objects.nonNull(this.money), Bill::getMoney, this.money);
|
||||||
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.status)), Bill::getStatus, this.status);
|
queryWrapper.eq(Objects.nonNull(this.status), Bill::getStatus, this.status);
|
||||||
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.type)), Bill::getType, this.type);
|
queryWrapper.like(Objects.nonNull(this.type), Bill::getType, this.type);
|
||||||
queryWrapper.eq(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName);
|
queryWrapper.like(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName);
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ mybatis-plus:
|
|||||||
|
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
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
|
username: root
|
||||||
password: 2002
|
password: 123123
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
Loading…
Reference in New Issue
Block a user