mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
refactor(pay-channel): 重构支付渠道查询逻辑并增加敏感信息脱敏处理
This commit is contained in:
1 parent
23b6f8cf8d
commit
2304e2490d
3 files changed
+81
-18
No files matched your search
+3
-9
@@ -18,8 +18,6 @@
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
@@ -61,12 +59,8 @@ public class PayChannelController {
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_view')")
|
||||
public R getpayChannelPage(Page page, PayChannel payChannel) {
|
||||
LambdaQueryWrapper<PayChannel> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(payChannel.getChannelName()), PayChannel::getChannelName,
|
||||
payChannel.getChannelName());
|
||||
wrapper.eq(StrUtil.isNotBlank(payChannel.getState()), PayChannel::getState, payChannel.getState());
|
||||
return R.ok(payChannelService.page(page, wrapper));
|
||||
public R page(Page page, PayChannel payChannel) {
|
||||
return R.ok(payChannelService.queryPage(page, payChannel));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +72,7 @@ public class PayChannelController {
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(payChannelService.getById(id));
|
||||
return R.ok(payChannelService.getChannel(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
|
||||
@@ -35,4 +36,20 @@ public interface PayChannelService extends IService<PayChannel> {
|
||||
*/
|
||||
Boolean saveChannel(PayChannel payChannel);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 页
|
||||
* @param payChannel 付费频道
|
||||
* @return {@link Page }<{@link PayChannel }>
|
||||
*/
|
||||
Page<PayChannel> queryPage(Page page, PayChannel payChannel);
|
||||
|
||||
/**
|
||||
* 获取channel
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link PayChannel }
|
||||
*/
|
||||
PayChannel getChannel(Long id);
|
||||
}
|
||||
+61
-9
@@ -16,13 +16,20 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.pay.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.sensitive.util.DesensitizedUtils;
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
import com.pig4cloud.pigx.pay.mapper.PayChannelMapper;
|
||||
import com.pig4cloud.pigx.pay.service.PayChannelService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 渠道
|
||||
*
|
||||
@@ -33,14 +40,59 @@ import org.springframework.stereotype.Service;
|
||||
@AllArgsConstructor
|
||||
public class PayChannelServiceImpl extends ServiceImpl<PayChannelMapper, PayChannel> implements PayChannelService {
|
||||
|
||||
/**
|
||||
* 新增支付渠道
|
||||
* @param payChannel 支付渠道
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveChannel(PayChannel payChannel) {
|
||||
return save(payChannel);
|
||||
}
|
||||
/**
|
||||
* 新增支付渠道
|
||||
*
|
||||
* @param payChannel 支付渠道
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveChannel(PayChannel payChannel) {
|
||||
return save(payChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 页
|
||||
* @param payChannel 付费频道
|
||||
* @return {@link Page }<{@link PayChannel }>
|
||||
*/
|
||||
@Override
|
||||
public Page<PayChannel> queryPage(Page page, PayChannel payChannel) {
|
||||
LambdaQueryWrapper<PayChannel> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(payChannel.getChannelName()), PayChannel::getChannelName,
|
||||
payChannel.getChannelName());
|
||||
wrapper.eq(StrUtil.isNotBlank(payChannel.getState()), PayChannel::getState, payChannel.getState());
|
||||
|
||||
Page<PayChannel> selectedPage = baseMapper.selectPage(page, wrapper);
|
||||
|
||||
// 对敏感信息进行脱敏
|
||||
selectedPage.setRecords(selectedPage.getRecords().stream().peek(channel -> channel
|
||||
.setParam(DesensitizedUtils.json(channel.getParam(), true, "key"))).collect(Collectors.toList()));
|
||||
|
||||
return selectedPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取channel
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link PayChannel }
|
||||
*/
|
||||
@Override
|
||||
public PayChannel getChannel(Long id) {
|
||||
|
||||
PayChannel channel = getById(id);
|
||||
|
||||
if (channel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 手动对key进行脱敏
|
||||
channel.setParam(DesensitizedUtils.json(channel.getParam(), true, "key"));
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user