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

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