-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/shipper2 #4
Changes from 1 commit
53786bb
aa08bf3
536e792
072b0c3
3737d84
5ef0b3d
a659479
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.flab.moduletrucker.truck.repository; | ||
|
||
import com.flab.moduletrucker.truck.domain.Account; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AccountRepository { | ||
Account save(Account account); | ||
public interface AccountRepository extends JpaRepository<Account, String> { | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
package com.flab.moduletrucker.truck.repository; | ||
|
||
import com.flab.moduletrucker.truck.domain.Car; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface CarRepository { | ||
|
||
Car save(Car car); | ||
|
||
Optional<Car> findById(String carId); | ||
public interface CarRepository extends JpaRepository<Car, String> { | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
package com.flab.moduletrucker.truck.repository; | ||
|
||
import com.flab.moduletrucker.truck.domain.Contract; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
public interface ContractRepository extends JpaRepository<Contract, String> { | ||
|
||
public interface ContractRepository { | ||
Contract save(Contract contract); | ||
|
||
Optional<Contract> findById(String contractId); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.flab.moduletrucker.truck.service; | ||
|
||
import com.flab.moduletrucker.truck.domain.Account; | ||
import com.flab.moduletrucker.truck.dto.TruckerDTO; | ||
import com.flab.moduletrucker.truck.repository.AccountRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class AccountService { | ||
|
||
private final AccountRepository accountRepository; | ||
|
||
public String createAccount(TruckerDTO.AccountRequest req) { | ||
Account account = req.dtoToDomain(req); | ||
Account save = accountRepository.save(account); | ||
return save.getAccountId(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||
package com.flab.moduletrucker.truck.service; | ||||||
|
||||||
import com.flab.moduletrucker.truck.domain.Car; | ||||||
import com.flab.moduletrucker.truck.dto.TruckerDTO; | ||||||
import com.flab.moduletrucker.truck.repository.CarRepository; | ||||||
import lombok.RequiredArgsConstructor; | ||||||
import lombok.extern.slf4j.Slf4j; | ||||||
import org.springframework.stereotype.Service; | ||||||
|
||||||
import java.util.Optional; | ||||||
|
||||||
@Slf4j | ||||||
@Service | ||||||
@RequiredArgsConstructor | ||||||
public class CarService { | ||||||
|
||||||
private final CarRepository carRepository; | ||||||
|
||||||
public String createCar(TruckerDTO.CarRequest req) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Car car = req.dtoToDomain(req); | ||||||
Car save = carRepository.save(car); | ||||||
return save.getCarId(); | ||||||
} | ||||||
|
||||||
public TruckerDTO.CarInfo getCar(String carId) { | ||||||
Optional<Car> byId = carRepository.findById(carId); | ||||||
if (byId.isPresent()) { | ||||||
Car car = byId.get(); | ||||||
return new TruckerDTO.CarInfo(car); | ||||||
} else { | ||||||
throw new RuntimeException("car not found"); | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
spring.application.name=module-trucker | ||
server.port=8002 | ||
server.port=8002 | ||
|
||
# mysql | ||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||
spring.datasource.url=jdbc:mysql://localhost:3306/truck_matching?serverTimezone=UTC&characterEncoding=UTF-8 | ||
spring.datasource.username=root | ||
spring.datasource.password=123963 |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전 여전히 각각의 서비스들을 컨트롤러에 가져오는 것의 이점을 아직 잘 모르겠어요!! 이 경우에도 특정 URL은 하나의 서비스만 사용하는 것 같기도 하구요. :-)