From 7b99089c67b3195e7b58df1612cd2ba2b3e6f727 Mon Sep 17 00:00:00 2001 From: Diyu0904 <1819728964@qq.com> Date: Fri, 7 Feb 2025 13:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20=E6=96=87=E4=BB=B6=E5=8A=A0=E5=AF=86/?= =?UTF-8?q?=E8=A7=A3=E5=AF=86=20=E6=96=87=E4=BB=B6=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/FileEncryptDecryptUtil.java | 34 +++- .../mcwl/web/controller/resource/Test.java | 180 ++++++++++++++++++ .../resource/WorkFlowController.java | 8 +- mcwl-common/pom.xml | 7 + .../mcwl/common/constant/DictConstants.java | 5 + .../com/mcwl/resource/domain/WorkFlow.java | 33 +--- .../domain/dto/AddRequestWorkFlow.java | 34 ++++ .../mcwl/resource/domain/dto/AddWorkFlow.java | 179 +++++++++++++++++ .../domain/dto/AddWorkFlowVersion.java | 92 +++++++++ .../resource/service/WorkFlowService.java | 3 +- .../service/impl/WorkFlowServiceImpl.java | 45 +---- 11 files changed, 553 insertions(+), 67 deletions(-) create mode 100644 mcwl-admin/src/main/java/com/mcwl/web/controller/resource/Test.java create mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddRequestWorkFlow.java create mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlow.java create mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileEncryptDecryptUtil.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileEncryptDecryptUtil.java index e4ca01f..5e7c393 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileEncryptDecryptUtil.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileEncryptDecryptUtil.java @@ -1,17 +1,22 @@ package com.mcwl.web.controller.resource; +import com.mcwl.web.controller.common.OssUtil; +import org.springframework.mock.web.MockMultipartFile; + import javax.crypto.Cipher; import javax.crypto.CipherInputStream; import javax.crypto.CipherOutputStream; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.security.AlgorithmParameters; import java.util.Base64; /** + * 加解密文件工具类 * @author DaiZibo * @date 2025/1/25 * @apiNote @@ -27,8 +32,10 @@ public class FileEncryptDecryptUtil { public static void main(String[] args) throws Exception { // 示例:加密文件 encryptFile("D:\\ASE\\encryption\\测试文件1.txt", "D:\\ASE\\decode\\加密测试文件1.txt"); -// 解密文件 -// decryptFile("D:\\Temp\\test\\test\\caaaa", "D:\\Temp\\test\\test\\日报.xlsx"); +//// 解密文件 + decryptFile("C:\\Users\\Dzb\\Desktop\\a.enc", "D:\\\\ASE\\\\encryption\\\\解密测试文件2.txt"); + uploadEncryptedFileToOSS("D:\\ASE\\encryption\\测试文件1.txt", "encrypted-test-file1.enc"); + } public static void encryptFile(String sourcePath, String encryptedPath) throws Exception { @@ -72,4 +79,27 @@ public class FileEncryptDecryptUtil { } return cipher; } + + + public static void uploadEncryptedFileToOSS(String sourcePath, String ossFileName) throws Exception { + Cipher cipher = initCipher(Cipher.ENCRYPT_MODE); + + // 使用ByteArrayOutputStream代替FileOutputStream + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try (FileInputStream fis = new FileInputStream(sourcePath); + CipherInputStream cis = new CipherInputStream(fis, cipher)) { + byte[] buffer = new byte[1024]; + int read; + while ((read = cis.read(buffer)) != -1) { + bos.write(buffer, 0, read); + } + } + System.out.println("加密完成"); + + // 将加密后的字节数组转换为MultipartFile + MockMultipartFile multipartFile = new MockMultipartFile(ossFileName, ossFileName, "application/octet-stream", bos.toByteArray()); + // 调用上传方法 + String s = OssUtil.uploadMultipartFile(multipartFile); + System.out.println("文件已上传至: " + s); + } } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/Test.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/Test.java new file mode 100644 index 0000000..d083da4 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/Test.java @@ -0,0 +1,180 @@ +package com.mcwl.web.controller.resource; + +import com.mcwl.web.controller.common.OssUtil; +import org.springframework.mock.web.MockMultipartFile; + +import javax.crypto.Cipher; +import javax.crypto.CipherInputStream; +import javax.crypto.CipherOutputStream; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.security.AlgorithmParameters; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; + +/** + * @author DaiZibo + * @date 2025/2/5 + * @apiNote + */ + +public class Test { + + + private static final String ALGORITHM = "AES/CBC/PKCS5Padding"; + private static final String TRANSFORMATION = "AES"; + private static final String KEY = "iamkeyeeddzasdfs"; + private static byte[] SAVED_IV; // 静态变量存储IV,确保解密时可访问 +// iv=gHauCGwTlX/mgXrvTUCifQ==, key=aWFta2V5ZWVkZHphc2Rmcw== + + public static void main(String[] args) throws Exception { + // 示例:加密文件并获取密钥 + // Map stringStringMap = encryptFile("D:\\ASE\\encryption\\测试文件1.txt", "D:\\ASE\\decode\\加密测试文件1.txt"); +// System.out.println("-------------------"+keyBase64); +// System.out.println("Encryption Key: " + keyBase64); +// +// // 使用上面得到的密钥解密文件 + decryptFile("C:\\Users\\Dzb\\Desktop\\a.enc", "D:\\ASE\\encryption\\解密测试文件3.txt","aWFta2V5ZWVkZHphc2Rmcw==","gHauCGwTlX/mgXrvTUCifQ=="); + +// Map stringStringMap = uploadEncryptedFileToOSS("D:\\ASE\\encryption\\测试文件1.txt", "encrypted-test-file1.enc"); +// System.out.println("-------------"+stringStringMap); + + } + + public static Map encryptFile(String sourcePath, String encryptedPath) throws Exception { + Cipher cipher = initCipher(Cipher.ENCRYPT_MODE); + try (FileInputStream fis = new FileInputStream(sourcePath); + FileOutputStream fos = new FileOutputStream(encryptedPath); + CipherOutputStream cos = new CipherOutputStream(fos, cipher)) { + byte[] buffer = new byte[1024]; + int read; + while ((read = fis.read(buffer)) != -1) { + cos.write(buffer, 0, read); + } + } + System.out.println("加密完成"); + + SecretKey secretKey = new SecretKeySpec(KEY.getBytes(), TRANSFORMATION); + Map result = new HashMap<>(); + result.put("key", Base64.getEncoder().encodeToString(secretKey.getEncoded())); + result.put("iv", Base64.getEncoder().encodeToString(SAVED_IV)); + return result; + } + +// public static void decryptFile(String encryptedPath, String decryptedPath, String keyBase64) throws Exception { +// byte[] keyBytes = Base64.getDecoder().decode(keyBase64); +// SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, TRANSFORMATION); +// Cipher cipher = initCipher(Cipher.DECRYPT_MODE, secretKeySpec); +// +// try (FileInputStream fis = new FileInputStream(encryptedPath); +// CipherInputStream cis = new CipherInputStream(fis, cipher); +// FileOutputStream fos = new FileOutputStream(decryptedPath)) { +// byte[] buffer = new byte[1024]; +// int read; +// while ((read = cis.read(buffer)) != -1) { +// fos.write(buffer, 0, read); +// } +// } +// System.out.println("解密完成"); +// } + + + public static void decryptFile(String encryptedPath, String decryptedPath, String keyBase64, String ivBase64) throws Exception { + byte[] keyBytes = Base64.getDecoder().decode(keyBase64); + byte[] ivBytes = Base64.getDecoder().decode(ivBase64); + SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, TRANSFORMATION); + IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes); + Cipher cipher = initCipher(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); + + try (FileInputStream fis = new FileInputStream(encryptedPath); + CipherInputStream cis = new CipherInputStream(fis, cipher); + FileOutputStream fos = new FileOutputStream(decryptedPath)) { + byte[] buffer = new byte[1024]; + int read; + while ((read = cis.read(buffer)) != -1) { + fos.write(buffer, 0, read); + } + } + System.out.println("解密完成"); + } + + +// private static Cipher initCipher(int mode) throws Exception { +//// return initCipher(mode, null); +//// } +//// +//// private static Cipher initCipher(int mode, SecretKeySpec secretKeySpec) throws Exception { +//// Cipher cipher = Cipher.getInstance(ALGORITHM); +//// if (secretKeySpec == null) { +//// secretKeySpec = new SecretKeySpec(KEY.getBytes(), TRANSFORMATION); +//// } +//// if (mode == Cipher.ENCRYPT_MODE && SAVED_IV == null) { +//// cipher.init(mode, secretKeySpec); +//// AlgorithmParameters params = cipher.getParameters(); +//// SAVED_IV = params.getParameterSpec(IvParameterSpec.class).getIV(); +//// System.out.println("Generated IV: " + Base64.getEncoder().encodeToString(SAVED_IV)); +//// } else { +//// cipher.init(mode, secretKeySpec, new IvParameterSpec(SAVED_IV)); +//// } +//// return cipher; +//// } + + + private static Cipher initCipher(int mode, SecretKeySpec secretKeySpec, IvParameterSpec ivParameterSpec) throws Exception { + Cipher cipher = Cipher.getInstance(ALGORITHM); + if (secretKeySpec == null){ + secretKeySpec = new SecretKeySpec(KEY.getBytes(), TRANSFORMATION); + } + if (mode == Cipher.ENCRYPT_MODE) { + cipher.init(mode, secretKeySpec); + AlgorithmParameters params = cipher.getParameters(); + SAVED_IV = params.getParameterSpec(IvParameterSpec.class).getIV(); + System.out.println("Generated IV: " + Base64.getEncoder().encodeToString(SAVED_IV)); + } else { + cipher.init(mode, secretKeySpec, ivParameterSpec); + } + return cipher; + } + + private static Cipher initCipher(int mode) throws Exception { + return initCipher(mode, null, null); + } + + private static Cipher initCipher(int mode, SecretKeySpec secretKeySpec) throws Exception { + return initCipher(mode, secretKeySpec, null); + } + + + public static Map uploadEncryptedFileToOSS(String sourcePath, String ossFileName) throws Exception { + Cipher cipher = initCipher(Cipher.ENCRYPT_MODE); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try (FileInputStream fis = new FileInputStream(sourcePath); + CipherInputStream cis = new CipherInputStream(fis, cipher)) { + byte[] buffer = new byte[1024]; + int read; + while ((read = cis.read(buffer)) != -1) { + bos.write(buffer, 0, read); + } + } + System.out.println("加密完成"); + + // 将加密后的字节数组转换为MultipartFile + MockMultipartFile multipartFile = new MockMultipartFile(ossFileName, ossFileName, "application/octet-stream", bos.toByteArray()); + // 调用上传方法 + String uploadedUrl = OssUtil.uploadMultipartFile(multipartFile); + + Map result = new HashMap<>(); + result.put("uploadedUrl", uploadedUrl); + SecretKey secretKey = new SecretKeySpec(KEY.getBytes(), TRANSFORMATION); + + result.put("key",Base64.getEncoder().encodeToString(secretKey.getEncoded())); + result.put("iv", Base64.getEncoder().encodeToString(SAVED_IV)); + return result; + } +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java index 54609f6..9c15d6b 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java @@ -3,6 +3,7 @@ package com.mcwl.web.controller.resource; import com.mcwl.common.core.controller.BaseController; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.resource.domain.WorkFlow; +import com.mcwl.resource.domain.dto.AddRequestWorkFlow; import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.service.impl.WorkFlowServiceImpl; @@ -14,6 +15,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.validation.Valid; import java.util.List; @@ -108,14 +110,14 @@ public class WorkFlowController extends BaseController { /** * 添加工作流 - * @param requestWorkFlow + * @param addRequestWorkFlow * @return */ @ApiOperation(value = "添加工作流") @PostMapping("/addWorkFlow") - public AjaxResult addWorkFlow(@RequestBody RequestWorkFlow requestWorkFlow){ + public AjaxResult addWorkFlow(@Valid @RequestBody AddRequestWorkFlow addRequestWorkFlow){ - return workFlowService.addWorkFlow(requestWorkFlow); + return workFlowService.addWorkFlow(addRequestWorkFlow); } /** diff --git a/mcwl-common/pom.xml b/mcwl-common/pom.xml index fce5171..ba4ae18 100644 --- a/mcwl-common/pom.xml +++ b/mcwl-common/pom.xml @@ -382,6 +382,13 @@ 2.6 + + + org.springframework + spring-test + 5.3.25 + + diff --git a/mcwl-common/src/main/java/com/mcwl/common/constant/DictConstants.java b/mcwl-common/src/main/java/com/mcwl/common/constant/DictConstants.java index 59688d1..711afd7 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/constant/DictConstants.java +++ b/mcwl-common/src/main/java/com/mcwl/common/constant/DictConstants.java @@ -56,4 +56,9 @@ public class DictConstants { */ public static final String IMAGE_LABEL = "image_label"; + /** + * 工作流内容类别 + */ + public static final String WORK_FLOW_TYPE_CHILD = "work_flow_type_child"; + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java index 2c0acfc..33faa68 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java @@ -49,26 +49,12 @@ public class WorkFlow { */ @ApiModelProperty(value = "名称(最多30字)") private String workflowName; - /** - * 垂类 - */ - @ApiModelProperty(value = "垂类") - private String category; - /** - * 主题 - */ - @ApiModelProperty(value = "主题") - private String theme; - /** - * 风格 - */ - @ApiModelProperty(value = "风格") - private String style; + /** * 功能 */ - @ApiModelProperty(value = "功能") - private String functions; + @ApiModelProperty(value = "类别") + private String type; /** * 参与活动 */ @@ -175,17 +161,12 @@ public class WorkFlow { @ApiModelProperty(value = "作品点赞数量") private Integer likeCount = 0; - /** - * 翻译后主体 - */ - @ApiModelProperty(value = "翻译后主体") - @TableField(exist = false) - private List themeList; /** - * 翻译后风格 + * 翻译后类别 */ - @ApiModelProperty(value = "翻译后风格") + @ApiModelProperty(value = "翻译后类别") @TableField(exist = false) - private List styleList; + private List typeList; + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddRequestWorkFlow.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddRequestWorkFlow.java new file mode 100644 index 0000000..739f3de --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddRequestWorkFlow.java @@ -0,0 +1,34 @@ +package com.mcwl.resource.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.Valid; +import java.util.List; + +/** + * 工作流入参 工作流+版本 + * + * @author DaiZibo + * @date 2025/1/9 + * @apiNote + */ + +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Data +@ApiModel(description = "工作流入参 工作流+版本") +public class AddRequestWorkFlow { + @ApiModelProperty(value = "工作流信息") + @Valid + private AddWorkFlow addWorkFlow; + @Valid + @ApiModelProperty(value = "工作流版本信息") + private List addWorkFlowVersions; + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlow.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlow.java new file mode 100644 index 0000000..5b8603a --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlow.java @@ -0,0 +1,179 @@ +package com.mcwl.resource.domain.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; + +/** + * 工作流表 + * @Author:ChenYan + * @Project:McWl + * @Package:com.mcwl.resource.domain + * @Filename:WorkFlow + * @Description 工作流表 + * @Version:1.0 + * @Date:2025/1/8 19:38 + */ +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Data +@TableName("work_flow") +@ApiModel(description = "工作流表") +public class AddWorkFlow { + + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + @TableId + private Long id; + /** + * 用户id + */ + @ApiModelProperty(value = "用户id") + private Long userId; + /** + * 名称(最多30字) + */ + @ApiModelProperty(value = "名称(最多30字)") + @NotBlank(message = "名称不能为空") + @Size(max = 30,message = "名称最多30字") + private String workflowName; + + /** + * 功能 + */ + @ApiModelProperty(value = "类别") + private String type; + /** + * 参与活动 + */ + @ApiModelProperty(value = "参与活动") + private String activityParticipation; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") + private Integer delFlag; + + /** + * 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过) + */ + @ApiModelProperty(value = "审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)") + private Integer auditStatus = 3; + + /** + * 审核失败原因 + */ + @ApiModelProperty(value = "审核失败原因") + private String auditText; + + /** + * 是否原创 + */ + @ApiModelProperty(value = "是否原创") + @NotNull(message = "是否公开原创必选") + private Integer original; + + /** + * 原文作者名字 + */ + @ApiModelProperty(value = "原文作者名字") + private String authorName; + + /** + * 使用数量 + */ + @ApiModelProperty(value = "使用数量") + private Long useNumber = 0L; + + /** + *下载数量 + */ + @ApiModelProperty(value = "下载数量") + private Long downloadNumber = 0L; + + /** + * 是否允许在线使用(0允许 1不允许) + */ + @ApiModelProperty(value = "是否允许在线使用(0允许 1不允许)") + private Integer onlineUse; + + /** + * 是否允许下载工作流(0允许 1不允许) + */ + @ApiModelProperty(value = "是否允许下载工作流(0允许 1不允许)") + private Integer download; + + /** + * 是否允许出售或商用(0允许 1不允许 + */ + + @ApiModelProperty(value = "是否允许出售或商用(0允许 1不允许)") + private Integer sell; + + /** + * 封面图地址 + */ + @ApiModelProperty(value = "封面图地址") + private String coverPath; + + /** + * 审核权限 + */ + @ApiModelProperty(value = "审核权限") + @NotNull(message = "是否公开必选") + private Integer jurisdiction; + + /** + * 是否置顶 + */ + @ApiModelProperty(value = "是否置顶") + private Integer isTop; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date createTime; + + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date updateTime; + + /** + * 作品点赞数量 + */ + @ApiModelProperty(value = "作品点赞数量") + private Integer likeCount = 0; + + + /** + * 翻译后类别 + */ + @ApiModelProperty(value = "翻译后类别") + @TableField(exist = false) + private List typeList; + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java new file mode 100644 index 0000000..6f159ea --- /dev/null +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/dto/AddWorkFlowVersion.java @@ -0,0 +1,92 @@ +package com.mcwl.resource.domain.dto; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +/**工作流版本表 + * @Author:ChenYan + * @Project:McWl + * @Package:com.mcwl.resource.domain + * @Filename:WorkFlow + * @Description TODO + * @Date:2025/1/8 19:38 + */ +@AllArgsConstructor +@NoArgsConstructor +@Data +@ApiModel(description = "工作流版本表") +@TableName("work_flow_version") +public class AddWorkFlowVersion { + + /** + * 主键ID + */ + @TableId + @ApiModelProperty("主键ID") + private Long id; + /** + * 版本名称 + */ + @ApiModelProperty("版本名称") + @NotBlank(message = "版本名称不能为空") + private String versionName; + /** + * 版本介绍(富文本) + */ + @ApiModelProperty("版本介绍(富文本)") + @NotBlank(message = "版本介绍不能为空") + private String versionDescription; + /** + * 文件地址 + */ + @ApiModelProperty("文件地址") + @NotBlank(message = "请上传文件") + private String filePath; + /** + * 图片地址(最多20张,切割) + */ + @ApiModelProperty("图片地址(最多20张,切割)") + @NotBlank(message = "图片至少上传一张") + private String imagePaths; + /** + * 是否隐藏图片生成信息 + */ + @ApiModelProperty("是否隐藏图片生成信息") + private Integer hideGenInfo; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty("删除标志(0代表存在 2代表删除)") + private String delFlag; + + /** + * 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过) + */ + @ApiModelProperty("审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)") + private Integer auditStatus = 3; + + /** + * 审核失败原因 + */ + @ApiModelProperty("审核失败原因") + private String auditText; + + /** + * 模型ID + */ + @ApiModelProperty("模型ID") + private Long workFlowId; + + /** + * 文件名字 + */ + @ApiModelProperty("文件名字") + private String fileName; +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java index 1545f62..ff315e9 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/WorkFlowService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.resource.domain.WorkFlow; +import com.mcwl.resource.domain.dto.AddRequestWorkFlow; import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.vo.PageVo; @@ -18,7 +19,7 @@ import java.util.List; */ public interface WorkFlowService extends IService { - AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow); + AjaxResult addWorkFlow(AddRequestWorkFlow addRequestWorkFlo); void updateWorkFlow(RequestWorkFlow requestWorkFlow); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java index c387858..c237ed6 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java @@ -19,6 +19,7 @@ import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.baidu.BaiduCensor; import com.mcwl.resource.domain.WorkFlow; import com.mcwl.resource.domain.WorkFlowVersion; +import com.mcwl.resource.domain.dto.AddRequestWorkFlow; import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.request.RequestWorkFlow; import com.mcwl.resource.domain.vo.PageVo; @@ -67,7 +68,10 @@ public class WorkFlowServiceImpl extends ServiceImpl i @Override - public AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow) { + public AjaxResult addWorkFlow(AddRequestWorkFlow addRequestWorkFlo) { + + RequestWorkFlow requestWorkFlow = new RequestWorkFlow(); + BeanUtil.copyProperties(addRequestWorkFlo, requestWorkFlow); //获取封面图 String filePath = requestWorkFlow.getWorkFlowVersionList().get(0).getFilePath(); @@ -302,45 +306,16 @@ public class WorkFlowServiceImpl extends ServiceImpl i if (type == 1){ - String category = workFlow.getCategory(); - //翻译属性 垂类 - if (StringUtils.isNotEmpty(category)) { - workFlow.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY, workFlow.getCategory())); - } - - //主体 - String theme = workFlow.getTheme(); - if (StringUtils.isNotEmpty(theme)) { + //类别 + if (StringUtils.isNotEmpty(workFlow.getType())) { ArrayList strings = new ArrayList<>(); - String[] split = workFlow.getTheme().split(","); + String[] split = workFlow.getType().split(","); for (String s : split) { if (s != "") { - strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_THEME, workFlow.getCategory())); + strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, s)); } } - workFlow.setThemeList(strings); - } - - //风格 - if (StringUtils.isNotEmpty(workFlow.getStyle())) { - ArrayList strings = new ArrayList<>(); - String[] split = workFlow.getStyle().split(","); - for (String s : split) { - if (s != "") { - strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_STYLE, workFlow.getStyle())); - } - } - workFlow.setStyleList(strings); - } - - //功能 - if (StringUtils.isNotEmpty(workFlow.getFunctions())) { - workFlow.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS, workFlow.getFunctions())); - } - - //活动 - if (StringUtils.isNotEmpty(workFlow.getActivityParticipation())) { - workFlow.setActivityParticipation(toActivityService.getById(workFlow.getActivityParticipation()).getActivityName()); + workFlow.setTypeList(strings); } }