package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsMysqlMapper;
import com.gxwebsoft.oa.service.OaAssetsMysqlService;
import com.gxwebsoft.oa.entity.OaAssetsMysql;
import com.gxwebsoft.oa.param.OaAssetsMysqlParam;
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:00:20
 */
@Service
public class OaAssetsMysqlServiceImpl extends ServiceImpl<OaAssetsMysqlMapper, OaAssetsMysql> implements OaAssetsMysqlService {

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

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

    @Override
    public OaAssetsMysql getByIdRel(Integer mysqlId) {
        OaAssetsMysqlParam param = new OaAssetsMysqlParam();
        param.setMysqlId(mysqlId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
