Kaynağa Gözat

api-update-stamp

new-feature
Viet.LeQ2 1 yıl önce
ebeveyn
işleme
d2e0584734
4 değiştirilmiş dosya ile 146 ekleme ve 4 silme
  1. BIN
      build/libs/smart-farm-0.0.1-SNAPSHOT-original.war
  2. BIN
      build/libs/smart-farm-0.0.1-SNAPSHOT.war
  3. +96
    -0
      src/main/java/vn/azteam/tpf/service/dto/TBExampleStampUpdateDTO.java
  4. +50
    -4
      src/main/java/vn/azteam/tpf/web/rest/TBExampleStampResource.java

BIN
build/libs/smart-farm-0.0.1-SNAPSHOT-original.war Dosyayı Görüntüle


BIN
build/libs/smart-farm-0.0.1-SNAPSHOT.war Dosyayı Görüntüle


+ 96
- 0
src/main/java/vn/azteam/tpf/service/dto/TBExampleStampUpdateDTO.java Dosyayı Görüntüle

@@ -0,0 +1,96 @@
package vn.azteam.tpf.service.dto;

import java.io.Serializable;

public class TBExampleStampUpdateDTO implements Serializable {

private Long id;

private String exampleStampName;

private String description;

private Integer width;

private Integer height;

private Integer x;

private Integer y;

private Integer size;

private String exampleStampImage;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getExampleStampName() {
return exampleStampName;
}

public void setExampleStampName(String exampleStampName) {
this.exampleStampName = exampleStampName;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Integer getWidth() {
return width;
}

public void setWidth(Integer width) {
this.width = width;
}

public Integer getHeight() {
return height;
}

public void setHeight(Integer height) {
this.height = height;
}

public Integer getX() {
return x;
}

public void setX(Integer x) {
this.x = x;
}

public Integer getY() {
return y;
}

public void setY(Integer y) {
this.y = y;
}

public Integer getSize() {
return size;
}

public void setSize(Integer size) {
this.size = size;
}

public String getExampleStampImage() {
return exampleStampImage;
}

public void setExampleStampImage(String exampleStampImage) {
this.exampleStampImage = exampleStampImage;
}
}

+ 50
- 4
src/main/java/vn/azteam/tpf/web/rest/TBExampleStampResource.java Dosyayı Görüntüle

@@ -14,10 +14,7 @@ import vn.azteam.tpf.Constants.Constants;
import vn.azteam.tpf.service.TBExampleStampQueryService;
import vn.azteam.tpf.service.TBExampleStampService;
import vn.azteam.tpf.service.UserService;
import vn.azteam.tpf.service.dto.TBExampleStampCreationDTO;
import vn.azteam.tpf.service.dto.TBExampleStampCriteria;
import vn.azteam.tpf.service.dto.TBExampleStampDTO;
import vn.azteam.tpf.service.dto.UserDTO;
import vn.azteam.tpf.service.dto.*;
import vn.azteam.tpf.service.util.PageableUtil;
import vn.azteam.tpf.service.util.UserRoleUtil;
import vn.azteam.tpf.web.rest.errors.BadRequestAlertException;
@@ -151,4 +148,53 @@ public class TBExampleStampResource {
throw new RuntimeException();
}
}

@PutMapping("/tb-example-stamp")
public ResponseEntity<TBExampleStampDTO> updateStamp(@RequestPart("data") TBExampleStampUpdateDTO tBExampleStampUpdateDTO,
@RequestPart("file") MultipartFile file) {

UserDTO currentUser = userService.getCurrentUserDTO().get();
if (tBExampleStampUpdateDTO.getId() == null) {
throw new BadRequestAlertException("1019", ENTITY_NAME, "1019");
}

try {
TBExampleStampDTO tbExampleStampDTO = new TBExampleStampDTO();
tbExampleStampDTO.setId(tBExampleStampUpdateDTO.getId());
tbExampleStampDTO.setY(tBExampleStampUpdateDTO.getY());
tbExampleStampDTO.setX(tBExampleStampUpdateDTO.getX());
tbExampleStampDTO.setWidth(tBExampleStampUpdateDTO.getWidth());
tbExampleStampDTO.setHeight(tBExampleStampUpdateDTO.getHeight());
tbExampleStampDTO.setDescription(tBExampleStampUpdateDTO.getDescription());
tbExampleStampDTO.setExampleStampName("");
tbExampleStampDTO.setSize(tBExampleStampUpdateDTO.getSize());

tbExampleStampDTO.setModifiedDate(Instant.now());
tbExampleStampDTO.setModifiedById(currentUser.getUserId());

TBExampleStampDTO result = null;
Boolean hasViolationException = false;
do {
try {
if (!file.isEmpty()) {
tbExampleStampDTO = tBExampleStampQueryService.saveUploadedFile(tbExampleStampDTO, file, Constants.EXAMPLE_STAMP);
}
result = tBExampleStampService.save(tbExampleStampDTO);
} catch (org.springframework.dao.DataIntegrityViolationException ex) {
if (ex.getMessage().contains("ux_tb_example_stamp")) {
hasViolationException = true;
} else {
throw ex;
}
}
}
while (hasViolationException);

return ResponseEntity.created(new URI("/api/tb-example-stamp/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
} catch (Exception exception) {
throw new RuntimeException();
}
}
}

Yükleniyor…
İptal
Kaydet