wjbk

导航

mapper.xml 返回map格式

//DAO层

List<Map<String,Object>> selectRecord(Map<String,Object>map);

 

 

//mapper层

<select id="selectUpCountByTime" parameterType="map" resultType="java.util.HashMap">
  SELECT create_by as username,DATE_FORMAT(create_time,'%Y-%m-%d') as dates,count(0) as counts FROM t_break_rule
  <where>
  del_flag='0'
  <if test="startTime != null">
    and DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') &gt;= DATE_FORMAT(#{startTime,jdbcType=TIMESTAMP},'%Y-%m-%d %H:%i:%S')
  </if>
  <if test="endTime != null">
    and DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') &lt;= DATE_FORMAT(#{endTime,jdbcType=TIMESTAMP},'%Y-%m-%d %H:%i:%S')
  </if>
  </where>
  GROUP BY create_by ,DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY DATE_FORMAT(create_time,'%Y-%m-%d') ASC
</select>

 注意:如果字段值为null时,map不返回该字段,需要在springboot项目.properties文件中配置

mybatis.configuration.call-setters-on-nulls=true

posted on 2023-10-09 14:29  wjbk  阅读(406)  评论(0编辑  收藏  举报