[스프링 마이크로서비스 코딩 공작소] 1장 책에 필기
공동 책임 모델
https://aws.amazon.com/ko/compliance/shared-responsibility-model/
package com.optimagrowth.license.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "v1/organization/{organizationId}/license")
public class LicenseController {
}
package com.optimagrowth.license.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class License {
private int id;
private String licenseId;
private String description;
private String organizationId;
private String productName;
private String licenseType;
}
DB가 없어서 임의의 데이터를 만드는 것 !
package com.optimagrowth.license.service;
import com.optimagrowth.license.model.License;
import org.springframework.stereotype.Service;
import java.util.Random;
// 각 메서드는 CRUD 테스트를 위해서 임의의 데이터를 반환하는 코드를 추가
@Service
public class LicenseService {
public License getLicense(String licenseId, String organizationId) {
License license = new License();
license.setId(new Random().nextInt(1000));
license.setLicenseId(licenseId);
license.setOrganizationId(organizationId);
license.setDescription("Software product");
license.setProductName("Ostock");
license.setLicenseType("full");
return license;
}
public String createLicense(License license, String organizationId) {
String responseMessage = null;
if (license != null) {
license.setOrganizationId(organizationId);
responseMessage = String.format("License created %s", license.toString());
}
return responseMessage;
}
public String updateLicense(License license, String organizationId) {
String responseMessage = null;
if (license != null) {
license.setOrganizationId(organizationId);
responseMessage = String.format("License updated %s", license.toString());
}
return responseMessage;
}
public String deleteLicense(String licenseId, String organizationId) {
String responseMessage = null;
responseMessage
= String.format("Deleting license with id %s for the organization %s",
licenseId, organizationId);
return responseMessage;
}
}
package com.optimagrowth.license.controller;
import com.optimagrowth.license.model.License;
import com.optimagrowth.license.service.LicenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "v1/organization/{organizationId}/license")
public class LicenseController {
@Autowired
private LicenseService licenseService;
@GetMapping(value = "/{licenseId}")
public ResponseEntity<License> getLicense(
@PathVariable("organizationId") String organizationId,
@PathVariable("licenseId") String licenseId) {
License license = licenseService.getLicense(licenseId, organizationId);
return ResponseEntity.ok(license);
}
@PutMapping
public ResponseEntity<String> updateLicense(
@PathVariable("organizationId") String organizationId,
@RequestBody License request) {
return ResponseEntity.ok(licenseService.updateLicense(request, organizationId));
}
@PostMapping
public ResponseEntity<String> createLicense(
@PathVariable("organizationId") String organizationId,
@RequestBody License request) {
return ResponseEntity.ok(licenseService.createLicense(request, organizationId));
}
@DeleteMapping(value= "/{licenseId}")
public ResponseEntity<String> createLicense(
@PathVariable("organizationId") String organizationId,
@PathVariable("licenseId") String licenseId) {
return ResponseEntity.ok(licenseService.deleteLicense(licenseId, organizationId));
}
}
organizationId: optimaGrowth
licenseId: 1234567890
목적: 배웠던 내용 정리하기, 함께 일할 때 발생하는 문제 대처
기간: 2월 21일(금) ~ 27일(목)
* 27일은 프로젝트 결과 발표 및 리뷰를 진행하므로 개발 일정에서 제외합니다.
내용: 아래 요구사항을 만족하는 웹 애플리케이션 개발
1. 요구사항
제출기한 : 2월 27일 9시까지
제출방법 : 공유디렉터리에 조별로 제출
파일형식 : 원본파일과 PDF파일을 함께 제출
파 일 명 : 1조-결과보고서.pptx / 1조-결과보고서.pdf (원본 제출이 불가한 경우 제외)
참조 자료 및 평가 방법은 추후 공지