CompanyMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.xyz.mapper.CompanyMapper">
  4. <resultMap id="BaseResultMap" type="cn.xyz.mianshi.vo.CompanyVO">
  5. <result column="id" property="id" jdbcType="INTEGER" />
  6. <result column="name" property="name" jdbcType="VARCHAR" />
  7. <result column="description" property="description" jdbcType="VARCHAR" />
  8. <result column="website" property="website" jdbcType="VARCHAR" />
  9. <result column="scale" property="scale" jdbcType="INTEGER" />
  10. <result column="industry_id" property="industryId" jdbcType="INTEGER" />
  11. <result column="nature_id" property="natureId" jdbcType="INTEGER" />
  12. <result column="country_id" property="countryId" jdbcType="INTEGER" />
  13. <result column="province_id" property="provinceId" jdbcType="INTEGER" />
  14. <result column="city_id" property="cityId" jdbcType="INTEGER" />
  15. <result column="area_id" property="areaId" jdbcType="INTEGER" />
  16. <result column="longitude" property="longitude" jdbcType="DOUBLE" />
  17. <result column="latitude" property="latitude" jdbcType="DOUBLE" />
  18. <result column="address" property="address" jdbcType="VARCHAR" />
  19. <result column="invite_code" property="inviteCode" jdbcType="VARCHAR" />
  20. <result column="total" property="total" jdbcType="INTEGER" />
  21. <result column="balance" property="balance" jdbcType="INTEGER" />
  22. <result column="pay_mode" property="payMode" jdbcType="INTEGER" />
  23. <result column="vtotal" property="vtotal" jdbcType="INTEGER" />
  24. <result column="vbalance" property="vbalance" jdbcType="INTEGER" />
  25. <result column="pay_end_time" property="payEndTime" jdbcType="INTEGER" />
  26. <result column="credential" property="credential" jdbcType="VARCHAR" />
  27. <result column="credential_url" property="credentialUrl"
  28. jdbcType="VARCHAR" />
  29. <result column="is_auth" property="isAuth" jdbcType="INTEGER" />
  30. <result column="create_time" property="createTime" jdbcType="INTEGER" />
  31. <result column="modify_time" property="modifyTime" jdbcType="INTEGER" />
  32. <result column="status" property="status" jdbcType="INTEGER" />
  33. </resultMap>
  34. <insert id="add" parameterType="cn.xyz.mianshi.vo.CompanyVO">
  35. <selectKey keyProperty="id" resultType="java.lang.Integer"
  36. order="AFTER">
  37. <![CDATA[
  38. SELECT LAST_INSERT_ID() as id
  39. ]]>
  40. </selectKey>
  41. <![CDATA[
  42. INSERT INTO tb_company (
  43. name,
  44. description,
  45. website,
  46. scale,
  47. industry_id,
  48. nature_id,
  49. country_id,
  50. province_id,
  51. city_id,
  52. area_id,
  53. longitude,
  54. latitude,
  55. address,
  56. invite_code,
  57. total,
  58. balance,
  59. pay_mode,
  60. vtotal,
  61. vbalance,
  62. pay_end_time,
  63. credential,
  64. credential_url,
  65. is_auth,
  66. create_time,
  67. modify_time,
  68. status
  69. )
  70. VALUES
  71. (
  72. #{name,jdbcType=VARCHAR},
  73. #{description,jdbcType=VARCHAR},
  74. #{website,jdbcType=VARCHAR},
  75. #{scale,jdbcType=INTEGER},
  76. #{industryId,jdbcType=INTEGER},
  77. #{natureId,jdbcType=INTEGER},
  78. #{countryId,jdbcType=INTEGER},
  79. #{provinceId,jdbcType=INTEGER},
  80. #{cityId,jdbcType=INTEGER},
  81. #{areaId,jdbcType=INTEGER},
  82. #{longitude,jdbcType=DOUBLE},
  83. #{latitude,jdbcType=DOUBLE},
  84. #{address,jdbcType=VARCHAR},
  85. '',
  86. 0,
  87. 0,
  88. 0,
  89. 0,
  90. 0,
  91. 0,
  92. #{credential,jdbcType=VARCHAR},
  93. #{credentialUrl,jdbcType=VARCHAR},
  94. 0,
  95. UNIX_TIMESTAMP(),
  96. UNIX_TIMESTAMP(),
  97. 1
  98. )
  99. ]]>
  100. </insert>
  101. <update id="updateOthers" parameterType="java.util.Map">
  102. UPDATE tb_company
  103. <set>
  104. <if test="vcount &gt; 0">
  105. total = total + ${vcount}, balance = balance + ${vcount},
  106. </if>
  107. <if test="vcount &lt; 0">
  108. balance = balance + ${vcount},
  109. </if>
  110. <if test="v &gt; 0">
  111. vtotal = vtotal + ${v}, vbalance = vbalance + ${v},
  112. </if>
  113. <if test="v &lt; 0">
  114. vbalance = vbalance + ${v},
  115. </if>
  116. <if test="payEndTime != null">
  117. pay_end_time = ${payEndTime},
  118. </if>
  119. modify_time = UNIX_TIMESTAMP()
  120. </set>
  121. WHERE id = ${companyId}
  122. </update>
  123. <update id="update" parameterType="cn.xyz.mianshi.vo.CompanyVO">
  124. UPDATE tb_company
  125. <set>
  126. <if test="name != null">
  127. name = #{name,jdbcType=VARCHAR},
  128. </if>
  129. <if test="description != null">
  130. description = #{description,jdbcType=VARCHAR},
  131. </if>
  132. <if test="website != null">
  133. website = #{website,jdbcType=INTEGER},
  134. </if>
  135. <if test="scale != null">
  136. scale = #{scale,jdbcType=INTEGER},
  137. </if>
  138. <if test="industryId != null">
  139. industry_id = #{industryId,jdbcType=INTEGER},
  140. </if>
  141. <if test="natureId != null">
  142. nature_id = #{natureId,jdbcType=INTEGER},
  143. </if>
  144. <if test="countryId != null">
  145. country_id = #{countryId,jdbcType=INTEGER},
  146. </if>
  147. <if test="provinceId != null">
  148. province_id = #{provinceId,jdbcType=INTEGER},
  149. </if>
  150. <if test="cityId != null">
  151. city_id = #{cityId,jdbcType=INTEGER},
  152. </if>
  153. <if test="areaId != null">
  154. area_id = #{areaId,jdbcType=INTEGER},
  155. </if>
  156. <if test="longitude != null">
  157. province_id = #{provinceId,jdbcType=DOUBLE},
  158. </if>
  159. <if test="latitude != null">
  160. province_id = #{provinceId,jdbcType=DOUBLE},
  161. </if>
  162. <if test="address != null">
  163. province_id = #{provinceId,jdbcType=VARCHAR},
  164. </if>
  165. <if test="inviteCode != null">
  166. invite_code = ${inviteCode},
  167. </if>
  168. <if test="payMode != null">
  169. pay_mode = ${payMode},
  170. </if>
  171. <if test="credential != null">
  172. credential = '${credential}',
  173. </if>
  174. <if test="credentialUrl != null">
  175. credential_url = '${credentialUrl}',
  176. </if>
  177. <if test="isAuth != null">
  178. is_auth = ${isAuth},
  179. </if>
  180. <if test="status != null">
  181. status = ${status},
  182. </if>
  183. modify_time = UNIX_TIMESTAMP()
  184. </set>
  185. WHERE id = #{id,jdbcType=INTEGER}
  186. </update>
  187. <select id="get" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  188. <![CDATA[
  189. SELECT * FROM tb_company WHERE id = ${value}
  190. ]]>
  191. </select>
  192. <select id="countByExample" parameterType="cn.xyz.mianshi.example.CompanyExample"
  193. resultType="java.lang.Integer">
  194. SELECT count(*) FROM tb_company WHERE status = 1
  195. <if test="industryId != null"> AND industry_id = ${industryId}</if>
  196. <if test="natureId != null"> AND nature_id = ${natureId}</if>
  197. <if test="name != null"> AND name like '%mianshi-service%'</if>
  198. <if test="scale != null"> AND scale = ${scale}</if>
  199. <if test="cityId != null"> AND city_id = ${cityId}</if>
  200. <if test="isAuth != null"> AND is_auth = ${isAuth}</if>
  201. </select>
  202. <select id="selectByExample" parameterType="cn.xyz.mianshi.example.CompanyExample"
  203. resultMap="BaseResultMap">
  204. SELECT * FROM tb_company WHERE status = 1
  205. <if test="industryId != null"> AND industry_id = ${industryId}</if>
  206. <if test="natureId != null"> AND nature_id = ${natureId}</if>
  207. <if test="name != null"> AND name like '%mianshi-service%'</if>
  208. <if test="scale != null"> AND scale = ${scale}</if>
  209. <if test="cityId != null"> AND city_id = ${cityId}</if>
  210. <if test="isAuth != null"> AND is_auth = ${isAuth}</if>
  211. LIMIT ${start},${pageSize}
  212. </select>
  213. </mapper>