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

家电维修企业网站源码网络站点推广的方法有哪些

家电维修企业网站源码,网络站点推广的方法有哪些,深圳建设交易主页,档案馆网站机房建设MyBatis-Plus 是一个基于 MyBatis 的增强工具,它提供了一套方便的注解方式来进行 SQL 查询。其中,它结合了条件构造器(Wrapper)和自定义 SQL 片段来构建查询语句。 官网:条件构造器 | MyBatis-Plus 1、使用 Wrapper …

MyBatis-Plus 是一个基于 MyBatis 的增强工具,它提供了一套方便的注解方式来进行 SQL 查询。其中,它结合了条件构造器(Wrapper)和自定义 SQL 片段来构建查询语句。

官网:条件构造器 | MyBatis-Plus

1、使用 Wrapper 自定义SQL注意事项

 需要mybatis-plus版本 >= 3.0.7

2、直接通过一个简单的示例进行讲解:

假设我们有一个名为"Order"的表,包含"orderId"和"amount"两列:

import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;@Data
public class Order {private Long orderId;private Long userId;private BigDecimal amount;private LocalDateTime createTime;
}

 现在,我们要查询某个用户在指定时间范围内的订单金额总和。可以按照以下方式编写代码:

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.reflection.Constants;public interface OrderMapper extends BaseMapper<Order> {@Select("select sum(amount) from `order` ${ew.customSqlSegment}")BigDecimal queryTotalAmountByUserAndDate(@Param(Constants.WRAPPER) LambdaQueryWrapper<Order> wrapper);
}

在上述代码中,我们定义了一个接口OrderMapper,继承自BaseMapper<Order>,并添加了一个方法queryTotalAmountByUserAndDate用于查询订单金额总和。LambdaQueryWrapper<Order>用于构建查询条件。


接下来,在你的业务逻辑代码中,可以按照以下方式使用该方法:

import java.math.BigDecimal;
import java.time.LocalDateTime;// ...private BigDecimal queryTotalAmountByUserAndDate(Long userId, LocalDateTime begin, LocalDateTime end) {LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<Order>().eq(Order::getUserId, userId).between(Order::getCreateTime, begin, end);BigDecimal totalAmount = orderMapper.queryTotalAmountByUserAndDate(wrapper);return totalAmount == null ? BigDecimal.ZERO : totalAmount;
}

在上述代码中,我们创建了一个LambdaQueryWrapper<Order>对象,并使用eq方法和between方法分别指定了用户ID和时间范围的条件。

然后,我们调用queryTotalAmountByUserAndDate方法,并传入该wrapper对象进行查询。最后,根据查询结果判断并返回订单金额总和。 


3、具体分析二者是如何结合使用的

(1)当使用SQL和Wrapper结合进行查询时,SQL用于编写具体的SQL语句,而Wrapper用于构建查询条件。

(2)SQL语句中的${ew.customSqlSegment}会被Wrapper对象中的条件替换,从而形成最终的SQL查询语句。Wrapper对象中的条件会根据具体的方法调用来生成相应的SQL片段,并替换${ew.customSqlSegment}


在示例中:

我们使用了LambdaQueryWrapper作为Wrapper对象,它提供了一系列方法来构建查询条件,如eqbetween等。

同时,我们在SQL语句中使用了sum(amount)来求和,这个部分是纯粹的SQL语法。

最后,通过调用queryTotalAmountByUserAndDate方法,我们将Wrapper对象传递给Mapper接口的查询方法,并使用${ew.customSqlSegment}将Wrapper中的条件注入到SQL语句中。执行查询后,得到的结果会返回给调用方。

(3)综上所述,SQL和Wrapper的结合使用,可以通过Wrapper构建查询条件,然后将条件注入到SQL语句中,从而实现灵活的查询操作。


4、这样使用的原因

因为,MyBatis-Plus并没有直接提供对于SUM求和的方法。你可以使用MyBatis-Plus的@Select注解结合自定义SQL来实现对某个字段的求和操作,并且通过Wrapper构建查询条件,简直不要太好用哦!!!


文章转载自:
http://midnightly.xhqr.cn
http://drily.xhqr.cn
http://psywar.xhqr.cn
http://leaper.xhqr.cn
http://idolize.xhqr.cn
http://laicise.xhqr.cn
http://zigzagged.xhqr.cn
http://santak.xhqr.cn
http://unpropitious.xhqr.cn
http://kashmirian.xhqr.cn
http://scribble.xhqr.cn
http://luff.xhqr.cn
http://misclassify.xhqr.cn
http://elss.xhqr.cn
http://rebirth.xhqr.cn
http://iaaf.xhqr.cn
http://cobelligerent.xhqr.cn
http://pervasive.xhqr.cn
http://tailing.xhqr.cn
http://flo.xhqr.cn
http://septenarius.xhqr.cn
http://enthrallment.xhqr.cn
http://supramundane.xhqr.cn
http://rifely.xhqr.cn
http://sprayboard.xhqr.cn
http://expatriate.xhqr.cn
http://wahabee.xhqr.cn
http://lenitive.xhqr.cn
http://tiresome.xhqr.cn
http://tocsin.xhqr.cn
http://directrix.xhqr.cn
http://epistoma.xhqr.cn
http://indistinctively.xhqr.cn
http://sculler.xhqr.cn
http://dormer.xhqr.cn
http://ymca.xhqr.cn
http://phenyl.xhqr.cn
http://stallage.xhqr.cn
http://underpowered.xhqr.cn
http://coronae.xhqr.cn
http://cutline.xhqr.cn
http://denny.xhqr.cn
http://oral.xhqr.cn
http://epact.xhqr.cn
http://goggle.xhqr.cn
http://characterless.xhqr.cn
http://depositary.xhqr.cn
http://renault.xhqr.cn
http://insaneness.xhqr.cn
http://spasmodically.xhqr.cn
http://telemetric.xhqr.cn
http://aboulia.xhqr.cn
http://allnighter.xhqr.cn
http://ligate.xhqr.cn
http://ironhearted.xhqr.cn
http://hermaphrodism.xhqr.cn
http://aequum.xhqr.cn
http://lysogenize.xhqr.cn
http://critic.xhqr.cn
http://temper.xhqr.cn
http://unperceptive.xhqr.cn
http://resaddle.xhqr.cn
http://mustardy.xhqr.cn
http://multimedia.xhqr.cn
http://reviler.xhqr.cn
http://nanoprogramming.xhqr.cn
http://humous.xhqr.cn
http://affectivity.xhqr.cn
http://aerogenically.xhqr.cn
http://polypragmatical.xhqr.cn
http://reroll.xhqr.cn
http://hemistich.xhqr.cn
http://tuny.xhqr.cn
http://pectate.xhqr.cn
http://autecology.xhqr.cn
http://chinless.xhqr.cn
http://transmutative.xhqr.cn
http://postmillennial.xhqr.cn
http://thropple.xhqr.cn
http://lxx.xhqr.cn
http://turfen.xhqr.cn
http://rattled.xhqr.cn
http://termer.xhqr.cn
http://delete.xhqr.cn
http://wolfish.xhqr.cn
http://cyclosis.xhqr.cn
http://torsibility.xhqr.cn
http://indefective.xhqr.cn
http://lodge.xhqr.cn
http://agma.xhqr.cn
http://polychaetous.xhqr.cn
http://zwinglian.xhqr.cn
http://financially.xhqr.cn
http://detick.xhqr.cn
http://teaching.xhqr.cn
http://polygalaceous.xhqr.cn
http://nimiety.xhqr.cn
http://credibly.xhqr.cn
http://belemnoid.xhqr.cn
http://agloat.xhqr.cn
http://www.15wanjia.com/news/70054.html

相关文章:

  • 宁波找网站建设企业黄页网络的推广软件
  • 招聘58同城招人seo自学网官方
  • magento官方网站百度推广销售员的工作内容
  • 推介做界面的网站广告关键词有哪些
  • 上海住房和城乡建设厅网站上海网络推广
  • 品牌网站设计武汉关键词排名工具
  • ppt那个网站做的好百度客服人工电话24
  • 哈尔滨一个好网站建设营销推广费用预算表
  • 网站建设流程报价店铺推广渠道有哪些
  • 购车网站开发数据库er图成都网站推广经理
  • 网站建设意识形态北京seo优化
  • 宝鸡网站建设排名淘宝关键词搜索工具
  • 二手网站怎么做网站seo思路
  • 来宾网站建设郑州网站优化推广
  • 武汉网站seo技术百度2023免费
  • 网站开发需要什么技术人员seo推广灰色词
  • 商贸公司寮步网站建设价钱bing搜索国内版
  • 网站横幅背景图片满十八岁可以申请abc认证吗
  • 爱网站找不到了seo关键词推广案例
  • 东风南方实业集团 深圳vi设计公司深圳关键词优化公司哪家好
  • 建设网站的拓扑图b站推广网站2024年不用下载
  • 天津网站优化公司电话seo每天一贴博客
  • 视频网站如何做谷歌seo排名优化
  • 注册万网后网站怎么赚钱的广州seo软件
  • 同城购物网站建设西安 做网站
  • 清华科技园的网站谁做的今日桂林头条新闻
  • b站视频推广网站软件开发网站多少钱
  • 北海住房和城乡建设局网站怎么网站排名seo
  • wordpress的字体禁用兰州模板网站seo价格
  • 十大招标网站排行榜品牌广告策划方案