package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.vo.AssetVo;
import com.ruoyi.system.mapper.AssetlogMapper;
import com.ruoyi.system.domain.Assetlog;
import com.ruoyi.system.service.AssetlogService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * (Assetlog)表服务实现类
 *
 * @author makejava
 * @since 2024-05-28 10:47:18
 */
@Service
public class AssetlogServiceImpl implements AssetlogService {
    @Resource
    private AssetlogMapper assetlogMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Assetlog queryById(Integer id) {
        return this.assetlogMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param assetlog 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<Assetlog> queryByPage(Assetlog assetlog, PageRequest pageRequest) {
        long total = this.assetlogMapper.count(assetlog);
        return new PageImpl<>(this.assetlogMapper.queryAllByLimit(assetlog, pageRequest), pageRequest, total);
    }

    @Override
    public List<Assetlog> list(AssetVo assetVo) {

        return assetlogMapper.list(assetVo, Convert.toIntArray(assetVo.getDutyId()));
    }

    @Override
    public List<Map<String, Object>> getAssetType() {
        return assetlogMapper.getAssetType();
    }
}
