package com.gxwebsoft.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.project.mapper.ProjectFieldMapper;
import com.gxwebsoft.project.service.ProjectFieldService;
import com.gxwebsoft.project.entity.ProjectField;
import com.gxwebsoft.project.param.ProjectFieldParam;
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 2025-03-14 16:21:11
 */
@Service
public class ProjectFieldServiceImpl extends ServiceImpl<ProjectFieldMapper, ProjectField> implements ProjectFieldService {

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

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

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

}
