TASK:style;
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.vo.ModelsVO;
|
||||
import com.ai.da.model.vo.StyleVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -29,13 +31,13 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
*/
|
||||
IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace);
|
||||
|
||||
boolean saveOrUpdate(Workspace workspace);
|
||||
boolean saveOrUpdate(WorkspaceDTO workspaceDTO);
|
||||
|
||||
WorkspaceVO getPage(WorkspaceDTO query);
|
||||
|
||||
List<BizJson> getEnumValues(String enumName);
|
||||
|
||||
Workspace getByIdNew(Long id);
|
||||
WorkspaceVO getByIdNew(Long id);
|
||||
|
||||
List<ModelsVO> getMannequins(String sex);
|
||||
|
||||
@@ -48,4 +50,6 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
List<Long> delete(List<Workspace> workspaceList);
|
||||
|
||||
Workspace getCurrentWorkspace();
|
||||
|
||||
List<StyleVO> styleList();
|
||||
}
|
||||
|
||||
@@ -9,18 +9,11 @@ import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.primary.LibraryMapper;
|
||||
import com.ai.da.mapper.primary.SysFileMapper;
|
||||
import com.ai.da.mapper.primary.WorkspaceMapper;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.SysFile;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.enums.*;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import com.ai.da.model.vo.ModelVO;
|
||||
import com.ai.da.model.vo.ModelsVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -43,6 +36,7 @@ import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -58,6 +52,12 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
@Resource
|
||||
private WorkspaceMapper workspaceMapper;
|
||||
|
||||
@Resource
|
||||
private StyleMapper styleMapper;
|
||||
|
||||
@Resource
|
||||
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
|
||||
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
|
||||
@@ -83,7 +83,8 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
private final static Integer SYSTEM_DESIGNER_PERCENTAGE = 30;
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(Workspace workspace) {
|
||||
public boolean saveOrUpdate(WorkspaceDTO workspaceDTO) {
|
||||
Workspace workspace = CopyUtil.copyObject(workspaceDTO, Workspace.class);
|
||||
// 防止前端传值修改标识
|
||||
workspace.setIsLastIndex(null);
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
@@ -114,12 +115,35 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
if (insert <= 0) {
|
||||
throw new BusinessException("save.workspace.failed");
|
||||
}
|
||||
if (workspaceDTO.getStyleId() != null) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(workspace.getId());
|
||||
rel.setStyleId(workspaceDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
int update = workspaceMapper.updateById(workspace);
|
||||
if (update <= 0) {
|
||||
throw new BusinessException("update.workspace.failed");
|
||||
}
|
||||
if (workspaceDTO.getStyleId() != null) {
|
||||
QueryWrapper<WorkspaceRelStyle> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(WorkspaceRelStyle::getWorkspaceId, workspace.getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(workspace.getId());
|
||||
rel.setStyleId(workspaceDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}else {
|
||||
WorkspaceRelStyle workspaceRelStyle = workspaceRelStyles.get(0);
|
||||
if (!Objects.equals(workspaceRelStyle.getStyleId(), workspaceDTO.getStyleId())) {
|
||||
workspaceRelStyle.setStyleId(workspaceRelStyle.getStyleId());
|
||||
workspaceRelStyleMapper.updateById(workspaceRelStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -250,7 +274,8 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
}
|
||||
|
||||
@Override
|
||||
public Workspace getByIdNew(Long id) {
|
||||
public WorkspaceVO getByIdNew(Long id) {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
QueryWrapper<Workspace> qwOld = new QueryWrapper<>();
|
||||
qwOld.lambda().eq(Workspace::getAccountId, accountId);
|
||||
@@ -261,7 +286,21 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
Workspace newIsLastIndex = workspaceMapper.selectById(id);
|
||||
newIsLastIndex.setIsLastIndex(1);
|
||||
workspaceMapper.updateById(newIsLastIndex);
|
||||
return newIsLastIndex;
|
||||
WorkspaceVO workspaceVO = CopyUtil.copyObject(newIsLastIndex, WorkspaceVO.class);
|
||||
QueryWrapper<WorkspaceRelStyle> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(WorkspaceRelStyle::getWorkspaceId, workspaceVO.getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(qw);
|
||||
if (!CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
Long styleId = workspaceRelStyles.get(0).getStyleId();
|
||||
Style style = styleMapper.selectById(styleId);
|
||||
StyleEnum styleEnum = StyleEnum.fromName(style.getName());
|
||||
if (authPrincipalVo.getLanguage().equals(Language.ENGLISH.name())) {
|
||||
workspaceVO.setStyleName(styleEnum.getEnglish());
|
||||
}else {
|
||||
workspaceVO.setStyleName(styleEnum.getChinese());
|
||||
}
|
||||
}
|
||||
return workspaceVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -498,44 +537,22 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
return workspaces.get(0);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws FileNotFoundException {
|
||||
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
|
||||
// File pngFile = new File(b);
|
||||
// SysFile sysFile = new SysFile();
|
||||
// String fileName = pngFile.getName();
|
||||
// sysFile.setName(fileName);
|
||||
// sysFile.setLevel1Type("Images");
|
||||
// sysFile.setLevel3Type("Male");
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append("aida-sys-image/images/male");
|
||||
// String absolutePath = pngFile.getAbsolutePath();
|
||||
// if (absolutePath.contains("bottom")) {
|
||||
// sysFile.setLevel2Type("Bottoms");
|
||||
// sb.append("/bottoms/");
|
||||
// }else if(absolutePath.contains("top")) {
|
||||
// sysFile.setLevel2Type("Tops");
|
||||
// sb.append("/tops/");
|
||||
// }else if(absolutePath.contains("outer")) {
|
||||
// sysFile.setLevel2Type("Outwear");
|
||||
// sb.append("/outwear/");
|
||||
// }
|
||||
// sb.append(fileName);
|
||||
// String url = sb.toString();
|
||||
// sysFile.setUrl(url);
|
||||
// sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
|
||||
//// boolean b = minioUtil.doesObjectExist("aida-sys-image", uploadMinioPath);
|
||||
//// if (!b) {
|
||||
//// FileItem a = getMultipartFile(file, file.getName());
|
||||
//// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
//// minioUtil.upload(bucketName, uploadMinioPath, multipartFile, "");
|
||||
//// }
|
||||
// FileItem a = getMultipartFile(pngFile, fileName);
|
||||
// MultipartFile multipartFile = new CommonsMultipartFile(a);
|
||||
// System.out.println(url.substring(0,14));
|
||||
// System.out.println(url.substring(15));
|
||||
//// minioUtil.upload(url.substring(0,14), url.substring(15), multipartFile, "");
|
||||
// sysFile.setCreateDate(new Date());
|
||||
// }
|
||||
@Override
|
||||
public List<StyleVO> styleList() {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
QueryWrapper<Style> qw = new QueryWrapper<>();
|
||||
List<Style> styles = styleMapper.selectList(qw);
|
||||
List<StyleVO> styleVOS = CopyUtil.copyList(styles, StyleVO.class);
|
||||
for (StyleVO styleVO : styleVOS) {
|
||||
StyleEnum styleEnum = StyleEnum.fromName(styleVO.getName());
|
||||
if (authPrincipalVo.getLanguage().equals(Language.ENGLISH.name())) {
|
||||
styleVO.setValue(styleEnum.getEnglish());
|
||||
}else {
|
||||
styleVO.setValue(styleEnum.getChinese());
|
||||
}
|
||||
}
|
||||
return styleVOS;
|
||||
}
|
||||
|
||||
public static List<File> getPNGFiles(String directoryPath) {
|
||||
List<File> pngFiles = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user