package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.HualalaCardMapper;
import com.gxwebsoft.apps.service.HualalaCardService;
import com.gxwebsoft.apps.entity.HualalaCard;
import com.gxwebsoft.apps.param.HualalaCardParam;
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 HualalaCardServiceImpl extends ServiceImpl<HualalaCardMapper, HualalaCard> implements HualalaCardService {

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

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

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

}
