<?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="org.springblade.modules.investment.mapper.IbaProjectVolumeMapper">

    <resultMap id="BaseResultMap" type="org.springblade.modules.investment.pojo.entity.IbaProjectVolume">
            <id property="id" column="id" />
            <result property="projectId" column="project_id" />
            <result property="year" column="year" />
            <result property="month" column="month" />
            <result property="number" column="number" />
            <result property="isDeleted" column="is_deleted" />
            <result property="createTime" column="create_time" />
            <result property="createUser" column="create_user" />
            <result property="updateTime" column="update_time" />
            <result property="updateUser" column="update_user" />
    </resultMap>
    <resultMap id="groupYear" type="org.springblade.modules.investment.pojo.dto.IbaProjectVolumeDTO">
        <result column="year" property="year"/>
        <collection property="ibaProjectVolumeList" javaType="java.util.List" resultMap="BaseResultMap"/>
    </resultMap>


    <sql id="Base_Column_List">
        id,project_id,year,month,number,is_deleted,
        create_time,create_user,update_time,update_user
    </sql>
    <update id="updateIsDeleted">
        UPDATE iba_project SET is_deleted = #{isDeleted} WHERE project_id IN
        <foreach item="id" collection="ids" separator="," open="(" close=")" index="">
            #{id}
        </foreach>
    </update>
    <select id="selectGroupYearList"
            resultMap="groupYear">
        select <include refid="Base_Column_List"/> from iba_project_volume where project_id = #{id}
        group by year, month
        order by year, month
    </select>
</mapper>
