TASK:数据迁移;
This commit is contained in:
@@ -30,6 +30,9 @@ public class MyTaskScheduler {
|
|||||||
// 用户到期时间戳
|
// 用户到期时间戳
|
||||||
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
||||||
|
|
||||||
|
if (null == timestamp) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 获取当前时间戳
|
// 获取当前时间戳
|
||||||
Long currentTimestamp = System.currentTimeMillis();
|
Long currentTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class MinioUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bucketName + path;
|
return bucketName + "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String upload(String bucketName, String path, File file) {
|
// public String upload(String bucketName, String path, File file) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class SendEmailUtil {
|
|||||||
* 发信地址
|
* 发信地址
|
||||||
*/
|
*/
|
||||||
private static String SEND_ADDRESS = "info@aida.com.hk";
|
private static String SEND_ADDRESS = "info@aida.com.hk";
|
||||||
|
private final static String CODE_CREATE_SEND_ADDRESS = "info@code-create.com.hk";
|
||||||
/**
|
/**
|
||||||
* 登入主题
|
* 登入主题
|
||||||
*/
|
*/
|
||||||
@@ -219,9 +220,10 @@ public class SendEmailUtil {
|
|||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
// 设置试用订单相关数据
|
// 设置试用订单相关数据
|
||||||
jsonObject.put("userName", account.getUserName());
|
jsonObject.put("userName", account.getUserName());
|
||||||
|
|
||||||
// 用户到期时间戳
|
// 用户到期时间戳
|
||||||
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
|
||||||
|
if (null != timestamp) {
|
||||||
// 获取当前时间戳
|
// 获取当前时间戳
|
||||||
Long currentTimestamp = System.currentTimeMillis();
|
Long currentTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -231,6 +233,7 @@ public class SendEmailUtil {
|
|||||||
// 向上取整计算天数
|
// 向上取整计算天数
|
||||||
long days = (timeDifference + 24 * 60 * 60 * 1000 - 1) / (24 * 60 * 60 * 1000);
|
long days = (timeDifference + 24 * 60 * 60 * 1000 - 1) / (24 * 60 * 60 * 1000);
|
||||||
jsonObject.put("days", days);
|
jsonObject.put("days", days);
|
||||||
|
}
|
||||||
return jsonObject.toJSONString();
|
return jsonObject.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,4 +272,40 @@ public class SendEmailUtil {
|
|||||||
jsonObject.put("email", trialOrder.getEmail());
|
jsonObject.put("email", trialOrder.getEmail());
|
||||||
return jsonObject.toJSONString();
|
return jsonObject.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
|
||||||
|
public static void sendUpgradeNotification(Account account, String senderAddress) {
|
||||||
|
try {
|
||||||
|
// 实例化一个认证对象
|
||||||
|
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||||
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
|
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||||
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
|
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||||
|
SendEmailRequest req = new SendEmailRequest();
|
||||||
|
if (StringUtils.isEmpty(senderAddress)) {
|
||||||
|
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
||||||
|
}
|
||||||
|
req.setFromEmailAddress(senderAddress);
|
||||||
|
req.setDestination(new String[]{account.getUserEmail()});
|
||||||
|
|
||||||
|
// 根据邮件类型设置不同的主题和模板
|
||||||
|
String subject = "";
|
||||||
|
Template template = new Template();
|
||||||
|
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
|
||||||
|
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||||
|
template.setTemplateData(buildAccountData(account));
|
||||||
|
|
||||||
|
req.setSubject(subject);
|
||||||
|
req.setTemplate(template);
|
||||||
|
|
||||||
|
// 发送邮件
|
||||||
|
SendEmailResponse resp = client.SendEmail(req);
|
||||||
|
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
log.info("邮件发送失败###{}", e.toString());
|
||||||
|
throw new BusinessException("failed.to.send.mail");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,4 +149,11 @@ public class AccountController {
|
|||||||
public Response<AccountLoginVO> noLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request){
|
public Response<AccountLoginVO> noLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request){
|
||||||
return Response.success(accountService.noLoginRequired(noLoginRequiredDTO, request));
|
return Response.success(accountService.noLoginRequired(noLoginRequiredDTO, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("upgradeNotification")
|
||||||
|
@ApiOperation(value = "升级邮件通知")
|
||||||
|
public Response<Boolean> upgradeNotification() {
|
||||||
|
accountService.upgradeNotification();
|
||||||
|
return Response.success(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -197,4 +198,11 @@ public class LibraryController {
|
|||||||
return "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
|
return "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("moveLibraryData")
|
||||||
|
@ApiOperation(value = "用户library数据迁移")
|
||||||
|
public Response<Boolean> moveLibraryDate() throws ParseException {
|
||||||
|
libraryService.moveLibraryDate();
|
||||||
|
return Response.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/main/java/com/ai/da/mapper/LibraryCopyMapper.java
Normal file
15
src/main/java/com/ai/da/mapper/LibraryCopyMapper.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ai.da.mapper;
|
||||||
|
|
||||||
|
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||||
|
import com.ai.da.mapper.entity.Library;
|
||||||
|
import com.ai.da.mapper.entity.LibraryCopy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper 接口
|
||||||
|
*
|
||||||
|
* @author easy-generator
|
||||||
|
* @since 2022-06-13
|
||||||
|
*/
|
||||||
|
public interface LibraryCopyMapper extends CommonMapper<LibraryCopy> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ai.da.mapper;
|
||||||
|
|
||||||
|
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||||
|
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||||
|
import com.ai.da.mapper.entity.LibraryModelPointCopy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper 接口
|
||||||
|
*
|
||||||
|
* @author easy-generator
|
||||||
|
* @since 2022-11-11
|
||||||
|
*/
|
||||||
|
public interface LibraryModelPointCopyMapper extends CommonMapper<LibraryModelPointCopy> {
|
||||||
|
|
||||||
|
}
|
||||||
83
src/main/java/com/ai/da/mapper/entity/LibraryCopy.java
Normal file
83
src/main/java/com/ai/da/mapper/entity/LibraryCopy.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package com.ai.da.mapper.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attendance
|
||||||
|
*
|
||||||
|
* @author easy-generator
|
||||||
|
* @since 2022-06-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("t_library_copy")
|
||||||
|
public class LibraryCopy implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long accountId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一级类型
|
||||||
|
*/
|
||||||
|
private String level1Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级类型
|
||||||
|
*/
|
||||||
|
private String level2Type;
|
||||||
|
|
||||||
|
// private String level3Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元素名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元素存放地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* md5值
|
||||||
|
*/
|
||||||
|
private String md5;
|
||||||
|
/**
|
||||||
|
* 图片高度,目前只争对 models类型
|
||||||
|
*/
|
||||||
|
private Integer high;
|
||||||
|
/**
|
||||||
|
* 图片宽度,目前只争对 models类型
|
||||||
|
*/
|
||||||
|
private Integer width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateDate;
|
||||||
|
|
||||||
|
// private Integer isCopy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.ai.da.mapper.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attendance
|
||||||
|
*
|
||||||
|
* @author easy-generator
|
||||||
|
* @since 2022-11-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("t_library_model_point_copy")
|
||||||
|
public class LibraryModelPointCopy implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联的 library或sys Id
|
||||||
|
*/
|
||||||
|
private Long libraryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左肩
|
||||||
|
*/
|
||||||
|
private String shoulderLeft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 右肩
|
||||||
|
*/
|
||||||
|
private String shoulderRight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左腰
|
||||||
|
*/
|
||||||
|
private String waistbandLeft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 右腰
|
||||||
|
*/
|
||||||
|
private String waistbandRight;
|
||||||
|
/**
|
||||||
|
* 左手
|
||||||
|
*/
|
||||||
|
private String handLeft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 右手
|
||||||
|
*/
|
||||||
|
private String handRight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateDate;
|
||||||
|
}
|
||||||
@@ -127,4 +127,8 @@ public interface AccountService extends IService<Account> {
|
|||||||
String addNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
String addNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||||
|
|
||||||
Boolean deleteNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
Boolean deleteNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||||
|
|
||||||
|
void upgradeNotification();
|
||||||
|
|
||||||
|
void moveLibraryDate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,4 +89,6 @@ public interface LibraryService extends IService<Library> {
|
|||||||
void batchDeleteLibrary(LibraryDeleteDTO deleteDTO);
|
void batchDeleteLibrary(LibraryDeleteDTO deleteDTO);
|
||||||
|
|
||||||
void deleteTrialData(Long id);
|
void deleteTrialData(Long id);
|
||||||
|
|
||||||
|
void moveLibraryDate() throws ParseException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import com.ai.da.common.response.PageBaseResponse;
|
|||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.utils.CopyUtil;
|
import com.ai.da.common.utils.CopyUtil;
|
||||||
import com.ai.da.common.utils.DateUtil;
|
import com.ai.da.common.utils.DateUtil;
|
||||||
|
import com.ai.da.common.utils.FileUtil;
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
|
import com.ai.da.mapper.LibraryCopyMapper;
|
||||||
import com.ai.da.mapper.LibraryMapper;
|
import com.ai.da.mapper.LibraryMapper;
|
||||||
|
import com.ai.da.mapper.LibraryModelPointCopyMapper;
|
||||||
import com.ai.da.mapper.SysFileMapper;
|
import com.ai.da.mapper.SysFileMapper;
|
||||||
import com.ai.da.mapper.entity.*;
|
import com.ai.da.mapper.entity.*;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
@@ -30,15 +33,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
import org.apache.commons.fileupload.FileItem;
|
||||||
|
import org.apache.commons.fileupload.FileItemFactory;
|
||||||
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -463,6 +477,121 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
libraryMapper.delete(qw);
|
libraryMapper.delete(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LibraryCopyMapper libraryCopyMapper;
|
||||||
|
@Resource
|
||||||
|
private LibraryModelPointCopyMapper libraryModelPointCopyMapper;
|
||||||
|
@Override
|
||||||
|
public void moveLibraryDate() throws ParseException {
|
||||||
|
QueryWrapper<LibraryCopy> qw = new QueryWrapper<>();
|
||||||
|
// 定义日期格式
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
// 定义日期字符串
|
||||||
|
String dateString = "2023-09-01 00:00:00";
|
||||||
|
qw.gt("create_date", dateFormat.parse(dateString));
|
||||||
|
// 生产所有数据
|
||||||
|
List<LibraryCopy> libraryList = libraryCopyMapper.selectList(qw);
|
||||||
|
for (LibraryCopy libraryCopy : libraryList) {
|
||||||
|
QueryWrapper<Library> one = new QueryWrapper<>();
|
||||||
|
one.lambda().eq(Library::getAccountId, libraryCopy.getAccountId());
|
||||||
|
one.lambda().eq(Library::getMd5, libraryCopy.getMd5());
|
||||||
|
List<Library> libraryList1 = libraryMapper.selectList(one);
|
||||||
|
if (CollectionUtil.isNotEmpty(libraryList1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String url = libraryCopy.getUrl();
|
||||||
|
if (StringUtils.isEmpty(url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (url.contains("/download/")) {
|
||||||
|
String[] downloads = url.split("/download/");
|
||||||
|
if (downloads.length == 2) {
|
||||||
|
String linux = downloads[1];
|
||||||
|
String windows = linux.replaceAll("/", "\\\\");
|
||||||
|
String path = "C:\\workspace\\fileData\\file\\" + windows;
|
||||||
|
File file = FileUtil.getFile(path);
|
||||||
|
if (file != null) {
|
||||||
|
String name = file.getName();
|
||||||
|
System.out.println(name);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(libraryCopy.getAccountId()).append("/").append(libraryCopy.getLevel1Type().toLowerCase()).append("/");
|
||||||
|
if (libraryCopy.getLevel1Type().equals("Sketchboard") || libraryCopy.getLevel1Type().equals("Models")) {
|
||||||
|
sb.append("female/");
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(libraryCopy.getLevel2Type())) {
|
||||||
|
sb.append(libraryCopy.getLevel2Type().toLowerCase()).append("/");
|
||||||
|
}
|
||||||
|
sb.append(name);
|
||||||
|
String bucketName = users;
|
||||||
|
boolean b = minioUtil.doesObjectExist(bucketName, sb.toString());
|
||||||
|
if (!b) {
|
||||||
|
FileItem a = getMultipartFile(file, file.getName());
|
||||||
|
MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||||
|
String upload = minioUtil.upload(bucketName, sb.toString(), multipartFile, "");
|
||||||
|
Library newInsert = CopyUtil.copyObject(libraryCopy, Library.class);
|
||||||
|
newInsert.setId(null);
|
||||||
|
if (libraryCopy.getLevel1Type().equals("Models")) {
|
||||||
|
newInsert.setLevel2Type("Female");
|
||||||
|
QueryWrapper<LibraryModelPointCopy> modelCopy = new QueryWrapper<>();
|
||||||
|
modelCopy.lambda().eq(LibraryModelPointCopy::getLibraryId, libraryCopy.getId());
|
||||||
|
LibraryModelPointCopy libraryModelPointCopy = libraryModelPointCopyMapper.selectOne(modelCopy);
|
||||||
|
LibraryModelPoint libraryModelPoint = CopyUtil.copyObject(libraryModelPointCopy, LibraryModelPoint.class);
|
||||||
|
libraryModelPoint.setModelType("Library");
|
||||||
|
|
||||||
|
upload = processMannequins(upload);
|
||||||
|
newInsert.setUrl(upload);
|
||||||
|
libraryMapper.insert(newInsert);
|
||||||
|
|
||||||
|
libraryModelPoint.setRelationId(newInsert.getId());
|
||||||
|
libraryModelPoint.setId(null);
|
||||||
|
libraryModelPointService.saveOrUpdate(libraryModelPoint);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (libraryCopy.getLevel1Type().equals("Sketchboard")) {
|
||||||
|
newInsert.setLevel3Type("Female");
|
||||||
|
}
|
||||||
|
newInsert.setUrl(upload);
|
||||||
|
libraryMapper.insert(newInsert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static FileItem getMultipartFile(File file, String fieldName) {
|
||||||
|
// 使用 DiskFileItemFactory 创建一个 FileItemFactory
|
||||||
|
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
||||||
|
|
||||||
|
// 使用 FileItemFactory 创建一个 FileItem 对象
|
||||||
|
String mimeType = getMimeType(file);
|
||||||
|
FileItem item = factory.createItem(fieldName, mimeType, true, file.getName());
|
||||||
|
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(file);
|
||||||
|
OutputStream os = item.getOutputStream()) {
|
||||||
|
// 从文件中读取数据并写入 FileItem
|
||||||
|
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getMimeType(File file) {
|
||||||
|
try {
|
||||||
|
return Files.probeContentType(file.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkModel(String value, List<Long> modelIds, Integer deleteModelConfirm) {
|
public void checkModel(String value, List<Long> modelIds, Integer deleteModelConfirm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user