package com.yida.data.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.system.UnionPayConfig;
import com.yida.data.system.mapper.UnionPayConfigMapper;
import com.yida.data.system.service.UnionPayConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Objects;

/**
 * 银联云闪付支付配置信息service
 *
 * @author ZYJ
 * @date 2022/6/23
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UnionPayConfigServiceImpl extends ServiceImpl<UnionPayConfigMapper, UnionPayConfig> implements UnionPayConfigService {

    @Override
    public UnionPayConfig getUnionPayConfigByDept(Long deptId) {
        UnionPayConfig config = getOne(Wrappers.<UnionPayConfig>lambdaQuery().eq(UnionPayConfig::getDeptId, deptId));
        if (Objects.nonNull(config.getParentId())) {
            config.setParentConfig(getById(config.getParentId()));
        }
        return config;
    }
}
