|
|
@ -6,15 +6,18 @@ import com.win.framework.common.pojo.CommonResult; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.common.util.servlet.ServletUtils; |
|
|
|
import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
import com.win.module.infra.controller.file.vo.file.FileListReqVO; |
|
|
|
import com.win.module.infra.controller.file.vo.file.FilePageReqVO; |
|
|
|
import com.win.module.infra.controller.file.vo.file.FileRespVO; |
|
|
|
import com.win.module.infra.controller.file.vo.file.FileUploadReqVO; |
|
|
|
import com.win.module.infra.convert.file.FileConvert; |
|
|
|
import com.win.module.infra.dal.dataobject.file.FileDO; |
|
|
|
import com.win.module.infra.service.file.FileService; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
|
import com.win.module.system.api.user.dto.AdminUserRespDTO; |
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
@ -27,6 +30,7 @@ import javax.annotation.security.PermitAll; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import static com.win.framework.common.pojo.CommonResult.success; |
|
|
|
|
|
|
@ -40,6 +44,9 @@ public class FileController { |
|
|
|
@Resource |
|
|
|
private FileService fileService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AdminUserApi adminUserApi; |
|
|
|
|
|
|
|
@PostMapping("/upload") |
|
|
|
@Operation(summary = "上传文件") |
|
|
|
@OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要
|
|
|
@ -89,4 +96,20 @@ public class FileController { |
|
|
|
return success(FileConvert.INSTANCE.convertPage(pageResult)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/list") |
|
|
|
@Operation(summary = "获得文件分页") |
|
|
|
@PreAuthorize("@ss.hasPermission('infra:file:query')") |
|
|
|
public CommonResult<List<FileRespVO>> getFilePage(@Valid FileListReqVO listVO) { |
|
|
|
List<FileDO> listResult = fileService.getFileList(listVO); |
|
|
|
List<FileRespVO> fileRespVOList = FileConvert.INSTANCE.convertList(listResult); |
|
|
|
for(FileRespVO fileRespVO : fileRespVOList) { |
|
|
|
AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(fileRespVO.getCreator())); |
|
|
|
if(user != null) { |
|
|
|
fileRespVO.setNickname(user.getNickname()); |
|
|
|
fileRespVO.setAvatar(user.getAvatar()); |
|
|
|
} |
|
|
|
} |
|
|
|
return success(fileRespVOList); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|