#32 multi module: use common module

This commit is contained in:
haerong22
2023-01-29 01:51:43 +09:00
parent d396757563
commit e41d43cd65
6 changed files with 81 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
###
GET http://localhost:8080/save

View File

@@ -3,7 +3,12 @@ package com.example.moduleapi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@SpringBootApplication(
scanBasePackages = {
"com.example.moduleapi",
"com.example.modulecommon"
}
)
public class ModuleApiApplication {
public static void main(String[] args) {

View File

@@ -0,0 +1,23 @@
package com.example.moduleapi.controller;
import com.example.moduleapi.service.DemoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
public class DemoController {
private final DemoService demoService;
@GetMapping("save")
public String save() {
return demoService.save();
}
@GetMapping("/find")
public String find() {
return demoService.find();
}
}

View File

@@ -0,0 +1,23 @@
package com.example.moduleapi.service;
import com.example.modulecommon.enums.CodeEnum;
import com.example.modulecommon.sevice.CommonDemoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class DemoService {
private final CommonDemoService commonDemoService;
public String save() {
System.out.println(CodeEnum.SUCCESS.getCode());
System.out.println(commonDemoService.commonService());
return "save";
}
public String find() {
return "find";
}
}

View File

@@ -0,0 +1,16 @@
package com.example.modulecommon.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum CodeEnum {
SUCCESS("0000", "SUCCESS"),
UNKNOWN_ERROR("9999", "UNKNOWN_ERROR"),
;
private final String code;
private final String message;
}

View File

@@ -0,0 +1,11 @@
package com.example.modulecommon.sevice;
import org.springframework.stereotype.Service;
@Service
public class CommonDemoService {
public String commonService() {
return "commonService";
}
}