<?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.liquidnet.service.sweet.mapper.SweetCityVoteStatMapper">

    <resultMap id="getListResult" type="com.liquidnet.service.sweet.dto.SweetCityVoteStatDto">
        <result column="city_code" property="cityCode"/>
        <result column="city_name" property="cityName"/>
        <result column="vote_num" property="voteNum"/>
        <result column="manual_vote_num" property="manualVoteNum"/>
        <result column="total_num" property="totalNum"/>
        <result column="type" property="type"/>
    </resultMap>

    <select id="getStatList" resultMap="getListResult">
        select
        *, (vote_num + manual_vote_num) as total_num
        from sweet_city_vote_stat
        <where>
            <if test="type != ''">
                AND type=${type}
            </if>
        </where>
        GROUP BY city_code
        ORDER BY total_num DESC
    </select>
</mapper>
