当前位置: 首页 > news >正文

做网站需要的技术做做网站2023

做网站需要的技术,做做网站2023,西安seo网络优化公司,做游戏网站年入百万问题描述 最近做项目时使用了mybatisplus#xff0c;分页插件也使用的是mybatisplus自带的分页插件#xff0c;业务需求是查询客户列表#xff0c;每个客户列表中有一个子列表#xff0c;在通过分页插件查询后#xff0c;会出现数量总数为子列表总数、客户列表与子列表不…问题描述 最近做项目时使用了mybatisplus分页插件也使用的是mybatisplus自带的分页插件业务需求是查询客户列表每个客户列表中有一个子列表在通过分页插件查询后会出现数量总数为子列表总数、客户列表与子列表不对等。 1、配置mybatis-plus插件 Configuration MapperScan(com.guigu.mapper) //可以将启动类中的注解移到此处 public class MybatisPlusConfig {/**** 1 怎么来配置mybatis-plus中的插件* 这里所需要的类型是MybatisPlusInterceptor这是mybatis-plus的一个拦截器用于配置mybatis-plus中的插件。* 2 为什么要使用拦截器MybatisPlusInterceptor呢* 这里边的原理和mybatis分页插件的功能是一样的工作流程如下 * 1第一步执行查询功能。* 2第二步拦截器对查询功能进行拦截。* 3第三步拦截器对查询功能的基础上做了额外的处理达到分页的效果功能。* 3 对比配置mybatis中的插件* 用的也是拦截器的方式。** return MybatisPlusInterceptor*/Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor interceptor new MybatisPlusInterceptor();//添加分页插件//参数new PaginationInnerInterceptor(DbType.MYSQL)是专门为mysql定制实现的内部的分页插件interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));return interceptor;}2、mapper语句 需求根据年龄查询用户列表分页显示** 第一步xml自定义分页Mapper接口方法* 第1步如果想要mybatis-plus的分布插件来作用于我们自定义的sql语句的话* 第一个参数必须得是一个分页对象Param(page) PageUser page。* 第二步因为Mapper接口方法有2个参数的话* 方案1使用mybatis提供的访问方式* 方案2也可以使用param来设置命名参数来规定参数的访问规则PageCustomerEntity queryCustomerList(Param(page) PageCustomerEntity customerPage,Param(customerName) String customerName,Param(deptIds) ListLong deptIds,Param(userIds) ListLong userIds,Param(delFlag) Integer logicNotDeleteValue)resultMap idcustomerList typecustomerEntityid propertycustomerId columncustomer_id/result propertycustomerName columncustomer_name/collection propertychildren selectqueryList columncustomer_id ofTypecustomerInfoEntity/collectioncollection propertychildren ofTypecustomerInfoEntityid propertycustomerInfoId columncustomer_info_id/result propertycustomerId columncustomer_id/result propertydeptId columndept_id/result propertyindustry columnindustry/result propertylevel columnlevel/result propertysource columnsource/result propertyhighSeas columnhigh_seas/result propertyremark columnremark/result propertycrtTime columncrt_time/result propertycrtName columncrt_name/result propertycrtUserId columncrt_user_id//collection/resultMapselect idqueryCustomerList resultMapcustomerListSELECTc.customer_id,c.customer_name,ci.customer_info_id,ci.customer_id,ci.dept_id,ci.industry,ci.level,ci.source,ci.high_seas,ci.remark,ci.crt_time,ci.crt_name,ci.crt_user_idFROM customer cJOIN customer_info ci on c.customer_id ci.customer_idwhere ci.high_seas 0and ci.del_flag #{delFlag}and c.del_flag #{delFlag}if testcustomerName ! nullAND c.customer_name like concat(%,#{customerName},%)/ifif testdeptIds.size0AND ci.dept_id inforeach collectiondeptIds itemid separator, open( close)#{id}/foreach/ifif testuserIds.size0AND ci.crt_user_id inforeach collectionuserIds itemid separator, open( close)#{id}/foreach/if/select上述语句查询的结果数是表customer_info的数量而不是表customer的数量客户列表下有多个子列表时会分成多个相同的客户。 解决办法 那我们怎么才能查到正确得一对多的分页结果呢mybatis提供另一种方式使用mybatis的子查询映射。 resultMap idcustomerList typecustomerEntityid propertycustomerId columncustomer_id/result propertycustomerName columncustomer_name/collection propertychildren selectqueryList columncustomer_id ofTypecustomerInfoEntity/collection/resultMapselect idqueryList resultTypecustomerInfoEntityselect ci.customer_info_id,ci.customer_id,ci.dept_id,ci.industry,ci.level,ci.source,ci.high_seas,ci.remark,ci.crt_time,ci.crt_name,ci.crt_user_idfrom customer_info ciwhere ci.customer_id #{customer_id};/select!-- 查询未加入公海池的客户列表--select idqueryCustomerList resultMapcustomerListSELECTc.customer_id,c.customer_name,ci.customer_info_id,ci.customer_id,ci.dept_id,ci.industry,ci.level,ci.source,ci.high_seas,ci.remark,ci.crt_time,ci.crt_name,ci.crt_user_idFROM customer cJOIN customer_info ci on c.customer_id ci.customer_idwhere ci.high_seas 0and ci.del_flag #{delFlag}and c.del_flag #{delFlag}if testcustomerName ! nullAND c.customer_name like concat(%,#{customerName},%)/ifif testdeptIds.size0AND ci.dept_id inforeach collectiondeptIds itemid separator, open( close)#{id}/foreach/ifif testuserIds.size0AND ci.crt_user_id inforeach collectionuserIds itemid separator, open( close)#{id}/foreach/if/select注意 collection中的colum属性需要填两表关联的字段也就是customer_id
http://www.yutouwan.com/news/71960/

相关文章:

  • 域名到期对网站影响网站营销的重要价值
  • 天津建设工程信息网网站首页wordpress 文件管理插件
  • 营销网站设计实验网站开发公司需要什么资质
  • 有个新网站能提供网站备案要多长时间
  • asp.net网站开发实例杭州哪些做网站公司好
  • 中国铁工建设有限公司网站php网站建设含义
  • 响应式布局网站网站免备案空间
  • 商城网站源代码莱芜高端网站建设价格
  • 网站首页优化如何快速推广一个新产品
  • wordpress适合做什么网站吗建设部网站资质公示
  • 网站开发流程中客户的任务是什么广东新闻联播林红
  • 道滘网站仿做做视频网站弹窗
  • 设计素材网站破解网站制作新报价
  • c2c网站功能本地网站建设多少钱
  • 网站建设超市visual studio怎么创建网页
  • 临沂网站建设微信大庆市建设局宫方网站
  • 建网站找哪个平台好呢怎么建立自己的公司网站
  • wordpress 商品站wordpress主题开发ide
  • 1万网站建设费入什么科目做网站如何排版
  • 简述一个网站开发流程网站开发后台服务器功能
  • 网站建设北京市唐山建设网站建站
  • 网站改版报告wow亚洲服有永久60级么
  • 给公司建立网站不可以做到的是wordpress如何自己写页面
  • 余姚市网站建设企业网站用什么做二次开发最快
  • 珠海营销型网站哪家好网站地图链接怎么做
  • ae有么有做gif的网站品牌推广型网站
  • 建筑工地网站杭州萧山做网站
  • 广州住房与建设 网站网站建设企业资质等级
  • 保定免费网站制作专业营销型网站建设公司
  • 东莞网站建设找谁大尺度做爰网站在线