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

信誉好的网站建设公司微信网站

信誉好的网站建设公司,微信网站,安徽城乡建设部网站首页,开发游戏需要什么条件个人总结三种方式#xff1a; Xml、queryWrapper、PageHelper第三方组件这三种方式进行查询#xff1b; 方式一#xff1a; xml中联表查询#xff0c;在mapper中传参IPageT和条件Map#xff08;这里用map装参数#xff09;。 代码示例#xff1a; Mapper层 M…个人总结三种方式 Xml、queryWrapper、PageHelper第三方组件这三种方式进行查询 方式一 xml中联表查询在mapper中传参IPageT和条件Map这里用map装参数。 代码示例 Mapper层 Mapper public interface UserInfoMapper extends BaseMapperUserInfo { IPageUserInfofindUserInfoByConditions(IPageUserInfopage,Param(map)MapString,Object map); } Xml文件 表关系user表id和user_scope表中user_id是主外键关系通过这两字段关联两张表查询 select idfindUserInfoByConditions resultMapUserInfoMap    SELECT psi.* FROM user_info ui ,user_scope us    where ui.idus.user_id    if testmap.userName ! null and map.userName !       and ui.user_name like concat(%,#{map.userName},%)    /if    if testmap.userCoding !null and map.userCoding!       and ui.user_coding like concat(%,#{map.userCoding},%)    /if    if testmap.userType ! null and map.userType!       and us.user_type like concat(%,#{map.userType},%)    /if /select Service层 Map map new HashMap(); map.put(“userName”,”james”); map.put(“userCoding”,”123456”); map.put(“userType”,”普通用户”); userInfoMapper.findUserInfoByConditions(page, map)); 方式二 PageHelper第三方组件分页查询最后new分页对象PageInfo返回需要注意设置分页参数和查询语句的顺序问题。 依赖引入 dependency    groupIdcom.github.pagehelper/groupId    artifactIdpagehelper-spring-boot-starter/artifactId    version1.4.6/version /dependency 代码示例 Mapper Mapper public interface UserInfoMapper extends BaseMapperUserInfo { ListUserInfo findUserInfoList(Param(map) MapString,Object map); } Xml select idfindUserInfoList resultMapUserInfoMap    SELECT psi.* FROM user_info ui ,user_scope us    where ui.idus.user_id    if testmap.userName ! null and map.userName !       and ui.user_name like concat(%,#{map.userName},%)    /if    if testmap.userCoding !null and map.userCoding!       and ui.user_coding like concat(%,#{map.userCoding},%)    /if    if testmap.userType ! null and map.userType!       and us.user_type like concat(%,#{map.userType},%)    /if /select Service层 int pageNumber1; int pageSize10; Map map new HashMap(); map.put(“userName”,”james”); map.put(“userCoding”,”123456”); map.put(“userType”,”普通用户”); PageHelper.startPage(pageNumber, pageSize);//这里顺序不能颠倒改行必须放在查询语句前面AOP切面编程即动态代理模式 ListUserInfo userInfoList userInfoMapper.findUserInfoList(map)); PageInfo pageInfo new PageInfo(userInfoList );//该行返回分页对象 方式三 QueryWrapper查询方式这里得注意联合查询时传参的语法问题具体见代码标记的红色部分 代码示例 Map层 Mapper public interface UserInfoMapper extends BaseMapperUserInfo { IPageUserInfo findUserInfo(IPageUserInfo page,Param(Constants.WRAPPER) QueryWrapperUserInfo wrappers); } Xml select idfindUserInfo resultMapuserInfoMap    SELECT ui.* FROM user_info ui left join user_scope us    on ui.idus.user_id    ${ew.customSqlSegment}//不能在此处前后加where /select Service层 Int current1; Int size10; QueryWrapperUserInfo wrapper new QueryWrapper(); //这里注意区分是哪张表的字段根xml里面别名对应不然如果两张表里面有相同字段//且出现在查询条件里面时会分不清是具体哪张表的字段所以一定得注明别名。 wrapper.like(ui.user_coding, “123455”); wrapper.like(ui.user_name, “james”); wrapper.like(us.user_type, “普通用户”) Page? page new Page(current, size); userInfoMapper.findUserInfo(page, wrapper) 分析上述三种方式就开发效率而言方式三最快且好用当然如果遇到业务逻辑复杂的则可以通过xml中sql的方式来查。其实就方式三而言如果不用QueryWrapper联表方式查询只想用QueryWrapper的单表方式查询可以将逻辑分层分成两部分查询上述三种方式其sql都是一样的即 SELECT ui.* FROM user_info ui , user_scope us where ui.idus.user_id and us.user_type like %钢% and ui.user_name like ‘%james%’ and ui.user_coding like ‘%123%’ 将该sql分成两部分 select * from user_info where id in (select user_id from user_scope where user_type like ‘%钢%’ ) 对应QueryWrapper代码是 wrapper.like(“user_type”,”普通用户”) ListObject idList userScopeService.list(wrapper); Wrapper.like(“user_name”,”james”); Wrapper.like(“user_coding”,”123”); IPage page userInfoService.page(page,wrapper); 这样也可以达到效果当然具体业务得具体调整拆分。如果有其他方式你分享我整理。
http://www.sczhlp.com/news/207020/

相关文章:

  • 个人政务公开网站建设工作总结石家庄自动seo
  • 市场营销专业招生网站策划书seo专员有前途吗
  • 深圳市官网网站建设哪家好零基础学全屋定制设计
  • 律师做推广宣传的网站网站权重问题
  • wordpress支付宝免插件seo技术是干什么的
  • 东莞网站设计推荐易维达2天津建设工程信息网查询
  • 349. 两个数组的交集
  • F5 BIG-IP 16.1.6.1 - 多云安全和应用交付
  • 2025 年最新推荐!污水处理设备优质厂家排行榜,帮企业避开劣质产品选到高效靠谱设备
  • Burp Suite Professional 2025.10 发布 - Web 应用安全、测试和扫描
  • 2025 年最新推荐真空炉制造厂家榜单:覆盖高温烧结 / 真空退火 / 智能铍铜炉,助力企业精准选型
  • 济宁市工程建设职业学校网站底价网站建设
  • 企业网站seo方案学网站建设哪里好
  • 怎么在传奇网站上做宣传科技公司官网首页
  • 杭州市做外贸网站的公司上海市嘉定区建设银行网站
  • 楼盘网站建设案例做网站在哪里申请
  • 搜索案例的网站中企动力建设的网站如何修改
  • 电商论坛网站模板电脑版qq在线登录网页入口
  • 医院网站做竞价需要注意广告法王烨桦
  • 郑州加盟网站建设物流网站建设图片
  • wordpress 公司建站优秀企业网站建设
  • 外贸开发模板网站模板关于建设二级网站的报告
  • 架设销售网站免费装修效果图网站
  • 婴贝儿网站建设厦门网站建设找哪家比较好
  • 1 高端品牌网站定制装修加盟网
  • 怎么进wordpress怎样做网站优化排名
  • h5 小米网站模板自己做的网站 jen
  • 有什么平台可以推广seo技术教程
  • 网站要多少钱杭州网站做的好公司名称
  • 上海企业建设网站价格杭州it培训机构推荐