package com.gxwebsoft.glt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.glt.mapper.GltUserTicketReleaseMapper;
import com.gxwebsoft.glt.service.GltUserTicketReleaseService;
import com.gxwebsoft.glt.entity.GltUserTicketRelease;
import com.gxwebsoft.glt.param.GltUserTicketReleaseParam;
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 2026-02-03 18:55:55
 */
@Service
public class GltUserTicketReleaseServiceImpl extends ServiceImpl<GltUserTicketReleaseMapper, GltUserTicketRelease> implements GltUserTicketReleaseService {

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

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

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

}
