Commit ea4fa68579a915fda88bfeb78ec3a07ddd452fb5
1 parent
1cc3483a
feat(pay): 新增支付渠道列表接口
- 新增 GET /pay/channel/list 按 appId 返回渠道列表 - Service/Mapper 补充按应用查询全部支付渠道 - 列表转换时清空 config,避免密钥和证书配置下发到列表页 - 保持 /pay/channel/get 返回完整配置用于编辑详情
Showing
5 changed files
with
38 additions
and
0 deletions
yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java
| ... | ... | @@ -71,6 +71,15 @@ public class PayChannelController { |
| 71 | 71 | return success(PayChannelConvert.INSTANCE.convert(channel)); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | + @GetMapping("/list") | |
| 75 | + @Operation(summary = "获得指定应用的支付渠道列表") | |
| 76 | + @Parameter(name = "appId", description = "应用编号", required = true, example = "1") | |
| 77 | + @PreAuthorize("@ss.hasPermission('pay:channel:query')") | |
| 78 | + public CommonResult<List<PayChannelRespVO>> getChannelList(@RequestParam("appId") Long appId) { | |
| 79 | + List<PayChannelDO> list = channelService.getChannelListByAppId(appId); | |
| 80 | + return success(PayChannelConvert.INSTANCE.convertList(list)); | |
| 81 | + } | |
| 82 | + | |
| 74 | 83 | @GetMapping("/get-enable-code-list") |
| 75 | 84 | @Operation(summary = "获得指定应用的开启的支付渠道编码列表") |
| 76 | 85 | @Parameter(name = "appId", description = "应用编号", required = true, example = "1") | ... | ... |
yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.convert.channel; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; |
| ... | ... | @@ -9,6 +10,8 @@ import org.mapstruct.Mapper; |
| 9 | 10 | import org.mapstruct.Mapping; |
| 10 | 11 | import org.mapstruct.factory.Mappers; |
| 11 | 12 | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 12 | 15 | @Mapper |
| 13 | 16 | public interface PayChannelConvert { |
| 14 | 17 | |
| ... | ... | @@ -23,6 +26,15 @@ public interface PayChannelConvert { |
| 23 | 26 | @Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))") |
| 24 | 27 | PayChannelRespVO convert(PayChannelDO bean); |
| 25 | 28 | |
| 29 | + default List<PayChannelRespVO> convertList(List<PayChannelDO> list) { | |
| 30 | + // 列表不下发 config(密钥/证书),详情接口再返回完整配置 | |
| 31 | + return CollectionUtils.convertList(list, channel -> { | |
| 32 | + PayChannelRespVO vo = convert(channel); | |
| 33 | + vo.setConfig(null); | |
| 34 | + return vo; | |
| 35 | + }); | |
| 36 | + } | |
| 37 | + | |
| 26 | 38 | PageResult<PayChannelRespVO> convertPage(PageResult<PayChannelDO> page); |
| 27 | 39 | |
| 28 | 40 | } | ... | ... |
yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java
| ... | ... | @@ -28,4 +28,8 @@ public interface PayChannelMapper extends BaseMapperX<PayChannelDO> { |
| 28 | 28 | .eq(PayChannelDO::getStatus, status)); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | + default List<PayChannelDO> selectListByAppId(Long appId) { | |
| 32 | + return selectList(PayChannelDO::getAppId, appId); | |
| 33 | + } | |
| 34 | + | |
| 31 | 35 | } | ... | ... |
yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java
| ... | ... | @@ -94,6 +94,14 @@ public interface PayChannelService { |
| 94 | 94 | List<PayChannelDO> getEnableChannelList(Long appId); |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | + * 获得指定应用的渠道列表 | |
| 98 | + * | |
| 99 | + * @param appId 应用编号 | |
| 100 | + * @return 渠道列表 | |
| 101 | + */ | |
| 102 | + List<PayChannelDO> getChannelListByAppId(Long appId); | |
| 103 | + | |
| 104 | + /** | |
| 97 | 105 | * 获得指定编号的支付客户端 |
| 98 | 106 | * |
| 99 | 107 | * @param id 编号 | ... | ... |
yudao-module-pay/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java
| ... | ... | @@ -157,6 +157,11 @@ public class PayChannelServiceImpl implements PayChannelService { |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | @Override |
| 160 | + public List<PayChannelDO> getChannelListByAppId(Long appId) { | |
| 161 | + return payChannelMapper.selectListByAppId(appId); | |
| 162 | + } | |
| 163 | + | |
| 164 | + @Override | |
| 160 | 165 | public PayClient getPayClient(Long id) { |
| 161 | 166 | PayChannelDO channel = validPayChannel(id); |
| 162 | 167 | return payClientFactory.createOrUpdatePayClient(id, channel.getCode(), channel.getConfig()); | ... | ... |