From e1bbc5e482e0de65e7ac8e52706dd412360fe932 Mon Sep 17 00:00:00 2001 From: Cekis Date: Sat, 27 Feb 2021 18:00:49 -0800 Subject: [PATCH] Initial Commit --- .../executionHistory/executionHistory.lock | Bin 0 -> 17 bytes .gradle/6.7/fileChanges/last-build.bin | Bin 0 -> 1 bytes .gradle/6.7/fileHashes/fileHashes.lock | Bin 0 -> 17 bytes .gradle/6.7/gc.properties | 0 .../buildOutputCleanup.lock | Bin 0 -> 17 bytes .gradle/buildOutputCleanup/cache.properties | 2 + .gradle/checksums/checksums.lock | Bin 0 -> 17 bytes .gradle/configuration-cache/gc.properties | 0 .gradle/vcs-1/gc.properties | 0 pom.xml | 64 ++++++++++++++ src/main/java/swg/SwgRestApiApplication.java | 13 +++ .../swg/controller/AccountController.java | 25 ++++++ src/main/java/swg/dao/AccountDao.java | 12 +++ src/main/java/swg/entity/Account.java | 79 ++++++++++++++++++ src/main/java/swg/service/AccountService.java | 22 +++++ src/main/resources/application.properties | 10 +++ 16 files changed, 227 insertions(+) create mode 100644 .gradle/6.7/executionHistory/executionHistory.lock create mode 100644 .gradle/6.7/fileChanges/last-build.bin create mode 100644 .gradle/6.7/fileHashes/fileHashes.lock create mode 100644 .gradle/6.7/gc.properties create mode 100644 .gradle/buildOutputCleanup/buildOutputCleanup.lock create mode 100644 .gradle/buildOutputCleanup/cache.properties create mode 100644 .gradle/checksums/checksums.lock create mode 100644 .gradle/configuration-cache/gc.properties create mode 100644 .gradle/vcs-1/gc.properties create mode 100644 pom.xml create mode 100644 src/main/java/swg/SwgRestApiApplication.java create mode 100644 src/main/java/swg/controller/AccountController.java create mode 100644 src/main/java/swg/dao/AccountDao.java create mode 100644 src/main/java/swg/entity/Account.java create mode 100644 src/main/java/swg/service/AccountService.java create mode 100644 src/main/resources/application.properties diff --git a/.gradle/6.7/executionHistory/executionHistory.lock b/.gradle/6.7/executionHistory/executionHistory.lock new file mode 100644 index 0000000000000000000000000000000000000000..1ad5ef023e946fe2dbf204a4d3dbaf4c941b6421 GIT binary patch literal 17 TcmZQB+pzbj_Ljy(1}FdkIDQ0e literal 0 HcmV?d00001 diff --git a/.gradle/6.7/fileChanges/last-build.bin b/.gradle/6.7/fileChanges/last-build.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001 diff --git a/.gradle/6.7/fileHashes/fileHashes.lock b/.gradle/6.7/fileHashes/fileHashes.lock new file mode 100644 index 0000000000000000000000000000000000000000..ef5471c297b4bd7a1dca532dbd86b3a9c0b867fe GIT binary patch literal 17 TcmZSf*Ymh*()aHp0~7!NG5!Qs literal 0 HcmV?d00001 diff --git a/.gradle/6.7/gc.properties b/.gradle/6.7/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000000000000000000000000000000000000..8cc212f2bdc366c99409400199a7b04ffcc0de9c GIT binary patch literal 17 UcmZQ>%>9_Sg-7{00|YPv05e1c4*&oF literal 0 HcmV?d00001 diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..5359064 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri Feb 26 21:25:37 PST 2021 +gradle.version=6.7 diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock new file mode 100644 index 0000000000000000000000000000000000000000..46f976bf87bc508b1d6d1bb12bcef42f8a289ef0 GIT binary patch literal 17 TcmZQxe4wUgf@h5j0~7!NGv@>N literal 0 HcmV?d00001 diff --git a/.gradle/configuration-cache/gc.properties b/.gradle/configuration-cache/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..87c9fea --- /dev/null +++ b/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.4.2 + + + + com.swg + swg-api + 0.0.1-SNAPSHOT + jar + + swg-api + API for SWG + + + 1.11 + UTF-8 + UTF-8 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-jdbc + + + com.oracle.database.jdbc + ojdbc10 + runtime + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + \ No newline at end of file diff --git a/src/main/java/swg/SwgRestApiApplication.java b/src/main/java/swg/SwgRestApiApplication.java new file mode 100644 index 0000000..24e136f --- /dev/null +++ b/src/main/java/swg/SwgRestApiApplication.java @@ -0,0 +1,13 @@ +package swg; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class SwgRestApiApplication { + public static void main(String[] args) { + SpringApplication.run(SwgRestApiApplication.class, args); + } +} diff --git a/src/main/java/swg/controller/AccountController.java b/src/main/java/swg/controller/AccountController.java new file mode 100644 index 0000000..a697388 --- /dev/null +++ b/src/main/java/swg/controller/AccountController.java @@ -0,0 +1,25 @@ +package swg.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import swg.entity.Account; +import swg.service.AccountService; + +import java.util.List; + +@RestController +@RequestMapping("/account") +public class AccountController { + @Autowired + AccountService accountService; + + @RequestMapping(value = "/all", method = RequestMethod.GET) + public List getAllAccounts() { + return accountService.getAllAccounts(); + } + + @RequestMapping(value = "/{stationId}", method = RequestMethod.GET) + public Account getByStationId(@PathVariable("stationId") Long stationId) { + return accountService.getAccountByStationId(stationId); + } +} diff --git a/src/main/java/swg/dao/AccountDao.java b/src/main/java/swg/dao/AccountDao.java new file mode 100644 index 0000000..580e6a8 --- /dev/null +++ b/src/main/java/swg/dao/AccountDao.java @@ -0,0 +1,12 @@ +package swg.dao; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import swg.entity.Account; + +import java.util.List; + +@Repository +public interface AccountDao extends JpaRepository { + public Account findByStationId(Long stationId); +} diff --git a/src/main/java/swg/entity/Account.java b/src/main/java/swg/entity/Account.java new file mode 100644 index 0000000..7394a51 --- /dev/null +++ b/src/main/java/swg/entity/Account.java @@ -0,0 +1,79 @@ +package swg.entity; + +import javax.persistence.*; + +@Entity +@NamedQuery(name = "Account.findByStationId", query = "SELECT a FROM Account a WHERE a.stationId = ?1") +@Table(name = "ACCOUNTS") +public class Account { + @Column(name = "STATION_ID") + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long stationId; + + @Column(name = "NUM_LOTS", nullable = true, length = 38) + private Long numLots; + + @Column(name = "IS_OUTCAST", nullable = true, length = 1) + private Character outcast; + + @Column(name = "CHEATER_LEVEL", nullable = true, length = 38) + private Long cheaterLevel; + + @Column(name = "MAX_LOTS_ADJUSTMENT", nullable = true, length = 38) + private Long maxLotsAdjustment; + + @Column(name = "HOUSE_ID", nullable = true, length = 38) + private Long houseId; + + protected Account() { + } + + public Long getStationId() { + return stationId; + } + + public void setStationId(Long stationId) { + this.stationId = stationId; + } + + public Long getNumLots() { + return numLots; + } + + public void setNumLots(Long numLots) { + this.numLots = numLots; + } + + public Character getOutcast() { + return outcast; + } + + public void setOutcast(Character outcast) { + this.outcast = outcast; + } + + public Long getCheaterLevel() { + return cheaterLevel; + } + + public void setCheaterLevel(Long cheaterLevel) { + this.cheaterLevel = cheaterLevel; + } + + public Long getMaxLotsAdjustment() { + return maxLotsAdjustment; + } + + public void setMaxLotsAdjustment(Long maxLotsAdjustment) { + this.maxLotsAdjustment = maxLotsAdjustment; + } + + public Long getHouseId() { + return houseId; + } + + public void setHouseId(Long houseId) { + this.houseId = houseId; + } +} diff --git a/src/main/java/swg/service/AccountService.java b/src/main/java/swg/service/AccountService.java new file mode 100644 index 0000000..0373f39 --- /dev/null +++ b/src/main/java/swg/service/AccountService.java @@ -0,0 +1,22 @@ +package swg.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import swg.dao.AccountDao; +import swg.entity.Account; + +import java.util.List; + +@Service +public class AccountService { + @Autowired + AccountDao accountDao; + + public List getAllAccounts() { + return this.accountDao.findAll(); + } + + public Account getAccountByStationId(Long stationId) { + return this.accountDao.findByStationId(stationId); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..947a253 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,10 @@ +## use create when running the app for the first time +## then change to "update" which just updates the schema when necessary +spring.jpa.hibernate.ddl-auto=none +spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect +spring.datasource.url= jdbc:oracle:thin:@192.168.68.135:1521:swg +spring.datasource.username=swg +spring.datasource.password=swg +spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver +## this shows the sql actions in the terminal logs +spring.jpa.show-sql=true