package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaCompanyFieldMapper;
import com.gxwebsoft.oa.service.OaCompanyFieldService;
import com.gxwebsoft.oa.entity.OaCompanyField;
import com.gxwebsoft.oa.param.OaCompanyFieldParam;
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-09-20 12:33:12
 */
@Service
public class OaCompanyFieldServiceImpl extends ServiceImpl<OaCompanyFieldMapper, OaCompanyField> implements OaCompanyFieldService {

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

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

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

}
