TASK:style;
This commit is contained in:
@@ -34,7 +34,7 @@ public class MyTaskScheduler {
|
||||
|
||||
// 定时任务,每十五天执行一次
|
||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
||||
@Scheduled(cron = "0 0 0 */15 * ?")
|
||||
// @Scheduled(cron = "0 0 0 */15 * ?")
|
||||
public void checkExpiry() {
|
||||
// 检测正式用户是否快要过期
|
||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||
@@ -68,7 +68,7 @@ public class MyTaskScheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
// @Scheduled(cron = "0 0 8 * * ?")
|
||||
public void sendTrialOrderExcelToManagements() {
|
||||
// 获取前一天日期
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
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.ai.da.service.WorkspaceService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -44,8 +46,8 @@ public class WorkspaceController {
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "详情", notes = "传入workspace")
|
||||
public Response<Workspace> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
Workspace detail = workspaceService.getByIdNew(id);
|
||||
public Response<WorkspaceVO> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
WorkspaceVO detail = workspaceService.getByIdNew(id);
|
||||
return Response.success(detail);
|
||||
}
|
||||
|
||||
@@ -66,8 +68,8 @@ public class WorkspaceController {
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
|
||||
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspace));
|
||||
public Response saveOrUpdate(@Valid @RequestBody WorkspaceDTO workspaceDTO) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspaceDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -115,10 +117,17 @@ public class WorkspaceController {
|
||||
}
|
||||
|
||||
@PostMapping("maleDataInsert")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperationSupport(order = 8)
|
||||
@ApiOperation(value = "男装数据入库入minio")
|
||||
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
||||
workspaceService.maleDataInsert();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("styleList")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@ApiOperation(value = "获取style列表")
|
||||
public Response<List<StyleVO>> styleList() {
|
||||
return Response.success(workspaceService.styleList());
|
||||
}
|
||||
}
|
||||
|
||||
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface StyleMapper extends CommonMapper<Style> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.WorkspaceRelStyle;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface WorkspaceRelStyleMapper extends CommonMapper<WorkspaceRelStyle> {
|
||||
|
||||
|
||||
}
|
||||
17
src/main/java/com/ai/da/mapper/primary/entity/Style.java
Normal file
17
src/main/java/com/ai/da/mapper/primary/entity/Style.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@TableName("style")
|
||||
public class Style implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@TableName("workspace_rel_style")
|
||||
public class WorkspaceRelStyle implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long workspaceId;
|
||||
private Long styleId;
|
||||
}
|
||||
@@ -16,4 +16,6 @@ import lombok.EqualsAndHashCode;
|
||||
public class WorkspaceDTO extends PageQueryBaseVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long styleId;
|
||||
|
||||
}
|
||||
|
||||
57
src/main/java/com/ai/da/model/enums/StyleEnum.java
Normal file
57
src/main/java/com/ai/da/model/enums/StyleEnum.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum StyleEnum {
|
||||
// 定义风格及其对应的中英文描述
|
||||
NEO_CHINESE("新中式", "Neo Chinese"),
|
||||
COUNTRY_STYLE("田园风", "Country Style"),
|
||||
FUTURISM("未来主义", "Futurism"),
|
||||
MINIMALISM("极简风", "Minimalism"),
|
||||
LOLITA("洛丽塔", "Lolita"),
|
||||
Y2K("Y2K", "Y2K"),
|
||||
BUSINESS("商务风", "Business"),
|
||||
MERLAD("美拉德", "Merlad"),
|
||||
OUTDOOR_FUNCTIONAL("户外机能", "Outdoor Functional"),
|
||||
ROCK("摇滚", "Rock"),
|
||||
DOPAMINE("多巴胺", "Dopamine"),
|
||||
GOTHIC("哥特风", "Gothic"),
|
||||
POST_APOCALYPTIC("废土", "Post-apocalyptic"),
|
||||
ROMANTIC("浪漫", "Romantic"),
|
||||
WABI_SABI("侘寂", "Wabi-sabi");
|
||||
|
||||
private final String chinese;
|
||||
private final String english;
|
||||
|
||||
// 构造函数
|
||||
StyleEnum(String chinese, String english) {
|
||||
this.chinese = chinese;
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
// 获取中文描述
|
||||
public String getChinese() {
|
||||
return chinese;
|
||||
}
|
||||
|
||||
// 获取英文描述
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
// 重写toString方法,返回格式化的描述
|
||||
@Override
|
||||
public String toString() {
|
||||
return chinese + " (" + english + ")";
|
||||
}
|
||||
public static StyleEnum fromName(String name) {
|
||||
for (StyleEnum style : StyleEnum.values()) {
|
||||
if (style.name().equals(name)) {
|
||||
return style;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No enum constant for name: " + name);
|
||||
}
|
||||
}
|
||||
16
src/main/java/com/ai/da/model/vo/StyleVO.java
Normal file
16
src/main/java/com/ai/da/model/vo/StyleVO.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class StyleVO extends Style {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String value;
|
||||
}
|
||||
@@ -33,4 +33,6 @@ public class WorkspaceVO extends Workspace {
|
||||
|
||||
private BizJson positionEnum;
|
||||
|
||||
private String styleName;
|
||||
|
||||
}
|
||||
|
||||
@@ -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