mybatis两种查询方式 一个是用resultMap 一个是用实体类 entity
1. resultMap
<resultMap type="java.util.HashMap" id="deptsubmitList">
<result property="count" jdbcType="VARCHAR" column="count"/>
<result property="number" jdbcType="VARCHAR" column="number"/>
</resultMap>
<!-- 查询列表 -->
<select id="queryDeptUtils" parameterType="java.util.HashMap" resultMap="deptsubmitList">
<![CDATA[
select
COUNT(id) count,
(CASE when number is null then 0 else number end ) as number
from t_f_submit
]]>
<where>
<if test="basicid != null and basicid != ''">
<![CDATA[
and basicid = #{basicid ,jdbcType=VARCHAR }
]]>
</if>
<if test="deptname != null and deptname != ''">
<![CDATA[
and deptname = #{deptname ,jdbcType=VARCHAR }
]]>
</if>
</where>
</select>
2.实体类entity
<select id="queryFileListCount" parameterType="java.util.HashMap" resultType="com.centit.cmip.main.entity.response.ResponseImgFileBean">
SELECT
COUNT(1) COUNT
FROM
t_file f
LEFT JOIN
t_dic d ON f.file_code = d.dic_code
<where>
f.file_status=0
<if test="id != null and id != ''">
<![CDATA[
AND f.id = #{id,jdbcType=VARCHAR}
]]>
</if>
</where>
ORDER BY f.file_createtime DESC
</select>