CmHeheActivityMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.caimei.modules.hehe.dao.CmHeheActivityDao">
  4. <sql id="cmHeheActivityColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.status AS "status",
  8. a.listImage AS "listImage",
  9. a.detailsImage AS "detailsImage",
  10. a.beginTime AS "beginTime",
  11. a.endTime AS "endTime",
  12. a.addTime AS "addTime",
  13. a.delFlag AS "delFlag"
  14. </sql>
  15. <sql id="cmHeheActivityJoins">
  16. </sql>
  17. <select id="get" resultType="CmHeheActivity">
  18. SELECT
  19. <include refid="cmHeheActivityColumns"/>
  20. FROM cm_hehe_activity a
  21. <include refid="cmHeheActivityJoins"/>
  22. WHERE a.id = #{id}
  23. </select>
  24. <select id="findList" resultType="CmHeheActivity">
  25. SELECT
  26. <include refid="cmHeheActivityColumns"/>
  27. FROM cm_hehe_activity a
  28. <include refid="cmHeheActivityJoins"/>
  29. <where>
  30. a.delFlag = 0
  31. <if test="name != null and name != ''">
  32. AND a.name LIKE concat('%',#{name},'%')
  33. </if>
  34. <if test="status != null and status != ''">
  35. AND a.status = #{status}
  36. </if>
  37. <if test="activityStatus == 1">
  38. AND a.beginTime <![CDATA[ > ]]> NOW()
  39. </if>
  40. <if test="activityStatus == 2">
  41. AND NOW() BETWEEN a.beginTime AND a.endTime
  42. </if>
  43. <if test="activityStatus == 3">
  44. AND a.endTime <![CDATA[ < ]]> NOW()
  45. </if>
  46. </where>
  47. <choose>
  48. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  49. ORDER BY ${page.orderBy}
  50. </when>
  51. <otherwise>
  52. ORDER BY addTime DESC
  53. </otherwise>
  54. </choose>
  55. </select>
  56. <select id="findAllList" resultType="CmHeheActivity">
  57. SELECT
  58. <include refid="cmHeheActivityColumns"/>
  59. FROM cm_hehe_activity a
  60. <include refid="cmHeheActivityJoins"/>
  61. <where>
  62. </where>
  63. <choose>
  64. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  65. ORDER BY ${page.orderBy}
  66. </when>
  67. <otherwise>
  68. </otherwise>
  69. </choose>
  70. </select>
  71. <insert id="insert" parameterType="CmHeheActivity" keyProperty="id" useGeneratedKeys="true">
  72. INSERT INTO cm_hehe_activity(
  73. name,
  74. status,
  75. listImage,
  76. detailsImage,
  77. beginTime,
  78. endTime,
  79. addTime,
  80. delFlag
  81. ) VALUES (
  82. #{name},
  83. #{status},
  84. #{listImage},
  85. #{detailsImage},
  86. #{beginTime},
  87. #{endTime},
  88. NOW(),
  89. 0
  90. )
  91. </insert>
  92. <update id="update">
  93. UPDATE cm_hehe_activity SET
  94. name = #{name},
  95. status = #{status},
  96. listImage = #{listImage},
  97. detailsImage = #{detailsImage},
  98. beginTime = #{beginTime},
  99. endTime = #{endTime}
  100. WHERE id = #{id}
  101. </update>
  102. <update id="delete">
  103. UPDATE cm_hehe_activity SET delFlag = 1 WHERE id = #{id}
  104. </update>
  105. <update id="updateStatusById">
  106. UPDATE cm_hehe_activity SET status = #{status} WHERE id = #{id}
  107. </update>
  108. <update id="deleteActivityProduct">
  109. UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE activityId = #{activityId}
  110. </update>
  111. <delete id="deleteUserActivity">
  112. DELETE FROM cm_hehe_user_activity WHERE activityId = #{activityId}
  113. </delete>
  114. <delete id="deleteActivityLadder">
  115. DELETE FROM cm_hehe_activity_ladder WHERE activityId = #{activityId}
  116. </delete>
  117. </mapper>