package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAppFieldMapper;
import com.gxwebsoft.oa.service.OaAppFieldService;
import com.gxwebsoft.oa.entity.OaAppField;
import com.gxwebsoft.oa.param.OaAppFieldParam;
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-10 20:57:41
 */
@Service
public class OaAppFieldServiceImpl extends ServiceImpl<OaAppFieldMapper, OaAppField> implements OaAppFieldService {

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

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

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

}
