自定义joinQueryWrapper实现

This commit is contained in:
张松
2025-02-20 14:18:32 +08:00
parent c4f0c9e6d4
commit d8935700f2
4 changed files with 82 additions and 4 deletions

View File

@@ -13,5 +13,5 @@ import com.mybatisflex.core.paginate.Page;
*/
public interface PadProductCategoryDetailMapper extends BaseMapper<PadProductCategoryDetail> {
Page<PadProductCategoryDTO> selectPageByKeyAndShopId();
Page<PadProductCategoryDTO> selectPageByKeyAndShopId_COUNT();
long selectPageByKeyAndShopId_COUNT();
}

View File

@@ -6,8 +6,11 @@ import com.czg.account.service.*;
import com.czg.enums.StatusEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.service.account.mapper.PadProductCategoryDetailMapper;
import com.czg.utils.JoinQueryWrapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.LambdaUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -32,12 +35,17 @@ public class PadProdServiceImpl implements PadProdService {
@Resource
private PadProductCategoryDetailService padProductCategoryDetailService;
void main() {
LambdaUtil.getQueryColumn(SysUser::getId).getName();
// new QueryWrapper().eq()
}
@Override
public Page<PadProductCategoryDTO> pageInfo(Page<PadProductCategoryDTO> objectPage, Long productCategoryId, Long shopId) {
QueryWrapper queryWrapper = new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, shopId);
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(PadProductCategory::getShopId, shopId);
if (productCategoryId != null) {
queryWrapper.eq(PadProductCategoryDetail::getPadProductCategoryId, productCategoryId);
queryWrapper.eq(PadProductCategory::getId, productCategoryId);
}
queryWrapper.orderBy(PadProductCategory::getSort, true).orderBy(PadProductCategory::getId, false);
return padProductCategoryDetailMapper.xmlPaginate("selectPageByKeyAndShopId", objectPage, queryWrapper);
}
@@ -72,6 +80,7 @@ public class PadProdServiceImpl implements PadProdService {
PadProductCategory padProductCategory = new PadProductCategory().setPadLayoutId(padDetailAddDTO.getPadLayoutId()).setProductCategoryId(padDetailAddDTO.getProductCategoryId())
.setShopId(shopId);
padProductCategory.setSort(0);
padProductCategoryService.save(padProductCategory);
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();

View File

@@ -20,7 +20,7 @@
${qwSql}
limit ${pageOffset}, ${pageSize}
</select>
<select id="selectPageByKeyAndShopId_COUNT" resultType="com.czg.account.dto.pad.PadProductCategoryDTO">
<select id="selectPageByKeyAndShopId_COUNT" resultType="java.lang.Long">
SELECT count(1)
FROM tb_pad_product_category
LEFT JOIN tb_pad_product_category_detail