Skip to content

Commit

Permalink
Merge pull request #152 from in27sung/develop2
Browse files Browse the repository at this point in the history
Develop2
  • Loading branch information
in27sung authored Dec 16, 2024
2 parents a0f6709 + df7f07a commit 5797a77
Show file tree
Hide file tree
Showing 10 changed files with 1,528 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion stockMate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,18 @@ public String dash(Locale locale, Model model) {

return "dashboard";
}

// http://localhost:8088/qrScanner
@RequestMapping(value = "/qrScanner", method = RequestMethod.GET)
public String qrScanner(Locale locale, Model model) {
logger.info("😁Welcome scanner😁! The client locale is {}.", locale);

Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

String formattedDate = dateFormat.format(date);

model.addAttribute("serverTime", formattedDate );

return "qrScanner";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.stockm8.domain.dto.QRCodeDTO;
import com.stockm8.domain.dto.ScanProductDTO;
import com.stockm8.domain.vo.ProductVO;
import com.stockm8.domain.vo.QRCodeVO;
import com.stockm8.exceptions.QRCodeGenerationException;
Expand Down Expand Up @@ -107,5 +110,36 @@ public ResponseEntity<Resource> downloadQRCode(@RequestBody QRCodeDTO qrCodeDTO)
.contentLength(qrCodeFile.length())
.body(resource);
}


// QR 코드 스캔 후 DB 조회
@PostMapping("/scan")
public Map<String, Object> scanProduct(@RequestBody ScanProductDTO scanProduct) {
Map<String, Object> response = new HashMap<>();
Gson gson = new Gson();

try {
// QR 코드 데이터에서 상품 ID 추출
int productId = scanProduct.getProductId();

// DB에서 상품 정보 조회
ProductVO product = productService.getProductByID(productId);

if (product != null) {
response.put("success", true);
response.put("productName", product.getProductName());
response.put("productPrice", product.getProductPrice());
response.put("productUnit", product.getBaseUnit());
response.put("productBarcode", product.getProductBarcode());
} else {
response.put("success", false);
response.put("message", "해당 상품을 찾을 수 없습니다.");
}
} catch (Exception e) {
response.put("success", false);
response.put("message", "오류가 발생했습니다: " + e.getMessage());
}
return response;
}

}
23 changes: 23 additions & 0 deletions stockMate/src/main/java/com/stockm8/domain/dto/ScanProductDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.stockm8.domain.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@Data
public class ScanProductDTO {
@JsonProperty("productId")
private int productId;

@JsonProperty("barcode")
private String barcode;

@JsonProperty("businessId")
private int businessId;

@JsonProperty("baseUnit")
private String baseUnit;

@JsonProperty("setSize")
private int setSize;
}
734 changes: 367 additions & 367 deletions stockMate/src/main/webapp/WEB-INF/views/order/register2.jsp

Large diffs are not rendered by default.

Loading

0 comments on commit 5797a77

Please sign in to comment.