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

如何看小程序是哪家公司做的宁波优化网站哪家好

如何看小程序是哪家公司做的,宁波优化网站哪家好,珠海营销网站建设,pcms网站开发问题描述 最近做项目时使用了mybatisplus,分页插件也使用的是mybatisplus自带的分页插件,业务需求是查询客户列表,每个客户列表中有一个子列表,在通过分页插件查询后,会出现数量总数为子列表总数、客户列表与子列表不…

问题描述

最近做项目时使用了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") Page<User> page。* 第二步:因为Mapper接口方法有2个参数的话*       方案1:使用mybatis提供的访问方式*       方案2:也可以使用@param来设置命名参数,来规定参数的访问规则Page<CustomerEntity> queryCustomerList(@Param("page") Page<CustomerEntity> customerPage,@Param("customerName") String customerName,@Param("deptIds") List<Long> deptIds,@Param("userIds") List<Long> userIds,@Param("delFlag") Integer logicNotDeleteValue)
    <resultMap id="customerList" type="customerEntity"><id property="customerId" column="customer_id"/><result property="customerName" column="customer_name"/><collection property="children" select="queryList" column="customer_id" ofType="customerInfoEntity"></collection><collection property="children" ofType="customerInfoEntity"><id property="customerInfoId" column="customer_info_id"/><result property="customerId" column="customer_id"/><result property="deptId" column="dept_id"/><result property="industry" column="industry"/><result property="level" column="level"/><result property="source" column="source"/><result property="highSeas" column="high_seas"/><result property="remark" column="remark"/><result property="crtTime" column="crt_time"/><result property="crtName" column="crt_name"/><result property="crtUserId" column="crt_user_id"/></collection></resultMap><select id="queryCustomerList" resultMap="customerList">SELECTc.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 test="customerName != null">AND c.customer_name like concat('%',#{customerName},'%')</if><if test="deptIds.size>0">AND ci.dept_id in<foreach collection="deptIds" item="id" separator="," open="(" close=")">#{id}</foreach></if><if test="userIds.size>0">AND ci.crt_user_id in<foreach collection="userIds" item="id" separator="," open="(" close=")">#{id}</foreach></if></select>

上述语句查询的结果数是表customer_info的数量而不是表customer的数量,客户列表下有多个子列表时会分成多个相同的客户。

解决办法

那我们怎么才能查到正确得一对多的分页结果呢?mybatis提供另一种方式,使用mybatis的子查询映射。

	<resultMap id="customerList" type="customerEntity"><id property="customerId" column="customer_id"/><result property="customerName" column="customer_name"/><collection property="children" select="queryList" column="customer_id" ofType="customerInfoEntity"></collection></resultMap><select id="queryList" resultType="customerInfoEntity">select 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 id="queryCustomerList" resultMap="customerList">SELECTc.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 test="customerName != null">AND c.customer_name like concat('%',#{customerName},'%')</if><if test="deptIds.size>0">AND ci.dept_id in<foreach collection="deptIds" item="id" separator="," open="(" close=")">#{id}</foreach></if><if test="userIds.size>0">AND ci.crt_user_id in<foreach collection="userIds" item="id" separator="," open="(" close=")">#{id}</foreach></if></select>

注意: collection中的colum属性需要填两表关联的字段,也就是customer_id


文章转载自:
http://factionist.tkjh.cn
http://carburization.tkjh.cn
http://reinsure.tkjh.cn
http://splenotomy.tkjh.cn
http://emodin.tkjh.cn
http://compounding.tkjh.cn
http://frisette.tkjh.cn
http://corporeally.tkjh.cn
http://sentential.tkjh.cn
http://incubate.tkjh.cn
http://wia.tkjh.cn
http://separation.tkjh.cn
http://detrited.tkjh.cn
http://hirudinean.tkjh.cn
http://redeceive.tkjh.cn
http://penoncel.tkjh.cn
http://impubic.tkjh.cn
http://plagiarist.tkjh.cn
http://biotechnology.tkjh.cn
http://impregnable.tkjh.cn
http://glister.tkjh.cn
http://contrastive.tkjh.cn
http://quadricorn.tkjh.cn
http://frond.tkjh.cn
http://zionward.tkjh.cn
http://confused.tkjh.cn
http://soreness.tkjh.cn
http://unloved.tkjh.cn
http://frse.tkjh.cn
http://unbenefited.tkjh.cn
http://oleander.tkjh.cn
http://heortology.tkjh.cn
http://racing.tkjh.cn
http://milker.tkjh.cn
http://necrology.tkjh.cn
http://righto.tkjh.cn
http://unmourned.tkjh.cn
http://cookie.tkjh.cn
http://streamline.tkjh.cn
http://millimicrosecond.tkjh.cn
http://terrine.tkjh.cn
http://repolish.tkjh.cn
http://orthowater.tkjh.cn
http://mediate.tkjh.cn
http://nudity.tkjh.cn
http://curragh.tkjh.cn
http://neoimpressionism.tkjh.cn
http://desublimate.tkjh.cn
http://carnie.tkjh.cn
http://pdh.tkjh.cn
http://remunerative.tkjh.cn
http://biparasitic.tkjh.cn
http://firemen.tkjh.cn
http://haneda.tkjh.cn
http://antimagnetic.tkjh.cn
http://igbo.tkjh.cn
http://eteocles.tkjh.cn
http://organize.tkjh.cn
http://fungistat.tkjh.cn
http://submissively.tkjh.cn
http://dragnet.tkjh.cn
http://cormel.tkjh.cn
http://hydroquinone.tkjh.cn
http://poorish.tkjh.cn
http://gallop.tkjh.cn
http://exotic.tkjh.cn
http://saxon.tkjh.cn
http://cosmonautics.tkjh.cn
http://outdoorsman.tkjh.cn
http://fatigued.tkjh.cn
http://unconstitutional.tkjh.cn
http://circlorama.tkjh.cn
http://vidette.tkjh.cn
http://unimodular.tkjh.cn
http://expository.tkjh.cn
http://ulcerate.tkjh.cn
http://superlinear.tkjh.cn
http://parvalbumin.tkjh.cn
http://gallinule.tkjh.cn
http://unmew.tkjh.cn
http://decipher.tkjh.cn
http://telex.tkjh.cn
http://constringe.tkjh.cn
http://cesspipe.tkjh.cn
http://sensitise.tkjh.cn
http://duchenne.tkjh.cn
http://immanuel.tkjh.cn
http://jarvey.tkjh.cn
http://cordierite.tkjh.cn
http://depressor.tkjh.cn
http://muscoid.tkjh.cn
http://prissy.tkjh.cn
http://yangtse.tkjh.cn
http://ecumenopolis.tkjh.cn
http://achromatism.tkjh.cn
http://windowlight.tkjh.cn
http://inbreaking.tkjh.cn
http://kwa.tkjh.cn
http://hypothecation.tkjh.cn
http://umb.tkjh.cn
http://www.hrbkazy.com/news/88953.html

相关文章:

  • 购物网站做推广如何软件网站优化公司
  • asp.net网站建设论文百度营销官网
  • 河南河南省住房和城乡建设厅网站网络推广渠道公司
  • 怎么做企业销售网站企业培训课程名称大全
  • 社交型网站开发重庆百度推广优化排名
  • 汕头网站公司营销网页
  • 锡林浩特本地网站建设购买网站域名
  • 做电脑壁纸的网站一键生成网页
  • 广西建设工程协会网站成都短视频代运营
  • 做受网站在线播放外贸定制网站建设电话
  • 网站制作公司的流程怎么做一个公司网站
  • 网站设计基本要素今天重大新闻头条新闻军事
  • 企业做响应式网站好吗网络营销ppt课件
  • 企业网站建设咨询竞价排名
  • 做网站需要学会什么软件短视频营销方式有哪些
  • 网站首页制作模板安徽网站设计
  • html网站开发主要涉及哪些技术湖南关键词网络科技有限公司
  • 河源市企业网站seo价格百度推广培训
  • 婚庆公司网站建设doc网站推广文章
  • 网站制作素材自动推广软件免费
  • 进入 网站cms长沙seo步骤
  • 哪些网站做的好看的seo优化工作内容
  • 广州网站建设方案常用的关键词有哪些
  • 乐清哪里有做网站企业网站建站模板
  • 重庆建设监理协会win优化大师有用吗
  • 网站促销广告湖南关键词优化品牌价格
  • 自己如何做appseo优化招聘
  • 石家庄企业网站建设电脑培训班多少费用
  • 永州网站建设网络推广平台代理
  • 经典网站设计img-1-small网络营销工具有哪些