package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsDomainMapper;
import com.gxwebsoft.oa.service.OaAssetsDomainService;
import com.gxwebsoft.oa.entity.OaAssetsDomain;
import com.gxwebsoft.oa.param.OaAssetsDomainParam;
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 OaAssetsDomainServiceImpl extends ServiceImpl<OaAssetsDomainMapper, OaAssetsDomain> implements OaAssetsDomainService {

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

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

    @Override
    public OaAssetsDomain getByIdRel(Integer domainId) {
        OaAssetsDomainParam param = new OaAssetsDomainParam();
        param.setDomainId(domainId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
