AdminLocationMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.goafanti.common.dao.AdminLocationMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.AdminLocation" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="admin_id" property="adminId" jdbcType="VARCHAR" />
  7. <result column="province" property="province" jdbcType="INTEGER" />
  8. <result column="city" property="city" jdbcType="INTEGER" />
  9. </resultMap>
  10. <sql id="Base_Column_List" >
  11. id, admin_id, province, city
  12. </sql>
  13. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  14. select
  15. <include refid="Base_Column_List" />
  16. from admin_location
  17. where id = #{id,jdbcType=VARCHAR}
  18. </select>
  19. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  20. delete from admin_location
  21. where id = #{id,jdbcType=VARCHAR}
  22. </delete>
  23. <insert id="insert" parameterType="com.goafanti.common.model.AdminLocation" >
  24. insert into admin_location (id, admin_id, province,
  25. city)
  26. values (#{id,jdbcType=VARCHAR}, #{adminId,jdbcType=VARCHAR}, #{province,jdbcType=INTEGER},
  27. #{city,jdbcType=INTEGER})
  28. </insert>
  29. <insert id="insertSelective" parameterType="com.goafanti.common.model.AdminLocation" >
  30. insert into admin_location
  31. <trim prefix="(" suffix=")" suffixOverrides="," >
  32. <if test="id != null" >
  33. id,
  34. </if>
  35. <if test="adminId != null" >
  36. admin_id,
  37. </if>
  38. <if test="province != null" >
  39. province,
  40. </if>
  41. <if test="city != null" >
  42. city,
  43. </if>
  44. </trim>
  45. <trim prefix="values (" suffix=")" suffixOverrides="," >
  46. <if test="id != null" >
  47. #{id,jdbcType=VARCHAR},
  48. </if>
  49. <if test="adminId != null" >
  50. #{adminId,jdbcType=VARCHAR},
  51. </if>
  52. <if test="province != null" >
  53. #{province,jdbcType=INTEGER},
  54. </if>
  55. <if test="city != null" >
  56. #{city,jdbcType=INTEGER},
  57. </if>
  58. </trim>
  59. </insert>
  60. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AdminLocation" >
  61. update admin_location
  62. <set >
  63. <if test="adminId != null" >
  64. admin_id = #{adminId,jdbcType=VARCHAR},
  65. </if>
  66. <if test="province != null" >
  67. province = #{province,jdbcType=INTEGER},
  68. </if>
  69. <if test="city != null" >
  70. city = #{city,jdbcType=INTEGER},
  71. </if>
  72. </set>
  73. where id = #{id,jdbcType=VARCHAR}
  74. </update>
  75. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.AdminLocation" >
  76. update admin_location
  77. set admin_id = #{adminId,jdbcType=VARCHAR},
  78. province = #{province,jdbcType=INTEGER},
  79. city = #{city,jdbcType=INTEGER}
  80. where id = #{id,jdbcType=VARCHAR}
  81. </update>
  82. <insert id="insertBatch" parameterType="com.goafanti.common.model.AdminLocation">
  83. insert into admin_location
  84. (id, admin_id,
  85. province, city)
  86. values
  87. <foreach item="item" index="index" collection="list" separator=",">
  88. (
  89. #{item.id,jdbcType=VARCHAR}, #{item.adminId,jdbcType=VARCHAR},
  90. #{item.province,jdbcType=INTEGER}, #{item.city,jdbcType=INTEGER}
  91. )
  92. </foreach>
  93. </insert>
  94. <select id="selectProvinceWhereCityIsNullByAdminId" parameterType="java.lang.String" resultType = "java.lang.Integer">
  95. select
  96. province
  97. from admin_location
  98. where admin_id = #{adminId, jdbcType=VARCHAR}
  99. and city is null
  100. </select>
  101. <select id="selectCityByAdminId" parameterType="java.lang.String" resultType = "java.lang.Integer">
  102. select
  103. city
  104. from admin_location
  105. where admin_id = #{adminId, jdbcType=VARCHAR}
  106. </select>
  107. <select id="selectByAdminId" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminLocationBo">
  108. SELECT
  109. province,
  110. GROUP_CONCAT(city) as city
  111. FROM
  112. admin_location
  113. WHERE
  114. admin_id = #{adminId,jdbcType=VARCHAR}
  115. GROUP BY province
  116. </select>
  117. <delete id="deleteByAdminId" parameterType="java.lang.String">
  118. delete from admin_location
  119. where admin_id = #{adminId,jdbcType=VARCHAR}
  120. </delete>
  121. </mapper>