<%_ if (position === 'import') { _%>
import org.apache.commons.lang3.ArrayUtils;
import cn.hutool.core.bean.BeanUtil;
<%_ } _%>
<%_ if (position === 'method') { _%>

     /**
     * {@code POST  /} : Create a new uploadFile.
     *
     * @param uploadFileDTO the UploadFileDTO to create.
     * @param file the uploadFile to create.
     * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new uploadFileDTO, or with status {@code 400 (Bad Request)} if the uploadFile has already an ID.
     * @throws URISyntaxException if the Location URI syntax is incorrect.
     */
    @PostMapping("")
    public ResponseEntity<UploadFileDTO> createUploadFile(
        @RequestPart(required = false) UploadFileDTO uploadFileDTO,
        @RequestPart(name = "file", required = false) MultipartFile file,
        @RequestPart(name = "files", required = false) MultipartFile[] files
    ) throws Exception {
        log.debug("REST request to save UploadFile : {}, {}", file.getOriginalFilename(), files);
        if (file.isEmpty() && ArrayUtils.isEmpty(files)) {
            throw new BadRequestAlertException("A new uploadImage cannot null", ENTITY_NAME, "imageisnull");
        }
        if (Objects.isNull(uploadFileDTO)) {
            uploadFileDTO = new UploadFileDTO();
        }
        List<MultipartFile> uploadFiles = new ArrayList<>();
        if (!file.isEmpty()) {
            uploadFiles.add(file);
        }
        if (ArrayUtils.isNotEmpty(files)) {
            uploadFiles.addAll(Arrays.asList(files));
        }
        List<UploadFileDTO> allUploadFileDTOS = new ArrayList<>();
        for (MultipartFile uploadFile : uploadFiles) {
            uploadFileDTO.setFile(uploadFile);
            allUploadFileDTOS.add(uploadFileService.save(uploadFileDTO));
            uploadFileDTO = BeanUtil.toBean(uploadFileDTO, UploadFileDTO.class);
        }
        UploadFileDTO result = allUploadFileDTOS.get(0);
        return ResponseEntity.created(new URI("/api/upload-files/" + result.getId()))
            .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
            .body(result);
    }
<%_ } _%>
