CurrencyMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.document.mapper.CurrencyMapper" >
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Currency" >
  5. <id column="cr_id" property="id" jdbcType="INTEGER" />
  6. <result column="cr_name" property="cr_name" jdbcType="VARCHAR" />
  7. <result column="cr_rate" property="cr_rate" jdbcType="VARCHAR" />
  8. <result column="companyId" property="companyId" jdbcType="INTEGER" />
  9. <result column="creatorId" property="creatorId" jdbcType="INTEGER" />
  10. <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
  11. <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
  12. <result column="creatorName" property="creatorName" jdbcType="INTEGER" />
  13. <result column="updaterName" property="updaterName" jdbcType="INTEGER" />
  14. <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
  15. <result column="cr_standard" property="cr_standard" jdbcType="INTEGER" />
  16. </resultMap>
  17. <sql id="Base_Column_List" >
  18. cr_id, cr_name, cr_rate, companyId, creatorId, updaterId, updateTime, creatorName, updaterName, createTime, cr_standard
  19. </sql>
  20. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  21. select
  22. <include refid="Base_Column_List" />
  23. from currencys
  24. where cr_id = #{id}
  25. </select>
  26. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
  27. delete from currencys
  28. where cr_id = #{id}
  29. </delete>
  30. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Currency" >
  31. <selectKey resultType="java.lang.Long" keyProperty="id">
  32. SELECT LAST_INSERT_ID() AS ID
  33. </selectKey>
  34. insert into Currencys
  35. <trim prefix="(" suffix=")" suffixOverrides="," >
  36. <if test="cr_name != null" >
  37. cr_name,
  38. </if>
  39. <if test="cr_rate != null">
  40. cr_rate,
  41. </if>
  42. <if test="cr_standard != null">
  43. cr_standard,
  44. </if>
  45. <if test="companyId != null" >
  46. companyId,
  47. </if>
  48. <if test="updaterId != null" >
  49. updaterId,
  50. </if>
  51. <if test="updateTime != null" >
  52. updateTime,
  53. </if>
  54. <if test="creatorId != null" >
  55. creatorId,
  56. </if>
  57. <if test="createTime != null" >
  58. createTime,
  59. </if>
  60. <if test="creatorName != null" >
  61. creatorName,
  62. </if>
  63. </trim>
  64. <trim prefix="values (" suffix=")" suffixOverrides="," >
  65. <if test="cr_name != null" >
  66. #{cr_name,jdbcType=VARCHAR},
  67. </if>
  68. <if test="cr_rate != null" >
  69. #{cr_rate,jdbcType=DOUBLE},
  70. </if>
  71. <if test="cr_standard != null" >
  72. #{cr_standard,jdbcType=INTEGER},
  73. </if>
  74. <if test="companyId != null" >
  75. #{companyId,jdbcType=INTEGER},
  76. </if>
  77. <if test="updaterId != null" >
  78. #{updaterId,jdbcType=INTEGER},
  79. </if>
  80. <if test="updateTime != null" >
  81. #{updateTime,jdbcType=TIMESTAMP},
  82. </if>
  83. <if test="creatorId != null" >
  84. #{creatorId,jdbcType=INTEGER},
  85. </if>
  86. <if test="createTime != null" >
  87. #{createTime,jdbcType=TIMESTAMP},
  88. </if>
  89. <if test="creatorName != null" >
  90. #{creatorName,jdbcType=VARCHAR},
  91. </if>
  92. </trim>
  93. </insert>
  94. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Currency" >
  95. update Currencys
  96. <set >
  97. <if test="cr_name != null" >
  98. cr_name = #{cr_name,jdbcType=VARCHAR},
  99. </if>
  100. <if test="cr_rate != null" >
  101. cr_rate = #{cr_rate,jdbcType=DOUBLE},
  102. </if>
  103. <if test="cr_standard != null" >
  104. cr_standard = #{cr_standard,jdbcType=INTEGER},
  105. </if>
  106. <if test="companyId != null" >
  107. companyId = #{companyId,jdbcType=INTEGER},
  108. </if>
  109. <if test="updaterId != null" >
  110. updaterId = #{updaterId,jdbcType=INTEGER},
  111. </if>
  112. <if test="updateTime != null" >
  113. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  114. </if>
  115. </set>
  116. where cr_id = #{id}
  117. </update>
  118. <select id="selectByCompanyId" resultMap="BaseResultMap">
  119. SELECT * FROM Currencys where companyId=#{companyId} ORDER BY CR_ID DESC
  120. </select>
  121. <select id="getAll" resultMap="BaseResultMap">
  122. SELECT * FROM Currencys
  123. <where>
  124. <if test="condition != null">
  125. ${condition}
  126. </if>
  127. <if test="companyId != null">
  128. and companyId = #{companyId}
  129. </if>
  130. </where>
  131. ORDER BY CR_ID DESC
  132. </select>
  133. <update id="clearStandard">
  134. UPDATE CURRENCYS SET CR_STANDARD = 0, CR_RATE = 0 WHERE COMPANYID = #{companyId}
  135. </update>
  136. <update id="setStandard">
  137. UPDATE CURRENCYS SET CR_STANDARD = #{standard}, CR_RATE = 1 WHERE COMPANYID = #{companyId} AND CR_NAME = #{name}
  138. </update>
  139. <select id="selectCountByName" resultType="int">
  140. SELECT COUNT(*) FROM CURRENCYS WHERE CR_NAME = #{name} AND COMPANYID = #{companyId}
  141. </select>
  142. <select id="getStandard" resultType="com.usoftchina.saas.document.dto.CurrencyDTO">
  143. select * from CURRENCYS where cr_standard = '1' and companyId = #{companyId}
  144. </select>
  145. </mapper>