package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.HualalaCardBenefitsMapper;
import com.gxwebsoft.apps.service.HualalaCardBenefitsService;
import com.gxwebsoft.apps.entity.HualalaCardBenefits;
import com.gxwebsoft.apps.param.HualalaCardBenefitsParam;
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 2023-01-08 12:22:50
 */
@Service
public class HualalaCardBenefitsServiceImpl extends ServiceImpl<HualalaCardBenefitsMapper, HualalaCardBenefits> implements HualalaCardBenefitsService {

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

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

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

}
