package com.ema.admin.modules.assets.service.impl;

import cn.hutool.core.util.StrUtil;
import com.ema.admin.modules.assets.entity.AssetsInfo;
import com.ema.admin.modules.assets.vo.AssetsInfoQueryVo;
import com.ema.admin.modules.assets.mapper.AssetsInfoMapper;
import com.ema.admin.modules.assets.service.AssetsInfoService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 *  资产信息表 服务层实现。
 *
 * @author LIJIAN
 * @since 2026-05-13
 */
@Service
public class AssetsInfoServiceImpl extends ServiceImpl<AssetsInfoMapper, AssetsInfo> implements AssetsInfoService {

    @Override
    public Page<AssetsInfo> page(AssetsInfoQueryVo queryVo) {
        QueryWrapper queryWrapper = QueryWrapper.create();
        queryWrapper.like(AssetsInfo::getDeptName, queryVo.getDeptName(), StrUtil.isNotBlank(queryVo.getDeptName()));
        queryWrapper.like(AssetsInfo::getAssetCode, queryVo.getAssetCode(), StrUtil.isNotBlank(queryVo.getAssetCode()));
        queryWrapper.eq(AssetsInfo::getAssetType, queryVo.getAssetType(), StrUtil.isNotBlank(queryVo.getAssetType()));
        queryWrapper.like(AssetsInfo::getBrand, queryVo.getBrand(), StrUtil.isNotBlank(queryVo.getBrand()));
        queryWrapper.like(AssetsInfo::getModel, queryVo.getModel(), StrUtil.isNotBlank(queryVo.getModel()));
        queryWrapper.eq(AssetsInfo::getInvstkStatus, queryVo.getInvstkStatus(), StrUtil.isNotBlank(queryVo.getInvstkStatus()));
        queryWrapper.orderBy(AssetsInfo::getCreateTime, false);
        return this.page(new Page<>(queryVo.getPageNumber(), queryVo.getPageSize()), queryWrapper);
    }
}
