package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsSoftwareCertMapper;
import com.gxwebsoft.oa.service.OaAssetsSoftwareCertService;
import com.gxwebsoft.oa.entity.OaAssetsSoftwareCert;
import com.gxwebsoft.oa.param.OaAssetsSoftwareCertParam;
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 19:46:21
 */
@Service
public class OaAssetsSoftwareCertServiceImpl extends ServiceImpl<OaAssetsSoftwareCertMapper, OaAssetsSoftwareCert> implements OaAssetsSoftwareCertService {

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

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

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

}
