PlatformProductMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.ym.mec.biz.dal.dao.PlatformProductDao">
  4. <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.PlatformProduct">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="name_" jdbcType="VARCHAR" property="name"/>
  7. <result column="menu_id_" jdbcType="VARCHAR" property="menuId"/>
  8. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  9. <result column="deleted_" jdbcType="INTEGER" property="deleted"/>
  10. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  11. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  12. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  13. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  14. </resultMap>
  15. <sql id="Base_Column_List">
  16. id_, name_, menu_id_, remark_, deleted_, created_by_, created_time_, updated_by_,
  17. updated_time_
  18. </sql>
  19. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  20. select
  21. <include refid="Base_Column_List"/>
  22. from platform_product
  23. where id_ = #{id,jdbcType=INTEGER}
  24. </select>
  25. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  26. delete
  27. from platform_product
  28. where id_ = #{id,jdbcType=INTEGER}
  29. </delete>
  30. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.PlatformProduct" useGeneratedKeys="true">
  31. insert into platform_product (name_, menu_id_, remark_,
  32. deleted_, created_by_, created_time_,
  33. updated_by_, updated_time_)
  34. values (#{name,jdbcType=VARCHAR}, #{menuId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
  35. #{deleted,jdbcType=INTEGER}, #{createdBy,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP},
  36. #{updatedBy,jdbcType=INTEGER}, #{updatedTime,jdbcType=TIMESTAMP})
  37. </insert>
  38. <insert id="insertSelective" parameterType="com.ym.mec.biz.dal.entity.PlatformProduct">
  39. insert into platform_product
  40. <trim prefix="(" suffix=")" suffixOverrides=",">
  41. <if test="name != null">
  42. name_,
  43. </if>
  44. <if test="menuId != null">
  45. menu_id_,
  46. </if>
  47. <if test="remark != null">
  48. remark_,
  49. </if>
  50. <if test="deleted != null">
  51. deleted_,
  52. </if>
  53. <if test="createdBy != null">
  54. created_by_,
  55. </if>
  56. <if test="createdTime != null">
  57. created_time_,
  58. </if>
  59. <if test="updatedBy != null">
  60. updated_by_,
  61. </if>
  62. <if test="updatedTime != null">
  63. updated_time_,
  64. </if>
  65. </trim>
  66. <trim prefix="values (" suffix=")" suffixOverrides=",">
  67. <if test="name != null">
  68. #{name,jdbcType=VARCHAR},
  69. </if>
  70. <if test="menuId != null">
  71. #{menuId,jdbcType=VARCHAR},
  72. </if>
  73. <if test="remark != null">
  74. #{remark,jdbcType=VARCHAR},
  75. </if>
  76. <if test="deleted != null">
  77. #{deleted,jdbcType=INTEGER},
  78. </if>
  79. <if test="createdBy != null">
  80. #{createdBy,jdbcType=VARCHAR},
  81. </if>
  82. <if test="createdTime != null">
  83. #{createdTime,jdbcType=TIMESTAMP},
  84. </if>
  85. <if test="updatedBy != null">
  86. #{updatedBy,jdbcType=VARCHAR},
  87. </if>
  88. <if test="updatedTime != null">
  89. #{updatedTime,jdbcType=TIMESTAMP},
  90. </if>
  91. </trim>
  92. </insert>
  93. <update id="updateByPrimaryKeySelective" parameterType="com.ym.mec.biz.dal.entity.PlatformProduct">
  94. update platform_product
  95. <set>
  96. <if test="name != null">
  97. name_ = #{name,jdbcType=VARCHAR},
  98. </if>
  99. <if test="menuId != null">
  100. menu_id_ = #{menuId,jdbcType=VARCHAR},
  101. </if>
  102. <if test="remark != null">
  103. remark_ = #{remark,jdbcType=VARCHAR},
  104. </if>
  105. <if test="deleted != null">
  106. deleted_ = #{deleted,jdbcType=INTEGER},
  107. </if>
  108. <if test="createdBy != null">
  109. created_by_ = #{createdBy,jdbcType=VARCHAR},
  110. </if>
  111. <if test="createdTime != null">
  112. created_time_ = #{createdTime,jdbcType=TIMESTAMP},
  113. </if>
  114. <if test="updatedBy != null">
  115. updated_by_ = #{updatedBy,jdbcType=VARCHAR},
  116. </if>
  117. <if test="updatedTime != null">
  118. updated_time_ = #{updatedTime,jdbcType=TIMESTAMP},
  119. </if>
  120. </set>
  121. where id_ = #{id,jdbcType=INTEGER}
  122. </update>
  123. <select id="queryPage" resultMap="BaseResultMap">
  124. select
  125. <include refid="Base_Column_List"/>
  126. from platform_product
  127. <where>
  128. deleted_ = 0
  129. <if test="search != null">
  130. and name_ like CONCAT('%',#{search},'%')
  131. </if>
  132. </where>
  133. </select>
  134. <select id="queryMenuIdList" parameterType="integer" resultType="string">
  135. SELECT
  136. b.`menu_id_`
  137. FROM
  138. `platform_serve` AS a
  139. JOIN `platform_product` AS b
  140. ON FIND_IN_SET(b.`id_`, a.`product_id_`)
  141. WHERE
  142. a.deleted_ = 0 AND b.deleted_ = 0
  143. AND a.`id_` = #{serveId}
  144. </select>
  145. <select id="queryTenantByMultiId" parameterType="integer" resultType="map">
  146. SELECT
  147. a.id_ as tenantId,
  148. a.`user_id_` as userId
  149. FROM
  150. tenant_info AS a
  151. JOIN `tenant_product_info` AS b
  152. ON a.`id_` = b.`tenant_id_` and b.using_ = 0
  153. JOIN
  154. (SELECT
  155. a.id_ AS serveId,
  156. a.`name_` AS serveName,
  157. GROUP_CONCAT(b.`name_`) AS productName
  158. FROM
  159. `platform_serve` AS a
  160. JOIN `platform_product` AS b
  161. ON FIND_IN_SET(b.`id_`, a.`product_id_`)
  162. WHERE
  163. a.deleted_ = 0 AND b.deleted_ = 0
  164. <if test="productId != null">
  165. and b.`id_` = #{productId}
  166. </if>
  167. <if test="serveId != null">
  168. and a.id_ = #{serveId}
  169. </if>
  170. GROUP BY a.`id_`) AS c
  171. ON b.`serve_id_` = c.serveId
  172. WHERE a.`pay_state_` = 1
  173. and a.user_id_ is not null
  174. <if test="tenantId != null">
  175. and a.id_ = #{tenantId}
  176. </if>
  177. </select>
  178. <insert id="batchInsertRoleMenu">
  179. INSERT INTO sys_role_menu (role_id_,menu_id_,tenant_id_) VALUES
  180. <foreach collection="menuIds" item="item" index="index" separator=",">
  181. (#{roleId}, #{item},#{tenantId})
  182. </foreach>
  183. ON DUPLICATE KEY UPDATE
  184. role_id_ = VALUES(role_id_),
  185. menu_id_ = VALUES(menu_id_),
  186. tenant_id_ = VALUES(tenant_id_)
  187. </insert>
  188. </mapper>