templateInfoMapper.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <!-- 命名,每一个映射对象不一样
  4. namespace:必须与对应的接口全类名一致
  5. -->
  6. <mapper namespace="com.iamberry.wechat.service.mapper.TemplateInfoMapper">
  7. <!-- palceInfo活动所有字段映射 -->
  8. <sql id="allField">
  9. TEMPLATE_ID templateId,
  10. PLACE_ID placeId,
  11. TEMPLATE_IS_GLOGAL isGlogal,
  12. TEMPLATE_NAME templateName,
  13. TEMPLATE_CREATE_DATE createDate,
  14. TEMPLATE_COUNT count,
  15. TEMPLATE_STATE state
  16. </sql>
  17. <!-- 用于下拉框选择 -->
  18. <select id="getTemplateListBySelect" resultType="TemplateInfo">
  19. select TEMPLATE_ID templateId,TEMPLATE_NAME templateName
  20. from tb_iamberry_template
  21. where TEMPLATE_STATE=1
  22. </select>
  23. <!-- 按条件获取模板列表 -->
  24. <select id="getTemplateList" resultType="TemplateInfo" parameterType="TemplateInfo">
  25. SELECT
  26. <include refid="allField"/>,
  27. (SELECT COUNT(FLOW_ID) FROM TB_IAMBERRY_TEMPLATE_FLOW where TEMPLATE_ID = templateId AND FLOW_STATE = 1) flowNum
  28. FROM
  29. TB_IAMBERRY_TEMPLATE
  30. <where>
  31. <if test="templateName != null and templateName != ''">
  32. TEMPLATE_NAME LIKE CONCAT('%',#{templateName},'%')
  33. </if>
  34. </where>
  35. LIMIT ${page.recordBegin},${page.pageSize}
  36. </select>
  37. <!-- 根据条件获取模板表数据数量 -->
  38. <select id="getTemplateCount" resultType="int" parameterType="TemplateInfo">
  39. SELECT
  40. COUNT(TEMPLATE_ID)
  41. FROM
  42. TB_IAMBERRY_TEMPLATE
  43. <where>
  44. <if test="templateName != null and templateName != ''">
  45. TEMPLATE_NAME LIKE CONCAT('%',#{templateName},'%')
  46. </if>
  47. </where>
  48. </select>
  49. <!-- 添加模板数据 -->
  50. <insert id="addTemplateInfo" parameterType="TemplateInfo" useGeneratedKeys="true" keyProperty="templateId">
  51. INSERT INTO TB_IAMBERRY_TEMPLATE
  52. (
  53. PLACE_ID,
  54. TEMPLATE_IS_GLOGAL,
  55. TEMPLATE_NAME,
  56. TEMPLATE_CREATE_DATE,
  57. TEMPLATE_COUNT,
  58. TEMPLATE_STATE,
  59. TEMPLATE_CREATER
  60. )
  61. VALUES
  62. (
  63. #{placeId},
  64. #{isGlogal},
  65. #{templateName},
  66. NOW(),
  67. #{count},
  68. #{state},
  69. #{createrId}
  70. )
  71. </insert>
  72. <!-- 修改模板信息 -->
  73. <update id="updateTemplateInfo" parameterType="TemplateInfo">
  74. UPDATE
  75. TB_IAMBERRY_TEMPLATE
  76. SET
  77. TEMPLATE_IS_GLOGAL = #{isGlogal},
  78. TEMPLATE_NAME = #{templateName},
  79. TEMPLATE_COUNT = #{count},
  80. TEMPLATE_STATE = #{state},
  81. TEMPLATE_UPDATE_DATE = NOW()
  82. WHERE
  83. TEMPLATE_ID = #{templateId}
  84. </update>
  85. <!-- 根据模板id查询模板信息 -->
  86. <select id="getTemplateInfoById" parameterType="TemplateInfo" resultType="TemplateInfo">
  87. SELECT
  88. <include refid="allField"/>
  89. FROM
  90. TB_IAMBERRY_TEMPLATE
  91. WHERE
  92. TEMPLATE_ID = #{templateId}
  93. <if test="state != null and state != ''">
  94. AND TEMPLATE_STATE = #{state}
  95. </if>
  96. </select>
  97. </mapper>