From 2da4c045299aad5898dea78d7c9371491ce2c155 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期三, 11 六月 2025 09:50:50 +0800 Subject: [PATCH] 文件上传模块 --- main-business/src/main/java/com/ruoyi/business/controller/FileController.java | 21 + main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java | 64 +++++ main-business/src/main/java/com/ruoyi/business/entity/Archive.java | 45 +++ main-business/src/main/java/com/ruoyi/business/entity/Tree.java | 34 ++ main-business/src/main/java/com/ruoyi/business/service/impl/FileServiceImpl.java | 22 + main-business/src/main/resources/mapper/FileMapper.xml | 32 ++ main-business/src/main/java/com/ruoyi/business/mapper/TreeMapper.java | 18 + main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java | 24 ++ main-business/src/main/java/com/ruoyi/business/mapper/ArchiveMapper.java | 18 + main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java | 52 ++++ main-business/src/main/resources/mapper/TreeMapper.xml | 27 ++ main-business/src/main/java/com/ruoyi/business/mapper/FileMapper.java | 18 + main-business/src/main/java/com/ruoyi/business/service/FileService.java | 16 + main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java | 120 ++++++++++ main-business/src/main/java/com/ruoyi/business/controller/TreeController.java | 53 ++++ main-business/src/main/java/com/ruoyi/business/service/TreeService.java | 25 ++ main-business/src/main/java/com/ruoyi/business/entity/File.java | 59 ++++ main-business/src/main/resources/mapper/ArchiveMapper.xml | 28 ++ 18 files changed, 676 insertions(+), 0 deletions(-) diff --git a/main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java b/main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java new file mode 100644 index 0000000..6abe09d --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java @@ -0,0 +1,52 @@ +package com.ruoyi.business.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.business.dto.ArchiveDto; +import com.ruoyi.business.entity.Archive; +import com.ruoyi.business.service.ArchiveService; +import com.ruoyi.common.core.domain.R; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鍓嶇鎺у埗鍣� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ + +@RestController +@AllArgsConstructor +@RequestMapping("/archive") +public class ArchiveController { + + private ArchiveService archiveService; + + /** + * 鏌ヨ妗f淇℃伅琛� + */ + @GetMapping("/list") + public R<IPage<Archive>> treeList(Page page, ArchiveDto archiveDto) { + IPage<Archive> list = archiveService.selectArchiveList(page, archiveDto); + return R.ok(list); + } + + /** + * 妗f淇℃伅琛ㄦ柊澧炰慨鏀� + */ + @PostMapping("/addOrEditArchive") + public R addOrEditArchive(@RequestBody ArchiveDto archiveDto) { + return R.ok(archiveService.addOrEditArchive(archiveDto)); + } + + /** + * 妗f淇℃伅琛ㄥ垹闄� + */ + @DeleteMapping("/delArchive") + public R remove(@RequestBody Long[] ids) { + return R.ok(archiveService.delByIds(ids)); + } +} diff --git a/main-business/src/main/java/com/ruoyi/business/controller/FileController.java b/main-business/src/main/java/com/ruoyi/business/controller/FileController.java new file mode 100644 index 0000000..1282a8c --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/controller/FileController.java @@ -0,0 +1,21 @@ +package com.ruoyi.business.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import lombok.AllArgsConstructor; + import org.springframework.web.bind.annotation.RestController; + +/** +* <p> + * 涓婁紶鏂囦欢鐨勫熀鏈俊鎭� 鍓嶇鎺у埗鍣� + * </p> +* +* @author ruoyi +* @since 2025-06-10 +*/ + +@RestController +@AllArgsConstructor +@RequestMapping("/business/file") + public class FileController { + + } diff --git a/main-business/src/main/java/com/ruoyi/business/controller/TreeController.java b/main-business/src/main/java/com/ruoyi/business/controller/TreeController.java new file mode 100644 index 0000000..d19b853 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/controller/TreeController.java @@ -0,0 +1,53 @@ +package com.ruoyi.business.controller; + +import com.ruoyi.business.dto.TreeDto; +import com.ruoyi.business.service.TreeService; +import com.ruoyi.business.vo.TreeVo; +import com.ruoyi.common.core.domain.R; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鍓嶇鎺у埗鍣� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ + +@RestController +@AllArgsConstructor +@RequestMapping("/tree") +public class TreeController { + + private TreeService treeService; + + + /** + * 鏌ヨtree鍒楄〃 + */ + @GetMapping("/list") + public R<List<TreeVo>> treeList(TreeDto treeDto) { + return R.ok(treeService.selectTreeList(treeDto)); + } + + + /** + * tree鍒楄〃鏂板淇敼 + */ + @PostMapping("/addOrEditTree") + public R addOrEditTree(@RequestBody TreeDto treeDto) { + return R.ok(treeService.addOrEditProduction(treeDto)); + } + + /** + * tree鍒楄〃鍒犻櫎 + */ + @DeleteMapping("/delTree") + public R remove(@RequestBody Long[] ids) { + return R.ok(treeService.delByIds(ids)); + } +} diff --git a/main-business/src/main/java/com/ruoyi/business/entity/Archive.java b/main-business/src/main/java/com/ruoyi/business/entity/Archive.java new file mode 100644 index 0000000..d45f825 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/entity/Archive.java @@ -0,0 +1,45 @@ +package com.ruoyi.business.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import com.ruoyi.common.core.domain.MyBaseEntity; + +/** + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 瀹炰綋绫� + * + * @author ruoyi + * @date 2025-06-10 + */ +@Data +@TableName("archive") +public class Archive extends MyBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 涓婚敭ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 鍏宠仈tree ID + */ + @TableField(value = "tree_id") + private Long treeId; + /** + * 妗f鍚嶇О + */ + @TableField(value = "name") + private String name; + /** + * 妗f绫诲瀷锛屼緥濡傦細鍚堝悓銆佹姤鍛娿�佽瘉浠剁瓑 + */ + @TableField(value = "type") + private String type; + /** + * 妗f鐘舵�侊紝渚嬪锛氭湁鏁堛�佽繃鏈熴�佷綔搴� + */ + @TableField(value = "status") + private String status; +} \ No newline at end of file diff --git a/main-business/src/main/java/com/ruoyi/business/entity/File.java b/main-business/src/main/java/com/ruoyi/business/entity/File.java new file mode 100644 index 0000000..2e85ac4 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/entity/File.java @@ -0,0 +1,59 @@ +package com.ruoyi.business.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; + import com.ruoyi.common.core.domain.MyBaseEntity; + +/** +* 涓婁紶鏂囦欢鐨勫熀鏈俊鎭� 瀹炰綋绫� +* +* @author ruoyi +* @date 2025-06-10 +*/ +@Data +@TableName("file") +public class File extends MyBaseEntity { + +private static final long serialVersionUID = 1L; + + /** + * 涓婚敭ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + /** + * 鍏宠仈鐨勬。妗圛D锛屽閿紩鐢� archive.id + */ + @TableField(value = "archive_id") + private Long archiveId; + /** + * 鍘熷鏂囦欢鍚嶏紙鐢ㄦ埛涓婁紶鏃剁殑鍚嶇О锛� + */ + @TableField(value = "original_name") + private String originalName; + /** + * 棰勮鍦板潃 + */ + @TableField(value = "preview_url") + private String previewUrl; + /** + * 绯荤粺瀛樺偍鐨勫敮涓�鏂囦欢鍚� + */ + @TableField(value = "file_name") + private String fileName; + /** + * 鏂囦欢鍦ㄦ湇鍔″櫒涓婄殑瀛樺偍璺緞鎴栬闂甎RL + */ + @TableField(value = "file_path") + private String filePath; + /** + * 鏂囦欢MIME绫诲瀷锛屼緥濡� image/png銆乤pplication/pdf + */ + @TableField(value = "file_type") + private String fileType; + /** + * 鏂囦欢澶у皬锛屽崟浣嶄负瀛楄妭 + */ + @TableField(value = "file_size") + private String fileSize; +} \ No newline at end of file diff --git a/main-business/src/main/java/com/ruoyi/business/entity/Tree.java b/main-business/src/main/java/com/ruoyi/business/entity/Tree.java new file mode 100644 index 0000000..fe449f0 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/entity/Tree.java @@ -0,0 +1,34 @@ +package com.ruoyi.business.entity; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import com.ruoyi.common.core.domain.MyBaseEntity; + +/** + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 瀹炰綋绫� + * + * @author ruoyi + * @date 2025-06-10 + */ +@Data +@TableName("tree") +public class Tree extends MyBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 涓婚敭ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + /** + * + */ + @TableField(value = "name") + private String name; + /** + * + */ + @TableField(value = "parent_id") + private Long parentId; +} \ No newline at end of file diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/ArchiveMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/ArchiveMapper.java new file mode 100644 index 0000000..798ab1c --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/mapper/ArchiveMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.business.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.business.entity.Archive; +import org.apache.ibatis.annotations.Mapper; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 Mapper 鎺ュ彛 + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Mapper +public interface ArchiveMapper extends BaseMapper<Archive> { + +} diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/FileMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/FileMapper.java new file mode 100644 index 0000000..268c7d7 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/mapper/FileMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.business.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.business.entity.File; +import org.apache.ibatis.annotations.Mapper; + +/** + * <p> + * 涓婁紶鏂囦欢鐨勫熀鏈俊鎭� Mapper 鎺ュ彛 + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Mapper +public interface FileMapper extends BaseMapper<File> { + +} diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/TreeMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/TreeMapper.java new file mode 100644 index 0000000..ec9bc03 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/mapper/TreeMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.business.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.business.entity.Tree; +import org.apache.ibatis.annotations.Mapper; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 Mapper 鎺ュ彛 + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Mapper +public interface TreeMapper extends BaseMapper<Tree> { + +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java b/main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java new file mode 100644 index 0000000..69d79ef --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java @@ -0,0 +1,24 @@ +package com.ruoyi.business.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.business.dto.ArchiveDto; +import com.ruoyi.business.entity.Archive; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鏈嶅姟绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +public interface ArchiveService extends IService<Archive> { + + IPage<Archive> selectArchiveList(Page page, ArchiveDto archiveDto); + + int addOrEditArchive(ArchiveDto archiveDto); + + int delByIds(Long[] ids); +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/FileService.java b/main-business/src/main/java/com/ruoyi/business/service/FileService.java new file mode 100644 index 0000000..87a300f --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/FileService.java @@ -0,0 +1,16 @@ +package com.ruoyi.business.service; + +import com.ruoyi.business.entity.File; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * <p> + * 涓婁紶鏂囦欢鐨勫熀鏈俊鎭� 鏈嶅姟绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +public interface FileService extends IService<File> { + +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/TreeService.java b/main-business/src/main/java/com/ruoyi/business/service/TreeService.java new file mode 100644 index 0000000..ddcb26b --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/TreeService.java @@ -0,0 +1,25 @@ +package com.ruoyi.business.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.business.dto.TreeDto; +import com.ruoyi.business.entity.Tree; +import com.ruoyi.business.vo.TreeVo; + +import java.util.List; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鏈嶅姟绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +public interface TreeService extends IService<Tree> { + + List<TreeVo> selectTreeList(TreeDto treeDto); + + int addOrEditProduction(TreeDto treeDto); + + int delByIds(Long[] ids); +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java new file mode 100644 index 0000000..a00c56e --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java @@ -0,0 +1,64 @@ +package com.ruoyi.business.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.business.dto.ArchiveDto; +import com.ruoyi.business.entity.Archive; +import com.ruoyi.business.mapper.ArchiveMapper; +import com.ruoyi.business.service.ArchiveService; +import com.ruoyi.common.utils.bean.BeanUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鏈嶅姟瀹炵幇绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Service +@RequiredArgsConstructor +public class ArchiveServiceImpl extends ServiceImpl<ArchiveMapper, Archive> implements ArchiveService { + + private final ArchiveMapper archiveMapper; + + @Override + public IPage<Archive> selectArchiveList(Page page, ArchiveDto archiveDto) { + LambdaQueryWrapper<Archive> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByDesc(Archive::getCreateTime); + return archiveMapper.selectPage(page, queryWrapper); + } + + @Override + public int addOrEditArchive(ArchiveDto archiveDto) { + Archive archive = new Archive(); + BeanUtils.copyProperties(archiveDto, archive); + if (Objects.isNull(archiveDto.getId())) { + + return archiveMapper.insert(archive); + } else { + return archiveMapper.updateById(archive); + } + } + + @Override + public int delByIds(Long[] ids) { + // 妫�鏌ュ弬鏁� + if (ids == null || ids.length == 0) { + return 0; + } + // 鏋勯�犳洿鏂版潯浠� + UpdateWrapper<Archive> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", ids) + .set("deleted", 1); // 璁剧疆 deleted 涓� 1 琛ㄧず宸插垹闄� + // 鎵ц鎵归噺閫昏緫鍒犻櫎 + return archiveMapper.update(null, updateWrapper); + } +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/FileServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..8508288 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/FileServiceImpl.java @@ -0,0 +1,22 @@ +package com.ruoyi.business.service.impl; + +import com.ruoyi.business.entity.File; +import com.ruoyi.business.mapper.FileMapper; +import com.ruoyi.business.service.FileService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import lombok.RequiredArgsConstructor; + +/** + * <p> + * 涓婁紶鏂囦欢鐨勫熀鏈俊鎭� 鏈嶅姟瀹炵幇绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Service +@RequiredArgsConstructor +public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements FileService { + +} diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java new file mode 100644 index 0000000..c549d74 --- /dev/null +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java @@ -0,0 +1,120 @@ +package com.ruoyi.business.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.business.dto.TreeDto; +import com.ruoyi.business.entity.Tree; +import com.ruoyi.business.mapper.TreeMapper; +import com.ruoyi.business.service.TreeService; +import com.ruoyi.business.vo.TreeVo; +import com.ruoyi.common.utils.bean.BeanUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * 妗f淇℃伅琛紝璁板綍绯荤粺涓悇绫绘。妗堢殑鍩烘湰淇℃伅 鏈嶅姟瀹炵幇绫� + * </p> + * + * @author ruoyi + * @since 2025-06-10 + */ +@Service +@RequiredArgsConstructor +public class TreeServiceImpl extends ServiceImpl<TreeMapper, Tree> implements TreeService { + + private final TreeMapper treeMapper; + + @Override + public List<TreeVo> selectTreeList(TreeDto treeDto) { + // 鏌ヨ鏍硅妭鐐癸紙parentId 涓� null锛� + LambdaQueryWrapper<Tree> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.isNull(Tree::getParentId); + + // 濡傛灉鏈変骇鍝佸悕绉版潯浠讹紝娣诲姞鍒版煡璇腑 + if (treeDto.getName() != null && !treeDto.getName().isEmpty()) { + queryWrapper.like(Tree::getName, treeDto.getName()); + } + + // 鏌ヨ鏍硅妭鐐瑰垪琛� + List<Tree> rootTrees = treeMapper.selectList(queryWrapper); + + // 杞崲涓烘爲鑺傜偣骞堕�掑綊鏋勫缓瀛愭爲 + List<TreeVo> tree = new ArrayList<>(); + for (Tree tr : rootTrees) { + TreeVo node = convertToTreeDto(tr); + node.setChildren(buildChildrenNodes(tr.getId())); + tree.add(node); + } + return tree; + } + + private TreeVo convertToTreeDto(Tree tree) { + TreeVo dto = new TreeVo(); + BeanUtils.copyProperties(tree, dto); + dto.setLabel(tree.getName()); + dto.setChildren(new ArrayList<>()); + return dto; + } + + // 閫掑綊鏋勫缓瀛愯妭鐐� + private List<TreeVo> buildChildrenNodes(Long parentId) { + // 鏌ヨ褰撳墠鐖惰妭鐐圭殑瀛愯妭鐐� + LambdaQueryWrapper<Tree> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Tree::getParentId, parentId); + List<Tree> childProducts = treeMapper.selectList(queryWrapper); + + // 杞崲瀛愯妭鐐瑰苟閫掑綊鏋勫缓瀹冧滑鐨勫瓙鏍� + List<TreeVo> children = new ArrayList<>(); + for (Tree child : childProducts) { + TreeVo childNode = convertToTreeDto(child); + childNode.setChildren(buildChildrenNodes(child.getId())); + children.add(childNode); + } + + return children; + } + + @Override + public int addOrEditProduction(TreeDto treeDto) { + if (treeDto.getId() == null) { + // 鏂板tree閫昏緫 + if (treeDto.getParentId() == null) { + // 鑻ユ湭鎸囧畾鐖惰妭鐐癸紝榛樿涓烘牴鑺傜偣锛坧arentId 璁句负 null锛� + treeDto.setParentId(null); + } else { + // 妫�鏌ョ埗鑺傜偣鏄惁瀛樺湪锛堝彲閫夛紝鏍规嵁涓氬姟闇�姹傦級 + Tree parent = treeMapper.selectById(treeDto.getParentId()); + if (parent == null) { + throw new IllegalArgumentException("鐖惰妭鐐逛笉瀛樺湪锛屾棤娉曟坊鍔犲瓙tree"); + } + } + return treeMapper.insert(treeDto); + } else { + // 缂栬緫tree閫昏緫 + Tree existingProduct = treeMapper.selectById(treeDto.getId()); + if (existingProduct == null) { + throw new IllegalArgumentException("瑕佺紪杈戠殑tree涓嶅瓨鍦�"); + } + return treeMapper.updateById(treeDto); + } + } + + @Override + public int delByIds(Long[] ids) { + // 妫�鏌ュ弬鏁� + if (ids == null || ids.length == 0) { + return 0; + } + // 鏋勯�犳洿鏂版潯浠� + UpdateWrapper<Tree> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", ids) + .set("deleted", 1); // 璁剧疆 deleted 涓� 1 琛ㄧず宸插垹闄� + // 鎵ц鎵归噺閫昏緫鍒犻櫎 + return treeMapper.update(null, updateWrapper); + } +} diff --git a/main-business/src/main/resources/mapper/ArchiveMapper.xml b/main-business/src/main/resources/mapper/ArchiveMapper.xml new file mode 100644 index 0000000..9d8a046 --- /dev/null +++ b/main-business/src/main/resources/mapper/ArchiveMapper.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.business.mapper.ArchiveMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.Archive"> + <id column="id" property="id" /> + <result column="deleted" property="deleted" /> + <result column="create_by" property="createBy" /> + <result column="create_time" property="createTime" /> + <result column="update_by" property="updateBy" /> + <result column="update_time" property="updateTime" /> + <result column="name" property="name" /> + <result column="type" property="type" /> + <result column="status" property="status" /> + </resultMap> + + <!-- 閫氱敤鏌ヨ缁撴灉鍒� --> + <sql id="Base_Column_List"> + deleted, + create_by, + create_time, + update_by, + update_time, + id, name, type, status + </sql> + +</mapper> \ No newline at end of file diff --git a/main-business/src/main/resources/mapper/FileMapper.xml b/main-business/src/main/resources/mapper/FileMapper.xml new file mode 100644 index 0000000..f6cc606 --- /dev/null +++ b/main-business/src/main/resources/mapper/FileMapper.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.business.mapper.FileMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.File"> + <id column="id" property="id" /> + <result column="create_time" property="createTime" /> + <result column="update_time" property="updateTime" /> + <result column="create_by" property="createBy" /> + <result column="update_by" property="updateBy" /> + <result column="deleted" property="deleted" /> + <result column="archive_id" property="archiveId" /> + <result column="original_name" property="originalName" /> + <result column="preview_url" property="previewUrl" /> + <result column="file_name" property="fileName" /> + <result column="file_path" property="filePath" /> + <result column="file_type" property="fileType" /> + <result column="file_size" property="fileSize" /> + </resultMap> + + <!-- 閫氱敤鏌ヨ缁撴灉鍒� --> + <sql id="Base_Column_List"> + create_time, + update_time, + create_by, + update_by, + deleted, + id, archive_id, original_name, preview_url, file_name, file_path, file_type, file_size + </sql> + +</mapper> \ No newline at end of file diff --git a/main-business/src/main/resources/mapper/TreeMapper.xml b/main-business/src/main/resources/mapper/TreeMapper.xml new file mode 100644 index 0000000..d9c0ef1 --- /dev/null +++ b/main-business/src/main/resources/mapper/TreeMapper.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.business.mapper.TreeMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.Tree"> + <id column="id" property="id" /> + <result column="deleted" property="deleted" /> + <result column="create_by" property="createBy" /> + <result column="create_time" property="createTime" /> + <result column="update_by" property="updateBy" /> + <result column="update_time" property="updateTime" /> + <result column="name" property="name" /> + <result column="parent_id" property="parentId" /> + </resultMap> + + <!-- 閫氱敤鏌ヨ缁撴灉鍒� --> + <sql id="Base_Column_List"> + deleted, + create_by, + create_time, + update_by, + update_time, + id, name, parent_id + </sql> + +</mapper> \ No newline at end of file -- Gitblit v1.9.3