Browse Source

Merge branch 'saas' of http://git.dayaedu.com/yonge/mec into saas_zouxuan_07_11

zouxuan 3 years ago
parent
commit
751c9991bf

+ 13 - 1
mec-biz/src/main/resources/config/mybatis/HfMerchantConfigMapper.xml

@@ -100,16 +100,28 @@
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="HfMerchantConfig" parameterType="map">
-		SELECT * FROM hf_merchant_config ORDER BY id_
+		SELECT * FROM hf_merchant_config
+        <include refid="queryPageSql"/>
+		ORDER BY id_
 		<include refid="global.limit" />
 	</select>
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM hf_merchant_config
+        <include refid="queryPageSql"/>
 	</select>
 	
 	<select id="queryByTenantId" resultMap="HfMerchantConfig">
 		SELECT * FROM hf_merchant_config where tenant_id_ = #{tenantId}
 	</select>
+
+    <sql id="queryPageSql">
+        <where>
+            <if test="tenantId != null">
+                AND tenant_id_ = #{tenantId}
+            </if>
+        </where>
+    </sql>
+
 </mapper>

+ 83 - 0
mec-web/src/main/java/com/ym/mec/web/controller/HfMerchantConfigController.java

@@ -0,0 +1,83 @@
+package com.ym.mec.web.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huifu.adapay.Adapay;
+import com.huifu.adapay.model.MerConfig;
+import com.ym.mec.biz.service.HfMerchantConfigService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * (HfMerchantConfig)表控制层
+ *
+ * @author hgw
+ * @since 2022-07-13 10:07:36
+ */
+@RestController
+@RequestMapping("/hfMerchantConfig")
+public class HfMerchantConfigController extends BaseController {
+    private static final Logger log = LoggerFactory.getLogger(HfMerchantConfigController.class);
+    /**
+     * 服务对象
+     */
+    @Resource
+    private HfMerchantConfigService hfMerchantConfigService;
+
+    @ApiOperation("创建汇付商户配置")
+    @PostMapping("/add")
+    public HttpResponseResult<Object> add(@RequestBody HfMerchantConfig dto) throws Exception {
+        long insert = hfMerchantConfigService.insert(dto);
+        if (insert == 1) {
+            MerConfig merConfig = new MerConfig();
+            merConfig.setApiKey(dto.getApiKey());
+            merConfig.setApiMockKey(dto.getMockApiKey());
+            merConfig.setRSAPrivateKey(dto.getRsaPrivateKey());
+            Adapay.addMerConfig(merConfig, dto.getMerKey());
+            MerConfig config = Adapay.getConfig(dto.getMerKey());
+            log.info("HfMerchantConfig in config:{}", JSONObject.toJSONString(config));
+            return succeed();
+        }
+        return failed("添加失败");
+    }
+
+    @ApiOperation("创建汇付商户配置")
+    @PostMapping("/update")
+    public HttpResponseResult<Object> update(@RequestBody HfMerchantConfig dto) throws Exception {
+        int update = hfMerchantConfigService.update(dto);
+        if (update == 1) {
+            MerConfig merConfig = new MerConfig();
+            merConfig.setApiKey(dto.getApiKey());
+            merConfig.setApiMockKey(dto.getMockApiKey());
+            merConfig.setRSAPrivateKey(dto.getRsaPrivateKey());
+            Adapay.addMerConfig(merConfig, dto.getMerKey());
+            MerConfig config = Adapay.getConfig(dto.getMerKey());
+            log.info("HfMerchantConfig up config:{}", JSONObject.toJSONString(config));
+            return succeed();
+        }
+        return failed("修改失败");
+    }
+
+    @ApiOperation("根据机构id查询汇付商户配置")
+    @GetMapping(value = "/queryByTenantId/{id}")
+    public HttpResponseResult<HfMerchantConfig> queryByTenantId(@ApiParam(value = "机构ID", required = true) @PathVariable("id") Integer id) {
+        return succeed(hfMerchantConfigService.queryByTenantId(id));
+    }
+
+    @ApiOperation("分页查询汇付商户配置")
+    @PostMapping(value = "/queryPage")
+    public HttpResponseResult<PageInfo<HfMerchantConfig>> queryPage(@RequestBody QueryInfo dto) {
+        return succeed(hfMerchantConfigService.queryPage(dto));
+    }
+
+}
+