package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.CompanyFieldMapper;
import com.gxwebsoft.oa.service.CompanyFieldService;
import com.gxwebsoft.oa.entity.CompanyField;
import com.gxwebsoft.oa.param.CompanyFieldParam;
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 2024-02-04 14:44:42
 */
@Service
public class CompanyFieldServiceImpl extends ServiceImpl<CompanyFieldMapper, CompanyField> implements CompanyFieldService {

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

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

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

}
