package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.EnvironmentMapper;
import com.gxwebsoft.common.system.service.EnvironmentService;
import com.gxwebsoft.common.system.entity.Environment;
import com.gxwebsoft.common.system.param.EnvironmentParam;
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 2023-10-18 08:45:13
 */
@Service
public class EnvironmentServiceImpl extends ServiceImpl<EnvironmentMapper, Environment> implements EnvironmentService {

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

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

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

}
