From 3368a995cabe56d19ffa4bbd6f110c67b4b35226 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 10 Nov 2021 09:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=20code=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/vo/PayChannelCreateReqVO.java | 4 +- .../vo/PayWechatChannelUpdateReqVO.java | 2 + .../pay/dal/mysql/app/PayAppMapper.java | 14 ++++--- .../service/app/impl/PayAppServiceImpl.java | 31 ++++++++------ .../service/channel/PayChannelService.java | 19 ++++----- .../channel/impl/PayChannelServiceImpl.java | 40 ++++++++----------- .../service/merchant/PayMerchantService.java | 21 +++++++--- .../merchant/impl/PayMerchantServiceImpl.java | 3 +- .../src/main/resources/application.yaml | 2 +- .../pay/app/service/PayAppServiceTest.java | 19 ++++----- .../pay/channel/PayChannelServiceTest.java | 30 +++++++------- .../dal/dataobject/merchant/PayChannelDO.java | 1 - .../pay/enums/PayErrorCodeCoreConstants.java | 2 + .../pay/core/enums/PayChannelEnum.java | 1 + 14 files changed, 101 insertions(+), 88 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayChannelCreateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayChannelCreateReqVO.java index f19b0384c..4ff0d7512 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayChannelCreateReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayChannelCreateReqVO.java @@ -11,6 +11,8 @@ import lombok.ToString; @ToString(callSuper = true) public class PayChannelCreateReqVO extends PayChannelBaseVO { - + // TODO @aquan:我在想,要不这个创建和修改特殊一点。前端传递 string 过来,后端解析成对应的。因为有 code,所以我们都知道是哪个配置类。 + // 然后,在 PayChannelEnum 里,枚举每个渠道对应的配置类。另外,我们就不单独给配置类搞 vo 了。参数校验,通过手动调用 Validator 去校验。 + // 通过这样的方式,VO 和 api 都收成,一个 update,一个 create } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayWechatChannelUpdateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayWechatChannelUpdateReqVO.java index 60c814308..168542092 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayWechatChannelUpdateReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayWechatChannelUpdateReqVO.java @@ -62,5 +62,7 @@ public class PayWechatChannelUpdateReqVO extends PayChannelBaseVO { @ApiModelProperty(value = "apiclient_cert.pem 证书对应的字符串", required = true, example = "-----BEGIN CERTIFICATE-----") private String privateCertContent; + + // TODO @aquan:参数校验。可以使用 @AssertTrue,v2 和 v3 的 } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/app/PayAppMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/app/PayAppMapper.java index 200ccf296..e6089d617 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/app/PayAppMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/app/PayAppMapper.java @@ -1,13 +1,15 @@ package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app; -import java.util.*; - +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; + +import java.util.Collection; +import java.util.List; /** * 支付应用信息 Mapper @@ -17,7 +19,7 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; @Mapper public interface PayAppMapper extends BaseMapperX { - default PageResult selectPage(PayAppPageReqVO reqVO,Collection merchantIds) { + default PageResult selectPage(PayAppPageReqVO reqVO, Collection merchantIds) { return selectPage(reqVO, new QueryWrapperX() .likeIfPresent("name", reqVO.getName()) .eqIfPresent("status", reqVO.getStatus()) @@ -38,7 +40,7 @@ public interface PayAppMapper extends BaseMapperX { .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) .eqIfPresent("merchant_id", reqVO.getMerchantId()) .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc("id") ); + .orderByDesc("id")); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/app/impl/PayAppServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/app/impl/PayAppServiceImpl.java index 499abe76e..327c57b42 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/app/impl/PayAppServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/app/impl/PayAppServiceImpl.java @@ -1,26 +1,31 @@ package cn.iocoder.yudao.adminserver.modules.pay.service.app.impl; import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert; +import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; +import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService; import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import com.google.common.annotations.VisibleForTesting; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import java.util.*; -import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService; +import javax.annotation.Resource; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.APP_NOT_EXISTS; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; /** * 支付应用信息 Service 实现类 @@ -84,7 +89,8 @@ public class PayAppServiceImpl implements PayAppService { @Override public PageResult getAppPage(PayAppPageReqVO pageReqVO) { - return appMapper.selectPage(pageReqVO,this.getMerchantCondition(pageReqVO.getMerchantName())); + // TODO @aquan:会有一个场景,merchantName 匹配不到商户编号的时候,应该返回没数据的 + return appMapper.selectPage(pageReqVO, this.getMerchantCondition(pageReqVO.getMerchantName())); } @Override @@ -94,6 +100,7 @@ public class PayAppServiceImpl implements PayAppService { /** * 获取商户编号集合,根据商户名称模糊查询得到所有的商户编号集合 + * * @param merchantName 商户名称 * @return 商户编号集合 */ @@ -101,7 +108,7 @@ public class PayAppServiceImpl implements PayAppService { if (StrUtil.isBlank(merchantName)) { return Collections.emptySet(); } - return CollectionUtils.convertSet(merchantService.getMerchantListByName(merchantName), PayMerchantDO::getId); + return convertSet(merchantService.getMerchantListByName(merchantName), PayMerchantDO::getId); } /** diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelService.java index 420c23123..49b5384bb 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelService.java @@ -1,22 +1,21 @@ package cn.iocoder.yudao.adminserver.modules.pay.service.channel; -import java.util.*; -import javax.validation.*; - import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.springframework.web.multipart.MultipartFile; +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + /** - * 支付渠道 - * Service 接口 + * 支付渠道 Service 接口 * - * @author 芋艿 + * @author 芋艿 // TODO @aquan:作者不要我 */ public interface PayChannelService { - /** * 创建支付渠道 * @@ -72,8 +71,7 @@ public interface PayChannelService { * 列表, 用于 Excel 导出 * * @param exportReqVO 查询条件 - * @return 支付渠道 - * 列表 + * @return 支付渠道列表 */ List getChannelList(PayChannelExportReqVO exportReqVO); @@ -83,6 +81,7 @@ public interface PayChannelService { * @param payIds 支付应用编号集合 * @return 支付渠道 */ + // TODO @aquan:暂时不用提供这种哈。之前提供的原因,是数据字典比较特殊。 List getSimpleChannels(Collection payIds); /** @@ -91,6 +90,7 @@ public interface PayChannelService { * @param file pem公私钥文件 * @return 解析后的字符串 */ + // TODO @aquan:可以前端读取么? String parsingPemFile(MultipartFile file); /** @@ -99,6 +99,7 @@ public interface PayChannelService { * @param reqVO 创建信息 * @return 创建结果 */ + // TODO @aquan:pojo 如果要做参数校验,需要添加 @Valid Long createWechatChannel(PayWechatChannelCreateReqVO reqVO); /** diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java index 4412ccf90..5e3d1b514 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java @@ -1,43 +1,34 @@ package cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl; import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.json.JsonMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -import org.springframework.util.Assert; -import org.springframework.validation.annotation.Validated; - -import java.io.IOException; -import java.util.*; - import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert; import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; +import java.io.IOException; +import java.util.Collection; +import java.util.List; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** - * 支付渠道 - * Service 实现类 + * 支付渠道 Service 实现类 * - * @author 芋艿 + * @author 芋艿 // TODO aquan:作者写自己哈 */ -@Slf4j @Service +@Slf4j @Validated public class PayChannelServiceImpl implements PayChannelService { @@ -162,6 +153,7 @@ public class PayChannelServiceImpl implements PayChannelService { ); } + // TODO @aquan:service 不出现 mybatis plus 哈 /** * 根据条件获取通道 * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/PayMerchantService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/PayMerchantService.java index be0e66039..ae13a01ef 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/PayMerchantService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/PayMerchantService.java @@ -1,15 +1,20 @@ package cn.iocoder.yudao.adminserver.modules.pay.service.merchant; -import java.util.*; -import javax.validation.*; - import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.*; -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantUpdateReqVO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import javax.validation.Valid; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + /** * 支付商户信息 Service 接口 * @@ -87,6 +92,7 @@ public interface PayMerchantService { */ List getMerchantListByName(String merchantName); + // TODO aquan:暂时不用提供这样的检索。商户不多的。 /** * 根据商户名称模糊查询一定数量的商户集合 * @param merchantName 商户名称 @@ -100,6 +106,7 @@ public interface PayMerchantService { * @param merchantIds 商户编号数组 * @return 商户列表 */ + // TODO @aquan:和 getMerchantList 重复了 List getSimpleMerchants(Collection merchantIds); /** @@ -108,11 +115,13 @@ public interface PayMerchantService { * @param merchantIds 商户编号数组 * @return 商户 Map */ - default Map getMerchantMap(Collection merchantIds){ + default Map getMerchantMap(Collection merchantIds) { + // TODO @aquan:可以不用判空,交给 getMerchantList 解决 if (CollUtil.isEmpty(merchantIds)) { return Collections.emptyMap(); } List list = getSimpleMerchants(merchantIds); return CollectionUtils.convertMap(list, PayMerchantDO::getId); } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java index 556792d2f..3d749181a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java @@ -113,6 +113,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { */ @Override public List getMerchantListByName(String merchantName) { + // TODO @aquan:Service 层,不要出现 mybatis plus 的代码,要放到 mapper 里提供。技术与业务分离,原则上 return this.merchantMapper.selectList(new QueryWrapper() .lambda().likeRight(PayMerchantDO::getName, merchantName)); } @@ -160,6 +161,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { return merchantMapper.selectBatchIds(merchantIds); } + // TODO @芋艿:后续增加下合适的算法 /** * 根据年月日时分秒毫秒生成商户号 * @return 商户号 @@ -168,5 +170,4 @@ public class PayMerchantServiceImpl implements PayMerchantService { return "M" + DateUtil.format(LocalDateTime.now(),"yyyyMMddHHmmssSSS"); } - } diff --git a/yudao-admin-server/src/main/resources/application.yaml b/yudao-admin-server/src/main/resources/application.yaml index 26af6c0ed..9781f08e1 100644 --- a/yudao-admin-server/src/main/resources/application.yaml +++ b/yudao-admin-server/src/main/resources/application.yaml @@ -61,5 +61,5 @@ yudao: - cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants - cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants pay: - payReturnUrl: http://127.0.0.1 + payReturnUrl: http://127.0.0.1 # TODO @aquan:这个变量,配置到 dev 或者 local 里,不同环境有差别哈 debug: false diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/app/service/PayAppServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/app/service/PayAppServiceTest.java index 8bea96b5f..64448dc56 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/app/service/PayAppServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/app/service/PayAppServiceTest.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.adminserver.modules.pay.app.service; -import javax.annotation.Resource; - import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO; import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; @@ -10,22 +8,21 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateRe import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; import cn.iocoder.yudao.adminserver.modules.pay.service.app.impl.PayAppServiceImpl; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.common.pojo.PageResult; - +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; -import java.util.*; -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.APP_NOT_EXISTS; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - /** * {@link PayAppServiceImpl} 的单元测试类 * @@ -148,7 +145,7 @@ public class PayAppServiceTest extends BaseDbUnitTest { assertPojoEquals(dbApp, pageResult.getList().get(0)); } - @Test // TODO 请修改 null 为需要的值 + @Test // TODO aquan:请修改 null 为需要的值 public void testGetAppList() { // mock 数据 PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/channel/PayChannelServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/channel/PayChannelServiceTest.java index 5e1875f8d..824cb087b 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/channel/PayChannelServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/channel/PayChannelServiceTest.java @@ -1,30 +1,28 @@ package cn.iocoder.yudao.adminserver.modules.pay.channel; -import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; -import org.junit.jupiter.api.Test; - -import javax.annotation.Resource; - import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl.PayChannelServiceImpl; -import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelUpdateReqVO; import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl.PayChannelServiceImpl; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; - +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; -import java.util.*; -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_NOT_EXISTS; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - /** * {@link PayChannelServiceImpl} 的单元测试类 * @@ -152,7 +150,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { assertPojoEquals(dbChannel, pageResult.getList().get(0)); } - @Test // TODO 请修改 null 为需要的值 + @Test // TODO aquan:请修改 null 为需要的值 public void testGetChannelList() { // mock 数据 PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到 diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java index 074585e5d..5275dd428 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java @@ -46,7 +46,6 @@ public class PayChannelDO extends BaseDO { * 渠道费率,单位:百分比 */ private Double feeRate; - /** * 备注 */ diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java index a7ed739e3..8d09e6865 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java @@ -45,5 +45,7 @@ public interface PayErrorCodeCoreConstants { */ ErrorCode CHANNEL_NOT_EXISTS = new ErrorCode(1007006000, "支付渠道不存在"); ErrorCode CHANNEL_KEY_READ_ERROR = new ErrorCode(1007006002, "支付渠道秘钥文件读取失败"); + // TODO @aquan:下面这个错误码,缺了 CHANNEL 前缀。另外,错误码的分段,上面有啦,合并下进去哈 ErrorCode EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007006003, "已存在相同的渠道"); + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java index a6734d961..55c2a5788 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java @@ -16,6 +16,7 @@ public enum PayChannelEnum { WX_PUB("wx_pub", "微信 JSAPI 支付"), // 公众号的网页 // TODO @芋艿 这个地方你写的是 wx_lit 是不是少写了一个e? 还是我这里多加了一个e + // TODO @aquan:这里就是 lite 哈,轻量 WX_LITE("wx_lite","微信小程序支付"), WX_APP("wx_app", "微信 App 支付"),