关于使用Mybatis-Plus中返回值类型与继承Service中泛型类型不一致的问题

今天遇到了一个问题,就是我使用开发框架自动生成了有关于数据库表中的数据(全部属性)的controller,service,Impl之类的,都是有关于数据库的表的实体类,但是我要传输的条件,和我要返回的条件不是数据库的那个实体类
需求:一个对应数据库中所有属性的实体类,一个输入的实体类,一个输出的实体类,完成分页查询

controller

public R getBigOthNppReportPageSimple(Page page, BigOthNppReport bigOthNppReport) {
		IPage<BigOthNppReportSimple> bigOthNppReportPageSimple = bigOthNppReportService.getBigOthNppReportPageSimple(page, bigOthNppReport);
		return R.ok(bigOthNppReportPageSimple);
	}

service

IPage<BigOthNppReportSimple> getBigOthNppReportPageSimple(Page page, BigOthNppReport bigOthNppReport);

Impl

public IPage<BigOthNppReportSimple> getBigOthNppReportPageSimple(Page page, BigOthNppReport bigOthNppReport) {

		Page<BigOthNppReport> page1 = new Page<>(page.getCurrent(), page.getSize());
		LambdaQueryWrapper<BigOthNppReport> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(Objects.nonNull(bigOthNppReport.getRptNd()),BigOthNppReport::getRptNd,bigOthNppReport.getRptNd())
				.like(StrUtil.isNotBlank(bigOthNppReport.getPublishOrg()),BigOthNppReport::getPublishOrg,bigOthNppReport.getPublishOrg())
				.like(StrUtil.isNotBlank(bigOthNppReport.getNppOrg()),BigOthNppReport::getNppOrg,bigOthNppReport.getNppOrg())
				.orderByDesc(BigOthNppReport::getId);
		Page<BigOthNppReport> pageList = page(page1, wrapper);

		return pageList.convert(item -> BigOthNppReportSimple.builder()
				.id(item.getId())
				.rptNd(item.getRptNd())
				.no(item.getNo())
				.theme(item.getTheme())
				.publishOrg(item.getPublishOrg())
				.nppOrg(item.getNppOrg())
				.crewNo(item.getCrewNo())
				.reportDate(item.getReportDate())
				.writeName(item.getWriteName())
				.writeTime(item.getWriteTime())
				.flag(item.getFlag())
				.build());
	}
Page<ProductCertificate> page = new Page<>(ibo.getPageIndex(), ibo.getPageSize());
  LambdaQueryWrapper<ProductCertificate> wrapper = new LambdaQueryWrapper<>();
  wrapper.eq(ProductCertificate::getType, ibo.getType())
    .like(StrUtil.isNotBlank(ibo.getNumber()),ProductCertificate::getNumber, ibo.getNumber())
    .eq(Objects.nonNull(ibo.getFactoryId()), ProductCertificate::getFactoryId, ibo.getFactoryId())
    .like(StrUtil.isNotBlank(ibo.getUploadFileName()), ProductCertificate::getUploadFileName,ibo.getUploadFileName())
    .like(StrUtil.isNotBlank(ibo.getName()), ProductCertificate::getName,ibo.getName())
    .eq(Objects.nonNull(ibo.getSupplierId()), ProductCertificate::getSupplierId,ibo.getSupplierId())
    .between(madeStartDateFlag && madeEndDateFlag, ProductCertificate::getMadeDate,madeStartDate,madeEndDate)
    .like(StrUtil.isNotBlank(ibo.getLicense()), ProductCertificate::getLicense, ibo.getLicense())
    .ge(beginDateFlag, ProductCertificate::getBeginDate, ibo.getBeginDate())
    .le(validityDateFlag, ProductCertificate::getValidityDate, ibo.getValidityDate())
    .eq(ProductCertificate::getDeleted, false).last(SqlConstant.ORDER_BY_DESC);
  Page<ProductCertificate> pageList = page(page, wrapper);

  return pageList.convert(item -> ProductCertificateBO.builder()
    .id(item.getId())
    .productCategory(item.getType())
    .number(item.getNumber())
    .name(item.getName())
    .model(item.getModel())
    .factoryId(item.getFactoryId())
    .factoryName(factoryInfoService.getFactoryName(item.getFactoryId()))
    .uploadFileName(item.getUploadFileName())
    .supplierId(item.getSupplierId())
    .supplierName(item.getSupplierName())
    .license(item.getLicense())
    .beginDate(item.getBeginDate())
    .validityDate(item.getValidityDate())
    .madeDate(item.getMadeDate())
    .build());
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值