Map<String, Object> map = new HashMap<>(); Integer page = pagination.getPage(); Integer limit = pagination.getLimit(); map.put("start", (page - 1) * limit); map.put("pageNo", limit); map.put("field", pagination.getField()); map.put("order", pagination.getOrder());
<select id="querySentEmails" resultType="EmailDTO"> SELECT m.*, s.realUserName AS receiver, FROM_UNIXTIME(m.createTime,'%Y-%m-%d') AS createTimeStr 秒级时间戳转换 -> FROM_UNIXTIME(a.createTime,'%Y-%m-%d %H:%i:%s') as createTimeStr FROM mail_info_data m LEFT JOIN sys_users s ON m.receiverId = s.userId <where> m.senderDelete != 1 <if test="senderId !=null"> AND m.senderId=#{senderId} </if> <if test="title != null and title !=''"> AND m.title like concat('%',#{title},'%') 模糊查询 </if> <if test="receiver != null and receiver !=''"> AND s.realUserName like concat('%',#{receiver},'%') </if> <if test="createTimeStartStr !=null and createTimeStartStr !=''"> AND FROM_UNIXTIME(m.createTime,'%Y-%m-%d') >= #{createTimeStartStr} 时间查询 </if> <if test="createTimeEndStr !=null and createTimeEndStr !=''"> AND FROM_UNIXTIME(m.createTime,'%Y-%m-%d') <= #{createTimeEndStr} </if> </where> <choose> <when test="field !=null and field !=''"> ORDER BY ${field} ${order} 分页 </when> <otherwise> ORDER BY m.createTime desc 默认分页 </otherwise> </choose> limit #{start}, #{pageNo} </select>