jhprjv2/yanzhu-jh/src/main/resources/mapper/project/SurProjectPlanMapper.xml

128 lines
6.9 KiB
XML

<?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="com.yanzhu.jh.project.mapper.SurProjectPlanMapper">
<resultMap type="SurProjectPlan" id="SurProjectPlanResult">
<result property="id" column="id" />
<result property="projectName" column="project_name" />
<result property="content" column="content" />
<result property="buildType" column="build_type" />
<result property="dept" column="dept" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="totalInvestment" column="total_investment" />
<result property="yearInvestment" column="year_investment" />
<result property="planType" column="plan_type" />
<result property="remark" column="remark" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSurProjectPlanVo">
select id, project_name, content, build_type, dept, start_date, end_date, total_investment, year_investment, plan_type, remark, is_del, create_by, create_time, update_by, update_time from sur_project_plan
</sql>
<select id="selectSurProjectPlanList" parameterType="SurProjectPlan" resultMap="SurProjectPlanResult">
<include refid="selectSurProjectPlanVo"/>
<where>
<if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="buildType != null and buildType != ''"> and build_type = #{buildType}</if>
<if test="dept != null and dept != ''"> and dept = #{dept}</if>
<if test="startDate != null and startDate != ''"> and start_date = #{startDate}</if>
<if test="endDate != null and endDate != ''"> and end_date = #{endDate}</if>
<if test="totalInvestment != null "> and total_investment = #{totalInvestment}</if>
<if test="yearInvestment != null "> and year_investment = #{yearInvestment}</if>
<if test="planType != null "> and plan_type = #{planType}</if>
<if test="isDel != null "> and is_del = #{isDel}</if>
</where>
</select>
<select id="selectSurProjectPlanById" parameterType="Long" resultMap="SurProjectPlanResult">
<include refid="selectSurProjectPlanVo"/>
where id = #{id}
</select>
<insert id="insertSurProjectPlan" parameterType="SurProjectPlan" useGeneratedKeys="true" keyProperty="id">
insert into sur_project_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="projectName != null">project_name,</if>
<if test="content != null">content,</if>
<if test="buildType != null">build_type,</if>
<if test="dept != null">dept,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="totalInvestment != null">total_investment,</if>
<if test="yearInvestment != null">year_investment,</if>
<if test="planType != null">plan_type,</if>
<if test="remark != null">remark,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectName != null">#{projectName},</if>
<if test="content != null">#{content},</if>
<if test="buildType != null">#{buildType},</if>
<if test="dept != null">#{dept},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="totalInvestment != null">#{totalInvestment},</if>
<if test="yearInvestment != null">#{yearInvestment},</if>
<if test="planType != null">#{planType},</if>
<if test="remark != null">#{remark},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSurProjectPlan" parameterType="SurProjectPlan">
update sur_project_plan
<trim prefix="SET" suffixOverrides=",">
<if test="projectName != null">project_name = #{projectName},</if>
<if test="content != null">content = #{content},</if>
<if test="buildType != null">build_type = #{buildType},</if>
<if test="dept != null">dept = #{dept},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="totalInvestment != null">total_investment = #{totalInvestment},</if>
<if test="yearInvestment != null">year_investment = #{yearInvestment},</if>
<if test="planType != null">plan_type = #{planType},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSurProjectPlanById" parameterType="Long">
delete from sur_project_plan where id = #{id}
</delete>
<delete id="deleteSurProjectPlanByIds" parameterType="String">
delete from sur_project_plan where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectSurProjectPlanListTop3" resultMap="SurProjectPlanResult">
SELECT * FROM (
SELECT * FROM sur_project_plan WHERE IF(is_del,is_del,0)=0 AND plan_type=0 LIMIT 0,3 ) a
UNION
SELECT * FROM (
SELECT * FROM sur_project_plan WHERE IF(is_del,is_del,0)=0 AND plan_type=1 LIMIT 0,3 ) b
</select>
</mapper>