<?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.kxs.user.biz.mapper.KxsShdScoreMapper">

    <resultMap type="com.kxs.user.api.model.KxsShdScore" id="KxsShdScoreMap">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="version" property="version" />
        <result column="username" property="username" />
        <result column="user_code" property="userCode" />
        <result column="first_score" property="firstScore" />
        <result column="center_score" property="centerScore" />
        <result column="high_score" property="highScore" />

    </resultMap>
    <select id="getMyStandards"
            resultType="com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsVO">
                SELECT
                     first_score,center_score,high_score
                 FROM kxs_shd_score
                 WHERE
                     del_flag != 1
                     and user_code = #{userCode}
                     and month = #{month}
    </select>
    <select id="getMyStandardsAll"
            resultType="com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsAllVO">
        SELECT
            sum(first_score) as firstScoreAll ,
            sum(center_score) as centerScoreAll ,
            sum(high_score) as highScoreAll
        FROM kxs_shd_score
        WHERE
            del_flag != 1
          and month = #{month}
    </select>

    <select id="getShareholderHighScoreUserList"
            resultType="com.kxs.user.api.vo.kxsapp.subGetShareholderUserList.UserScoreListVO">
        SELECT
        <choose>
            <when test="type == 1">
                first_score AS score
            </when>
            <when test="type == 2">
                center_score AS score
            </when>
            <when test="type == 3">
                high_score AS score
            </when>
        </choose>,
        id,username,user_code,id
        FROM kxs_shd_score
        WHERE del_flag != 1
        AND month = #{month}
        <choose>
            <when test="type == 1">
                ORDER BY first_score
            </when>
            <when test="type == 2">
                ORDER BY center_score
            </when>
            <when test="type == 3">
                ORDER BY high_score
            </when>
        </choose>
    </select>































</mapper>
