|
|
@@ -2,13 +2,16 @@ package com.izouma.uwip.web;
|
|
|
|
|
|
import com.izouma.uwip.domain.LogoPatent;
|
|
|
import com.izouma.uwip.domain.Partner;
|
|
|
+import com.izouma.uwip.service.AttachmentService;
|
|
|
import com.izouma.uwip.service.LogoPatentService;
|
|
|
import com.izouma.uwip.dto.PageQuery;
|
|
|
import com.izouma.uwip.exception.BusinessException;
|
|
|
import com.izouma.uwip.repo.LogoPatentRepo;
|
|
|
import com.izouma.uwip.utils.ObjUtils;
|
|
|
+import com.izouma.uwip.utils.SecurityUtils;
|
|
|
import com.izouma.uwip.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -23,12 +26,19 @@ import java.util.List;
|
|
|
public class LogoPatentController extends BaseController {
|
|
|
private LogoPatentService logoPatentService;
|
|
|
private LogoPatentRepo logoPatentRepo;
|
|
|
+ private AttachmentService attachmentService;
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
public LogoPatent save(@RequestBody LogoPatent record) {
|
|
|
+
|
|
|
if (record.getId() != null) {
|
|
|
LogoPatent orig = logoPatentRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
+ // 保存附件
|
|
|
+ if (CollectionUtils.isNotEmpty(record.getAttachments())) {
|
|
|
+ attachmentService.batchSave(record.getAttachments(), SecurityUtils.getAuthenticatedUser()
|
|
|
+ .getId(), record.getId());
|
|
|
+ }
|
|
|
ObjUtils.merge(orig, record);
|
|
|
return logoPatentRepo.save(orig);
|
|
|
}
|
|
|
@@ -36,7 +46,13 @@ public class LogoPatentController extends BaseController {
|
|
|
record.setSort(logoPatentRepo.findMax());
|
|
|
}
|
|
|
record.setUwNo(logoPatentService.getUwNo(record));
|
|
|
- return logoPatentRepo.save(record);
|
|
|
+ record = logoPatentRepo.save(record);
|
|
|
+ // 保存附件
|
|
|
+ if (CollectionUtils.isNotEmpty(record.getAttachments())) {
|
|
|
+ attachmentService.batchSave(record.getAttachments(), SecurityUtils.getAuthenticatedUser()
|
|
|
+ .getId(), record.getId());
|
|
|
+ }
|
|
|
+ return record;
|
|
|
}
|
|
|
|
|
|
|