package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractMapper;
import com.gxwebsoft.tower.service.TowerContractService;
import com.gxwebsoft.tower.entity.TowerContract;
import com.gxwebsoft.tower.param.TowerContractParam;
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-06-08 22:36:47
 */
@Service
public class TowerContractServiceImpl extends ServiceImpl<TowerContractMapper, TowerContract> implements TowerContractService {

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

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

    @Override
    public TowerContract getByIdRel(Integer contractId) {
        TowerContractParam param = new TowerContractParam();
        param.setContractId(contractId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
