CompanyMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.usoftchina.saas.account.mapper.CompanyMapper">
  4. <resultMap id="FullResultMap" type="com.usoftchina.saas.account.po.Company">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="name" jdbcType="VARCHAR" property="name"/>
  7. <result column="business_code" jdbcType="VARCHAR" property="businessCode"/>
  8. <result column="address" jdbcType="VARCHAR" property="address"/>
  9. <result column="logo_url" jdbcType="VARCHAR" property="logoUrl"/>
  10. <result column="uu" jdbcType="BIGINT" property="uu"/>
  11. <result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  13. <result column="updater_id" jdbcType="BIGINT" property="updaterId"/>
  14. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  15. <result column="fax" jdbcType="VARCHAR" property="fax"/>
  16. <result column="tel" jdbcType="VARCHAR" property="tel"/>
  17. <result column="signet" jdbcType="VARCHAR" property="signet"/>
  18. <result column="uu" jdbcType="VARCHAR" property="uu"/>
  19. <result column="logo_url" jdbcType="VARCHAR" property="logoUrl"/>
  20. </resultMap>
  21. <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.vo.CompanyBaseVO">
  22. <id column="id" jdbcType="BIGINT" property="id"/>
  23. <result column="name" jdbcType="VARCHAR" property="name"/>
  24. <result column="logo_url" jdbcType="VARCHAR" property="logoUrl"/>
  25. </resultMap>
  26. <sql id="baseColumns">
  27. id,name,business_code,address,uu,creator_id,create_time,updater_id,update_time,fax,tel,signet,uu,logo_url
  28. </sql>
  29. <insert id="insert" parameterType="com.usoftchina.saas.account.po.Company"
  30. useGeneratedKeys="true" keyProperty="id">
  31. <selectKey resultType="java.lang.Long" keyProperty="id">
  32. SELECT LAST_INSERT_ID() AS ID
  33. </selectKey>
  34. insert into ac_company(name, business_code, address, logo_url, creator_id, create_time, updater_id, update_time,
  35. tel, fax, signet, uu)
  36. values (#{name,jdbcType=VARCHAR}, #{businessCode,jdbcType=VARCHAR},
  37. #{address,jdbcType=VARCHAR}, #{logoUrl,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT},
  38. #{createTime,jdbcType=TIMESTAMP}, #{updaterId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
  39. #{tel,jdbcType=VARCHAR}, #{fax,jdbcType=VARCHAR}, #{signet,jdbcType=VARCHAR}, #{uu,jdbcType=VARCHAR})
  40. </insert>
  41. <insert id="insertSelective" parameterType="com.usoftchina.saas.account.po.Company"
  42. useGeneratedKeys="true" keyProperty="id">
  43. insert into ac_company
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="name != null">
  46. name,
  47. </if>
  48. <if test="businessCode != null">
  49. business_code,
  50. </if>
  51. <if test="address != null">
  52. address,
  53. </if>
  54. <if test="logoUrl != null">
  55. logo_url,
  56. </if>
  57. <if test="uu != null">
  58. uu,
  59. </if>
  60. <if test="creatorId != null">
  61. creator_id,
  62. </if>
  63. <if test="createTime != null">
  64. create_time,
  65. </if>
  66. <if test="updaterId != null">
  67. updater_id,
  68. </if>
  69. <if test="updateTime != null">
  70. update_time,
  71. </if>
  72. </trim>
  73. <trim prefix="values (" suffix=")" suffixOverrides=",">
  74. <if test="name != null">
  75. #{name,jdbcType=VARCHAR},
  76. </if>
  77. <if test="businessCode != null">
  78. #{businessCode,jdbcType=VARCHAR},
  79. </if>
  80. <if test="address != null">
  81. #{address,jdbcType=VARCHAR},
  82. </if>
  83. <if test="logoUrl != null">
  84. #{logoUrl,jdbcType=VARCHAR},
  85. </if>
  86. <if test="uu != null">
  87. #{uu,jdbcType=BIGINT},
  88. </if>
  89. <if test="creatorId != null">
  90. #{creatorId,jdbcType=BIGINT},
  91. </if>
  92. <if test="createTime != null">
  93. #{createTime,jdbcType=TIMESTAMP},
  94. </if>
  95. <if test="updaterId != null">
  96. #{updaterId,jdbcType=BIGINT},
  97. </if>
  98. <if test="updateTime != null">
  99. #{updateTime,jdbcType=TIMESTAMP},
  100. </if>
  101. </trim>
  102. </insert>
  103. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="FullResultMap">
  104. select <include refid="baseColumns"/> from ac_company where id=#{id,jdbcType=BIGINT}
  105. </select>
  106. <select id="selectByName" parameterType="java.lang.String" resultMap="FullResultMap">
  107. select <include refid="baseColumns"/> from ac_company where name=#{name,jdbcType=VARCHAR}
  108. </select>
  109. <select id="selectByUu" parameterType="java.lang.Long" resultMap="FullResultMap">
  110. select <include refid="baseColumns"/> from ac_company where uu=#{uu,jdbcType=BIGINT}
  111. </select>
  112. <select id="selectByBusinessCode" parameterType="java.lang.String" resultMap="FullResultMap">
  113. select <include refid="baseColumns"/> from ac_company where business_code=#{businessCode,jdbcType=VARCHAR}
  114. </select>
  115. <select id="selectBaseByAccountId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  116. select ac_company.id,ac_company.name,ac_company.logo_url from ac_account_company,ac_company
  117. where ac_account_company.company_id=ac_company.id and ac_account_company.account_id=#{accountId,jdbcType=BIGINT}
  118. </select>
  119. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  120. delete from ac_company where id=#{id,jdbcType=BIGINT}
  121. </delete>
  122. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.account.dto.CompanyRegDTO">
  123. UPDATE ac_company
  124. <set>
  125. <if test="name != null">
  126. name = #{name, jdbcType=VARCHAR},
  127. </if>
  128. <if test="address != null">
  129. address = #{address,jdbcType=VARCHAR},
  130. </if>
  131. <if test="logoUrl != null">
  132. logo_url = #{logoUrl,jdbcType=VARCHAR},
  133. </if>
  134. <if test="tel != null">
  135. tel = #{tel,jdbcType=VARCHAR},
  136. </if>
  137. <if test="fax != null">
  138. fax = #{fax,jdbcType=VARCHAR},
  139. </if>
  140. <if test="signet != null">
  141. signet = #{signet,jdbcType=VARCHAR},
  142. </if>
  143. </set>
  144. where id = #{id}
  145. </update>
  146. <update id="updateUUByPrimaryKey">
  147. UPDATE ac_company set uu = #{uu} where id = #{companyId}
  148. </update>
  149. </mapper>