WechatFollowersDao.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.kmall.admin.dao.statistics.WechatFollowersDao">
  4. <resultMap type="com.kmall.admin.entity.WechatFollowersEntity" id="wechatFollowersMap">
  5. <result property="id" column="id"/>
  6. <result property="merchSn" column="merch_sn"/>
  7. <result property="wechatFollowers" column="wechat_followers"/>
  8. <result property="createrSn" column="creater_sn"/>
  9. <result property="createTime" column="create_time"/>
  10. <result property="moderSn" column="moder_sn"/>
  11. <result property="modTime" column="mod_time"/>
  12. <result property="tstm" column="tstm"/>
  13. </resultMap>
  14. <select id="queryObject" resultType="com.kmall.admin.entity.WechatFollowersEntity">
  15. select
  16. `id`,
  17. `merch_sn`,
  18. `wechat_followers`,
  19. `creater_sn`,
  20. `create_time`,
  21. `moder_sn`,
  22. `mod_time`,
  23. `tstm`
  24. from mall_wechat_followers
  25. where id = #{id}
  26. </select>
  27. <select id="queryList" resultType="com.kmall.admin.entity.WechatFollowersEntity">
  28. select
  29. `id`,
  30. `merch_sn`,
  31. `wechat_followers`,
  32. `creater_sn`,
  33. `create_time`,
  34. `moder_sn`,
  35. `mod_time`,
  36. `tstm`
  37. from mall_wechat_followers
  38. WHERE 1=1
  39. <if test="name != null and name.trim() != ''">
  40. AND name LIKE concat('%',#{name},'%')
  41. </if>
  42. <choose>
  43. <when test="sidx != null and sidx.trim() != ''">
  44. order by ${sidx} ${order}
  45. </when>
  46. <otherwise>
  47. order by id desc
  48. </otherwise>
  49. </choose>
  50. <if test="offset != null and limit != null">
  51. limit #{offset}, #{limit}
  52. </if>
  53. </select>
  54. <select id="queryTotal" resultType="int">
  55. select count(*) from mall_wechat_followers
  56. WHERE 1=1
  57. <if test="name != null and name.trim() != ''">
  58. AND name LIKE concat('%',#{name},'%')
  59. </if>
  60. </select>
  61. <select id="queryMonthlyWechatFollowers" resultType="com.kmall.admin.entity.WechatFollowersEntity">
  62. SELECT
  63. merch_sn,
  64. sum(mwf.wechat_followers) wechatFollowers,
  65. DATE_FORMAT(mwf.create_time,'%Y-%m') as yearAndMonth
  66. FROM
  67. mall_wechat_followers mwf
  68. <where>
  69. DATE_FORMAT(mwf.create_time,'%Y-%m') &gt;= #{startMonth}
  70. AND DATE_FORMAT(mwf.create_time,'%Y-%m') &lt;= #{endMonth}
  71. <if test="merchSn != null">
  72. and m.merch_sn = #{merchSn}
  73. </if>
  74. </where>
  75. group by DATE_FORMAT(mwf.create_time,'%Y-%m')
  76. </select>
  77. <insert id="save" parameterType="com.kmall.admin.entity.WechatFollowersEntity">
  78. insert into mall_wechat_followers(
  79. `id`,
  80. `merch_sn`,
  81. `wechat_followers`,
  82. `creater_sn`,
  83. `create_time`,
  84. `moder_sn`,
  85. `mod_time`,
  86. `tstm`)
  87. values(
  88. #{id},
  89. #{merchSn},
  90. #{wechatFollowers},
  91. #{createrSn},
  92. #{createTime},
  93. #{moderSn},
  94. #{modTime},
  95. #{tstm})
  96. </insert>
  97. <update id="update" parameterType="com.kmall.admin.entity.WechatFollowersEntity">
  98. update mall_wechat_followers
  99. <set>
  100. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  101. <if test="wechatFollowers != null">`wechat_followers` = #{wechatFollowers}, </if>
  102. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  103. <if test="createTime != null">`create_time` = #{createTime}, </if>
  104. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  105. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  106. <if test="tstm != null">`tstm` = #{tstm}</if>
  107. </set>
  108. where id = #{id}
  109. </update>
  110. <delete id="delete">
  111. delete from mall_wechat_followers where id = #{value}
  112. </delete>
  113. <delete id="deleteBatch">
  114. delete from mall_wechat_followers where id in
  115. <foreach item="id" collection="array" open="(" separator="," close=")">
  116. #{id}
  117. </foreach>
  118. </delete>
  119. </mapper>