feat(pay): 新增支付渠道列表接口

- 新增 GET /pay/channel/list 按 appId 返回渠道列表
- Service/Mapper 补充按应用查询全部支付渠道
- 列表转换时清空 config,避免密钥和证书配置下发到列表页
- 保持 /pay/channel/get 返回完整配置用于编辑详情
This commit is contained in:
YunaiV
2026-06-24 10:59:52 -07:00
parent 1cc3483aa0
commit ea4fa68579
5 changed files with 38 additions and 0 deletions

View File

@ -71,6 +71,15 @@ public class PayChannelController {
return success(PayChannelConvert.INSTANCE.convert(channel));
}
@GetMapping("/list")
@Operation(summary = "获得指定应用的支付渠道列表")
@Parameter(name = "appId", description = "应用编号", required = true, example = "1")
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
public CommonResult<List<PayChannelRespVO>> getChannelList(@RequestParam("appId") Long appId) {
List<PayChannelDO> list = channelService.getChannelListByAppId(appId);
return success(PayChannelConvert.INSTANCE.convertList(list));
}
@GetMapping("/get-enable-code-list")
@Operation(summary = "获得指定应用的开启的支付渠道编码列表")
@Parameter(name = "appId", description = "应用编号", required = true, example = "1")

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.convert.channel;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
@ -9,6 +10,8 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface PayChannelConvert {
@ -23,6 +26,15 @@ public interface PayChannelConvert {
@Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))")
PayChannelRespVO convert(PayChannelDO bean);
default List<PayChannelRespVO> convertList(List<PayChannelDO> list) {
// 列表不下发 config密钥/证书),详情接口再返回完整配置
return CollectionUtils.convertList(list, channel -> {
PayChannelRespVO vo = convert(channel);
vo.setConfig(null);
return vo;
});
}
PageResult<PayChannelRespVO> convertPage(PageResult<PayChannelDO> page);
}

View File

@ -28,4 +28,8 @@ public interface PayChannelMapper extends BaseMapperX<PayChannelDO> {
.eq(PayChannelDO::getStatus, status));
}
default List<PayChannelDO> selectListByAppId(Long appId) {
return selectList(PayChannelDO::getAppId, appId);
}
}

View File

@ -93,6 +93,14 @@ public interface PayChannelService {
*/
List<PayChannelDO> getEnableChannelList(Long appId);
/**
* 获得指定应用的渠道列表
*
* @param appId 应用编号
* @return 渠道列表
*/
List<PayChannelDO> getChannelListByAppId(Long appId);
/**
* 获得指定编号的支付客户端
*

View File

@ -156,6 +156,11 @@ public class PayChannelServiceImpl implements PayChannelService {
return payChannelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus());
}
@Override
public List<PayChannelDO> getChannelListByAppId(Long appId) {
return payChannelMapper.selectListByAppId(appId);
}
@Override
public PayClient getPayClient(Long id) {
PayChannelDO channel = validPayChannel(id);