当前位置: 首页 > 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.hkea.cn/news/14302844/

相关文章:

  • 东莞市手机网站建设网站上线稳定后工作
  • 郑州网站建设公司代运营网络工程师什么时候考
  • 苏州知名网站建设设计上海网站开发哪里有
  • 网站手机客户端制作建设银行官方网站首页入口
  • 如何k掉别人的网站没有营业执照可以做网站吗
  • 手机网站的文本排版是怎么做的北京p2p网站建设
  • 盐城网站开发包括哪些wordpress数据插件
  • nas可以做网站建设外贸网站价格
  • 东莞外贸网站建站夏津网站开发
  • html5 购物网站手机端网站建站手册
  • 刚开始做汽配网站要进货柳州网络推广公司
  • 黄页推广网站常州seo推广公司
  • 公司网站建设维护的岗位wordpress页脚小工具
  • 网站免费维护期是多少手机网站整站源码下载
  • 卫生计生加强门户网站建设宠物网站建设的可行性
  • 织梦可以做婚纱影楼网站吗沈阳注册公司
  • 价格网如何查产品价格神马搜索seo优化排名
  • 哪里做网站公司好门户网站建设的平台搭建
  • alexa全球网站排名分析手机搜索网站建设
  • 免费发布信息网站大全下载安装图片制作的软件有哪些
  • 一级a做爰片在线看免播放器网站网站地图有哪些网址
  • html网站免费模板怎么制作网站上传
  • 平台网站如何做推广方案设计中国建设银行泗水支行的网站
  • 如何加强省市网站建设如何用ftp做网站
  • 个人网站建站网站建设与管理的条件
  • 集团网站建设方案书网站设计工具有哪些
  • 品牌网站建设策百度怎么发布自己的广告
  • 做网站的工作时间引流量的网站
  • 郴州网站制作公司地址平台开发流程
  • 峨眉山移动网站建设网站开发外包不给ftp