package com.gxwebsoft.credit.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.credit.entity.CreditGqdj;
import com.gxwebsoft.credit.mapper.CreditGqdjMapper;
import com.gxwebsoft.credit.param.CreditGqdjParam;
import com.gxwebsoft.credit.service.CreditGqdjService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 股权冻结Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:50:37
 */
@Service
public class CreditGqdjServiceImpl extends ServiceImpl<CreditGqdjMapper, CreditGqdj> implements CreditGqdjService {

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

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

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

}
