first version of aida_back
This commit is contained in:
69
src/main/java/com/ai/da/controller/AccountController.java
Normal file
69
src/main/java/com/ai/da/controller/AccountController.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.AccountLoginVO;
|
||||
import com.ai.da.model.vo.AccountPreLoginVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
@Api(tags = "Account模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/account")
|
||||
public class AccountController {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@ApiOperation(value = "预先登入")
|
||||
@PostMapping("/preLogin")
|
||||
public Response<AccountPreLoginVO> preLogin(@Valid @RequestBody AccountPreLoginDTO accountDTO) {
|
||||
return Response.success(accountService.preLogin(accountDTO));
|
||||
}
|
||||
@ApiOperation(value = "登入")
|
||||
@PostMapping("/login")
|
||||
public Response<AccountLoginVO> login(@Valid @RequestBody AccountLoginDTO accountDTO, HttpServletRequest request) {
|
||||
return Response.success(accountService.login(accountDTO,request));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "绑定邮箱")
|
||||
@PostMapping("/bindEmail")
|
||||
public Response<Boolean> bindEmail(@Valid @RequestBody AccountBindEmailDTO accountBindEmailDTO) {
|
||||
return Response.success(accountService.bindEmail(accountBindEmailDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "忘记密码")
|
||||
@PostMapping("/resetPwd")
|
||||
public Response<Boolean> resetPwd(@Valid @RequestBody AccountRegisterDTO accountRegisterDTO) {
|
||||
return Response.success(accountService.forgetPwd(accountRegisterDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送邮件")
|
||||
@PostMapping("/sendEmail")
|
||||
public Response<Boolean> sendEmail(@Valid @RequestBody EmailSendDTO emailSendDTO) {
|
||||
return Response.success(accountService.sendEmail(emailSendDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登出")
|
||||
@PostMapping("/logout")
|
||||
public Response<Boolean> logout(@Valid @RequestBody AccountLogoutDTO accountLogoutDTO) {
|
||||
return Response.success( accountService.logout(accountLogoutDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "是否登入")
|
||||
@PostMapping("/isLogin")
|
||||
public Response<Boolean> isLogin(@Valid @RequestBody AccountLogoutDTO accountLogoutDTO) {
|
||||
return Response.success( accountService.isLogin(accountLogoutDTO));
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/com/ai/da/controller/DesignController.java
Normal file
63
src/main/java/com/ai/da/controller/DesignController.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.DesignCollectionVO;
|
||||
import com.ai.da.model.vo.DesignItemDetailVO;
|
||||
import com.ai.da.model.vo.DesignLikeVO;
|
||||
import com.ai.da.service.DesignService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Api(tags = "design模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/design")
|
||||
public class DesignController {
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
|
||||
@ApiOperation(value = "设计 Conllection")
|
||||
@PostMapping("/designCollection")
|
||||
public Response<DesignCollectionVO> designCollection(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
||||
return Response.success(designService.designCollection(designDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "重新设计 Collection")
|
||||
@PostMapping("/reDesignCollection")
|
||||
public Response<DesignCollectionVO> reDesignCollection(@Valid @RequestBody ReDesignCollectionDTO reDesignDTO) {
|
||||
return Response.success(designService.reDesignCollection(reDesignDTO));
|
||||
}
|
||||
@ApiOperation(value = "designItem list,刷新用")
|
||||
@GetMapping("/designItemList")
|
||||
public Response<DesignCollectionVO> designItemList(@ApiParam("designId") @RequestParam("designId") Long designId) {
|
||||
return Response.success(designService.designItemList(designId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "统计design进度")
|
||||
@PostMapping("/countDesignProcess")
|
||||
public Response<BigDecimal> countDesignProcess() {
|
||||
return Response.success(designService.countDesignProcess());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Design Like")
|
||||
@PostMapping("/like")
|
||||
public Response<DesignLikeVO> like(@Valid @RequestBody DesignLikeDTO designLikeDTO) {
|
||||
return Response.success(designService.like(designLikeDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Design Dislike")
|
||||
@PostMapping("/dislike")
|
||||
public Response<Boolean> dislike(@Valid @RequestBody DisDesignLikeDTO disDesignLikeDTO) {
|
||||
return Response.success(designService.dislike(disDesignLikeDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.entity.CollectionElement;
|
||||
import com.ai.da.mapper.entity.DesignItem;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.DesignItemService;
|
||||
import com.ai.da.service.DesignService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Api(tags = "design Detail模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/design/detail")
|
||||
public class DesignDetailController {
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
@Resource
|
||||
private DesignItemService designItemService;
|
||||
|
||||
@ApiOperation(value = "生成高级design图片")
|
||||
@PostMapping("/generateHighDesign")
|
||||
public Response<String> generateHighDesign(@Valid @RequestBody GenerateHighDesignDTO generateHighDesignDTO) {
|
||||
Response response = new Response();
|
||||
response.setData(designService. generateHighDesign(generateHighDesignDTO));
|
||||
return response;
|
||||
}
|
||||
@ApiOperation(value = "删除高级design图片")
|
||||
@PostMapping("/deleteHighDesign")
|
||||
public Response<Boolean> deleteHighDesign(@Valid @RequestBody GenerateHighDesignDTO generateHighDesignDTO) {
|
||||
Response response = new Response();
|
||||
response.setData(designService.deleteHighDesign(generateHighDesignDTO));
|
||||
return response;
|
||||
}
|
||||
@ApiOperation(value = "查询design详情")
|
||||
@GetMapping("/getDetail")
|
||||
public Response<DesignItemDetailVO> getDetail(@ApiParam("designItemId") @RequestParam("designItemId") Long designItemId) {
|
||||
return Response.success(designService.detail(designItemId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "切换系统的element")
|
||||
@GetMapping("/getNextSysElement")
|
||||
public Response<GetNextSysElementVO> getNextSysElement(@ApiParam("要切换的系统element 类型") @RequestParam("type") String type,
|
||||
@ApiParam("要切换的系统element id") @RequestParam("id") Long id,
|
||||
@ApiParam("操作类型 PREV 上一步 NEXT 下一步") @RequestParam("operateType") String operateType) {
|
||||
return Response.success(designItemService.getNextSysElement(id,type,operateType));
|
||||
}
|
||||
@ApiOperation(value = "单个design")
|
||||
@PostMapping("/designSingle")
|
||||
public Response<DesignCollectionItemVO> designSingle(@Valid @RequestBody DesignSingleDTO designSingleDTO ) {
|
||||
return Response.success(designItemService.designSingle(designSingleDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "print打点")
|
||||
@PostMapping("/printDot")
|
||||
public Response<String> printDot(@Valid @RequestBody DesignSingleDTO designSingleDTO ) {
|
||||
Response<String> response =new Response();
|
||||
String url = designItemService.printDot(designSingleDTO);
|
||||
response.setData(url);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
99
src/main/java/com/ai/da/controller/ElementController.java
Normal file
99
src/main/java/com/ai/da/controller/ElementController.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.CollectionElementService;
|
||||
import com.ai.da.service.PanToneService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Api(tags = "collection模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/element")
|
||||
public class ElementController {
|
||||
|
||||
@Resource
|
||||
private CollectionElementService collectionElementService;
|
||||
@Resource
|
||||
private PanToneService panToneService;
|
||||
@Resource
|
||||
private SysFileService sysFileService;
|
||||
|
||||
@ApiOperation(value = "初始化系统文件")
|
||||
@PostMapping("/initDefaultSysFile")
|
||||
public Response<Boolean> initDefaultSysFile(@RequestParam("validate") String validateUse) {
|
||||
if (validateUse.equals("da_fl_mm_dad88888")) {
|
||||
//防止被调用
|
||||
sysFileService.initDefaultSysFile();
|
||||
}
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "element文件上传")
|
||||
@PostMapping("/upload")
|
||||
public Response<CollectionElementVO> upload(@RequestParam("file") MultipartFile file,
|
||||
@ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Colorboard")
|
||||
@RequestParam(value = "level1Type") String level1Type,
|
||||
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
|
||||
@RequestParam(value = "timeZone") String timeZone) {
|
||||
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
|
||||
return Response.success(collectionElementService.upload(
|
||||
new CollectionElementUploadDTO(file, level1Type, timeZone, MD5Utils.encryptFile(file))));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "element文件删除")
|
||||
@PostMapping("/delete")
|
||||
public Response<Boolean> delete(@Valid @RequestBody CollectionDeleteFileDTO deleteFileDTO) {
|
||||
collectionElementService.delete(deleteFileDTO.getId());
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成印花")
|
||||
@PostMapping("/generatePrint")
|
||||
public Response<CollectionGeneratePrintVO> generatePrint(@Valid @RequestBody CollectionGeneratePrintDTO generatePrintDTO) {
|
||||
return Response.success(collectionElementService.generatePrint(generatePrintDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存印花")
|
||||
@PostMapping("/savePrint")
|
||||
public Response<Boolean> savePrint(@Valid @RequestBody CollectionSavePrintDTO savePrintDTO) {
|
||||
return Response.success(collectionElementService.savePrint(savePrintDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过tcx值获取潘通信息")
|
||||
@GetMapping("/getRgbByTcx")
|
||||
public Response<PantoneVO> getRgbByHsv(@ApiParam("tcx") @RequestParam("tcx") String tcx) {
|
||||
return Response.success(panToneService.getByTCX(tcx));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过hsv值获取潘通信息")
|
||||
@GetMapping("/getRgbByHsv")
|
||||
public Response<PantoneVO> getRgbByHsv(@RequestParam("h") Integer h,
|
||||
@RequestParam("s") Integer s, @RequestParam("v") Integer v) {
|
||||
return Response.success(panToneService.getByHSV(h, s, v));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过hsv值数组批量获取潘通信息")
|
||||
@PostMapping("/getRgbByHsvBatch")
|
||||
public Response<List<PantoneVO>> getRgbByHsvBatch(@RequestBody @Valid List<GetRgbByHsvBatchDTO> rgbByHsvBatch) {
|
||||
return Response.success(panToneService.getRgbByHsvBatch(rgbByHsvBatch));
|
||||
}
|
||||
|
||||
}
|
||||
158
src/main/java/com/ai/da/controller/LibraryController.java
Normal file
158
src/main/java/com/ai/da/controller/LibraryController.java
Normal file
@@ -0,0 +1,158 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.system.UserInfo;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Api(tags = "library模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/library")
|
||||
public class LibraryController {
|
||||
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
|
||||
@ApiOperation(value = "Library分页列表")
|
||||
@PostMapping("/queryLibraryPage")
|
||||
public Response<PageBaseResponse<QueryLibraryPageVO>> queryLibraryPage(@Valid @RequestBody QueryLibraryPageDTO query) {
|
||||
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query,QueryLibraryPageServiceDTO.class)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Library分页列表(查询top和bottom)")
|
||||
@PostMapping("/queryLibraryTopAndBottomPage")
|
||||
public Response<PageBaseResponse<QueryLibraryPageVO>> queryLibraryTopAndBottomPage(@Valid @RequestBody QueryLibraryTopPageDTO query) {
|
||||
return Response.success(libraryService.queryLibraryPage(CopyUtil.copyObject(query,QueryLibraryPageServiceDTO.class)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Library文件上传")
|
||||
@PostMapping("/upload")
|
||||
public Response<LibraryUpdateVo> upload(@RequestParam("file") MultipartFile file,
|
||||
@ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Models")
|
||||
@RequestParam(value = "level1Type") String level1Type,
|
||||
@ApiParam("二级类型 争对 Sketchboard; 有 Outwear Dress Blouse Skirt Trousers")
|
||||
@RequestParam(value = "level2Type",required = false) String level2Type,
|
||||
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
|
||||
@RequestParam(value = "timeZone") String timeZone) {
|
||||
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
|
||||
Integer high =null;
|
||||
Integer width =null;
|
||||
if(level1Type.equals(LibraryLevel1TypeEnum.MODELS.getRealName())){
|
||||
FileVO fileVO = FileUtil.getFileSize(file);
|
||||
high = fileVO.getHigh();
|
||||
width = fileVO.getWidth();
|
||||
}
|
||||
return Response.success(libraryService.upload(new LibraryUploadDTO(file, level1Type,level2Type,
|
||||
timeZone, MD5Utils.encryptFile(file),high,width)));
|
||||
}
|
||||
@ApiOperation(value = "保存或者编辑template打点")
|
||||
@PostMapping("/saveOrEditTemplatePoint")
|
||||
public Response<LibraryModelPointVO> saveOrEditTemplatePoint(@Valid @RequestBody LibraryModelPointDTO libraryModelPoint) {
|
||||
return Response.success(libraryModelPointService.saveOrEditTemplatePoint(libraryModelPoint));
|
||||
}
|
||||
@ApiOperation(value = "批量Library修改用户文件名")
|
||||
@PostMapping("/batchUpdateLibraryName")
|
||||
public Response<Boolean> batchUpdateLibraryName(@Valid @RequestBody LibraryUpdateDTO libraryUpdateDTO) {
|
||||
libraryService.updateLibraryName(libraryUpdateDTO);
|
||||
return Response.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除library")
|
||||
@PostMapping("/batchDeleteLibrary")
|
||||
public Response<Boolean> batchDeleteLibrary(@Valid @RequestBody LibraryDeleteDTO deleteDTO) {
|
||||
List<Library> librarys = libraryService.getByIds(deleteDTO.getLibraryIds());
|
||||
Assert.notEmpty(librarys,"librarys does not exist!");
|
||||
libraryService.removeBatchByIds(deleteDTO.getLibraryIds());
|
||||
librarys.forEach(library -> {
|
||||
FileUtil.delete(library.getUrl());
|
||||
});
|
||||
return Response.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "Models打点预览")
|
||||
@PostMapping("/modelsDot")
|
||||
public Response<String> modelsDot(@ApiParam("file") @RequestPart(value = "file",required = false) MultipartFile file,
|
||||
@ApiParam("models对象")@RequestPart("models") ModelsDotDTO modelsDotDTO) {
|
||||
if(Objects.nonNull(file)){
|
||||
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
//需要宽高和地址参数design
|
||||
FileVO fileVO = FileUtil.getFileSize(file);
|
||||
modelsDotDTO.setHigh(fileVO.getHigh());
|
||||
modelsDotDTO.setWidth(fileVO.getWidth());
|
||||
//存储template临时地址
|
||||
String path = calculateTempFileUrl(userInfo.getId());
|
||||
File uploadFile = FileUtil.upload(file, path);
|
||||
modelsDotDTO.setTemplateUrl(calculateTemplateUrl(uploadFile));
|
||||
}else{
|
||||
Assert.notNull(modelsDotDTO.getLibraryId(),"libraryId cannot be empty!");
|
||||
Assert.notNull(modelsDotDTO.getTemplateId(),"templateId cannot be empty!");
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getById(modelsDotDTO.getTemplateId());
|
||||
Assert.notNull(modelPoint,"template does not exist!");
|
||||
Library library = libraryService.getById(modelsDotDTO.getLibraryId());
|
||||
Assert.notNull(library,"library does not exist!");
|
||||
modelsDotDTO.setHigh(library.getHigh());
|
||||
modelsDotDTO.setWidth(library.getWidth());
|
||||
modelsDotDTO.setTemplateUrl(library.getUrl());
|
||||
}
|
||||
Response<String> response =new Response();
|
||||
log.info("Models打点预览入参####{}", JSON.toJSONString(modelsDotDTO));
|
||||
String url = libraryModelPointService.modelsDot(modelsDotDTO);
|
||||
response.setData(url);
|
||||
return response;
|
||||
}
|
||||
|
||||
private String calculateTempFileUrl(Long userId) {
|
||||
String rootPath = fileProperties.getSys().getPath();
|
||||
String day = DateUtil.dateToStr(new Date(), DateUtil.YYYYMM);
|
||||
return rootPath + day + File.separator + "tmp" + File.separator + userId + File.separator+ UUID.randomUUID().toString();
|
||||
}
|
||||
private String calculateTemplateUrl(File uploadFile){
|
||||
String linuxDomain = fileProperties.getLinuxDomain();
|
||||
if (!StringUtils.isEmpty(linuxDomain)) {
|
||||
//linux 系统
|
||||
String oldPath = fileProperties.getSys().getPath();
|
||||
return uploadFile.getAbsolutePath().replace(oldPath, linuxDomain);
|
||||
}
|
||||
//本地用
|
||||
// return "/home/pangkaicheng/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";
|
||||
}
|
||||
|
||||
}
|
||||
67
src/main/java/com/ai/da/controller/PythonController.java
Normal file
67
src/main/java/com/ai/da/controller/PythonController.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.model.dto.CollectionDeleteFileDTO;
|
||||
import com.ai.da.model.dto.CollectionElementUploadDTO;
|
||||
import com.ai.da.model.dto.CollectionGeneratePrintDTO;
|
||||
import com.ai.da.model.dto.CollectionSavePrintDTO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.service.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Api(tags = "python对接模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/python")
|
||||
public class PythonController {
|
||||
|
||||
@Resource
|
||||
private PythonService pythonService;
|
||||
@Resource
|
||||
private SysFileService sysFileService;
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
|
||||
@ApiOperation(value = "python服务保存图片到java服务")
|
||||
@PostMapping("/saveGeneratePicture")
|
||||
public Response<String> upload(@RequestParam("file") MultipartFile file,
|
||||
@ApiParam("操作类型 generatePrint ->生成印花 " +
|
||||
"designCollection ->设计collection generateAdvancedDesign ->生成高级design")
|
||||
@RequestParam(value = "operateType") String operateType) {
|
||||
return Response.success(pythonService.upload(file,operateType));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过文件类型获取系统文件")
|
||||
@GetMapping("/getSysFileByLevel2Type")
|
||||
public Response<List<SysFileVO>> getSysFileByLevel2Type(/*@RequestParam(value = "level2Type",required = false) String level2Type*/) {
|
||||
return Response.success(sysFileService.getByLevel2Type("All"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过用户id获取library")
|
||||
@GetMapping("/getLibraryByUserId")
|
||||
public Response<Map<String,List<String>>> getLibraryByUserId(@RequestParam(value = "userId") Long userId) {
|
||||
List<PythonLibraryVo> response = CopyUtil.copyList(libraryService.selectByAccountIdAnd1TypeList(userId,
|
||||
Collections.singletonList(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())),PythonLibraryVo.class);
|
||||
//key转小写 统一
|
||||
return Response.success(response.stream().collect(Collectors.groupingBy(v ->v.getLevel2Type().toLowerCase(),
|
||||
Collectors.mapping(PythonLibraryVo::getUrl,Collectors.toList()))));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.PageResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.mapper.entity.UserLikeGroup;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.Function;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Api(tags = "History模块(saved Collection)")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/history")
|
||||
public class SavedCollectionController {
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
@Resource
|
||||
private UserLikeService userLikeService;
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@ApiOperation(value = "History用户分页分组列表")
|
||||
@PostMapping("/queryUserGroup")
|
||||
public Response<PageBaseResponse<UserLikeGroupVO>> queryUserGroup(@Valid @RequestBody QueryHistoryPageDTO query) {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
// 分页数据
|
||||
QueryWrapper<UserLikeGroup> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("account_id", authPrincipalVo.getId());
|
||||
if(!StringUtils.isEmpty(query.getCollectionName())){
|
||||
queryWrapper.like("name", query.getCollectionName());
|
||||
}
|
||||
if(Objects.nonNull(query.getStartDate())){
|
||||
queryWrapper.ge("update_date", new Date(query.getStartDate()));
|
||||
}
|
||||
if(Objects.nonNull(query.getEndDate())){
|
||||
queryWrapper.le("update_date", new Date(query.getEndDate()));
|
||||
}
|
||||
queryWrapper.orderByDesc("id");
|
||||
IPage<UserLikeGroup> page = userLikeGroupService.getBaseMapper().selectPage(
|
||||
new Page<>(query.getPage(), query.getSize()), queryWrapper);
|
||||
if(CollectionUtils.isEmpty(page.getRecords())){
|
||||
return Response.success(PageBaseResponse.success(new Page<>()));
|
||||
}
|
||||
List<Long> groupIds = page.getRecords().stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
||||
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
|
||||
Assert.notEmpty(groupDetails,"History detail does not exist!");
|
||||
Map<Long,List<UserLikeVO>> groupDetailMap = groupDetails.stream()
|
||||
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
|
||||
|
||||
Account account = accountService.getById(authPrincipalVo.getId());
|
||||
IPage<UserLikeGroupVO> convert = page.convert((Function<UserLikeGroup, UserLikeGroupVO>) group -> {
|
||||
if(group != null){
|
||||
UserLikeGroupVO userLikeGroupVO = CopyUtil.copyObject(group,UserLikeGroupVO.class);
|
||||
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
|
||||
userLikeGroupVO.setAuthor(account.getUserName());
|
||||
//count 和detail
|
||||
List<UserLikeVO> details = groupDetailMap.get(group.getId());
|
||||
userLikeGroupVO.setGroupDetails(details);
|
||||
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 :details.size());
|
||||
return userLikeGroupVO;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return Response.success(PageBaseResponse.success(convert));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "History用户分组详情,目前弃用 ")
|
||||
@GetMapping("/getUserGroupDetail")
|
||||
public Response<List<UserLikeVO>> getUserGroupDetail(
|
||||
@ApiParam("用户分组id") @RequestParam("userGroupId") Long userGroupId) {
|
||||
return Response.success(userLikeService.getGroupDetail(userGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "History修改用户分组名")
|
||||
@PostMapping("/updateUserGroupName")
|
||||
public Response<HistoryUpdateVO> updateUserGroupName(@Valid @RequestBody HistoryUpdateDTO historyUpdateDTO) {
|
||||
return Response.success(userLikeGroupService.updateUserGroupName(historyUpdateDTO.getUserGroupId()
|
||||
,historyUpdateDTO.getUserGroupName(),historyUpdateDTO.getTimeZone()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "History删除用户分组")
|
||||
@PostMapping("/deleteUserGroup")
|
||||
public Response<Boolean> deleteUserGroup(@Valid @RequestBody HistoryDeleteDTO deleteDTO) {
|
||||
userLikeGroupService.deleteUserGroup(deleteDTO.getUserGroupId());
|
||||
userLikeService.deleteByUserGroupId(deleteDTO.getUserGroupId());
|
||||
return Response.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "History choose")
|
||||
@GetMapping("/choose")
|
||||
public Response<UserLikeChooseVO> choose(
|
||||
@ApiParam("用户分组id") @RequestParam("userGroupId") Long userGroupId) {
|
||||
return Response.success(userLikeGroupService.choose(userGroupId));
|
||||
}
|
||||
|
||||
}
|
||||
40
src/main/java/com/ai/da/controller/ThirdPartyController.java
Normal file
40
src/main/java/com/ai/da/controller/ThirdPartyController.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.AccountLoginVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
@Api(tags = "Third Party Modules")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/third/party")
|
||||
public class ThirdPartyController {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@ApiOperation(value = "Add user information")
|
||||
@PostMapping("/addUser")
|
||||
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
||||
return Response.success(accountService.addUser(accountAddDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Edit user information")
|
||||
@PostMapping("/editUser")
|
||||
public Response<Boolean> editUser( @RequestBody AccountEditDTO accountEditDTO) {
|
||||
return Response.success(accountService.editUser(accountEditDTO));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user