浏览代码

图稿库

24282 1 年之前
父节点
当前提交
8a1dad6cff

+ 71 - 0
sd-business/src/main/java/com/sd/business/controller/artwork/ArtworkLibraryController.java

@@ -0,0 +1,71 @@
+package com.sd.business.controller.artwork;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.sd.business.service.artwork.ArtworkLibraryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * 图稿库 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@RestController
+@RequestMapping("/artworkLibrary")
+public class ArtworkLibraryController {
+
+    @Autowired
+    private ArtworkLibraryService artworkLibraryService;
+
+    /**
+     * 图稿库分页
+     */
+    @PostMapping("/page")
+    public Page<ArtworkLibraryVo> page(@RequestBody ArtworkLibrarySelectDto dto) {
+        return artworkLibraryService.getPage(dto);
+    }
+
+    /**
+     * 图稿库明细
+     */
+    @PostMapping("/detail")
+    public ArtworkLibraryVo detail(@RequestBody BaseSelectDto dto) {
+        return artworkLibraryService.detail(dto.getId());
+    }
+
+    /**
+     * 图稿库新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody ArtworkLibraryDto dto) {
+        artworkLibraryService.add(dto);
+    }
+
+    /**
+     * 图稿库编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody ArtworkLibraryDto dto) {
+        artworkLibraryService.edit(dto);
+    }
+
+    /**
+     * 图稿库删除
+     */
+    @PostMapping("/delete")
+    public void delete(@RequestBody BaseSelectDto dto) {
+        artworkLibraryService.delete(dto.getId());
+    }
+
+}

+ 17 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/dto/ArtworkLibraryDto.java

@@ -0,0 +1,17 @@
+package com.sd.business.entity.artwork.dto;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库新增编辑入参实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class ArtworkLibraryDto extends ArtworkLibrary {
+
+}

+ 22 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/dto/ArtworkLibrarySelectDto.java

@@ -0,0 +1,22 @@
+package com.sd.business.entity.artwork.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库列表查询入参实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class ArtworkLibrarySelectDto extends BaseSelectDto {
+
+    /**
+     * 图稿名称
+     */
+    private String artworkName;
+
+}

+ 56 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/po/ArtworkLibrary.java

@@ -0,0 +1,56 @@
+package com.sd.business.entity.artwork.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 图稿库
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+@TableName("artwork_library")
+public class ArtworkLibrary extends BasePo {
+
+    /**
+     * 名称
+     */
+    private String artworkName;
+
+    /**
+     * 图片id
+     */
+    private Long imgId;
+
+    /**
+     * 图片名称
+     */
+    private String imgName;
+
+    /**
+     * 图片链接
+     */
+    private String imgUrl;
+
+    /**
+     * 文件id
+     */
+    private Long fileId;
+
+    /**
+     * 文件名称
+     */
+    private String fileName;
+
+    /**
+     * 文件链接
+     */
+    private String fileUrl;
+
+}

+ 17 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/vo/ArtworkLibraryVo.java

@@ -0,0 +1,17 @@
+package com.sd.business.entity.artwork.vo;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库列表查询返回值实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class ArtworkLibraryVo extends ArtworkLibrary {
+
+}

+ 16 - 0
sd-business/src/main/java/com/sd/business/mapper/artwork/ArtworkLibraryMapper.java

@@ -0,0 +1,16 @@
+package com.sd.business.mapper.artwork;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+
+/**
+ * <p>
+ * 图稿库 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+public interface ArtworkLibraryMapper extends BaseMapper<ArtworkLibrary> {
+
+}

+ 46 - 0
sd-business/src/main/java/com/sd/business/service/artwork/ArtworkLibraryService.java

@@ -0,0 +1,46 @@
+package com.sd.business.service.artwork;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.service.BaseService;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+
+
+/**
+ * <p>
+ * 图稿库 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+public interface ArtworkLibraryService extends BaseService<ArtworkLibrary> {
+
+    /**
+     * 图稿库分页
+     */
+    Page<ArtworkLibraryVo> getPage(ArtworkLibrarySelectDto dto);
+
+    /**
+     * 图稿库明细
+     */
+    ArtworkLibraryVo detail(Long id);
+
+    /**
+     * 图稿库新增
+     */
+    void add(ArtworkLibraryDto dto);
+
+    /**
+     * 图稿库编辑
+     */
+    void edit(ArtworkLibraryDto dto);
+
+    /**
+     * 图稿库删除
+     */
+    void delete(Long id);
+
+}

+ 106 - 0
sd-business/src/main/java/com/sd/business/service/artwork/impl/ArtworkLibraryServiceImpl.java

@@ -0,0 +1,106 @@
+package com.sd.business.service.artwork.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.file.entity.ObsFile;
+import com.fjhx.file.utils.ObsFileUtil;
+import com.ruoyi.common.core.domain.BaseIdPo;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.sd.business.mapper.artwork.ArtworkLibraryMapper;
+import com.sd.business.service.artwork.ArtworkLibraryService;
+import com.sd.framework.util.Assert;
+import com.sd.framework.util.sql.Sql;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+
+
+/**
+ * <p>
+ * 图稿库 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Service
+public class ArtworkLibraryServiceImpl extends ServiceImpl<ArtworkLibraryMapper, ArtworkLibrary> implements ArtworkLibraryService {
+
+    @Override
+    public Page<ArtworkLibraryVo> getPage(ArtworkLibrarySelectDto dto) {
+
+        Page<ArtworkLibraryVo> page = Sql.create(ArtworkLibraryVo.class)
+                .selectAll(ArtworkLibrary.class)
+                .from(ArtworkLibrary.class)
+                .like(ArtworkLibrary::getArtworkName, dto.getArtworkName())
+                .orderByDesc(ArtworkLibrary::getId)
+                .page(dto.getPage());
+
+        return page;
+    }
+
+    @Override
+    public ArtworkLibraryVo detail(Long id) {
+
+        ArtworkLibraryVo vo = Sql.create(ArtworkLibraryVo.class)
+                .selectAll(ArtworkLibrary.class)
+                .from(ArtworkLibrary.class)
+                .eq(ArtworkLibrary::getId, id)
+                .one();
+
+        Assert.notNull(vo, "未知图稿");
+
+        return vo;
+    }
+
+    @Override
+    public void add(ArtworkLibraryDto dto) {
+        // 判断图稿名称是否存在
+        long count = count(q -> q
+                .eq(ArtworkLibrary::getArtworkName, dto.getArtworkName())
+                .last("limit 1"));
+        Assert.eqZero(count, "图稿名称已存在");
+
+        save(dto);
+
+        ObsFile imgFile = new ObsFile();
+        imgFile.setId(dto.getImgId());
+
+        ObsFile fileFile = new ObsFile();
+        fileFile.setId(dto.getFileId());
+
+        ObsFileUtil.saveFile(Collections.singletonList(imgFile), dto.getId(), 1);
+        ObsFileUtil.saveFile(Collections.singletonList(fileFile), dto.getId(), 2);
+    }
+
+    @Override
+    public void edit(ArtworkLibraryDto dto) {
+        // 判断修改的稿名是否已经存在
+        long count = count(q -> q
+                .eq(ArtworkLibrary::getArtworkName, dto.getArtworkName())
+                .ne(BaseIdPo::getId, dto.getId())
+                .last("limit 1"));
+        Assert.eqZero(count, "图稿名称已存在");
+
+        updateById(dto);
+
+        ObsFile imgFile = new ObsFile();
+        imgFile.setId(dto.getImgId());
+
+        ObsFile fileFile = new ObsFile();
+        fileFile.setId(dto.getFileId());
+
+        ObsFileUtil.editFile(Collections.singletonList(imgFile), dto.getId(), 1);
+        ObsFileUtil.editFile(Collections.singletonList(fileFile), dto.getId(), 2);
+    }
+
+    @Override
+    public void delete(Long id) {
+        removeById(id);
+        ObsFileUtil.removeFile(id);
+    }
+
+}

+ 5 - 0
sd-business/src/main/resources/mapper/artwork/ArtworkLibraryMapper.xml

@@ -0,0 +1,5 @@
+<?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.sd.business.mapper.artwork.ArtworkLibraryMapper">
+
+</mapper>