package org.jeecg.modules.wps.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.wps.mapper.WpsFileWatermarkMapper;
import org.jeecg.modules.wps.entity.WpsFileWatermark;
import org.jeecg.modules.wps.service.IWpsFileWatermarkService;
import org.springframework.stereotype.Service;

/**
 * wps文件水印
 * @author jeecg-boot
 * @date   2020-06-01
 * @version V1.0
 */
@Service
public class WpsFileWatermarkServiceImpl extends ServiceImpl<WpsFileWatermarkMapper, WpsFileWatermark> implements IWpsFileWatermarkService {

    @Override
    public WpsFileWatermark findFirstByFileId(String fileId) {
        QueryWrapper<WpsFileWatermark>queryWrapper = new QueryWrapper<>();
        if(null!=fileId&&!"".equals(fileId.trim())){
            queryWrapper.eq("file_id",fileId);
        }
        queryWrapper.orderByDesc("id").last("limit 1");
        return this.getOne(queryWrapper);
    }

    @Override
    public void saveWatermark(String fileId) {
        this.save(new WpsFileWatermark(fileId));
    }
}
