fix: application 导入导出接口路径调整
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/application")
|
@RequestMapping("/api/v1/workspace")
|
||||||
public class ApplicationController {
|
public class ApplicationController {
|
||||||
|
|
||||||
private static final Log log = Log.get();
|
private static final Log log = Log.get();
|
||||||
@@ -33,244 +33,11 @@ public class ApplicationController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IApplicationService applicationService;
|
private IApplicationService applicationService;
|
||||||
|
|
||||||
/*@Autowired
|
@PostMapping("/{workspaceId}/branch/{branchName}/application/import")
|
||||||
private IApplicationSignatureService signatureService;
|
public synchronized R importApplication(@PathVariable("workspaceId") String workspaceId,
|
||||||
|
@PathVariable("branchName") String branchName,
|
||||||
@Autowired
|
@RequestParam(defaultValue = "tsg2402") String format,
|
||||||
private IApplicationNoteService noteService;
|
@RequestParam(value = "files") List<MultipartFile> fileList) {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IApplicationHrefService hrefService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IApplicationAttachmentService attachmentService;
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public R detail(@PathVariable("id") String id, String workspaceId) {
|
|
||||||
T.VerifyUtil.is(workspaceId).notNull();
|
|
||||||
ApplicationEntity entity = applicationService.detail(id, workspaceId);
|
|
||||||
if (T.ObjectUtil.isNull(entity)) {
|
|
||||||
throw new ASWException(RCode.APP_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return R.ok().putData("record", entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public R list(@RequestParam Map<String, Object> params) {
|
|
||||||
T.VerifyUtil.is(params).notNull()
|
|
||||||
.and(T.MapUtil.getStr(params, "workspaceId")).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
|
||||||
Page page = applicationService.queryList(params);
|
|
||||||
return R.ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public R add(@RequestParam(required = true) String basic,
|
|
||||||
@RequestParam(required = false) String signature,
|
|
||||||
@RequestParam(required = false) String note,
|
|
||||||
@RequestParam(required = false) String hrefs,
|
|
||||||
@RequestParam(required = false, value = "files") List<MultipartFile> fileList) {
|
|
||||||
// validate
|
|
||||||
ApplicationEntity entity;
|
|
||||||
try {
|
|
||||||
entity = T.JSONUtil.toBean(basic, ApplicationEntity.class);
|
|
||||||
|
|
||||||
if (T.StrUtil.isNotEmpty(signature)) {
|
|
||||||
ApplicationSignatureEntity signatureEntity = T.JSONUtil.toBean(signature, ApplicationSignatureEntity.class);
|
|
||||||
entity.setSignature(signatureEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (T.StrUtil.isNotEmpty(note)) {
|
|
||||||
ApplicationNoteEntity noteEntity = T.JSONUtil.toBean(note, ApplicationNoteEntity.class);
|
|
||||||
entity.setNote(noteEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (T.StrUtil.isNotEmpty(hrefs)) {
|
|
||||||
T.JSONUtil.toList(hrefs, ApplicationHrefEntity.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e, "[add] [param format error]");
|
|
||||||
throw new ASWException(RCode.ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
T.VerifyUtil.is(entity).notNull()
|
|
||||||
.and(entity.getName()).notEmpty(RCode.APP_NAME_CANNOT_EMPTY)
|
|
||||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
|
||||||
|
|
||||||
// save application
|
|
||||||
ApplicationEntity applicationEntity = applicationService.saveApplication(entity);
|
|
||||||
|
|
||||||
// save attachment
|
|
||||||
fileList = T.CollUtil.defaultIfEmpty(fileList, new ArrayList<>());
|
|
||||||
for (MultipartFile file : fileList) {
|
|
||||||
attachmentService.saveAttachment(file.getResource(), applicationEntity.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// save href
|
|
||||||
if (T.StrUtil.isNotEmpty(hrefs)) {
|
|
||||||
List<ApplicationHrefEntity> hrefList = T.JSONUtil.toList(hrefs, ApplicationHrefEntity.class);
|
|
||||||
hrefService.updateBatchHref(applicationEntity.getId(), hrefList);
|
|
||||||
}
|
|
||||||
return R.ok().putData("id", applicationEntity.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
public R update(@RequestBody ApplicationEntity entity) {
|
|
||||||
T.VerifyUtil.is(entity).notNull()
|
|
||||||
.and(entity.getId()).notEmpty(RCode.ID_CANNOT_EMPTY)
|
|
||||||
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
|
|
||||||
//.and(entity.getSignature()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
|
|
||||||
//.and(entity.getNote()).notEmpty(RCode.APP_PROPERTIES_CANNOT_EMPTY)
|
|
||||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
|
||||||
|
|
||||||
ApplicationEntity applicationEntity = applicationService.updateApplication(entity);
|
|
||||||
return R.ok().putData("id", applicationEntity.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/{id}/basic")
|
|
||||||
public R basic(@PathVariable String id, @RequestBody ApplicationEntity entity) {
|
|
||||||
T.VerifyUtil.is(entity).notNull()
|
|
||||||
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
|
|
||||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
|
||||||
entity.setId(id);
|
|
||||||
ApplicationEntity app = applicationService.updateBasic(entity);
|
|
||||||
return R.ok().putData("id", app.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{applicationId}/signature")
|
|
||||||
public R updateSignature(@PathVariable("applicationId") String applicationId, @RequestBody ApplicationSignatureEntity signature) {
|
|
||||||
T.VerifyUtil.is(signature).notNull()
|
|
||||||
.and(signature.getContent()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
|
|
||||||
.and(signature.getContent()).json(RCode.APP_SURROGATES_CANNOT_EMPTY);
|
|
||||||
|
|
||||||
signatureService.saveSignature(signature, applicationId);
|
|
||||||
return R.ok().putData("id", signature.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{applicationId}/note")
|
|
||||||
public R updateNote(@PathVariable("applicationId") String applicationId, @RequestBody ApplicationNoteEntity note) {
|
|
||||||
T.VerifyUtil.is(note).notNull();
|
|
||||||
//.and(note.getContent()).notEmpty(RCode.APP_NOTE_CONTENT_CANNOT_EMPTY);
|
|
||||||
|
|
||||||
noteService.saveNote(note, applicationId);
|
|
||||||
return R.ok().putData("id", note.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
public R delete(String[] ids) {
|
|
||||||
T.VerifyUtil.is(ids).notEmpty();
|
|
||||||
applicationService.removeApplication(T.ListUtil.of(ids));
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{applicationId}/attachment")
|
|
||||||
public R queryAttachment(@PathVariable String applicationId) {
|
|
||||||
T.VerifyUtil.is(applicationId).notNull();
|
|
||||||
|
|
||||||
List<ApplicationAttachmentEntity> list = attachmentService.list(new LambdaQueryWrapper<ApplicationAttachmentEntity>().eq(ApplicationAttachmentEntity::getApplicationId, applicationId));
|
|
||||||
return R.ok().putData("records", list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{applicationId}/attachment/{attachmentId}")
|
|
||||||
public void downloadAttachment(HttpServletResponse response, @PathVariable String applicationId, @PathVariable String attachmentId) throws IOException {
|
|
||||||
T.VerifyUtil.is(applicationId).notNull()
|
|
||||||
.and(attachmentId).notNull();
|
|
||||||
|
|
||||||
attachmentService.download(response, applicationId, attachmentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/{applicationId}/attachment")
|
|
||||||
public R uploadAttachment(@PathVariable String applicationId, @RequestParam("files") List<MultipartFile> fileList) {
|
|
||||||
|
|
||||||
List<ApplicationAttachmentEntity> recordList = T.ListUtil.list(true);
|
|
||||||
for (int i = 0; i < fileList.size(); i++) {
|
|
||||||
MultipartFile file = fileList.get(i);
|
|
||||||
ApplicationAttachmentEntity attachmentEntity = attachmentService.saveAttachment(file.getResource(), applicationId);
|
|
||||||
recordList.add(attachmentEntity);
|
|
||||||
}
|
|
||||||
return R.ok().putData("records", recordList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{applicationId}/attachment")
|
|
||||||
public R removedAttachment(@PathVariable String applicationId, @RequestParam String ids) {
|
|
||||||
|
|
||||||
attachmentService.removedAttachment(applicationId, ids);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{applicationId}/signature")
|
|
||||||
public R querySignature(@PathVariable String applicationId) {
|
|
||||||
T.VerifyUtil.is(applicationId).notNull();
|
|
||||||
List<ApplicationSignatureEntity> signatureList = signatureService.queryList(applicationId);
|
|
||||||
return R.ok().putData("records", signatureList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{applicationId}/signature/{oldVersion}/{newVersion}")
|
|
||||||
public R signatureCompare(@PathVariable("applicationId") String applicationId,
|
|
||||||
@PathVariable("oldVersion") String oldVersion,
|
|
||||||
@PathVariable("newVersion") String newVersion) {
|
|
||||||
List<ApplicationSignatureEntity> list = signatureService.compare(applicationId, oldVersion, newVersion);
|
|
||||||
return R.ok().putData("records", list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/{applicationId}/signature/{version}/restore")
|
|
||||||
public R restore(@PathVariable("applicationId") String applicationId,
|
|
||||||
@PathVariable("version") String version) {
|
|
||||||
signatureService.restore(applicationId, version);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// application href
|
|
||||||
@GetMapping("/{applicationId}/href")
|
|
||||||
public R queryHref(@PathVariable String applicationId) {
|
|
||||||
List<ApplicationHrefEntity> entityList = hrefService.queryList(applicationId);
|
|
||||||
return R.ok().putData("records", entityList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/{applicationId}/href", method = {RequestMethod.POST, RequestMethod.PUT})
|
|
||||||
public R updateBatchHref(@PathVariable String applicationId, @RequestBody List<ApplicationHrefEntity> hrefList) {
|
|
||||||
// validate
|
|
||||||
ApplicationEntity application = applicationService.getById(applicationId);
|
|
||||||
T.VerifyUtil.is(application).notNull(RCode.APP_NOT_EXIST);
|
|
||||||
|
|
||||||
for (ApplicationHrefEntity href : hrefList) {
|
|
||||||
T.VerifyUtil.is(href).notNull()
|
|
||||||
.and(href.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
|
|
||||||
.and(href.getUrl()).notEmpty(RCode.PARAM_CANNOT_EMPTY);
|
|
||||||
|
|
||||||
href.setApplicationId(applicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// save or update batch
|
|
||||||
List<ApplicationHrefEntity> entityList = hrefService.updateBatchHref(hrefList);
|
|
||||||
List<Map<String, String>> records = entityList.stream()
|
|
||||||
.map(entity -> Map.of("id", entity.getId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
return R.ok().putData("records", records);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{applicationId}/href")
|
|
||||||
public R deleteHref(@PathVariable String applicationId, @RequestParam String[] ids) {
|
|
||||||
// remove
|
|
||||||
hrefService.remove(new LambdaQueryWrapper<ApplicationHrefEntity>()
|
|
||||||
.eq(ApplicationHrefEntity::getApplicationId, applicationId)
|
|
||||||
.in(ApplicationHrefEntity::getId, T.ListUtil.of(ids)));
|
|
||||||
return R.ok();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@PostMapping("/import")
|
|
||||||
public synchronized R importApplication(@RequestParam String workspaceId,
|
|
||||||
@RequestParam String branchName,
|
|
||||||
@RequestParam(defaultValue = "tsg2402") String format,
|
|
||||||
@RequestParam(value = "files") List<MultipartFile> fileList) {
|
|
||||||
// validate
|
// validate
|
||||||
WorkspaceEntity workspace = workspaceService.getById(workspaceId);
|
WorkspaceEntity workspace = workspaceService.getById(workspaceId);
|
||||||
T.VerifyUtil.is(workspace).notNull(RCode.WORKSPACE_NOT_EXIST);
|
T.VerifyUtil.is(workspace).notNull(RCode.WORKSPACE_NOT_EXIST);
|
||||||
@@ -311,9 +78,9 @@ public class ApplicationController {
|
|||||||
return R.ok().putData("records", records);
|
return R.ok().putData("records", records);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/{workspaceId}/branch/{branchName}/application/export")
|
||||||
public void exportApplication(@RequestParam String workspaceId,
|
public void exportApplication(@PathVariable("workspaceId") String workspaceId,
|
||||||
@RequestParam String branchName,
|
@PathVariable("branchName") String branchName,
|
||||||
@RequestParam String names,
|
@RequestParam String names,
|
||||||
@RequestParam(defaultValue = "tsg2402") String format,
|
@RequestParam(defaultValue = "tsg2402") String format,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user