package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsVhostMapper;
import com.gxwebsoft.oa.service.OaAssetsVhostService;
import com.gxwebsoft.oa.entity.OaAssetsVhost;
import com.gxwebsoft.oa.param.OaAssetsVhostParam;
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-10-18 18:27:02
 */
@Service
public class OaAssetsVhostServiceImpl extends ServiceImpl<OaAssetsVhostMapper, OaAssetsVhost> implements OaAssetsVhostService {

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

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

    @Override
    public OaAssetsVhost getByIdRel(Integer vhostId) {
        OaAssetsVhostParam param = new OaAssetsVhostParam();
        param.setVhostId(vhostId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
