package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.WechatDepositMapper;
import com.gxwebsoft.shop.service.WechatDepositService;
import com.gxwebsoft.shop.entity.WechatDeposit;
import com.gxwebsoft.shop.param.WechatDepositParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 押金Service实现
 *
 * @author 科技小王子
 * @since 2024-05-03 15:50:28
 */
@Service
public class WechatDepositServiceImpl extends ServiceImpl<WechatDepositMapper, WechatDeposit> implements WechatDepositService {

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

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

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

}
