package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.VersionMapper;
import com.gxwebsoft.common.system.service.VersionService;
import com.gxwebsoft.common.system.entity.Version;
import com.gxwebsoft.common.system.param.VersionParam;
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-01-15 18:52:24
 */
@Service
public class VersionServiceImpl extends ServiceImpl<VersionMapper, Version> implements VersionService {

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

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

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

}
