<?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.dayou.mapper.PersonalCalculateMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dayou.entity.PersonalCalculate">
        <result column="id" property="id" />
        <result column="created" property="created" />
        <result column="modified" property="modified" />
        <result column="deleted" property="deleted" />
        <result column="fix_value" property="fixValue" />
        <result column="rights_type" property="rightsType" />
        <result column="calculate_type" property="calculateType" />
        <result column="method" property="method" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,fix_value, rights_type, calculate_type, method,rolling_level,sell_money,sell_money_base,sell_money_rate
    </sql>

    <delete id="realDelete" parameterType="java.lang.Long">
        delete from personal_calculate where id = #{id}
    </delete>

    <select id="getByTargetId" parameterType="java.lang.Long" resultType="com.dayou.entity.PersonalCalculate">
        select <include refid="Base_Column_List" /> from personal_calculate where
            id = ( select distinct calculate_id from personal_example where target_id = #{targetId} and deleted = 0 and is_example=0)
            and deleted = 0
    </select>
</mapper>
