<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="cn.wisenergy.mapper.WorkProjectMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkProject"> <id column="id" property="id" /> <result column="oa_project_id" property="oaProjectId" /> <result column="project_name" property="projectName" /> <result column="type" property="type" /> <result column="manager_id" property="managerId" /> <result column="dept_id" property="deptId" /> <result column="work_time" property="workTime" /> <result column="cost_budget" property="costBudget" /> <result column="is_conclusion" property="isConclusion" /> <result column="start_time" property="startTime" /> <result column="end_time" property="endTime" /> <result column="create_time" property="createTime" /> <result column="modify_time" property="modifyTime" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, oa_project_id, project_name, type, manager_id, dept_id, work_time, cost_budget, is_conclusion,start_time,end_time, create_time, modify_time </sql> <sql id="table"> work_project </sql> <!--查询条件--> <sql id="criteria"> <if test="id != null">and id = #{id}</if> <if test="oaProjectId != null">and oa_project_id = #{oaProjectId}</if> <if test="projectName != null">and project_name = #{projectName}</if> <if test="type != null">and type =#{type}</if> <if test="managerId != null">and manager_id = #{managerId}</if> <if test="dept_id != null">and dept_id = #{dept_id}</if> <if test="workTime != null">and work_time =#{workTime}</if> <if test="costBudget != null">and cost_budget = #{costBudget}</if> <if test="isConclusion != null">and is_onclusion =#{isConclusion},</if> <if test="startTime != null">and start_time =#{startTime},</if> <if test="endTime != null">and end_time =#{endTime},</if> <if test="createTime != null">and create_time >= #{createTime}</if> <if test="modifyTime != null">and #{modifyTime} >= modify_time</if> </sql> <select id="getProjectsByCriteria" resultMap="BaseResultMap" parameterType="map"> select <include refid="Base_Column_List"/> from <include refid="table"/> <where> <include refid="criteria"/> <if test="deptIds != null"> AND dept_id IN <foreach collection="deptIds" item="deptId" separator="," open="(" close=")"> #{deptId} </foreach> </if> </where> </select> </mapper>