MerchantAppConfigMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.his.mapper.MerchantAppConfigMapper">
  6. <resultMap type="MerchantAppConfig" id="MerchantAppConfigResult">
  7. <result property="id" column="id" />
  8. <result property="merchantType" column="merchant_type" />
  9. <result property="appId" column="app_id" />
  10. <result property="callbackUrl" column="callback_url" />
  11. <result property="dataJson" column="data_json" />
  12. <result property="createdTime" column="created_time" />
  13. <result property="updatedTime" column="updated_time" />
  14. <result property="isDeleted" column="is_deleted" />
  15. <result property="createdBy" column="created_by" />
  16. <result property="updatedBy" column="updated_by" />
  17. <result property="merchantId" column="merchant_id" />
  18. </resultMap>
  19. <!-- 检查表是否存在 -->
  20. <select id="checkTableExists" resultType="java.lang.Integer">
  21. SELECT COUNT(*) FROM information_schema.tables
  22. WHERE table_schema = DATABASE() AND table_name = 'merchant_app_config'
  23. </select>
  24. <!-- 创建商户配置表 -->
  25. <update id="createMerchantAppConfigTable">
  26. CREATE TABLE `merchant_app_config` (
  27. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  28. `merchant_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户类型:如WECHAT_PAY、ALIPAY等',
  29. `app_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用ID',
  30. `callback_url` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '回调地址,用于接收支付结果等通知',
  31. `data_json` json DEFAULT NULL COMMENT '扩展配置数据,JSON格式存储其他配置信息',
  32. `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  33. `updated_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  34. `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT '删除状态:0-正常,1-已删除',
  35. `created_by` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '创建人ID或用户名',
  36. `updated_by` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '修改人ID或用户名',
  37. `merchant_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商户号',
  38. PRIMARY KEY (`id`),
  39. KEY `idx_merchant_type` (`merchant_type`),
  40. KEY `idx_app_id` (`app_id`),
  41. KEY `idx_created_time` (`created_time`),
  42. KEY `merchant_app_config_merchant_type_IDX` (`merchant_type`,`is_deleted`,`merchant_id`) USING BTREE
  43. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商户应用配置表'
  44. </update>
  45. <sql id="selectMerchantAppConfigVo">
  46. select id, merchant_type, app_id, merchant_id,callback_url, data_json, created_time, updated_time, is_deleted, created_by, updated_by from merchant_app_config
  47. </sql>
  48. <select id="selectMerchantAppConfigList" parameterType="MerchantAppConfig" resultMap="MerchantAppConfigResult">
  49. <include refid="selectMerchantAppConfigVo"/>
  50. <where>
  51. <if test="merchantId != null and merchantId != ''"> and merchant_id = #{merchantId}</if>
  52. <if test="merchantType != null and merchantType != ''"> and merchant_type = #{merchantType}</if>
  53. <if test="appId != null and appId != ''"> and app_id = #{appId}</if>
  54. <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
  55. <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
  56. </where>
  57. </select>
  58. <select id="selectMerchantAppConfigById" parameterType="Long" resultMap="MerchantAppConfigResult">
  59. <include refid="selectMerchantAppConfigVo"/>
  60. where id = #{id}
  61. </select>
  62. <insert id="insertMerchantAppConfig" parameterType="MerchantAppConfig" useGeneratedKeys="true" keyProperty="id">
  63. insert into merchant_app_config
  64. <trim prefix="(" suffix=")" suffixOverrides=",">
  65. <if test="merchantType != null and merchantType != ''">merchant_type,</if>
  66. <if test="appId != null and appId != ''">app_id,</if>
  67. <if test="callbackUrl != null">callback_url,</if>
  68. <if test="dataJson != null">data_json,</if>
  69. <if test="createdTime != null">created_time,</if>
  70. <if test="updatedTime != null">updated_time,</if>
  71. <if test="isDeleted != null">is_deleted,</if>
  72. <if test="createdBy != null and createdBy != ''">created_by,</if>
  73. <if test="updatedBy != null and updatedBy != ''">updated_by,</if>
  74. <if test="merchantId != null and merchantId != ''">merchant_id,</if>
  75. </trim>
  76. <trim prefix="values (" suffix=")" suffixOverrides=",">
  77. <if test="merchantType != null and merchantType != ''">#{merchantType},</if>
  78. <if test="appId != null and appId != ''">#{appId},</if>
  79. <if test="callbackUrl != null">#{callbackUrl},</if>
  80. <if test="dataJson != null">#{dataJson},</if>
  81. <if test="createdTime != null">#{createdTime},</if>
  82. <if test="updatedTime != null">#{updatedTime},</if>
  83. <if test="isDeleted != null">#{isDeleted},</if>
  84. <if test="createdBy != null and createdBy != ''">#{createdBy},</if>
  85. <if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
  86. <if test="merchantId != null and merchantId != ''">#{merchantId},</if>
  87. </trim>
  88. </insert>
  89. <update id="updateMerchantAppConfig" parameterType="MerchantAppConfig">
  90. update merchant_app_config
  91. <trim prefix="SET" suffixOverrides=",">
  92. <if test="merchantType != null and merchantType != ''">merchant_type = #{merchantType},</if>
  93. <if test="appId != null and appId != ''">app_id = #{appId},</if>
  94. <if test="callbackUrl != null">callback_url = #{callbackUrl},</if>
  95. <if test="dataJson != null">data_json = #{dataJson},</if>
  96. <if test="createdTime != null">created_time = #{createdTime},</if>
  97. <if test="updatedTime != null">updated_time = #{updatedTime},</if>
  98. <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
  99. <if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
  100. <if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
  101. <if test="merchantId != null and merchantId != ''">merchant_id = #{merchantId},</if>
  102. </trim>
  103. where id = #{id}
  104. </update>
  105. <delete id="deleteMerchantAppConfigById" parameterType="Long">
  106. delete from merchant_app_config where id = #{id}
  107. </delete>
  108. <delete id="deleteMerchantAppConfigByIds" parameterType="String">
  109. delete from merchant_app_config where id in
  110. <foreach item="id" collection="array" open="(" separator="," close=")">
  111. #{id}
  112. </foreach>
  113. </delete>
  114. </mapper>