<commit_before><?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="SHCrowd">


    <insert id="addCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        INSERT INTO SHCROWD(TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ, DEL,ENDFLAG,REWARD,WDATE,LATLNG) VALUES
        (#{title},#{content},#{id},#{goalMoney},0,0,#{tag},
        #{sdate},#{edate},#{category},
        <if test="address != null and address!=''">
            #{address}
        </if>
        <if test="address == null or address==''">''</if>
        ,#{type},0,0,'0','0',DATE_FORMAT(NOW(), '%Y-%m-%d'),
        <if test="latlng != null and latlng!=''">
            #{latlng}

        </if>
        <if test="latlng == null or latlng==''">''</if>
        )
    </insert>

    <update id="delCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET DEL=1 WHERE SEQ=#{seq}

    </update>

    <select id="detailCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

     SELECT PNUM, SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE, REQ, LATLNG, WDATE FROM (
    SELECT IFNULL(PNUM,0) AS PNUM, SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE, REQ, LATLNG, WDATE
    FROM SHCROWD LEFT JOIN
    (SELECT COUNT(*) PNUM, PSEQ, SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY PSEQ) COUNTS ON COUNTS.PSEQ=SHCROWD.SEQ WHERE SEQ =#{seq}) A

    </select>

    <select id="reqCrowdList"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
    SELECT rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE FROM (
    SELECT @ROWNUM := @ROWNUM + 1 as rnn,IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE
    FROM SHCROWD left join
    (SELECT COUNT(*) PNUM,PSEQ,SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq,(SELECT @ROWNUM := 0)R WHERE REQ = 0 ORDER BY SEQ DESC) A

    </select>
    <select id="myReqCrowdList" parameterType="com.sung.hee.user.model.SHUser"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
    SELECT rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE FROM (
    SELECT @ROWNUM := @ROWNUM + 1 as rnn,IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE
    FROM SHCROWD left join
    (SELECT COUNT(*) PNUM,PSEQ,SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq,(SELECT @ROWNUM := 0)R WHERE ID = #{id} ORDER BY SEQ DESC) A
    </select>
    <update id="accCrowd"
            parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET REQ=1 WHERE SEQ=#{seq}


    </update>
    <update id="noCrowd"
            parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET REQ=2 WHERE SEQ=#{seq}


    </update>
    <select id="crowdListAll"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

        SELECT rnn,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT @ROWNUM := @ROWNUM + 1 as rnn,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD,(SELECT @ROWNUM := 0)R WHERE REQ = 1 AND ENDFLAG='0' ORDER BY SEQ DESC) A

    </select>
    <select id="crowdList" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

        SELECT RESULT.* FROM (SELECT @ROWNUM := @ROWNUM + 1 as rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        CURMONEY,
        TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        IFNULL(COUNTS.CURMONEY,0)
        AS CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD left join (SELECT COUNT(*)
        PNUM,PSEQ,SUM(MONEY) CURMONEY FROM
        SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq WHERE REQ = 1 AND ENDFLAG='0'
        ORDER BY SEQ DESC) A,(SELECT @ROWNUM := 0)R

        ) RESULT
        <if test="rnn == null or rnn ==''">
            WHERE 12 >= rnn
        </if>
        <if test="rnn != null and rnn !=''">
            WHERE rnn between #{rnn}+1 AND #{rnn}+12
        </if>
    </select>
    <select id="listbySearch" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
        SELECT RESULT.* FROM (SELECT @ROWNUM := @ROWNUM + 1 as rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        IFNULL(COUNTS.CURMONEY,0)
        AS CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD left join (SELECT COUNT(*)
        PNUM,PSEQ,SUM(MONEY) CURMONEY FROM
        SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq WHERE REQ = 1 AND ENDFLAG='0'
        <if test="search_type != '' and search_type != null">
            <if test="search_type == 'search'">
                AND (TAG like CONCAT('%',#{search},'%') OR TITLE like CONCAT('%',#{search},'%') OR CONTENT like
                CONCAT('%',#{search},'%'))
            </if>
            <if test="search_type == 'tag'">
                AND (TAG like CONCAT('%',#{search},'%'))
            </if>
            <if test="search_type == 'category'">

                AND (CATEGORY like CONCAT('%',#{category},'%')) AND (TAG like CONCAT('%',#{category},'%') OR TITLE like
                CONCAT('%',#{category},'%') OR CONTENT like CONCAT('%',#{category},'%'))
            </if>
        </if>
        ORDER BY SEQ DESC
        ) A,(SELECT @ROWNUM := 0)R ) RESULT
        <if test="rnn !=9999">
            <if test="rnn == null or rnn ==''">
                WHERE 12 >= rnn
            </if>
            <if test="rnn != null and rnn !=''"><commit_msg>search bug fix ( sql syntax error )<commit_after><?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="SHCrowd">


    <insert id="addCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        INSERT INTO SHCROWD(TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ, DEL,ENDFLAG,REWARD,WDATE,LATLNG) VALUES
        (#{title},#{content},#{id},#{goalMoney},0,0,#{tag},
        #{sdate},#{edate},#{category},
        <if test="address != null and address!=''">
            #{address}
        </if>
        <if test="address == null or address==''">''</if>
        ,#{type},0,0,'0','0',DATE_FORMAT(NOW(), '%Y-%m-%d'),
        <if test="latlng != null and latlng!=''">
            #{latlng}

        </if>
        <if test="latlng == null or latlng==''">''</if>
        )
    </insert>

    <update id="delCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET DEL=1 WHERE SEQ=#{seq}

    </update>

    <select id="detailCrowd" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

     SELECT PNUM, SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE, REQ, LATLNG, WDATE FROM (
    SELECT IFNULL(PNUM,0) AS PNUM, SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE, REQ, LATLNG, WDATE
    FROM SHCROWD LEFT JOIN
    (SELECT COUNT(*) PNUM, PSEQ, SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY PSEQ) COUNTS ON COUNTS.PSEQ=SHCROWD.SEQ WHERE SEQ =#{seq}) A

    </select>

    <select id="reqCrowdList"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
    SELECT rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE FROM (
    SELECT @ROWNUM := @ROWNUM + 1 as rnn,IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE
    FROM SHCROWD left join
    (SELECT COUNT(*) PNUM,PSEQ,SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq,(SELECT @ROWNUM := 0)R WHERE REQ = 0 ORDER BY SEQ DESC) A

    </select>
    <select id="myReqCrowdList" parameterType="com.sung.hee.user.model.SHUser"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
    SELECT rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
    SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE FROM (
    SELECT @ROWNUM := @ROWNUM + 1 as rnn,IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
    IFNULL(COUNTS.CURMONEY,0) AS CURMONEY, TAG, SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE
    FROM SHCROWD left join
    (SELECT COUNT(*) PNUM,PSEQ,SUM(MONEY) CURMONEY
    FROM SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq,(SELECT @ROWNUM := 0)R WHERE ID = #{id} ORDER BY SEQ DESC) A
    </select>
    <update id="accCrowd"
            parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET REQ=1 WHERE SEQ=#{seq}


    </update>
    <update id="noCrowd"
            parameterType="com.sung.hee.shcrowd.model.SHCrowd">

        UPDATE SHCROWD SET REQ=2 WHERE SEQ=#{seq}


    </update>
    <select id="crowdListAll"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

        SELECT rnn,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT @ROWNUM := @ROWNUM + 1 as rnn,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM, CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD,(SELECT @ROWNUM := 0)R WHERE REQ = 1 AND ENDFLAG='0' ORDER BY SEQ DESC) A

    </select>
    <select id="crowdList" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">

        SELECT RESULT.* FROM (SELECT @ROWNUM := @ROWNUM + 1 as rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        CURMONEY,
        TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        IFNULL(COUNTS.CURMONEY,0)
        AS CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD left join (SELECT COUNT(*)
        PNUM,PSEQ,SUM(MONEY) CURMONEY FROM
        SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq WHERE REQ = 1 AND ENDFLAG='0'
        ORDER BY SEQ DESC) A,(SELECT @ROWNUM := 0)R

        ) RESULT
        <if test="rnn == null or rnn ==''">
            WHERE 12 >= rnn
        </if>
        <if test="rnn != null and rnn !=''">
            WHERE rnn between #{rnn}+1 AND #{rnn}+12
        </if>
    </select>
    <select id="listbySearch" parameterType="com.sung.hee.shcrowd.model.SHCrowd"
            resultType="com.sung.hee.shcrowd.model.SHCrowd">
        SELECT RESULT.* FROM (SELECT @ROWNUM := @ROWNUM + 1 as rnn,pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM (
        SELECT IFNULL(pnum,0) as pnum,SEQ, TITLE, CONTENT, ID, GOALMONEY, LIKENUM,
        IFNULL(COUNTS.CURMONEY,0)
        AS CURMONEY, TAG,
        SDATE, EDATE, CATEGORY, ADDRESS, TYPE,REQ,LATLNG,WDATE,ENDFLAG,REWARD FROM SHCROWD left join (SELECT COUNT(*)
        PNUM,PSEQ,SUM(MONEY) CURMONEY FROM
        SHFUND GROUP BY pseq) COUNTS ON COUNTS.PSEQ=SHCROWD.seq WHERE REQ = 1 AND ENDFLAG='0'
        <if test="search_type != '' and search_type != null">
            <if test="search_type == 'search'">
                AND (TAG like CONCAT('%',#{search},'%') OR TITLE like CONCAT('%',#{search},'%') OR CONTENT like
                CONCAT('%',#{search},'%'))
            </if>
            <if test="search_type == 'tag'">
                AND (TAG like CONCAT('%',#{search},'%'))
            </if>
            <if test="search_type == 'category'">

                AND (CATEGORY like CONCAT('%',#{search},'%')) AND (TAG like CONCAT('%',#{category},'%') OR TITLE like
                CONCAT('%',#{category},'%') OR CONTENT like CONCAT('%',#{category},'%'))
            </if>
        </if>
        ORDER BY SEQ DESC
        ) A,(SELECT @ROWNUM := 0)R ) RESULT
        <if test="rnn !=9999">
            <if test="rnn == null or rnn ==''">
                WHERE 12 >= rnn
            </if>
            <if test="rnn != null and rnn !=''">
{'fraction_non_alphanumeric': 0.15273050170193872, 'fraction_numerical': 0.007843717626165458, 'mean_word_length': 2.972663139329806, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 2, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '109118', 'n_tokens_mistral': 5701, 'n_tokens_neox': 5266, 'n_words': 1164}