package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsSiteMapper;
import com.gxwebsoft.oa.service.OaAssetsSiteService;
import com.gxwebsoft.oa.entity.OaAssetsSite;
import com.gxwebsoft.oa.param.OaAssetsSiteParam;
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 OaAssetsSiteServiceImpl extends ServiceImpl<OaAssetsSiteMapper, OaAssetsSite> implements OaAssetsSiteService {

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

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

    @Override
    public OaAssetsSite getByIdRel(Integer websiteId) {
        OaAssetsSiteParam param = new OaAssetsSiteParam();
        param.setWebsiteId(websiteId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
