PopularCitiesMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.kede.common.dao.PopularCitiesMapper">
  4. <resultMap id="BaseResultMap" type="com.kede.common.model.PopularCities">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="sort" jdbcType="INTEGER" property="sort" />
  7. <result column="status" jdbcType="INTEGER" property="status" />
  8. <result column="name" jdbcType="VARCHAR" property="name" />
  9. <result column="url" jdbcType="VARCHAR" property="url" />
  10. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. </resultMap>
  13. <sql id="Base_Column_List">
  14. id, sort, `status`, `name`, url, remarks, create_time
  15. </sql>
  16. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  17. select
  18. <include refid="Base_Column_List" />
  19. from popular_cities
  20. where id = #{id,jdbcType=INTEGER}
  21. </select>
  22. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  23. delete from popular_cities
  24. where id = #{id,jdbcType=INTEGER}
  25. </delete>
  26. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.kede.common.model.PopularCities" useGeneratedKeys="true">
  27. insert into popular_cities (sort, `status`, `name`,
  28. url, remarks, create_time
  29. )
  30. values (#{sort,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
  31. #{url,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
  32. )
  33. </insert>
  34. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.kede.common.model.PopularCities" useGeneratedKeys="true">
  35. insert into popular_cities
  36. <trim prefix="(" suffix=")" suffixOverrides=",">
  37. <if test="sort != null">
  38. sort,
  39. </if>
  40. <if test="status != null">
  41. `status`,
  42. </if>
  43. <if test="name != null">
  44. `name`,
  45. </if>
  46. <if test="url != null">
  47. url,
  48. </if>
  49. <if test="remarks != null">
  50. remarks,
  51. </if>
  52. <if test="createTime != null">
  53. create_time,
  54. </if>
  55. </trim>
  56. <trim prefix="values (" suffix=")" suffixOverrides=",">
  57. <if test="sort != null">
  58. #{sort,jdbcType=INTEGER},
  59. </if>
  60. <if test="status != null">
  61. #{status,jdbcType=INTEGER},
  62. </if>
  63. <if test="name != null">
  64. #{name,jdbcType=VARCHAR},
  65. </if>
  66. <if test="url != null">
  67. #{url,jdbcType=VARCHAR},
  68. </if>
  69. <if test="remarks != null">
  70. #{remarks,jdbcType=VARCHAR},
  71. </if>
  72. <if test="createTime != null">
  73. #{createTime,jdbcType=TIMESTAMP},
  74. </if>
  75. </trim>
  76. </insert>
  77. <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.PopularCities">
  78. update popular_cities
  79. <set>
  80. <if test="sort != null">
  81. sort = #{sort,jdbcType=INTEGER},
  82. </if>
  83. <if test="status != null">
  84. `status` = #{status,jdbcType=INTEGER},
  85. </if>
  86. <if test="name != null">
  87. `name` = #{name,jdbcType=VARCHAR},
  88. </if>
  89. <if test="url != null">
  90. url = #{url,jdbcType=VARCHAR},
  91. </if>
  92. <if test="remarks != null">
  93. remarks = #{remarks,jdbcType=VARCHAR},
  94. </if>
  95. <if test="createTime != null">
  96. create_time = #{createTime,jdbcType=TIMESTAMP},
  97. </if>
  98. </set>
  99. where id = #{id,jdbcType=INTEGER}
  100. </update>
  101. <update id="updateByPrimaryKey" parameterType="com.kede.common.model.PopularCities">
  102. update popular_cities
  103. set sort = #{sort,jdbcType=INTEGER},
  104. `status` = #{status,jdbcType=INTEGER},
  105. `name` = #{name,jdbcType=VARCHAR},
  106. url = #{url,jdbcType=VARCHAR},
  107. remarks = #{remarks,jdbcType=VARCHAR},
  108. create_time = #{createTime,jdbcType=TIMESTAMP}
  109. where id = #{id,jdbcType=INTEGER}
  110. </update>
  111. <select id="popularCitiesList" resultType="com.kede.linksAndHot.bo.outPopularCitiesList">
  112. select id,sort,status,name,url,remarks, date_format(create_time,'%Y-%m-%d %H:%i:%S') createTimes
  113. from popular_cities where 1=1
  114. <if test="name !=null">
  115. and name like concat('%',#{name},'%')
  116. </if>
  117. <if test="status !=null">
  118. and status = #{status}
  119. </if>
  120. order by sort
  121. <if test="sortType ==0">
  122. desc
  123. </if>
  124. <if test="page_sql !=null">
  125. ${page_sql}
  126. </if>
  127. </select>
  128. <select id="popularCitiesCount" resultType="integer">
  129. select count(*)
  130. from popular_cities where 1=1
  131. <if test="name !=null">
  132. and name like concat('%',#{name},'%')
  133. </if>
  134. <if test="status !=null">
  135. and status = #{status}
  136. </if>
  137. </select>
  138. </mapper>