package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.AppFieldMapper;
import com.gxwebsoft.oa.service.AppFieldService;
import com.gxwebsoft.oa.entity.AppField;
import com.gxwebsoft.oa.param.AppFieldParam;
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-01-14 11:42:53
 */
@Service
public class AppFieldServiceImpl extends ServiceImpl<AppFieldMapper, AppField> implements AppFieldService {

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

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

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

}
