package com.yonge.cooleshow.biz.dal.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import com.yonge.cooleshow.biz.dal.entity.FileImportInfo;
import com.yonge.cooleshow.biz.dal.wrapper.FileImportInfoWrapper;
import com.yonge.cooleshow.biz.dal.mapper.FileImportInfoMapper;
import com.yonge.cooleshow.biz.dal.service.FileImportInfoService;

/**
 * 文件数据导入
 * 2023-09-19 19:47:50
 */
@Slf4j
@Service
public class FileImportInfoServiceImpl extends ServiceImpl<FileImportInfoMapper, FileImportInfo> implements FileImportInfoService {

	/**
     * 查询详情
     * @param id 详情ID
     * @return FileImportInfo
     */
	@Override
    public FileImportInfo detail(Long id) {
        
        return baseMapper.selectById(id);
    }
    
    /**
     * 分页查询
     * @param page IPage<FileImportInfo>
     * @param query FileImportInfoWrapper.FileImportInfoQuery
     * @return IPage<FileImportInfo>
     */
    @Override
    public IPage<FileImportInfo> selectPage(IPage<FileImportInfo> page, FileImportInfoWrapper.FileImportInfoQuery query) {
        
        return page.setRecords(baseMapper.selectPage(page, query));
    }
	
    /**
     * 添加
     * @param fileImportInfo FileImportInfoWrapper.FileImportInfo
     * @return Boolean
     */
    @Override
    public Boolean add(FileImportInfoWrapper.FileImportInfo fileImportInfo) {
        FileImportInfo importInfo = JSON.parseObject(fileImportInfo.jsonString(), FileImportInfo.class);
        boolean save = this.save(importInfo);
        fileImportInfo.setId(importInfo.getId());
        return save;
    }

    /**
     * 更新
     * @param fileImportInfo FileImportInfoWrapper.FileImportInfo
     * @return Boolean
     */
    @Override
    public Boolean update(FileImportInfoWrapper.FileImportInfo fileImportInfo){

        return this.updateById(JSON.parseObject(fileImportInfo.jsonString(), FileImportInfo.class));       
    }
}