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

网站推广公司兴田德润紧急网页升级紧急通知

网站推广公司兴田德润,紧急网页升级紧急通知,网络推广引流软件,房地产营销网站建设注解作用SelectProvider动态查询SQLInsertProvider动态新增SQLUpdateProvider动态更新SQLDeleteProvider动态删除SQL Select 与 SelectProvider 只是在定义注解的方式上有所不同, 一个是静态SQL, 一个是动态SQL 。 SelectProvider 是 MyBatis 中的一个注解#xff0c;用于指定…注解作用SelectProvider动态查询SQLInsertProvider动态新增SQLUpdateProvider动态更新SQLDeleteProvider动态删除SQL Select 与 SelectProvider 只是在定义注解的方式上有所不同, 一个是静态SQL, 一个是动态SQL 。 SelectProvider 是 MyBatis 中的一个注解用于指定一个类或者类的某个方法提供 SQL 查询语句。该注解常用于动态 SQL 的场景例如根据不同的参数生成不同的查询语句。 使用 SelectProvider 注解的方式可以让 MyBatis 在运行时根据注解指定的类或方法来生成对应的 SQL 查询语句从而实现动态 SQL 功能。注解的语法如下 SelectProvider(type XxxProvider.class, method xxxMethod) 其中type 属性表示提供 SQL 查询语句的类method 属性表示类中提供查询语句的方法。在查询时MyBatis 会调用指定类中的指定方法来生成 SQL 查询语句然后执行该查询语句并返回结果。 需要注意的是提供 SQL 查询语句的类需要实现 org.apache.ibatis.builder.annotation.ProviderMethodResolver 接口该接口中定义了查找提供 SQL 查询的方法的逻辑。同时提供查询语句的方法需要返回一个字符串类型的 SQL 查询语句。 使用 SelectProvider 注解可以让 MyBatis 的查询语句更加灵活适用于各种复杂的查询场景。 1 SelectProvider 使用 1 TestMapper.java public interface TestMapper {/*** 根据性别获取老师信息** param sex* return* date 2022年11月26日12点09分*/SelectProvider(type Test.class, method list)ListTeacher list(Integer sex);} 2 Test.java public class Test {/*** 根据性别获取老师信息** param sex* return* date 2022年11月26日12点09分*/public String list(Integer sex) {return new SQL() {{SELECT(*);FROM(teacher);if (null ! sex) {WHERE( 1 1 sex sex);} else {WHERE( 1 1 );}ORDER_BY(create_time desc);}}.toString();}}2 模拟 Mybatis Plus 可以使用 SelectProvider 写一个适用于所有表的查询的方法。 1 BasicWrapper.java import java.util.LinkedList; import java.util.List;/*** author Administrator*/ public class BasicWrapperT {public String last;public ClassT bean;public String table;public String[] field;public ListString condition new LinkedList();public String orderBy;}2 QueryWrapper.java import java.util.Arrays;import org.apache.ibatis.jdbc.SQL;import cn.hutool.core.collection.CollectionUtil;/*** author */ public class QueryWrapperT extends BasicWrapper {public QueryWrapper() {}public QueryWrapper(String table, String... field) {super.bean null;super.table table;super.field (null field || field.length 0) ? new String[]{*} : field;}public String list(QueryWrapper wrapper) {Query query wrapper.build();return new SQL() {{SELECT(query.getFields());FROM(query.getTable());WHERE( 1 1 query.getCondition());ORDER_BY(query.getOrderBy());}}.toString();}public Query build() {Query query new Query();query.setTable(super.table);query.setFields((null super.field || super.field.length 0) ? * : String.join(, , Arrays.asList(super.field)));String condition CollectionUtil.isEmpty(super.condition) ? 1 1 : String.join( , super.condition);String last null super.last ? : super.last;query.setCondition(condition last);return query;}public QueryWrapper orderBy(String sql) {super.orderBy sql;return this;}public QueryWrapper orderBy(boolean condition, String sql) {if (condition) {super.orderBy sql;}return this;}public QueryWrapper apply(String sql) {super.condition.add( and ( sql ) );return this;}public QueryWrapper apply(boolean condition, String sql) {if (condition) {super.condition.add( and ( sql ) );}return this;}public QueryWrapper eq(String filed, Object value) {super.condition.add( and filed value);return this;}public QueryWrapper eq(boolean condition, String filed, Object value) {if (condition) {if (value instanceof String) {super.condition.add( and filed value );} else {super.condition.add( and filed value);}}return this;}public QueryWrapper last(String value) {super.last value;return this;}public QueryWrapper last(boolean condition, String value) {if (condition) {super.last value;}return this;}public QueryWrapper like(String filed, Object value) {super.condition.add( and filed like % value %);return this;}public QueryWrapper likeLeft(String filed, Object value) {super.condition.add( and filed like % value %);return this;}public QueryWrapper likeRight(String filed, Object value) {super.condition.add( and filed like % value %);return this;}public QueryWrapper like(boolean condition, String filed, Object value) {if (condition) {super.condition.add( and filed like % value %);}return this;}public QueryWrapper likeLeft(boolean condition, String filed, Object value) {if (condition) {super.condition.add( and filed like % value %);}return this;}public QueryWrapper likeRight(boolean condition, String filed, Object value) {if (condition) {super.condition.add( and filed like % value %);}return this;}} 3 Query.java import lombok.Data;/*** author Administrator*/ Data public class Query {private String table;private String fields;private String orderBy;private String condition;} 4 Test.java import org.apache.ibatis.jdbc.SQL;public class Test {public static void main(String agrs[]) {QueryWrapperTeacher wrapper new QueryWrapper(teacher);wrapper.eq(sex, 1);wrapper.eq(StringUtils.isNotBlank(name), name, name);wrapper.orderBy(create_time desc);ListTeacher list processMapper.list(wrapper);}}
http://www.w-s-a.com/news/260071/

相关文章:

  • 厦门做网站哪家强企业网站网页设计的步骤
  • 普拓网站建设济南行业网站建设
  • 燕郊 网站开发网站里的地图定位怎么做
  • 门户网站建设招标互联网创业项目概述
  • 用什么做网站比较好市场调研公司是做什么的
  • 电商网站充值消费系统绍兴网站优化
  • 深圳网站建设公司联虚拟币交易网站开发
  • 专业网站设计建设公司抖音代运营公司排名前十强
  • 做网站架构肃北蒙古族自治县建设局网站
  • 推广网站怎么建经济研究院网站建设方案
  • 网站建设商家淘宝客自建网站做还是用微信qq做
  • django做网站效率高吗涉县移动网站建设报价
  • 做外贸网站注册什么邮箱能够做渗透的网站
  • 购物网站 怎么做织梦网站会员功能
  • 北京市网站开发公司郑州联通网站备案
  • 温岭专业营销型网站建设地址wordpress小程序怎么不用认证审核
  • 网站建设主体设计要求微信公众号缴费
  • 网站建设的税率WordPress多用户建站
  • 专业门户网站的规划与建设网络培训
  • 东莞汽车总站停止营业crm管理系统在线使用
  • 深圳网站建设公司哪个网络优化是做什么的
  • 大连地区做网站自己怎么做电影网站
  • 成都APP,微网站开发手机要访问国外网站如何做
  • 网站app建设用discuz做的手机网站
  • vs 2008网站做安装包公众号登录超时
  • 银川做网站推广wordpress dux会员中心
  • 双辽做网站wordpress怎么写html代码
  • 建站公司哪家好 知道万维科技西安都有哪些公司
  • 设计网站官网入口佛山 品牌设计
  • 专用网站建设wordpress mega