MemberInfoMapper.xml 3.33 KB
<?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.example.mapper.api.MemberInfoMapper">


    <insert id="create" parameterType="com.example.models.api.MemberInfo" useGeneratedKeys="true" keyProperty="id">

        INSERT INTO t_hpai_member_info (
     source,
     `timestamp`,
     barcode,
     channel_id,
     manager_id,
     `name`,
     gender,
     birthday_str,
     mobile_number,
     sampling_date,
     recipients,
     address,
     family_disease,
     existing_disease,
     weight,
     height,
     remarks,
     member_number,
     create_at,
     status,
     openid
        )
        VALUES (
     #{source},
     #{timestamp},
     #{barcode},
     #{channelId},
     #{managerId},
     #{name},
     #{gender},
     #{birthdayStr},
     #{mobileNumber},
     #{samplingDate},
     #{recipients},
     #{address},
     #{familyDisease},
     #{existingDisease},
     #{weight},
     #{height},
     #{remarks},
     #{memberNumber},
     #{createAt},
     #{status},
     #{openid}
     );
    </insert>
    
    <select id="getByopenid" resultType="com.example.models.api.MemberInfo">
        select * from t_hpai_member_info where openid = #{openid} limit 1;
    </select>

    <update id="genereport">
        update t_hpai_member_info set
     is_genereport = #{isGenereport},
     genereport_at = #{genereportAt},
     pack_name = #{packName},
     pdf_name = #{pdfName},
     url = #{url},
     genereport_name = #{genereportName} where openid = #{openid};
    </update>


    <select id="list" resultType="com.example.models.api.MemberInfo">
        select * from t_hpai_member_info where 1 = 1
        <if test="keyWord != null and keyWord != ''">
            and `name` LIKE CONCAT('%', #{keyWord}, '%')
        </if>
        <if test="status != -1">
            and is_genereport = #{status}
        </if>
    </select>


    <select id="count" resultType="int">
        select count(*) c from t_hpai_member_info where 1 = 1
        <if test="keyWord != null and keyWord != ''">
            and `name` LIKE CONCAT('%', #{keyWord}, '%')
        </if>
        <if test="status != -1">
            and is_genereport = #{status}
        </if>
    </select>


    <select id="registerByDay" resultType="map">
        select count(*) c,DATE_FORMAT(create_at,'%Y-%m-%d') d from t_hpai_member_info
        where create_at BETWEEN #{startTime} and #{endTime}
         group by DATE_FORMAT(create_at,'%Y-%m-%d')
    </select>

    <select id="genereportByDay" resultType="map">
        select count(*) c,DATE_FORMAT(genereport_at,'%Y-%m-%d') d from t_hpai_member_info
         where is_genereport = 1 and create_at BETWEEN #{startTime} and #{endTime} group by DATE_FORMAT(genereport_at,'%Y-%m-%d')
    </select>

    <select id="registerByMonth" resultType="map">
        select count(*) c,DATE_FORMAT(create_at,'%Y-%m') d from t_hpai_member_info
        where create_at BETWEEN #{startTime} and #{endTime}
        group by DATE_FORMAT(create_at,'%Y-%m')
    </select>

    <select id="genereportByMonth" resultType="map">
        select count(*) c,DATE_FORMAT(genereport_at,'%Y-%m') d from t_hpai_member_info
        where is_genereport = 1 and create_at BETWEEN #{startTime} and #{endTime} group by DATE_FORMAT(genereport_at,'%Y-%m')
    </select>


</mapper>