我是靠谱客的博主 仁爱万宝路,这篇文章主要介绍关于使用Mybatis-Plus中返回值类型与继承Service中泛型类型不一致的问题controllerserviceImpl,现在分享给大家,希望可以做个参考。
今天遇到了一个问题,就是我使用开发框架自动生成了有关于数据库表中的数据(全部属性)的controller,service,Impl之类的,都是有关于数据库的表的实体类,但是我要传输的条件,和我要返回的条件不是数据库的那个实体类
需求:一个对应数据库中所有属性的实体类,一个输入的实体类,一个输出的实体类,完成分页查询
controller
复制代码
1
2
3
4
5public R getBigOthNppReportPageSimple(Page page, BigOthNppReport bigOthNppReport) { IPage<BigOthNppReportSimple> bigOthNppReportPageSimple = bigOthNppReportService.getBigOthNppReportPageSimple(page, bigOthNppReport); return R.ok(bigOthNppReportPageSimple); }
service
复制代码
1
2IPage<BigOthNppReportSimple> getBigOthNppReportPageSimple(Page page, BigOthNppReport bigOthNppReport);
Impl
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23public 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()); }
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31Page<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());
最后
以上就是仁爱万宝路最近收集整理的关于关于使用Mybatis-Plus中返回值类型与继承Service中泛型类型不一致的问题controllerserviceImpl的全部内容,更多相关关于使用Mybatis-Plus中返回值类型与继承Service中泛型类型不一致内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复