时间参数的传递

 

时间 参数在 postman 中发送的形式如上(字符串的形式):

在Controller 中定义的字段:

@RequestBody GxySignDto gxySignDto
@TableField(exist = false)
private Date startTime;
@TableField(exist = false)
private Date endTime;
就可以把 startTime 和 endTime 映射到 gxySignDto 实体中。
mapper:
List<GxySignDto> list(Page page, @Param("gxySignDto") GxySignDto gxySignDto);
在xml 中即可以 用 SIGN_TIME              datetime   形式的字段与传入的
 <select >
        SELECT * FROM gxy_sign where state='CREATE'
        <if test="gxySignDto.startTime != null">
            AND SIGN_TIME &gt;= #{gxySignDto.startTime}
        </if>
        <if test="gxySignDto.endTime != null ">
            AND SIGN_TIME &lt;= #{gxySignDto.endTime}
        </if>
    </select>

 

startTime 和 endTime 是Date 类型,只需要与null 比较,不需要加上 and gxySignDto.endTime != '' 否则会报错


 

相关文章:

  • 2022-12-23
  • 2021-10-07
  • 2022-02-04
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2021-11-29
猜你喜欢
  • 2021-10-31
  • 2022-02-11
  • 2021-08-27
  • 2021-11-23
  • 2021-10-21
  • 2021-04-02
  • 2022-12-23
相关资源
相似解决方案