package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.oa.entity.OaAssetsServer;
import com.gxwebsoft.oa.mapper.OaAssetsServerMapper;
import com.gxwebsoft.oa.param.OaAssetsServerParam;
import com.gxwebsoft.oa.service.OaAssetsServerService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务Service实现
 *
 * @author 科技小王子
 * @since 2024-10-21 19:15:26
 */
@Service
public class OaAssetsServerServiceImpl extends ServiceImpl<OaAssetsServerMapper, OaAssetsServer> implements OaAssetsServerService {

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

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

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

}
