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

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.WhiteDomainMapper;
import com.gxwebsoft.common.system.service.WhiteDomainService;
import com.gxwebsoft.common.system.entity.WhiteDomain;
import com.gxwebsoft.common.system.param.WhiteDomainParam;
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-03-26 00:22:21
 */
@Service
public class WhiteDomainServiceImpl extends ServiceImpl<WhiteDomainMapper, WhiteDomain> implements WhiteDomainService {

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

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

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

}
