后端
实体类中时间注解
import org.springframework.format.annotation.DateTimeFormat;
@ApiModelProperty(value = "点赞范围起始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startDate;
@ApiModelProperty(value = "点赞范围终止时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endDate;
mybatis-plus查询
wrapper.between("CREATE_TIME", userFavoritePageParam.getStartDate(), userFavoritePageParam.getEndDate());
前端
HTML
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
<a-row :gutter="24">
<a-col :span="6">
<a-form-item label="创建时间" name="selectTime">
<a-range-picker v-model:value="searchFormState.selectTime" value-format="YYYY-MM-DD HH:mm:ss" show-time />
</a-form-item>
</a-col>
<a-col :span="6">
<a-button type="primary" @click="table.refresh(true)">查询</a-button>
<a-button style="margin: 0 8px" @click="reset">重置</a-button>
</a-col>
</a-row>
</a-form>
JS
const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
// selectTime范围查询条件重载
if (searchFormParam.selectTime) {
searchFormParam.startDate = searchFormParam.selectTime[0]
searchFormParam.endDate = searchFormParam.selectTime[1]
delete searchFormParam.selectTime
}