TASK:aida;
This commit is contained in:
@@ -897,6 +897,57 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
" </html>";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
||||
// 验证机房注册序列号(001-100)
|
||||
String id = noLoginRequiredDTO.getId();
|
||||
if (!isStringInRange(id)) {
|
||||
throw new BusinessException("Illegal serial number.");
|
||||
}
|
||||
// 获取真实 IP 地址,考虑了经过代理的情况
|
||||
String ipAddress = request.getHeader("X-Forwarded-For");
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
}
|
||||
String browserIdentifiers = ipAddress + "," + id;
|
||||
// 构建查询条件,查找已注册的账户数量
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(Account::getUserName, "PolyU-SFT-" + id);
|
||||
// queryWrapper.lambda().eq(Account::getBrowserIdentifiers, browserIdentifiers);
|
||||
List<Account> existingAccounts = accountMapper.selectList(queryWrapper);
|
||||
|
||||
// 检查序列号是否被注册
|
||||
if (!CollectionUtil.isNotEmpty(existingAccounts)) {
|
||||
throw new BusinessException("Updated serial number not found.");
|
||||
}
|
||||
|
||||
Account account = existingAccounts.get(0);
|
||||
account.setBrowserIdentifiers(browserIdentifiers);
|
||||
accountMapper.updateById(account);
|
||||
|
||||
return "<!DOCTYPE html>\n" +
|
||||
" <html lang=\"en\">\n" +
|
||||
" <head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
|
||||
" <title>Document</title>\n" +
|
||||
" <link rel=\"icon\" href=\"https://polyu.aida.com.hk/favicon.ico\">\n" +
|
||||
" </head>\n" +
|
||||
" <body>\n" +
|
||||
" </body>\n" +
|
||||
" <script>\n" +
|
||||
" window.location.href = 'https://polyu.aida.com.hk?" + id + "';\n" +
|
||||
" </script>\n" +
|
||||
" </html>";
|
||||
}
|
||||
|
||||
public static boolean isStringInRange(String input) {
|
||||
// 去除字符串两端的空格
|
||||
input = input.trim();
|
||||
|
||||
@@ -78,6 +78,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
@Value("${minio.bucketName.gradient}")
|
||||
private String gradientBucketName;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public CollectionElementVO upload(CollectionElementUploadDTO uploadDTO) {
|
||||
@@ -101,6 +104,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
//保存element元素
|
||||
CollectionElement collectionElement = resolveData(uploadDTO, userInfo, path, level2Type);
|
||||
saveOne(collectionElement);
|
||||
// if (!StringUtils.isEmpty(uploadDTO.getMoodboardPosition())) {
|
||||
// redisUtil.saveMoodboardPosition(collectionElement.getId(), uploadDTO.getMoodboardPosition());
|
||||
// }
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setMinIOPath(collectionElementVO.getUrl());
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), 24 * 60));
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ai.da.common.enums.DesignTypeEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.mapper.primary.CollectionMapper;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
@@ -47,11 +48,12 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Long saveCollection(Long accountId, String timeZone, String moodTemplateId) {
|
||||
public Long saveCollection(Long accountId, String timeZone, String moodTemplateId, String moodboardPostion) {
|
||||
Collection collection = new Collection();
|
||||
collection.setAccountId(accountId);
|
||||
collection.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
||||
collection.setMoodTemplateId(moodTemplateId);
|
||||
collection.setMoodboardPosition(moodboardPostion);
|
||||
if (collectionMapper.insert(collection) <= 0) {
|
||||
throw new BusinessException("save.collection.failed");
|
||||
}
|
||||
@@ -63,6 +65,9 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
return collectionMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public UserLikeCollectionVO chooseCollection(Long id) {
|
||||
UserLikeCollectionVO response = new UserLikeCollectionVO();
|
||||
@@ -78,6 +83,9 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
response.setMoodTemplateId(collection.getMoodTemplateId());
|
||||
if (collection.getMoodTemplateId() != null) {
|
||||
CollectionElement byId = collectionElementService.getById(response.getMoodTemplateId());
|
||||
if (null != collection.getMoodboardPosition()) {
|
||||
response.setMoodboardPosition(collection.getMoodboardPosition());
|
||||
}
|
||||
if (Objects.nonNull(byId)) {
|
||||
response.setMoodTemplateName(byId.getName());
|
||||
response.setMoodTemplateUrl(minioUtil.getPreSignedUrl(byId.getUrl(), 24 * 60));
|
||||
|
||||
@@ -291,8 +291,20 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||
}
|
||||
//保存collection
|
||||
Long collectionId = (null == collectionIdParam) ?
|
||||
collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId()) : collectionIdParam;
|
||||
Long collectionId;
|
||||
if (null == collectionIdParam) {
|
||||
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPostion());
|
||||
}else {
|
||||
collectionId = collectionIdParam;
|
||||
Collection byId = collectionService.getById(collectionIdParam);
|
||||
if (!designDTO.getMoodboardPostion().equals(byId.getMoodboardPosition())) {
|
||||
byId.setMoodboardPosition(designDTO.getMoodboardPostion());
|
||||
}
|
||||
if (!designDTO.getMoodTemplateId().equals(byId.getMoodTemplateId())) {
|
||||
byId.setMoodTemplateId(designDTO.getMoodTemplateId());
|
||||
}
|
||||
collectionService.updateById(byId);
|
||||
}
|
||||
List<Long> elementIds = getElementId(elementVO);
|
||||
//批量关联element 到 collection
|
||||
collectionElementService.relationCollection(elementIds, collectionId);
|
||||
@@ -367,8 +379,63 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO) {
|
||||
List<CollectionSketchDTO> sketchBoards = sketchesBoundingBoxDTO.getSketchBoards();
|
||||
public List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignDTO) {
|
||||
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
||||
for (CollectionSketchDTO dto : reDesignDTO.getSketchBoards()) {
|
||||
// 这里假设 CollectionSketchDTO 有一个复制构造函数,或者你可以手动复制它的属性
|
||||
CollectionSketchDTO newDto = CopyUtil.copyObject(dto, CollectionSketchDTO.class);
|
||||
sketchBoards.add(newDto);
|
||||
}
|
||||
|
||||
if (null != reDesignDTO.getCollectionId()) {
|
||||
//校验collection
|
||||
Collection collection = collectionService.getById(reDesignDTO.getCollectionId());
|
||||
if (Objects.isNull(collection)) {
|
||||
throw new BusinessException("collection.not.found");
|
||||
}
|
||||
if (!reDesignDTO.getMoodboardPosition().equals(collection.getMoodboardPosition())) {
|
||||
collection.setMoodboardPosition(reDesignDTO.getMoodboardPosition());
|
||||
}
|
||||
if (!reDesignDTO.getMoodTemplateId().equals(collection.getMoodTemplateId())) {
|
||||
collection.setMoodTemplateId(reDesignDTO.getMoodTemplateId());
|
||||
}
|
||||
collectionService.updateById(collection);
|
||||
//校验collection element
|
||||
DesignCollectionDTO designCollectionDTO = CopyUtil.copyObject(reDesignDTO, DesignCollectionDTO.class);
|
||||
ValidateElementVO elementVO = collectionElementService.validateElement(designCollectionDTO);
|
||||
//计算并删除对应的未关联的element
|
||||
List<Long> longs = calculateNoRelationElement(reDesignDTO.getCollectionId(), elementVO.getUsedElementIds());
|
||||
if (!CollectionUtils.isEmpty(longs)) {
|
||||
collectionElementService.batchDelete(longs);
|
||||
}
|
||||
//redesign
|
||||
DesignCollectionDTO designDTO = CopyUtil.copyObject(reDesignDTO, DesignCollectionDTO.class);
|
||||
Long collectionIdParam = reDesignDTO.getCollectionId();
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
//编辑sketchBoard
|
||||
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||
//编辑printBoard
|
||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||
}
|
||||
//保存collection
|
||||
Long collectionId = collectionIdParam;
|
||||
List<Long> elementIds = getElementId(elementVO);
|
||||
//批量关联element 到 collection
|
||||
collectionElementService.relationCollection(elementIds, collectionId);
|
||||
//library转化为collection(生成)
|
||||
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||
//generate转化为collection(生成)
|
||||
saveCollectionElemntsByGenerates(elementVO, collectionId);
|
||||
//保存颜色版
|
||||
collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(sketchBoards)) {
|
||||
List<CollectionSketchVO> result = new ArrayList<>();
|
||||
List<CollectionSketchDTO> collect = sketchBoards.stream()
|
||||
@@ -423,6 +490,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> relationImageIds(DesignPythonObjects pythonObjects) {
|
||||
List<Long> imageIds = new ArrayList<>();
|
||||
if (Objects.isNull(pythonObjects)) {
|
||||
|
||||
@@ -715,6 +715,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// throw new BusinessException("");
|
||||
}
|
||||
ToProductImageResult toProductImageResult = toProductImageResults.get(0);
|
||||
if (toProductImageResult.getBrightenValue() != null && toProductImageResult.getBrightenValue() != 1.0) {
|
||||
pythonService.bright(url, toProductImageResult.getBrightenValue());
|
||||
}
|
||||
toProductImageResult.setUrl(url);
|
||||
toProductImageResult.setResultType("Relight");
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
|
||||
@@ -512,6 +512,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setIsLike(0);
|
||||
toProductImageResult.setTaskId(taskId);
|
||||
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
||||
if (toProductImageDTO.getBrightenValue() != null) {
|
||||
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
||||
}
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
@@ -527,6 +530,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
// toProductImageResult.setUrl(productImageUrl);
|
||||
toProductImageResult.setIsLike(0);
|
||||
toProductImageResult.setTaskId(taskId);
|
||||
if (toProductImageDTO.getBrightenValue() != null) {
|
||||
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
||||
}
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
|
||||
Reference in New Issue
Block a user