WeCorpAccountMapper.xml 4.8 KB
Newer Older
1 2 3 4
<?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">
5
<mapper namespace="com.linkwechat.wecom.mapper.WeCorpAccountMapper">
6
    
7
    <resultMap type="WeCorpAccount" id="WeCorpAccountResult">
8 9 10 11 12 13 14 15 16 17
        <result property="id"    column="id"    />
        <result property="companyName"    column="company_name"    />
        <result property="corpId"    column="corp_id"    />
        <result property="corpSecret"    column="corp_secret"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
18
        <result property="contactSecret" column="contact_secret" />
19 20
        <result property="agentId" column="agent_id" />
        <result property="providerSecret" column="provider_secret" />
21 22
    </resultMap>

23
    <sql id="selectWeCorpAccountVo">
24
        select id,provider_secret,company_name, corp_id, corp_secret,agent_id ,status, del_flag, create_by, create_time, update_by, update_time,contact_secret from we_corp_account
25 26
    </sql>

27 28
    <select id="selectWeCorpAccountList" parameterType="WeCorpAccount" resultMap="WeCorpAccountResult">
        <include refid="selectWeCorpAccountVo"/>
29 30 31 32 33 34 35 36
        <where>  
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
            <if test="corpSecret != null  and corpSecret != ''"> and corp_secret = #{corpSecret}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
37 38
    <select id="selectWeCorpAccountById" parameterType="Long" resultMap="WeCorpAccountResult">
        <include refid="selectWeCorpAccountVo"/>
39 40 41
        where id = #{id}
    </select>
        
42
    <insert id="insertWeCorpAccount" parameterType="WeCorpAccount" useGeneratedKeys="true" keyProperty="id">
43
        insert into we_corp_account
44 45 46 47 48 49 50 51 52 53
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyName != null">company_name,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="corpSecret != null">corp_secret,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
水库浪子 已提交
54
            <if test="contactSecret != null ">contact_secret,</if>
55 56 57 58 59 60 61 62 63 64 65
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyName != null">#{companyName},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="corpSecret != null">#{corpSecret},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
66
            <if test="contactSecret != null ">#{contactSecret},</if>
67 68 69
         </trim>
    </insert>

70
    <update id="updateWeCorpAccount" parameterType="WeCorpAccount">
71
        update we_corp_account
72 73 74 75 76 77 78 79 80 81
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyName != null">company_name = #{companyName},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="corpSecret != null">corp_secret = #{corpSecret},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
82
            <if test="contactSecret != null ">contact_secret = #{contactSecret},</if>
83 84 85 86
        </trim>
        where id = #{id}
    </update>

87 88 89 90 91 92 93 94 95 96


    <select id="findValidWeCorpAccount" resultMap="WeCorpAccountResult">
        <include refid="selectWeCorpAccountVo"/>
        WHERE
            del_flag = 0
        AND STATUS = 0
    </select>


水库浪子 已提交
97 98
    <update id="startVailWeCorpAccount">
          UPDATE we_corp_account
水库浪子 已提交
99
          SET `status` = (CASE WHEN corp_id = #{corpId} THEN 0 ELSE 1 END)
水库浪子 已提交
100 101 102 103 104
    </update>




105

106 107
    
</mapper>