package org.jeecg.modules.wps.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.wps.dto.FileListDTO;
import org.jeecg.modules.wps.entity.WpsFile;

import java.util.List;

/**
 * wps文件
 * @author: jeecg-boot
 * @date:   2020-06-01
 * @cersion: V1.0
 */
public interface WpsFileMapper extends BaseMapper<WpsFile> {

    @Select("select file.id, " +
            "       file.name, " +
            "       file.version, " +
            "       file.size, " +
            "       user1.name as 'creator', " +
            "       user2.name as 'modifier', " +
            "       file.create_time, " +
            "       file.modify_time, " +
            "       '_' as 'download_url', " +
            "       file.modifier as 'user_id' " +
            " from wps_file file " +
            "         left join wps_user user1 on file.creator = user1.id " +
            "         left join wps_user user2 on file.modifier = user2.id " +
            " where file.deleted = 'N' " +
            " order by file.create_time desc ")
    List<FileListDTO> findAllFile();

    @Select("select file.id, " +
            "       file.name, " +
            "       file.version, " +
            "       file.size, " +
            "       user1.name as 'creator', " +
            "       user2.name as 'modifier', " +
            "       file.create_time, " +
            "       file.modify_time, " +
            "       '_' as 'download_url', " +
            "       file.modifier as 'user_id' " +
            " from wps_file file " +
            "         left join wps_user user1 on file.creator = user1.id " +
            "         left join wps_user user2 on file.modifier = user2.id " +
            " where file.deleted = 'N' " +
            " order by file.create_time desc ")
    List<FileListDTO> getAllFileByPage();
}
