package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerWorksheetAuditMapper;
import com.gxwebsoft.tower.service.TowerWorksheetAuditService;
import com.gxwebsoft.tower.entity.TowerWorksheetAudit;
import com.gxwebsoft.tower.param.TowerWorksheetAuditParam;
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-08-21 00:46:43
 */
@Service
public class TowerWorksheetAuditServiceImpl extends ServiceImpl<TowerWorksheetAuditMapper, TowerWorksheetAudit> implements TowerWorksheetAuditService {

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

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

    @Override
    public TowerWorksheetAudit getByIdRel(Integer worksheetAuditId) {
        TowerWorksheetAuditParam param = new TowerWorksheetAuditParam();
        param.setWorksheetAuditId(worksheetAuditId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
