Commit bbf5444a by gonglei

加入框架代码

1 parent 4d8f9682
......@@ -112,7 +112,6 @@ public class AuctionController {
@PostMapping("pageRandomAuctionVehicle")
public Page<AuctionVehicle> pageRandomAuctionVehicle(@RequestBody Pagination<AuctionVehicle> pagination, @RequestAttribute(value = LOGIN_ACCOUNT, required = false) Account account) {
pagination.addFetch(root -> root.fetch(AuctionVehicle_.vehicle, JoinType.LEFT));
pagination.addFetch(root -> root.fetch(AuctionVehicle_.auction, JoinType.LEFT));
String cityCode = (String) pagination.getDataValue("cities");
// 已审核的拍卖场次
......@@ -125,6 +124,7 @@ public class AuctionController {
if (CollectionUtils.isEmpty(accountTags)) {
pagination.addFilter(Auction.AccessScope.GLOBAL, AuctionVehicle_.auction, Auction_.accessScope);
pagination.addCondition((root, query, builder) -> {
// root.fetch(AuctionVehicle_.auction, JoinType.LEFT);
Expression<Double> randomExp = builder.function("RAND", Double.class); // MySQL 用 RAND()
if (StringUtils.hasText(cityCode)) {
CriteriaBuilder.Case<Number> caseExpr = builder.selectCase();
......@@ -138,6 +138,7 @@ public class AuctionController {
} else {
List<AccountTag> finalAccountTags = accountTags;
pagination.addCondition((root, query, builder) -> {
// root.fetch(AuctionVehicle_.auction, JoinType.LEFT);
// 关联AccountTag(左连接,确保有角色关联的用户被筛选)
Join auctionJoin = root.join(AuctionVehicle_.auction, JoinType.LEFT);
Join<Auction, AccountTag> tagsJoin = auctionJoin.join(Auction_.accountTags, JoinType.LEFT);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!