<?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.changhu.module.assessmentCriteria.mapper.CkProjectMapper">
    <select id="pager" resultType="com.changhu.module.assessmentCriteria.pojo.vo.CkProjectPagerVo">
        select cp.*, msu.name as 'createUserName'
        from ck_project cp
        left join management_super_user msu on cp.create_by = msu.snow_flake_id
        where cp.delete_flag = 0
        <if test="params.name != null and params.name != ''">
            and cp.name like concat('%',#{params.name},'%')
        </if>
        <if test="params.type != null">
            and cp.type = #{params.type.value}
        </if>
        order by cp.create_time desc
    </select>
    <select id="ckProjectDetail"
            resultType="com.changhu.module.assessmentCriteria.pojo.vo.CkProjectDetailTableVo">
        select cg.snow_flake_id as 'ckGroupId',
               cg.name          as 'groupName',
               cg.total_score   as 'groupTotalScore',
               cg.remark        as 'groupRemark',
               ci.snow_flake_id as 'ckItemId',
               ci.name          as 'itemName',
               ci.type          as 'itemType',
               ci.remark        as 'itemRemark',
               cs.snow_flake_id as 'ckStandardId',
               cs.`name`        as 'standardName',
               cs.deduction_points
        from ck_project cp
                 left join ck_group cg on cp.snow_flake_id = cg.ck_project_id and cg.delete_flag = 0
                 left join ck_item ci on cg.snow_flake_id = ci.ck_group_id and ci.delete_flag = 0
                 left join ck_standard cs on ci.snow_flake_id = cs.ck_item_id and cs.delete_flag = 0
        where cp.delete_flag = 0
          and cp.snow_flake_id = #{ckProjectId}
        order by cp.snow_flake_id, cg.create_time, cs.create_time
    </select>
</mapper>