package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.ProjectMapper;
import com.gxwebsoft.oa.service.ProjectService;
import com.gxwebsoft.oa.entity.Project;
import com.gxwebsoft.oa.param.ProjectParam;
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 WebSoft
 * @since 2022-11-16 11:00:43
 */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {

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

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

    @Override
    public Project getByIdRel(Integer projectId) {
        ProjectParam param = new ProjectParam();
        param.setProjectId(projectId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
