feat: 添加通用附件管理功能,包括实体、服务、控制器及相关模板
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.controller;
|
||||
|
||||
import cn.meowrain.aioj.backend.fileservice.dao.entity.AttachmentDO;
|
||||
import cn.meowrain.aioj.backend.fileservice.service.AttachmentService;
|
||||
import cn.meowrain.aioj.backend.framework.core.web.Result;
|
||||
import cn.meowrain.aioj.backend.framework.core.web.Results;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用附件表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author meowrain
|
||||
* @since 2026-01-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/attachment")
|
||||
@RequiredArgsConstructor
|
||||
public class AttachmentController {
|
||||
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
/**
|
||||
* 分页查询通用附件表列表
|
||||
*/
|
||||
@Operation(summary = "分页查询通用附件表列表")
|
||||
@GetMapping("/page")
|
||||
public Result<Page<AttachmentDO>> page(
|
||||
@Parameter(description = "当前页码") @RequestParam(defaultValue = "1") Integer current,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "10") Integer size) {
|
||||
Page<AttachmentDO> page = new Page<>(current, size);
|
||||
return Results.success(attachmentService.page(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有通用附件表列表
|
||||
*/
|
||||
@Operation(summary = "查询所有通用附件表列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<AttachmentDO>> list() {
|
||||
return Results.success(attachmentService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询通用附件表详情
|
||||
*/
|
||||
@Operation(summary = "根据ID查询通用附件表详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<AttachmentDO> getById(
|
||||
@Parameter(description = "通用附件表ID") @PathVariable Long id) {
|
||||
return Results.success(attachmentService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增通用附件表
|
||||
*/
|
||||
@Operation(summary = "新增通用附件表")
|
||||
@PostMapping
|
||||
public Result<Boolean> save(@RequestBody AttachmentDO entity) {
|
||||
return Results.success(attachmentService.save(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通用附件表
|
||||
*/
|
||||
@Operation(summary = "修改通用附件表")
|
||||
@PutMapping
|
||||
public Result<Boolean> update(@RequestBody AttachmentDO entity) {
|
||||
return Results.success(attachmentService.updateById(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通用附件表
|
||||
*/
|
||||
@Operation(summary = "删除通用附件表")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> delete(
|
||||
@Parameter(description = "通用附件表ID") @PathVariable Long id) {
|
||||
return Results.success(attachmentService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除通用附件表
|
||||
*/
|
||||
@Operation(summary = "批量删除通用附件表")
|
||||
@DeleteMapping("/batch")
|
||||
public Result<Boolean> deleteBatch(@RequestBody List<Long> ids) {
|
||||
return Results.success(attachmentService.removeByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AttachmentDAO {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用附件表
|
||||
* </p>
|
||||
*
|
||||
* @author meowrain
|
||||
* @since 2026-01-10
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@TableName("attachment")
|
||||
public class AttachmentDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 原始文件名
|
||||
*/
|
||||
@TableField("file_name")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件后缀名
|
||||
*/
|
||||
@TableField("file_extension")
|
||||
private String fileExtension;
|
||||
|
||||
/**
|
||||
* 文件大小(Byte)
|
||||
*/
|
||||
@TableField("file_size")
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 文件哈希(MD5/SHA256)用于去重
|
||||
*/
|
||||
@TableField("file_hash")
|
||||
private String fileHash;
|
||||
|
||||
/**
|
||||
* MIME类型
|
||||
*/
|
||||
@TableField("mime_type")
|
||||
private String mimeType;
|
||||
|
||||
/**
|
||||
* 存储方案: LOCAL, OSS, S3, MINIO
|
||||
*/
|
||||
@TableField("storage_type")
|
||||
private String storageType;
|
||||
|
||||
/**
|
||||
* 物理存储路径或对象存储Key
|
||||
*/
|
||||
@TableField("storage_path")
|
||||
private String storagePath;
|
||||
|
||||
/**
|
||||
* 所属业务模块
|
||||
*/
|
||||
@TableField("business_type")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 所属业务id
|
||||
*/
|
||||
@TableField("business_id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 上传者ID
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 图片宽高、EXIF等元数据
|
||||
*/
|
||||
@TableField("image_info")
|
||||
private String imageInfo;
|
||||
|
||||
/**
|
||||
* 逻辑删除(0-正常, 1-已删除)
|
||||
*/
|
||||
@TableField("is_deleted")
|
||||
private Byte isDeleted;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.dao.mapper;
|
||||
|
||||
import cn.meowrain.aioj.backend.fileservice.dao.entity.AttachmentDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用附件表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author meowrain
|
||||
* @since 2026-01-10
|
||||
*/
|
||||
public interface AttachmentMapper extends BaseMapper<AttachmentDO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.service;
|
||||
|
||||
import cn.meowrain.aioj.backend.fileservice.dao.entity.AttachmentDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用附件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author meowrain
|
||||
* @since 2026-01-10
|
||||
*/
|
||||
public interface AttachmentService extends IService<AttachmentDO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.meowrain.aioj.backend.fileservice.service.impl;
|
||||
|
||||
import cn.meowrain.aioj.backend.fileservice.dao.entity.AttachmentDO;
|
||||
import cn.meowrain.aioj.backend.fileservice.dao.mapper.AttachmentMapper;
|
||||
import cn.meowrain.aioj.backend.fileservice.service.AttachmentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用附件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author meowrain
|
||||
* @since 2026-01-10
|
||||
*/
|
||||
@Service
|
||||
public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, AttachmentDO> implements AttachmentService {
|
||||
|
||||
}
|
||||
@@ -1,20 +1,4 @@
|
||||
spring:
|
||||
mail:
|
||||
host: smtp.qq.com
|
||||
port: 465
|
||||
username: 2705356115@qq.com
|
||||
# 这里使用授权码
|
||||
password: yohcndfrlxwcdfed
|
||||
default-encoding: UTF-8
|
||||
protocol: smtp
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
ssl:
|
||||
enable: true # 在 properties 中明确指定
|
||||
auth: true
|
||||
starttls:
|
||||
enable: true # QQ邮箱也支持STARTTLS,但使用465端口时,ssl.enable=true是必须的
|
||||
data:
|
||||
redis:
|
||||
host: 10.0.0.10
|
||||
|
||||
Reference in New Issue
Block a user