package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Payment;
import com.gxwebsoft.common.system.mapper.PaymentMapper;
import com.gxwebsoft.common.system.param.PaymentParam;
import com.gxwebsoft.common.system.service.PaymentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 支付方式Service实现
 *
 * @author 科技小王子
 * @since 2024-05-11 12:39:11
 */
@Service
public class PaymentServiceImpl extends ServiceImpl<PaymentMapper, Payment> implements PaymentService {

    @Override
    public PageResult<Payment> pageRel(PaymentParam param) {
        PageParam<Payment, PaymentParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<Payment> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<Payment> listRel(PaymentParam param) {
        List<Payment> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<Payment, PaymentParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public Payment getByIdRel(Integer id) {
        PaymentParam param = new PaymentParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

    @Override
    public Payment getByType(PaymentParam paymentParam) {
      return baseMapper.getByType(paymentParam);
    }

}
