当前位置:首页>java>Java编程技巧之样板代码

Java编程技巧之样板代码

  • 2026-01-22 05:14:53
Java编程技巧之样板代码

前言
北宋科学家沈括在《梦溪笔谈》第十八卷《技艺》中这样描述“活字印刷术
庆历中,有布衣毕昇,又为活版。其法用胶泥刻字,薄如钱唇,每字为一印,火烧令坚……若止印三、二本,未为简易;若印数十百千本,则极为神速。
在日常编码的过程中,我们可以总结出很多“样板代码,就像”活字印刷术中的“活字一样。当我们编写新的代码时,需要用到这些“活字,就把“样板代码拷贝过来,修改替换一下就可以了,写起代码来“极为神速。“样板代码其实就是一种样例、一种模式、一种经验……总结的“样板代码”越多,编写代码的格式越规范、质量越高、速度越快。
这里,作者总结了几种常见Java的“样板代码”,希望起到抛砖引玉的作用,希望大家不断总结和完善,形成自己的样板代码库。
一  样板代码简介
1  什么是样板代码?
样板代码(Boilerplate Code),通常是指一堆具有固定模式的代码块,可以被广泛地应用到各个程序模块。
例如,读取文件就是典型的样板代码:
try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {    String line;    while (Objects.nonNull(line = reader.readLine())) {        // 处理一行        ...    }} catch (IOException e) {    String message = String.format("读取文件(%s)异常", fileName);    log.error(message, e);    throw new ExampleException(message, e);}
2  样板代码有什么用?
样板(Boilerplate ),可以拆分为样例(Example)和模式(Pattern)两个单词进行理解——样例(Example)指可以当成一种标准范例,模式(Pattern)指可以作为一种解决方案。当遇到类似的案例时,就把样板代码拷贝过去,根据实际情况进行修改,该案例就被轻松解决了。
样板代码的主要作用:
  1. 提供一种标准样例:可以用于新人学习,能够快速上手并使用;

  2. 提供一种解决方案:遇到类似案例时,可以快速利用该方案进行解决;

  3. 有助于不断积累经验:当发现一种样例代码时,都会不断地进行优化,力求达到最佳样例;

  4. 有助于提高代码质量:样板代码必然通过了时间考验,存在BUG和出错的几率相对比较低;

  5. 有助于提高编码速度:利用样板代码编码,只是复制粘贴修改代码,编码速度大幅提高;

  6. 有助于统一代码样式:心中有了样板代码,就能保证每次都写出统一样式的代码。

3  如何编写样板代码?
在作者以前的文章《这6种编码方法,你掌握了几个?》中,有详细的说明和举例,这里不再累述。其中,适合于样板代码的编写方法有:
  • 复制粘贴生成代码:利用复制粘贴样板代码,用好了编码会事半功倍。

  • 用文本替换生成代码:利用文本替换生成代码,可以很快生成一段新代码。

  • 用Excel公式生成代码:把样板代码先公式化,传入不同的参数,生成不同的代码。

  • 用工具或插件生成代码:很多开发工具或插件都提供一些工具生成代码,比如:生成构造方法、重载基类/接口方法、生成Getter/Setter方法、生成toString方法、生成数据库访问方法……能够避免很多手敲代码。

  • 用代码生成代码:用代码生成代码,就是自己编写代码,按照自己的样板代码格式生成代码。

4  如何减少样板代码?
样板代码(Boilerplate Code)具有很大的重复性,通常被认为是一种冗余而又不得不写的代码。其实不然,有些样板代码不能减少,只是我们还没有遇到合适的解决方案而已。通常情况下,我们可以通过以下几种方式减少样板代码:
利用注解减少样板代码
比如,JavaBean模型类中的Getter/Setter就是样板代码,我们可以通过Lombok的@Getter/@Setter注解来减少这样的样板代码。
原始代码:
public class User {    private Long id;    ...    public Long getId() {        return id;    }    public void setId(Long id) {        this.id = id;    }    ...}
优化代码:
@Getter@Setterpublic class User {    private Long id;    ...}
利用框架减少样板代码
比如,MyBatis 是一款优秀的持久层框架,封装了获取数据库连接和声明、设置参数、获取结果集等所有JDBC操作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接口和 Java POJO(Plain Old Java Objects,普通老式 Java 对象)为数据库中的记录。
原始代码:
/** 查询公司员工 */public List<EmployeeDO> queryEmployee(Long companyId) {    try (Connection connection = tddlDataSource.getConnection();        PreparedStatement statement = connection.prepareStatement(QUERY_EMPLOYEE_SQL)) {        statement.setLong(1, companyId);        try (ResultSet result = statement.executeQuery()) {            List<EmployeeDO> employeeList = new ArrayList<>();            while (result.next()) {                EmployeeDO employee = new EmployeeDO();                employee.setId(result.getLong(1));                employee.setName(result.getString(2));                ...                employeeList.add(employee);            }            return employeeList;        }    } catch (SQLException e) {        String message = String.format("查询公司(%s)用户异常", companyId);        log.error(message, e);        throw new ExampleException(message, e);    }}
优化代码:
1)UserDAO.java
@Mapperpublic interface UserDAO {    List<EmployeeDO> queryEmployee(@Param("companyId") Long companyId);}
2)UserDAO.xml
<mapper namespace="com.example.repository.UserDAO">    <select id="queryEmployee" resultType="com.example.repository.UserDO">        select id        , name        ...        from t_user        where company_id = #{companyId}    </select></mapper>
利用设计模式减少样板代码
利用设计模式,可以把一些重复性代码进行封装。比如,上面的读取文件行模式代码,就可以用模板方法进行封装。
原始代码:
try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {    String line;    while (Objects.nonNull(line = reader.readLine())) {        // 处理一行        ...    }} catch (IOException e) {    String message = String.format("读取文件(%s)异常", fileName);    log.error(message, e);    throw new ExampleException(message, e);}
优化代码:
/** 定义方法 */public static void readLine(String fileName, Consumer<String> lineConsumer) {    try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {        String line;        while (Objects.nonNull(line = reader.readLine())) {            lineConsumer.accept(line);        }    } catch (IOException e) {        String message = String.format("读取文件(%s)异常", fileName);        log.error(message, e);        throw new ExampleException(message, e);    }}// 使用代码readLine("example.txt", line -> {    // 处理一行    ...});
5  消灭不了的样板代码
如果样板代码可以被消灭,那么世界上就不存在样板代码了。即便是上一节提供的减少样板代码方法,也不能完全的消灭样板代码,因为这些样板代码依旧存在于框架和模式的实现中。所以,样板代码是消灭不了的。
既然不能消灭样板代码,那就应该合理地利用样板代码。提炼一段样板代码,若只用二三次,未为简便;若用数十百千次,则极为神速。下面,列举了几种常见Java的样板代码,描述了样板代码在日常编程中如何提炼和使用。
二  定义工具类
1  常用定义方式
通常,我们会如下定义工具类:
/** 例子工具类 */public class ExampleHelper {    /** 常量值 */    public final static int CONST_VALUE = 123;    /** 求和方法 */    public static int sum(int a, int b) {        return a + b;    }}
2  存在一些问题
修饰符顺序不规范
通过SonarLint插件扫描,会出现以下问题:

Java语言规范建议使用”static final”,而不是”final static”。请记住这么一条规则:静态常量,静态(static)在前,常量(final)在后。
工具类可以被继承覆盖
如果我们定义一个MyExampleHelper来继承ExampleHelper:
public class MyExampleHelper extends ExampleHelper {    /** 常量值 */    public static final int CONST_VALUE = 321;    /** 求和方法 */    public static int sum(int a, int b) {        return a * b;    }}
会发现,MyExampleHelper会对ExampleHelper中的常量和方法进行覆盖,导致我们不知道是不是使用了ExampleHelper中的常量和方法。
对于Apache提供的工具类,很多同学都喜欢定义相同名称的工具类,并让这个工具类继承Apache的工具类,并在这个类中添加自己的实现方法。其实,我是非常不推荐这种做法的,因为你不知道——你调用的是Apache工具类提供的常量和方法,还是被覆盖的常量和方法。最好的办法,就是对工具类添加final关键字,让这个工具类不能被继承和覆盖。
工具类可以被实例化
对于ExampleHelper工具类,我们可以这样使用:
int value = ExampleHelper.CONST_VALUE;int sum = ExampleHelper.sum(1, 2);
也可以被这样使用:
ExampleHelper exampleHelper = new ExampleHelper();int value = exampleHelper.CONST_VALUE;int sum = exampleHelper.sum(1, 2);
对于工具类来说,没有必要进行实例化。所以,我们建议添加私有构造方法,并在方法中抛出UnsupportedOperationException(不支持的操作异常)。
3  最佳定义方式
根据以上存在问题及其解决方法,最佳定义的ExampleHelper工具类如下:
/** 例子工具类 */public final class ExampleHelper {    /** 常量值 */    public static final int CONST_VALUE = 123;    /** 构造方法 */    private ExampleHelper() {        throw new UnsupportedOperationException();    }    /** 求和方法 */    public static int sum(int a, int b) {        return a + b;    }}
三  定义枚举类
1  常用定义方式
通常,我们会如下定义枚举类:
/** 例子枚举类 */public enum ExampleEnum {    /** 枚举相关 */    ONE(1, "one(1)"),    TWO(2, "two(2)"),    THREE(3, "two(3)");    /** 属性相关 */    private Integer value;    private String desc;    /** 构造方法 */    private ExampleEnum(Integer value, String desc) {        this.value = value;        this.desc = desc;    }    /** 获取取值 */    public Integer getValue() {        return value;    }    /** 获取描述 */    public String getDesc() {        return desc;    }}
2  一些优化建议
修饰符private可缺省
通过SonarLint插件扫描,会出现以下问题:

根据建议,应该删除构造方法前多余的private修饰符。
建议使用基础类型
用包装类型Integer保存枚举取值,本身并没有什么问题。但是,本着能用基础类型就用基础类型的规则,所以建议使用基础类型int。
建议使用final字段
假设,我们要实现一个静态方法,可能一不小心就把枚举值给修改了:
/** 修改取值 */public static void modifyValue() {    for (ExampleEnum value : values()) {        value.value++;    }}
如果调用了modifyValue方法,就会把枚举值修改,导致应用程序出错。为了避免这样的情况出现,我们建议对字段添加final修饰符,从而避免字段值被恶意篡改。
3  最佳定义方式
/** 例子枚举类 */public enum ExampleEnum {    /** 枚举相关 */    ONE(1, "one(1)"),    TWO(2, "two(2)"),    THREE(3, "two(3)");    /** 字段相关 */    private final int value;    private final String desc;    /** 构造方法 */    ExampleEnum(int value, String desc) {        this.value = value;        this.desc = desc;    }    /** 获取取值 */    public int getValue() {        return value;    }    /** 获取描述 */    public String getDesc() {        return desc;    }}
四  定义模型类
下面,以定义User(用户)模型类为例,从JavaBean模式、重载构造方法、Builder模式3种方式,来说明模型类的定义方法以及优缺点。
假设:User(用户)模型类共有4个属性——id(标识)、name(名称)、age(年龄)、desc(描述),其中必填属性为——id(标识)、name(名称),可填属性为——age(年龄)、desc(描述)。
1  JavaBean模式
JavaBean是一个遵循特定写法的Java类,它通常具有如下特点:
  1. 必须具有一个无参的构造方法;

  2. 所有属性字段必须是私有的;

  3. 所有属性字段必须通过遵循一种命名规范的Getter/Setter方法开放出来。

通过JavaBean模式定义的User(用户)模型类如下:
/** 用户类 */public class User {    private Long id;    private String name;    private Integer age;    private String desc;    public Long getId() {return id;}    public void setId(Long id) {this.id = id;}    public String getName() {return name;}    public void setName(String name) {this.name = name;}    public Integer getAge() {return age;}    public vid setAge(Integer age) {this.age = age;}    public String getDesc() {return desc;}    public void setDesc(String desc) {this.desc = desc;}}
注意:也可以通过Lombok的@Getter/@Setter注解生成对应个Getter/Setter方法。
使用代码:
User user = new User();user.setId(1L);user.setName("alibaba");user.setAge(102);user.setDesc("test");verifyUser(user);
主要优点:
  1. 代码非常简单,只有私有属性字段及其公有Getter/Setter方法;

  2. 赋值对象代码可读性较强,明确地知道哪个属性字段对应哪个值;

  3. 非常简单实用,被广泛地用于HSF、Dubbo、MyBatis等中间件。

主要缺点:
  1. 由于可以通过Setter方法设置属性字段,所以不能定义为不可变类;

  2. 由于每个字段分别设置,所以不能保证字段必填,必须设置完毕后进行统一验证。

2  重载构造方法
通过”重载构造方法”定义User(用户)模型类如下:
/** 用户类 */public final class User {    private Long id;    private String name;    private Integer age;    private String desc;    public User(Long id, String name) {        this(id, name, null);    }    public User(Long id, String name, Integer age) {        this(id, name, age, null);    }    public User(Long id, String name, Integer age, String desc) {        Assert.notNull(id, "标识不能为空");        Assert.notNull(name, "名称不能为空");        this.id = id;        this.name = name;        this.age = age;        this.desc = desc;    }    public Long getId() {return id;}    public String getName() {return name;}    public Integer getAge() {return age;}    public String getDesc() {return desc;}}
使用代码:
User user1 = new User(1L, "alibaba");User user2 = new User(1L, "alibaba", 102, "test");
主要优点:
  1. 初始化对象代码简洁,只有简单的一行代码;

  2. 可以定义为不可变类,初始化后属性字段值不可变更;

  3. 可以在构造方法内进行不可空验证。

主要缺点:
  1. 重载构造方法数量过多,无法覆盖必填字段和非必填字段的所有组合;

  2. 初始化对象代码可读性差,无法看出哪个属性字段对应哪个值;

  3. 如果删除某个字段,初始化对象代码可能不会报错,导致出现赋值错误问题。

3  Builder模式
/** 用户类 */public final class User {    private Long id;    private String name;    private Integer age;    private String desc;    private User(Builder builder) {        this.id = builder.id;        this.name = builder.name;        this.age = builder.age;        this.desc = builder.desc;    }    public static Builder newBuilder(Long id, String name) {        return new Builder(id, name);    }    public Long getId() {return id;}    public String getName() {return name;}    public Integer getAge() {return age;}    public String getDesc() {return desc;}    public static class Builder {        private Long id;        private String name;        private Integer age;        private String desc;        private Builder(Long id, String name) {            Assert.notNull(id, "标识不能为空");            Assert.notNull(name, "名称不能为空");            this.id = id;            this.name = name;        }        public Builder age(Integer age) {            this.age = age;            return this;        }        public Builder desc(String desc) {            this.desc = desc;            return this;        }        public User build() {            return new User(this);        }    }}
注意:可以采用Lombok的@Builder注解简化代码。
使用代码:
User user = User.newBuilder(1L, "alibaba").age(102).desc("test").build();
主要优点:
  1. 明确了必填参数和可选参数,在构造方法中进行验证;

  2. 可以定义为不可变类,初始化后属性字段值不可变更;

  3. 赋值代码可读性较好,明确知道哪个属性字段对应哪个值;

  4. 支持链式方法调用,相比于调用Setter方法,代码更简洁。

主要缺点:
  1. 代码量较大,多定义了一个Builder类,多定义了一套属性字段,多实现了一套赋值方法;

  2. 运行效率低,需要先创建Builder实例,再赋值属性字段,再创建目标实例,最后拷贝属性字段。

五  定义集合常量
在编码中,经常使用到各种集合常量,比如List(列表)常量、Set(集合)常量、Map(映射)常量等。
1  普通定义方式
定义代码:
最简单的方法,就是直接定义一个普通的集合常量。
/** 例子工具类 */public final class ExampleHelper {    /** 常量值列表 */    public static final List<Integer> CONST_VALUE_LIST = Arrays.asList(1, 2, 3);    /** 常量值集合 */    public static final Set<Integer> CONST_VALUE_SET = new HashSet<>(Arrays.asList(1, 2, 3));    /** 常量值映射 */    public static final Map<Integer, String> CONST_VALUE_MAP;    static {        CONST_VALUE_MAP = new HashMap<>(MapHelper.DEFAULT);        CONST_VALUE_MAP.put(1, "value1");        CONST_VALUE_MAP.put(2, "value2");        CONST_VALUE_MAP.put(3, "value3");    }    ...}
使用代码:
使用也很方便,直接通过”类名.常量名”使用。
// 使用常量值集合List<Integer> constValueList = ExampleHelper.CONST_VALUE_LIST;Set<Integer> constValueSet = ExampleHelper.CONST_VALUE_SET;Map<Integer, String> constValueMap = ExampleHelper.CONST_VALUE_MAP
2  存在主要问题
通过SonarLint插件扫描,会出现以下问题:

由于普通的集合对象(如ArrayList、HashMap、HashSet等)都是可变集合对象,即便是定义为静态常量,也可以通过操作方法进行修改。所以,上面方法定义的集合常量,并不是真正意义上的集合常量。其中,Arrays.asList方法生成的内部ArrayList不能执行add/remove/clear方法,但是可以set方法,也属于可变集合对象。
// 操作常量列表ExampleHelper.CONST_VALUE_LIST.remove(3); // UnsupportedOperationExceptionExampleHelper.CONST_VALUE_LIST.add(4); // UnsupportedOperationExceptionExampleHelper.CONST_VALUE_LIST.set(1, 20); // [1,20,3]ExampleHelper.CONST_VALUE_LIST.clear(); // UnsupportedOperationException// 操作常量集合ExampleHelper.CONST_VALUE_SET.remove(3); // [1,2]ExampleHelper.CONST_VALUE_SET.add(3); // [1,2,3]ExampleHelper.CONST_VALUE_SET.clear(); // []// 操作常量映射ExampleHelper.CONST_VALUE_MAP.remove(3); // {1:"value1",2:"value2"}ExampleHelper.CONST_VALUE_MAP.put(3, "value3"); // {1:"value1",2:"value2",3:"value3"}ExampleHelper.CONST_VALUE_MAP.clear(); // []
3  最佳定义方式
在JDK中,Collections工具类中提供一套方法,用于把可变集合对象变为不可变(不可修改,修改时会抛出UnsupportedOperationException异常)集合对象。所以,可以利用这套方法定义集合静态常量。
/** 例子工具类 */public final class ExampleHelper {    /** 常量值列表 */    public static final List<Integer> CONST_VALUE_LIST = Collections.unmodifiableList(Arrays.asList(1, 2, 3));    /** 常量值集合 */    public static final Set<Integer> CONST_VALUE_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(1, 2, 3)));    /** 常量值映射 */    public static final Map<Integer, String> CONST_VALUE_MAP;    static {        Map<Integer, String> valueMap = new HashMap<>(MapHelper.DEFAULT);        valueMap.put(1, "value1");        valueMap.put(2, "value2");        valueMap.put(3, "value3");        CONST_VALUE_MAP = Collections.unmodifiableMap(valueMap);    }    ...}
六  定义数组常量
上一章介绍了如何定义集合常量,这一章就来介绍一下如何定义数组常量。
1  定义公有数组常量
定义代码:
一般人定义数组常量,就会像下面代码一样,定义一个公有数组常量。
/** 例子工具类 */public final class ExampleHelper {    /** 常量值数组 */    public static final int[] CONST_VALUES = new int[] {1, 2, 3};    ...}
使用代码:
使用也很方便,直接通过”类名.常量名”使用。
// 使用常量值数组int[] constValues = ExampleHelper.CONST_VALUES;
存在问题:
但是,可以通过下标修改数组值,导致数组常量的值可变。所以,这种方法定义的数组常量,并不是一个真正意义上的数组常量。
// 修改常量值数组ExampleHelper.CONST_VALUES[1] = 20// [1, 20, 3]
2  定义公有集合常量
定义代码:
可以通过上一章定义集合常量的方法,返回一个公有集合常量。
/** 例子工具类 */public final class ExampleHelper {    /** 常量值列表 */    public static final List<Integer> CONST_VALUE_LIST =        Collections.unmodifiableList(Arrays.asList(1, 2, 3));    ...}
使用代码:
要想得到数组常量,就把集合常量转化为数组常量。
// 使用常量值列表int[] constValues = ExampleHelper.CONST_VALUE_LIST.stream()    .mapToInt(Integer::intValue).toArray();
存在问题:
每一次都会把集合常量转化为数组常量,导致程序运行效率降低。
3  最佳定义方式
最佳法”私有数组常量+公有克隆方法”的解决方案。如下代码所示:先定义一个私有数组常量,保证不会被外部类使用;在定义一个获取数组常量方法,并返回一个数组常量的克隆值。
定义代码:
这里,提供一个”私有数组常量+公有克隆方法”的解决方案。如下代码所示:先定义一个私有数组常量,保证不会被外部类使用;在定义一个获取数组常量方法,并返回一个数组常量的克隆值。
/** 例子工具类 */public final class ExampleHelper {    /** 常量值数组 */    private static final int[] CONST_VALUES = new int[] {1, 2, 3};    /** 获取常量值数组方法 */    public static int[] getConstValues() {        return CONST_VALUES.clone();    }    ...}
使用代码:
由于每次返回的是一个克隆数组,即便修改了克隆数组的常量值,也不会导致原始数组常量值的修改。
// 使用常量值方法int[] constValues = ExampleHelper.getConstValues(); // [1, 2, 3]constValues[1] = 20; // [1, 20, 3]constValues = ExampleHelper.getConstValues(); // [1, 2, 3]
七  定义多条件表达式
1  利用运算符&&(或||)直接拼接
定义代码:
有时候,我们会判断很多条件,需求用&&(或||)连接多个条件表达式。
/** 获取审核结果方法 */private static Integer getAuditResult(AuditDataVO data) {    if (isPassed(data.getAuditItem1())        && isPassed(data.getAuditItem2())        ...        && isPassed(data.getAuditItem11())) {        return AuditResult.PASSED;    }    return AuditResult.REJECTED;}
存在问题:
通过SonarLint插件扫描,会存在2个问题:

其中,圈复杂度(Cyclomatic complexity,CC)也称为条件复杂度,是一种衡量代码复杂度的标准,其符号为V(G)。
麦凯布最早提出一种称为“基础路径测试”(Basis Path Testing)的软件测试方式,测试程序中的每一线性独立路径,所需的测试用例个数即为程序的圈复杂度。
圈复杂度可以用来衡量一个模块判定结构的复杂程度,其数量上表现为独立路径的条数,也可理解为覆盖所有的可能情况最少使用的测试用例个数。
2  利用运算符=和&&(或||)级联拼接
定义代码:
那么,就把&&(或||)连接符拆开,利用运算符=和&&(或||)级联进行拼接。
/** 获取审核结果方法 */private static AuditResult getAuditResult(AuditDataVO data) {    boolean isPassed = isPassed(data.getAuditItem1());    isPassed = isPassed && isPassed(data.getAuditItem2());    ...    isPassed = isPassed && isPassed(data.getAuditItem11());    if (isPassed) {        return AuditResult.PASSED;    }    return AuditResult.REJECTED;}
存在问题:
通过SonarLint插件扫描,还存在1个问题:

也就是,利用运算符=和&&(或||)级联进行拼接,并不能减少方法的圈复杂度。
3  利用动态无参数Lambda表达式列表
定义代码:
下面,利用动态无参数Lambda表达式列表优化,即把每个条件表达式作为BooleanSupplier对象存在列表中,然后依次执行条件表达式得出最后结果。
/** 获取审核结果方法 */private static AuditResult getAuditResult(AuditDataVO data) {    List<BooleanSupplier> supplierList = new ArrayList<>();    supplierList.add(() -> isPassed(data.getAuditItem1()));    supplierList.add(() -> isPassed(data.getAuditItem2()));    ...    supplierList.add(() -> isPassed(data.getAuditItem11()));    for (BooleanSupplier supplier : supplierList) {        if (!supplier.getAsBoolean()) {            return AuditResult.REJECTED;        }    }    return AuditResult.PASSED;}
存在问题:
通过SonarLint插件扫描,没有提示任何问题。但是,每次都动态添加Lambda表达式,就会导致程序效率低下。那么,有没有把Lambda表达式静态化的方法呢?
4  利用静态有参数Lambda表达式列表
定义代码:
要想固化Lambda表达式,就必须动态传入AuditDataVO对象。这里,采用Predicate<AuditDataVO>来接收Lambda表达式,在Lambda表达式中指定AuditDataVO对象data。然后,在for循环中,依次指定AuditDataVO对象data,并计算表达式的值。
/** 审核结果断言列表 */private static final List<Predicate<AuditDataVO>> AUDIT_RESULT_PREDICATE_LIST =    Collections.unmodifiableList(Arrays.asList(        data -> isPassed(data.getAuditItem1()),        data -> isPassed(data.getAuditItem2()),        ...        data -> isPassed(data.getAuditItem11())));/** 获取审核结果方法 */private static AuditResult getAuditResult(AuditDataVO data) {    for (Predicate<AuditDataVO> predicate : AUDIT_RESULT_PREDICATE_LIST) {        if (!predicate.test(data)) {            return AuditResult.REJECTED;        }    }    return AuditResult.PASSED;}
适用条件:
  1. 适合于&&(或||)连接大量条件表达式的情况;

  2. 适合于每个条件表达式都需要传入相同参数的情况,如果每个条件表达式传入参数不同,只能使用动态无参数Lambda表达式列表方法;

  3. 如果需要传入两个参数,可以使用BiPredicate类型来接收Lambda表达式;如果需要传入多个参数,则需要自定义方法接口。

后记
明代思想家王阳明在《传习录》中说道:
初种根时,只管栽培灌溉,勿作枝想,勿作叶想,勿作花想,勿作实想。悬想何益?但不忘栽培之功,怕没有枝叶花实?
这也是我们高德研发团队的人才宗旨——不论学历、不论经历、不论年龄、不论性别,只要有缘来到我们的团队,我们都将一视同仁地“栽培灌溉”;力求让每一个新人都能够茁壮成长,绽放出最完美的“枝叶花实”。
我们诚聘各类优秀人才:Java工程师、C++工程师、算法工程师、前端工程师、客户端工程师。欢迎大家投简历到gdtech@alibaba-inc.com,邮件标题格式为“姓名-技术方向-来自阿里技术”。


免费领取电子书

高德技术2020年刊合辑

高德技术重磅发布《高德技术2020年刊合辑》电子书,覆盖了大前端、算法、架构、汽车工程、质量等多个领域,以及数篇高德入选顶会论文的解读,分享高德在智慧出行上的最佳技术实践和总结。

扫码加阿里妹好友回复“高德”获取吧~(若扫码无效,可通过微信号alimei4、alimei5、alimei6、alimei7直接添加)

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-10 12:34:22 HTTP/2.0 GET : https://f.mffb.com.cn/a/458938.html
  2. 运行时间 : 0.110602s [ 吞吐率:9.04req/s ] 内存消耗:4,970.29kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=5806184eb096e3a6c10f8f4bada5c263
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000485s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000993s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001436s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000304s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000538s ]
  6. SELECT * FROM `set` [ RunTime:0.000195s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000513s ]
  8. SELECT * FROM `article` WHERE `id` = 458938 LIMIT 1 [ RunTime:0.000656s ]
  9. UPDATE `article` SET `lasttime` = 1770698062 WHERE `id` = 458938 [ RunTime:0.010860s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 65 LIMIT 1 [ RunTime:0.000229s ]
  11. SELECT * FROM `article` WHERE `id` < 458938 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000541s ]
  12. SELECT * FROM `article` WHERE `id` > 458938 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.010587s ]
  13. SELECT * FROM `article` WHERE `id` < 458938 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000953s ]
  14. SELECT * FROM `article` WHERE `id` < 458938 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002572s ]
  15. SELECT * FROM `article` WHERE `id` < 458938 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002090s ]
0.112175s