Преглед на файлове

Merge remote-tracking branch 'origin/sit-plantform' into sit-plantform

lyx преди 1 седмица
родител
ревизия
398aa2fe74

+ 66 - 0
alien-entity/src/main/java/shop/alien/entity/store/ProtocolManagement.java

@@ -0,0 +1,66 @@
+package shop.alien.entity.store;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 协议管理表
+ *
+ * @author alien
+ * @since 2025-12-09
+ */
+@Data
+@JsonInclude
+@EqualsAndHashCode(callSuper = false)
+@TableName("protocol_management")
+@ApiModel(value = "ProtocolManagement对象", description = "协议管理表")
+public class ProtocolManagement extends Model<ProtocolManagement> {
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "协议名称")
+    @TableField("protocol_file_name")
+    private String protocolFileName;
+
+    @ApiModelProperty(value = "展示位置")
+    @TableField("display_position")
+    private String displayPosition;
+
+    @ApiModelProperty(value = "协议文件存储路径")
+    @TableField("protocol_file_path")
+    private String protocolFilePath;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createdTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "创建人")
+    @TableField("created_user_id")
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "修改人")
+    @TableField("updated_user_id")
+    private Integer updatedUserId;
+
+    @ApiModelProperty(value = "删除标识, 0:未删除, 1:已删除")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+}
+

+ 15 - 0
alien-entity/src/main/java/shop/alien/mapper/ProtocolManagementMapper.java

@@ -0,0 +1,15 @@
+package shop.alien.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import shop.alien.entity.store.ProtocolManagement;
+
+/**
+ * 协议管理表 Mapper 接口
+ *
+ * @author alien
+ * @since 2025-12-09
+ */
+public interface ProtocolManagementMapper extends BaseMapper<ProtocolManagement> {
+
+}
+

+ 232 - 0
alien-store/src/main/java/shop/alien/store/controller/ProtocolManagementController.java

@@ -0,0 +1,232 @@
+package shop.alien.store.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartRequest;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.ProtocolManagement;
+import shop.alien.store.service.ProtocolManagementService;
+
+/**
+ * 协议管理表 前端控制器
+ *
+ * @author alien
+ * @since 2025-12-09
+ */
+@Slf4j
+@Api(tags = {"协议管理"})
+@ApiSort(100)
+@CrossOrigin
+@RestController
+@RequestMapping("/protocolManagement")
+@RequiredArgsConstructor
+public class ProtocolManagementController {
+
+    private final ProtocolManagementService protocolManagementService;
+
+    @ApiOperation("协议列表-分页查询")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "页容", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "protocolFileName", value = "协议名称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "displayPosition", value = "展示位置", dataType = "String", paramType = "query")
+    })
+    @GetMapping("/getPage")
+    public R<IPage<ProtocolManagement>> getPage(
+            @RequestParam("pageNum") Integer pageNum,
+            @RequestParam("pageSize") Integer pageSize,
+            @RequestParam(value = "protocolFileName", required = false) String protocolFileName,
+            @RequestParam(value = "displayPosition", required = false) String displayPosition) {
+        log.info("ProtocolManagementController.getPage?pageNum={}&pageSize={}&protocolFileName={}&displayPosition={}", 
+                pageNum, pageSize, protocolFileName, displayPosition);
+        
+        try {
+            IPage<ProtocolManagement> page = protocolManagementService.getProtocolPage(pageNum, pageSize, protocolFileName, displayPosition);
+            return R.data(page);
+        } catch (Exception e) {
+            log.error("查询协议列表失败", e);
+            return R.fail("查询失败: " + e.getMessage());
+        }
+    }
+
+    @ApiOperation("协议详情-根据ID查询")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "协议ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getById")
+    public R<ProtocolManagement> getById(@RequestParam("id") Integer id) {
+        log.info("ProtocolManagementController.getById?id={}", id);
+        
+        try {
+            ProtocolManagement protocol = protocolManagementService.getProtocolById(id);
+            return R.data(protocol);
+        } catch (IllegalArgumentException e) {
+            log.error("查询协议详情失败", e);
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("查询协议详情失败", e);
+            return R.fail("查询失败: " + e.getMessage());
+        }
+    }
+
+    @ApiOperation("新增协议")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "protocolFileName", value = "协议名称", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "displayPosition", value = "展示位置", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "protocolFilePath", value = "协议文件存储路径", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "createdUserId", value = "创建人ID", dataType = "Integer", paramType = "query")
+
+    })
+    @PostMapping("/add")
+    public R<Boolean> add(
+            @RequestParam("protocolFileName") String protocolFileName,
+            @RequestParam(value = "displayPosition") String displayPosition,
+            @RequestParam(value = "createdUserId", required = false) Integer createdUserId,
+            MultipartFile multipartFile) {
+        log.info("ProtocolManagementController.add?protocolFileName={}&displayPosition={}&createdUserId={}",
+                protocolFileName, displayPosition, createdUserId);
+        
+        try {
+            ProtocolManagement protocolManagement = new ProtocolManagement();
+            protocolManagement.setProtocolFileName(protocolFileName);
+            protocolManagement.setDisplayPosition(displayPosition);
+            
+            // 当createdUserId不为空时才设置值
+            if (createdUserId != null) {
+                protocolManagement.setCreatedUserId(createdUserId);
+            }
+            
+            boolean result = protocolManagementService.addProtocol(multipartFile, protocolManagement);
+            
+            if (result) {
+                return R.success("新增成功");
+            } else {
+                return R.fail("新增失败");
+            }
+        } catch (IllegalArgumentException e) {
+            log.error("新增协议失败", e);
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("新增协议失败", e);
+            return R.fail("新增失败: " + e.getMessage());
+        }
+    }
+
+    @ApiOperation("修改协议")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "协议ID", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "protocolFileName", value = "协议名称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "displayPosition", value = "展示位置", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "protocolFilePath", value = "协议文件存储路径", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "updatedUserId", value = "修改人ID", dataType = "Integer", paramType = "query")
+    })
+    @PostMapping("/update")
+    public R<Boolean> update(
+            @RequestParam("id") Integer id,
+            @RequestParam(value = "protocolFileName", required = false) String protocolFileName,
+            @RequestParam(value = "displayPosition", required = false) String displayPosition,
+            @RequestParam(value = "protocolFilePath", required = false) String protocolFilePath,
+            @RequestParam(value = "updatedUserId", required = false) Integer updatedUserId,
+            MultipartRequest multipartRequest) {
+        log.info("ProtocolManagementController.update?id={}&protocolFileName={}&displayPosition={}&protocolFilePath={}&updatedUserId={}", 
+                id, protocolFileName, displayPosition, protocolFilePath, updatedUserId);
+        
+        try {
+            ProtocolManagement protocolManagement = new ProtocolManagement();
+            protocolManagement.setId(id);
+            protocolManagement.setProtocolFileName(protocolFileName);
+            protocolManagement.setDisplayPosition(displayPosition);
+            protocolManagement.setProtocolFilePath(protocolFilePath);
+            protocolManagement.setUpdatedUserId(updatedUserId);
+            
+            boolean result = protocolManagementService.updateProtocol(multipartRequest, protocolManagement);
+            
+            if (result) {
+                return R.success("修改成功");
+            } else {
+                return R.fail("修改失败");
+            }
+        } catch (IllegalArgumentException e) {
+            log.error("修改协议失败", e);
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("修改协议失败", e);
+            return R.fail("修改失败: " + e.getMessage());
+        }
+    }
+
+    @ApiOperation("删除协议")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "协议ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @PostMapping("/delete")
+    public R<Boolean> delete(@RequestParam("id") Integer id) {
+        log.info("ProtocolManagementController.delete?id={}", id);
+        
+        try {
+            boolean result = protocolManagementService.deleteProtocol(id);
+            
+            if (result) {
+                return R.success("删除成功");
+            } else {
+                return R.fail("删除失败");
+            }
+        } catch (IllegalArgumentException e) {
+            log.error("删除协议失败", e);
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("删除协议失败", e);
+            return R.fail("删除失败: " + e.getMessage());
+        }
+    }
+
+//    @ApiOperation("批量删除协议")
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "ids", value = "协议ID列表(逗号分隔)", dataType = "String", paramType = "query", required = true, example = "1,2,3")
+//    })
+//    @PostMapping("/batchDelete")
+//    public R<Boolean> batchDelete(@RequestParam("ids") String ids) {
+//        log.info("ProtocolManagementController.batchDelete?ids={}", ids);
+//
+//        try {
+//            boolean result = protocolManagementService.batchDeleteProtocol(ids);
+//
+//            if (result) {
+//                return R.success("批量删除成功");
+//            } else {
+//                return R.fail("批量删除失败");
+//            }
+//        } catch (IllegalArgumentException e) {
+//            log.error("批量删除协议失败", e);
+//            return R.fail(e.getMessage());
+//        } catch (Exception e) {
+//            log.error("批量删除协议失败", e);
+//            return R.fail("批量删除失败: " + e.getMessage());
+//        }
+//    }
+
+    @ApiOperation("校验文件名是否重复")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "protocolFileName", value = "协议文件名", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/checkFileNameDuplicate")
+    public R<Boolean> checkFileNameDuplicate(@RequestParam("protocolFileName") String protocolFileName) {
+        log.info("ProtocolManagementController.checkFileNameDuplicate?protocolFileName={}", protocolFileName);
+
+        try {
+            Boolean result = protocolManagementService.checkFileNameDuplicate(protocolFileName);
+            return R.data(result);
+        } catch (IllegalArgumentException e) {
+            log.error("校验文件名失败", e);
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("校验文件名失败", e);
+            return R.fail("校验失败: " + e.getMessage());
+        }
+    }
+}
+

+ 76 - 0
alien-store/src/main/java/shop/alien/store/service/ProtocolManagementService.java

@@ -0,0 +1,76 @@
+package shop.alien.store.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartRequest;
+import shop.alien.entity.store.ProtocolManagement;
+
+/**
+ * 协议管理表 服务类
+ *
+ * @author alien
+ * @since 2025-12-09
+ */
+public interface ProtocolManagementService extends IService<ProtocolManagement> {
+
+    /**
+     * 分页查询协议列表
+     *
+     * @param pageNum          页数
+     * @param pageSize         页容
+     * @param protocolFileName 协议名称
+     * @param displayPosition  展示位置
+     * @return IPage<ProtocolManagement>
+     */
+    IPage<ProtocolManagement> getProtocolPage(Integer pageNum, Integer pageSize, String protocolFileName, String displayPosition);
+
+    /**
+     * 根据ID查询协议详情
+     *
+     * @param id 协议ID
+     * @return ProtocolManagement
+     */
+    ProtocolManagement getProtocolById(Integer id);
+
+    /**
+     * 新增协议
+     *
+     * @param protocolManagement 协议对象
+     * @return boolean
+     */
+    boolean addProtocol(MultipartFile multipartFile, ProtocolManagement protocolManagement);
+
+    /**
+     * 更新协议
+     *
+     * @param protocolManagement 协议对象
+     * @return boolean
+     */
+    boolean updateProtocol(MultipartRequest multipartRequest, ProtocolManagement protocolManagement);
+
+    /**
+     * 删除协议(逻辑删除)
+     *
+     * @param id 协议ID
+     * @return boolean
+     */
+    boolean deleteProtocol(Integer id);
+
+    /**
+     * 批量删除协议
+     *
+     * @param ids 协议ID列表
+     * @return boolean
+     */
+    boolean batchDeleteProtocol(String ids);
+
+    /**
+     * 校验文件名是否重复
+     *
+     * @param protocolFileName 协议文件名
+     * @return String "已重复" 或 "不重复"
+     */
+    Boolean checkFileNameDuplicate(String protocolFileName);
+}
+

+ 235 - 0
alien-store/src/main/java/shop/alien/store/service/impl/ProtocolManagementServiceImpl.java

@@ -0,0 +1,235 @@
+package shop.alien.store.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartRequest;
+import shop.alien.entity.store.ProtocolManagement;
+import shop.alien.mapper.ProtocolManagementMapper;
+import shop.alien.store.service.ProtocolManagementService;
+import shop.alien.store.util.FileUploadUtil;
+import shop.alien.util.common.RandomCreateUtil;
+import shop.alien.util.ali.AliOSSUtil;
+import shop.alien.util.file.FileUtil;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 协议管理表 服务实现类
+ *
+ * @author alien
+ * @since 2025-12-09
+ */
+@Slf4j
+@Service
+@Transactional
+@RequiredArgsConstructor
+public class ProtocolManagementServiceImpl extends ServiceImpl<ProtocolManagementMapper, ProtocolManagement> implements ProtocolManagementService {
+
+    private final ProtocolManagementMapper protocolManagementMapper;
+
+    private final FileUploadUtil fileUploadUtil;
+
+    private final AliOSSUtil aliOSSUtil;
+
+    @Override
+    public IPage<ProtocolManagement> getProtocolPage(Integer pageNum, Integer pageSize, String protocolFileName, String displayPosition) {
+        log.info("协议管理-分页查询, pageNum: {}, pageSize: {}, protocolFileName: {}, displayPosition: {}", 
+                pageNum, pageSize, protocolFileName, displayPosition);
+        
+        IPage<ProtocolManagement> page = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<ProtocolManagement> queryWrapper = new LambdaQueryWrapper<>();
+        
+        // 协议名称模糊查询
+        if (StringUtils.isNotBlank(protocolFileName)) {
+            queryWrapper.like(ProtocolManagement::getProtocolFileName, protocolFileName);
+        }
+        
+        // 展示位置模糊查询
+        if (StringUtils.isNotBlank(displayPosition)) {
+            queryWrapper.like(ProtocolManagement::getDisplayPosition, displayPosition);
+        }
+        
+        // 按创建时间倒序排列
+        queryWrapper.orderByDesc(ProtocolManagement::getCreatedTime);
+        
+        return protocolManagementMapper.selectPage(page, queryWrapper);
+    }
+
+    @Override
+    public ProtocolManagement getProtocolById(Integer id) {
+        log.info("协议管理-查询详情, id: {}", id);
+        
+        if (id == null) {
+            throw new IllegalArgumentException("协议ID不能为空");
+        }
+        
+        ProtocolManagement protocol = protocolManagementMapper.selectById(id);
+        
+        if (protocol == null) {
+            throw new IllegalArgumentException("协议不存在");
+        }
+        
+        return protocol;
+    }
+
+    @Override
+    public boolean addProtocol(MultipartFile multipartFile, ProtocolManagement protocolManagement) {
+        log.info("协议管理-新增, 请求参数: {}", protocolManagement);
+
+        // 参数校验
+        if (StringUtils.isBlank(protocolManagement.getProtocolFileName())) {
+            throw new IllegalArgumentException("协议名称不能为空");
+        }
+        String prefix;
+        prefix = "privacy/";
+        Map<String, String> fileNameAndType = FileUtil.getFileNameAndType(multipartFile);
+
+        String s = aliOSSUtil.uploadFile(multipartFile, prefix + fileNameAndType.get("name") + RandomCreateUtil.getRandomNum(6) + "." + fileNameAndType.get("type"));
+        // 上传文件
+        protocolManagement.setProtocolFilePath(s);
+
+        // 根据 type(displayPosition) 和名称(protocolFileName) 查询是否存在
+        LambdaQueryWrapper<ProtocolManagement> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(ProtocolManagement::getProtocolFileName, protocolManagement.getProtocolFileName());
+        if (StringUtils.isNotBlank(protocolManagement.getDisplayPosition())) {
+            queryWrapper.eq(ProtocolManagement::getDisplayPosition, protocolManagement.getDisplayPosition());
+        } else {
+            queryWrapper.isNull(ProtocolManagement::getDisplayPosition);
+        }
+        
+        ProtocolManagement existProtocol = protocolManagementMapper.selectOne(queryWrapper);
+        
+        int result;
+        if (existProtocol != null) {
+            // 如果存在,则覆盖(更新)
+            log.info("协议管理-发现已存在记录,执行更新操作, id: {}", existProtocol.getId());
+            protocolManagement.setId(existProtocol.getId());
+            result = protocolManagementMapper.updateById(protocolManagement);
+            log.info("协议管理-更新, 结果: {}", result > 0 ? "成功" : "失败");
+        } else {
+            // 如果不存在,则新增
+            result = protocolManagementMapper.insert(protocolManagement);
+            log.info("协议管理-新增, 结果: {}", result > 0 ? "成功" : "失败");
+        }
+
+        return result > 0;
+    }
+
+    @Override
+    public boolean updateProtocol(MultipartRequest multipartRequest, ProtocolManagement protocolManagement) {
+        log.info("协议管理-修改, 请求参数: {}", protocolManagement);
+        
+        // 参数校验
+        if (protocolManagement.getId() == null) {
+            throw new IllegalArgumentException("协议ID不能为空");
+        }
+        
+        // 检查协议是否存在
+        ProtocolManagement existProtocol = protocolManagementMapper.selectById(protocolManagement.getId());
+        if (existProtocol == null) {
+            throw new IllegalArgumentException("协议不存在");
+        }
+        
+        // 如果修改了协议名称,检查新名称是否与其他协议重复
+        if (StringUtils.isNotBlank(protocolManagement.getProtocolFileName()) 
+                && !protocolManagement.getProtocolFileName().equals(existProtocol.getProtocolFileName())) {
+            LambdaQueryWrapper<ProtocolManagement> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(ProtocolManagement::getProtocolFileName, protocolManagement.getProtocolFileName());
+            queryWrapper.ne(ProtocolManagement::getId, protocolManagement.getId());
+            Integer count = protocolManagementMapper.selectCount(queryWrapper);
+            
+            if (count > 0) {
+                throw new IllegalArgumentException("协议名称已存在");
+            }
+        }
+
+        protocolManagement.setProtocolFilePath(fileUploadUtil.uploadMoreFile(multipartRequest).get(0));
+        
+        int result = protocolManagementMapper.updateById(protocolManagement);
+        log.info("协议管理-修改, 结果: {}", result > 0 ? "成功" : "失败");
+        
+        return result > 0;
+    }
+
+    @Override
+    public boolean deleteProtocol(Integer id) {
+        log.info("协议管理-删除, id: {}", id);
+        
+        if (id == null) {
+            throw new IllegalArgumentException("协议ID不能为空");
+        }
+        
+        // 检查协议是否存在
+        ProtocolManagement protocol = protocolManagementMapper.selectById(id);
+        if (protocol == null) {
+            throw new IllegalArgumentException("协议不存在");
+        }
+        protocol.setDeleteFlag(1);
+        
+        // 逻辑删除
+        int result = protocolManagementMapper.updateById(protocol);
+        log.info("协议管理-删除, 结果: {}", result > 0 ? "成功" : "失败");
+        
+        return result > 0;
+    }
+
+    @Override
+    public boolean batchDeleteProtocol(String ids) {
+        log.info("协议管理-批量删除, ids: {}", ids);
+        
+        if (StringUtils.isBlank(ids)) {
+            throw new IllegalArgumentException("协议ID不能为空");
+        }
+        
+        // 将ID字符串转换为列表
+        List<Integer> idList = Arrays.stream(ids.split(","))
+                .map(String::trim)
+                .filter(StringUtils::isNotBlank)
+                .map(Integer::parseInt)
+                .collect(Collectors.toList());
+        
+        if (idList.isEmpty()) {
+            throw new IllegalArgumentException("协议ID不能为空");
+        }
+        
+        // 批量逻辑删除
+        int result = protocolManagementMapper.deleteBatchIds(idList);
+        log.info("协议管理-批量删除, 删除数量: {}", result);
+        
+        return result > 0;
+    }
+
+    @Override
+    public Boolean checkFileNameDuplicate(String protocolFileName) {
+        log.info("协议管理-校验文件名是否重复, protocolFileName: {}", protocolFileName);
+
+        if (StringUtils.isBlank(protocolFileName)) {
+            throw new IllegalArgumentException("协议文件名不能为空");
+        }
+
+        // 查询数据库中是否存在同名文件
+        LambdaQueryWrapper<ProtocolManagement> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(ProtocolManagement::getProtocolFileName, protocolFileName);
+        Integer count = protocolManagementMapper.selectCount(queryWrapper);
+
+        if (count > 0) {
+            log.info("协议管理-校验文件名, 结果: 已重复");
+            return true;
+        } else {
+            log.info("协议管理-校验文件名, 结果: 不重复");
+            return false;
+        }
+    }
+}
+