接口修改

This commit is contained in:
马超 2021-03-06 22:58:33 +08:00
parent 801cc2268c
commit 7e6876a295
7 changed files with 104 additions and 8 deletions

View File

@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwenshare.file.domain.RecoveryFile;
import com.qiwenshare.file.domain.Share;
import com.qiwenshare.file.domain.ShareFile;
import com.qiwenshare.file.vo.share.ShareFileListVO;
import java.util.List;
public interface IShareService extends IService<Share> {
void batchInsertShareFile(List<ShareFile> shareFiles);
List<ShareFileListVO> selectShareFileListByBatchNum(Share share);
}

View File

@ -12,10 +12,8 @@ import com.qiwenshare.file.api.IUserService;
import com.qiwenshare.file.domain.Share;
import com.qiwenshare.file.domain.ShareFile;
import com.qiwenshare.file.domain.UserBean;
import com.qiwenshare.file.dto.sharefile.CheckExtractionCodeDTO;
import com.qiwenshare.file.dto.sharefile.ShareFileListBySecretDTO;
import com.qiwenshare.file.dto.sharefile.ShareFileDTO;
import com.qiwenshare.file.dto.sharefile.ShareTypeDTO;
import com.qiwenshare.file.dto.sharefile.*;
import com.qiwenshare.file.vo.share.ShareFileListVO;
import com.qiwenshare.file.vo.share.ShareFileVO;
import com.qiwenshare.file.vo.share.ShareTypeVO;
import io.swagger.v3.oas.annotations.Operation;
@ -24,6 +22,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@ -68,11 +68,13 @@ public class ShareController {
@Operation(summary = "分享列表", description = "分享列表", tags = {"share"})
@GetMapping(value = "/sharefileList")
@ResponseBody
public RestResult<List<Share>> shareFileListBySecret(ShareFileListBySecretDTO shareFileListBySecretDTO) {
public RestResult<List<ShareFileListVO>> shareFileListBySecret(ShareFileListBySecretDTO shareFileListBySecretDTO) {
log.info(JSON.toJSONString(shareFileListBySecretDTO));
LambdaQueryWrapper<Share> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Share::getShareBatchNum, shareFileListBySecretDTO.getShareBatchNum());
List<Share> list = shareService.list(lambdaQueryWrapper);
Share share = new Share();
share.setShareBatchNum(shareFileListBySecretDTO.getShareBatchNum());
List<ShareFileListVO> list = shareService.selectShareFileListByBatchNum(share);
return RestResult.success().data(list);
}
@ -104,4 +106,26 @@ public class ShareController {
return RestResult.success();
}
}
@Operation(summary = "校验过期时间", description = "校验过期时间", tags = {"share"})
@GetMapping(value = "/checkendtime")
@ResponseBody
public RestResult<String> checkEndTime(CheckEndTimeDTO checkEndTimeDTO) {
LambdaQueryWrapper<Share> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Share::getShareBatchNum, checkEndTimeDTO.getShareBatchNum());
Share share = shareService.getOne(lambdaQueryWrapper);
String endTime = share.getEndTime();
Date endTimeDate = null;
try {
endTimeDate = DateUtil.getDateByFormatString(endTime, "yyyy-MM-dd HH:mm:ss");
} catch (ParseException e) {
log.error("日期解析失败:{}" , e);
}
if (new Date().after(endTimeDate)) {
return RestResult.fail().message("分享已过期");
} else {
return RestResult.success();
}
}
}

View File

@ -0,0 +1,12 @@
package com.qiwenshare.file.dto.sharefile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "校验过期时间DTO",required = true)
public class CheckEndTimeDTO {
@Schema(description="批次号")
private String shareBatchNum;
}

View File

@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwenshare.file.domain.FileBean;
import com.qiwenshare.file.domain.Share;
import com.qiwenshare.file.domain.ShareFile;
import com.qiwenshare.file.vo.share.ShareFileListVO;
import java.util.List;
public interface ShareMapper extends BaseMapper<Share> {
void batchInsertShareFile(List<ShareFile> shareFiles);
List<ShareFileListVO> selectShareFileListByBatchNum(Share share);
}

View File

@ -7,6 +7,7 @@ import com.qiwenshare.file.domain.Share;
import com.qiwenshare.file.domain.ShareFile;
import com.qiwenshare.file.mapper.RecoveryFileMapper;
import com.qiwenshare.file.mapper.ShareMapper;
import com.qiwenshare.file.vo.share.ShareFileListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -22,4 +23,9 @@ public class ShareService extends ServiceImpl<ShareMapper, Share> implements ISh
public void batchInsertShareFile(List<ShareFile> shareFiles) {
shareMapper.batchInsertShareFile(shareFiles);
}
@Override
public List<ShareFileListVO> selectShareFileListByBatchNum(Share share) {
return shareMapper.selectShareFileListByBatchNum(share);
}
}

View File

@ -0,0 +1,43 @@
package com.qiwenshare.file.vo.share;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description="分享文件列表VO")
@Data
public class ShareFileListVO {
@Schema(description="文件id")
private Long fileId;
@Schema(description="文件时间戳姓名")
private String timeStampName;
@Schema(description="文件url")
private String fileUrl;
@Schema(description="文件大小")
private Long fileSize;
@Schema(description="是否sso存储")
private Integer isOSS;
//
// private Long userFileId;
//
// private Long userId;
@Schema(description="文件名")
private String fileName;
@Schema(description="文件路径")
private String filePath;
@Schema(description="文件扩展名")
private String extendName;
@Schema(description="是否是目录 0-否, 1-是")
private Integer isDir;
@Schema(description="上传时间")
private String uploadTime;
//
// private Long shareId;
//
// private String shareTime;
// private String endTime;
// private String extractionCode;
// private String shareBatchNum;
// private Integer shareType;//0公共1私密2好友
// private Integer shareStatus;//0正常1已失效2已撤销
}

View File

@ -15,6 +15,13 @@
</foreach>
</insert>
<select id="selectShareFileListByBatchNum" parameterType="com.qiwenshare.file.domain.Share" resultType="com.qiwenshare.file.vo.share.ShareFileListVO">
select * from sharefile a
left join userfile b on b.userFileId = a.userFileId
left join file c on c.fileId = b.fileId
where a.shareBatchNum = #{shareBatchNum}
</select>
<!-- <update id="updateFile" parameterType="java">-->