package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsMapper;
import com.gxwebsoft.oa.service.OaAssetsService;
import com.gxwebsoft.oa.entity.OaAssets;
import com.gxwebsoft.oa.param.OaAssetsParam;
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:34:15
 */
@Service
public class OaAssetsServiceImpl extends ServiceImpl<OaAssetsMapper, OaAssets> implements OaAssetsService {

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

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

    @Override
    public OaAssets getByIdRel(Integer assetsId) {
        OaAssetsParam param = new OaAssetsParam();
        param.setAssetsId(assetsId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
