VendorkindMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.VendorkindMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Vendorkind">
  5. <id column="vk_id" jdbcType="INTEGER" property="id" />
  6. <result column="vk_name" jdbcType="VARCHAR" property="vk_name" />
  7. <result column="companyId" jdbcType="INTEGER" property="companyId" />
  8. <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
  9. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
  10. </resultMap>
  11. <sql id="Base_Column_List">
  12. vk_id, vk_name, companyId, updaterId, updateTime
  13. </sql>
  14. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  15. select
  16. <include refid="Base_Column_List" />
  17. from vendorkind
  18. where vk_id = #{id}
  19. </select>
  20. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  21. delete from vendorkind
  22. where vk_id = #{id}
  23. </delete>
  24. <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Vendorkind">
  25. <selectKey resultType="java.lang.Long" keyProperty="id">
  26. SELECT LAST_INSERT_ID() AS ID
  27. </selectKey>
  28. insert into vendorkind (vk_name, companyId,
  29. updaterId, updateTime)
  30. values (#{vk_name,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER},
  31. #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP})
  32. </insert>
  33. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Vendorkind">
  34. <selectKey resultType="java.lang.Long" keyProperty="id">
  35. SELECT LAST_INSERT_ID() AS ID
  36. </selectKey>
  37. insert into vendorkind
  38. <trim prefix="(" suffix=")" suffixOverrides=",">
  39. <if test="vk_name != null">
  40. vk_name,
  41. </if>
  42. <if test="companyId != null">
  43. companyId,
  44. </if>
  45. <if test="updaterId != null">
  46. updaterId,
  47. </if>
  48. <if test="updateTime != null">
  49. updateTime,
  50. </if>
  51. </trim>
  52. <trim prefix="values (" suffix=")" suffixOverrides=",">
  53. <if test="vk_name != null">
  54. #{vk_name,jdbcType=VARCHAR},
  55. </if>
  56. <if test="companyId != null">
  57. #{companyId,jdbcType=INTEGER},
  58. </if>
  59. <if test="updaterId != null">
  60. #{updaterId,jdbcType=INTEGER},
  61. </if>
  62. <if test="updateTime != null">
  63. #{updateTime,jdbcType=TIMESTAMP},
  64. </if>
  65. </trim>
  66. </insert>
  67. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Vendorkind">
  68. update vendorkind
  69. <set>
  70. <if test="vk_name != null">
  71. vk_name = #{vk_name,jdbcType=VARCHAR},
  72. </if>
  73. <if test="companyId != null">
  74. companyId = #{companyId,jdbcType=INTEGER},
  75. </if>
  76. <if test="updaterId != null">
  77. updaterId = #{updaterId,jdbcType=INTEGER},
  78. </if>
  79. <if test="updateTime != null">
  80. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  81. </if>
  82. </set>
  83. where vk_id = #{id}
  84. </update>
  85. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Vendorkind">
  86. update vendorkind
  87. set vk_name = #{vk_name,jdbcType=VARCHAR},
  88. companyId = #{companyId,jdbcType=INTEGER},
  89. updaterId = #{updaterId,jdbcType=INTEGER},
  90. updateTime = #{updateTime,jdbcType=TIMESTAMP}
  91. where vk_id = #{id}
  92. </update>
  93. <select id="selectAll" resultMap="BaseResultMap">
  94. SELECT * FROM VENDORKIND where companyId = #{companyId} ORDER BY VK_ID DESC
  95. </select>
  96. <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
  97. SELECT VK_NAME display, VK_NAME value FROM VENDORKIND WHERE COMPANYID=#{companyId}
  98. </select>
  99. <select id="selectCountByName" resultType="int">
  100. SELECT COUNT(*) FROM VENDORKIND
  101. <where>
  102. <if test="name!=null">
  103. and VK_NAME=#{name}
  104. </if>
  105. <if test="companyId!=0 and companyId!=null">
  106. and COMPANYID=#{companyId}
  107. </if>
  108. <if test="id!=0 and id!=null">
  109. and vk_id != #{id}
  110. </if>
  111. </where>
  112. </select>
  113. <select id="getCountFromVendor" resultType="int">
  114. SELECT COUNT(*) FROM VENDOR WHERE VE_TYPE = (SELECT VK_NAME FROM VENDORKIND WHERE VK_ID = #{id}) AND companyId = #{companyId}
  115. </select>
  116. </mapper>