package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerContractFileMapper;
import com.gxwebsoft.tower.service.TowerContractFileService;
import com.gxwebsoft.tower.entity.TowerContractFile;
import com.gxwebsoft.tower.param.TowerContractFileParam;
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-09 13:42:20
 */
@Service
public class TowerContractFileServiceImpl extends ServiceImpl<TowerContractFileMapper, TowerContractFile> implements TowerContractFileService {

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

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

    @Override
    public TowerContractFile getByIdRel(Integer contractFileId) {
        TowerContractFileParam param = new TowerContractFileParam();
        param.setContractFileId(contractFileId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
