DX
3 days ago
27 changed files with 671 additions and 198 deletions
@ -0,0 +1,106 @@
|
||||
package com.ruoyi.web.controller.common; |
||||
|
||||
import java.util.List; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.PutMapping; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import com.ruoyi.common.annotation.Log; |
||||
import com.ruoyi.common.core.controller.BaseController; |
||||
import com.ruoyi.common.core.domain.AjaxResult; |
||||
import com.ruoyi.common.enums.BusinessType; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import com.ruoyi.system.service.IFileInfoService; |
||||
import com.ruoyi.common.utils.poi.ExcelUtil; |
||||
import com.ruoyi.common.core.page.TableDataInfo; |
||||
|
||||
/** |
||||
* 附件信息Controller |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/system/fileInfo") |
||||
public class FileInfoController extends BaseController |
||||
{ |
||||
@Autowired |
||||
private IFileInfoService fileInfoService; |
||||
|
||||
/** |
||||
* 查询附件信息列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:fileInfo:list')") |
||||
@GetMapping("/list") |
||||
public TableDataInfo list(FileInfo fileInfo) |
||||
{ |
||||
startPage(); |
||||
List<FileInfo> list = fileInfoService.list(new QueryWrapper<FileInfo>()); |
||||
return getDataTable(list); |
||||
} |
||||
|
||||
// /**
|
||||
// * 导出附件信息列表
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:fileInfo:export')")
|
||||
// @Log(title = "附件信息", businessType = BusinessType.EXPORT)
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, FileInfo fileInfo)
|
||||
// {
|
||||
// List<FileInfo> list = fileInfoService.selectFileInfoList(fileInfo);
|
||||
// ExcelUtil<FileInfo> util = new ExcelUtil<FileInfo>(FileInfo.class);
|
||||
// util.exportExcel(response, list, "附件信息数据");
|
||||
// }
|
||||
|
||||
/** |
||||
* 获取附件信息详细信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:fileInfo:query')") |
||||
@GetMapping(value = "/{id}") |
||||
public AjaxResult getInfo(@PathVariable("id") Long id) |
||||
{ |
||||
return success(fileInfoService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 新增附件信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:fileInfo:add')") |
||||
@Log(title = "附件信息", businessType = BusinessType.INSERT) |
||||
@PostMapping |
||||
public AjaxResult add(@RequestBody FileInfo fileInfo) |
||||
{ |
||||
return toAjax(fileInfoService.save(fileInfo)); |
||||
} |
||||
|
||||
/** |
||||
* 修改附件信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:fileInfo:edit')") |
||||
@Log(title = "附件信息", businessType = BusinessType.UPDATE) |
||||
@PutMapping |
||||
public AjaxResult edit(@RequestBody FileInfo fileInfo) |
||||
{ |
||||
return toAjax(fileInfoService.updateById(fileInfo)); |
||||
} |
||||
|
||||
/** |
||||
* 删除附件信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('system:fileInfo:remove')") |
||||
@Log(title = "附件信息", businessType = BusinessType.DELETE) |
||||
@DeleteMapping("/{ids}") |
||||
public AjaxResult remove(@PathVariable List<Long> ids) |
||||
{ |
||||
return toAjax(fileInfoService.removeByIds(ids)); |
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.ruoyi.web.controller.common; |
||||
|
||||
import com.ruoyi.common.utils.MinioUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.InputStream; |
||||
|
||||
@RestController |
||||
@RequestMapping("/minio") |
||||
public class MinioController { |
||||
|
||||
@Autowired |
||||
private MinioUtils minioUtils; |
||||
|
||||
/** |
||||
* 上传文件 |
||||
*/ |
||||
@PostMapping("/upload") |
||||
public String uploadFile(@RequestParam("file") MultipartFile file) { |
||||
String objectName = "uploads/" + System.currentTimeMillis() + "_" + file.getOriginalFilename(); |
||||
|
||||
try (InputStream inputStream = file.getInputStream()) { |
||||
minioUtils.uploadFile( objectName, inputStream, file.getSize(), file.getContentType()); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException("文件上传失败", e); |
||||
} |
||||
|
||||
return minioUtils.generateShortUrl(objectName); |
||||
} |
||||
|
||||
/** |
||||
* 下载文件 |
||||
*/ |
||||
@GetMapping("/download") |
||||
public ResponseEntity<byte[]> downloadFile(@RequestParam("fileName") String fileName) { |
||||
try { |
||||
InputStream inputStream = minioUtils.downloadFile(fileName); |
||||
return ResponseEntity.ok(inputStream.readAllBytes()); |
||||
} catch (Exception e) { |
||||
return ResponseEntity.badRequest().body(e.getMessage().getBytes()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取存储桶中的文件列表 |
||||
*/ |
||||
@GetMapping("/listBuckets") |
||||
public ResponseEntity<?> listBuckets() { |
||||
return ResponseEntity.ok(minioUtils.listBuckets()); |
||||
} |
||||
} |
@ -1,44 +0,0 @@
|
||||
package com.ruoyi.system.controller; |
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import com.ruoyi.system.service.IFileService; |
||||
import com.ruoyi.system.utils.FileUploadUtil; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Date; |
||||
|
||||
@RestController |
||||
@RequestMapping("/system/file") |
||||
public class FileInfoController { |
||||
|
||||
@Autowired |
||||
private FileUploadUtil fileUploadUtil; |
||||
|
||||
@Autowired |
||||
private IFileService fileService; |
||||
|
||||
/** |
||||
* 文件上传接口 |
||||
*/ |
||||
@PostMapping("/upload") |
||||
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException { |
||||
// 上传文件并获取访问 URL
|
||||
String fileUrl = fileUploadUtil.uploadFile(file); |
||||
return AjaxResult.success("文件上传成功", fileUrl); |
||||
} |
||||
|
||||
/** |
||||
* 保存文件信息接口 |
||||
*/ |
||||
@PostMapping("/save") |
||||
public AjaxResult saveFileRecord(@RequestBody FileInfo fileInfo) { |
||||
fileInfo.setCreateTime(new Date()); |
||||
fileService.saveFileRecord(fileInfo); |
||||
return AjaxResult.success("文件信息保存成功"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,87 @@
|
||||
package com.ruoyi.common.utils; |
||||
|
||||
import io.minio.*; |
||||
import io.minio.http.Method; |
||||
import io.minio.messages.Bucket; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.InputStream; |
||||
import java.util.List; |
||||
|
||||
@Component |
||||
public class MinioUtils { |
||||
|
||||
@Autowired |
||||
private MinioClient minioClient; |
||||
|
||||
@Value("${minio.bucketName}") |
||||
private String bucketName; |
||||
|
||||
@Value("${minio.endpoint}") |
||||
private String endpoint; |
||||
|
||||
/** |
||||
* 上传文件 |
||||
*/ |
||||
public void uploadFile(String objectName, InputStream fileInputStream, long size, String contentType) throws Exception { |
||||
minioClient.putObject( |
||||
PutObjectArgs.builder() |
||||
.bucket(bucketName) |
||||
.object(objectName) |
||||
.stream(fileInputStream, size, -1) |
||||
.contentType(contentType) |
||||
.build() |
||||
); |
||||
} |
||||
|
||||
public String generateShortUrl(String objectName) { |
||||
// 返回自定义短链接地址
|
||||
return endpoint + "/" +bucketName + "/" + objectName; |
||||
} |
||||
|
||||
public String generatePresignedUrl(String objectName) { |
||||
try { |
||||
return minioClient.getPresignedObjectUrl( |
||||
GetPresignedObjectUrlArgs.builder() |
||||
.bucket(bucketName) |
||||
.object(objectName) |
||||
.expiry(3600) // 有效期1小时
|
||||
.build() |
||||
); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException("Failed to generate presigned URL", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 下载文件 |
||||
*/ |
||||
public InputStream downloadFile(String objectName) { |
||||
try { |
||||
return minioClient.getObject( |
||||
GetObjectArgs.builder() |
||||
.bucket(bucketName) |
||||
.object(objectName) |
||||
.build() |
||||
); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException("文件下载失败:" + e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 列出存储桶中的所有文件 |
||||
*/ |
||||
public List<Bucket> listBuckets() { |
||||
try { |
||||
return minioClient.listBuckets(); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException("获取存储桶列表失败:" + e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,27 @@
|
||||
package com.ruoyi.framework.config; |
||||
|
||||
import io.minio.MinioClient; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MinioConfig { |
||||
|
||||
@Value("${minio.endpoint}") |
||||
private String endpoint; |
||||
|
||||
@Value("${minio.accessKey}") |
||||
private String accessKey; |
||||
|
||||
@Value("${minio.secretKey}") |
||||
private String secretKey; |
||||
|
||||
@Bean |
||||
public MinioClient minioClient() { |
||||
return MinioClient.builder() |
||||
.endpoint(endpoint) |
||||
.credentials(accessKey, secretKey) |
||||
.build(); |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.ruoyi.system.domain; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.ruoyi.common.annotation.Excel; |
||||
import com.ruoyi.common.core.domain.BaseEntity; |
||||
import lombok.Data; |
||||
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||
import org.apache.commons.lang3.builder.ToStringStyle; |
||||
|
||||
/** |
||||
* 用户审核日志对象 user_audit_log |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
@TableName("user_audit_log") |
||||
@Data |
||||
public class UserAuditLog extends BaseEntity |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** 主键 */ |
||||
@TableId(value = "id",type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** 用户id */ |
||||
@Excel(name = "用户id") |
||||
private Long userId; |
||||
|
||||
/** 驳回内容 */ |
||||
@Excel(name = "驳回内容") |
||||
private String content; |
||||
|
||||
/** 审批状态 */ |
||||
@Excel(name = "审批状态") |
||||
private String status; |
||||
|
||||
public void setId(Long id) |
||||
{ |
||||
this.id = id; |
||||
} |
||||
|
||||
public Long getId() |
||||
{ |
||||
return id; |
||||
} |
||||
public void setUserId(Long userId) |
||||
{ |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public Long getUserId() |
||||
{ |
||||
return userId; |
||||
} |
||||
public void setContent(String content) |
||||
{ |
||||
this.content = content; |
||||
} |
||||
|
||||
public String getContent() |
||||
{ |
||||
return content; |
||||
} |
||||
public void setStatus(String status) |
||||
{ |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getStatus() |
||||
{ |
||||
return status; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
||||
.append("id", getId()) |
||||
.append("userId", getUserId()) |
||||
.append("content", getContent()) |
||||
.append("status", getStatus()) |
||||
.append("createBy", getCreateBy()) |
||||
.append("createTime", getCreateTime()) |
||||
.append("updateBy", getUpdateBy()) |
||||
.append("updateTime", getUpdateTime()) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.mapper; |
||||
|
||||
import java.util.List; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
|
||||
/** |
||||
* 附件信息Mapper接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
public interface FileInfoMapper extends BaseMapper<FileInfo> { |
||||
} |
@ -1,9 +0,0 @@
|
||||
package com.ruoyi.system.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface FileMapper extends BaseMapper<FileInfo> { |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.mapper; |
||||
|
||||
import java.util.List; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.ruoyi.system.domain.UserAuditLog; |
||||
|
||||
/** |
||||
* 用户审核日志Mapper接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
public interface UserAuditLogMapper extends BaseMapper<UserAuditLog> { |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.service; |
||||
|
||||
import java.util.List; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* 附件信息Service接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
public interface IFileInfoService extends IService<FileInfo> { |
||||
} |
@ -1,7 +0,0 @@
|
||||
package com.ruoyi.system.service; |
||||
|
||||
import com.ruoyi.system.domain.FileInfo; |
||||
|
||||
public interface IFileService { |
||||
void saveFileRecord(FileInfo fileInfo); |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.service; |
||||
|
||||
import java.util.List; |
||||
import com.ruoyi.system.domain.UserAuditLog; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* 用户审核日志Service接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
public interface IUserAuditLogService extends IService<UserAuditLog> { |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.system.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import com.ruoyi.system.mapper.FileInfoMapper; |
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import com.ruoyi.system.service.IFileInfoService; |
||||
|
||||
/** |
||||
* 附件信息Service业务层处理 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
@Service |
||||
public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements IFileInfoService { |
||||
} |
@ -1,19 +0,0 @@
|
||||
package com.ruoyi.system.service.impl; |
||||
|
||||
import com.ruoyi.system.domain.FileInfo; |
||||
import com.ruoyi.system.mapper.FileMapper; |
||||
import com.ruoyi.system.service.IFileService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class FileServiceImpl implements IFileService { |
||||
|
||||
@Autowired |
||||
private FileMapper fileMapper; |
||||
|
||||
@Override |
||||
public void saveFileRecord(FileInfo fileInfo) { |
||||
fileMapper.insert(fileInfo); |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.ruoyi.system.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import com.ruoyi.system.mapper.UserAuditLogMapper; |
||||
import com.ruoyi.system.domain.UserAuditLog; |
||||
import com.ruoyi.system.service.IUserAuditLogService; |
||||
|
||||
/** |
||||
* 用户审核日志Service业务层处理 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2025-01-16 |
||||
*/ |
||||
@Service |
||||
public class UserAuditLogServiceImpl extends ServiceImpl<UserAuditLogMapper, UserAuditLog> implements IUserAuditLogService { |
||||
|
||||
} |
Loading…
Reference in new issue