mirror of
https://github.com/cekis/swg-api
synced 2026-01-16 19:05:10 -05:00
Initial Commit
This commit is contained in:
BIN
.gradle/6.7/executionHistory/executionHistory.lock
Normal file
BIN
.gradle/6.7/executionHistory/executionHistory.lock
Normal file
Binary file not shown.
BIN
.gradle/6.7/fileChanges/last-build.bin
Normal file
BIN
.gradle/6.7/fileChanges/last-build.bin
Normal file
Binary file not shown.
BIN
.gradle/6.7/fileHashes/fileHashes.lock
Normal file
BIN
.gradle/6.7/fileHashes/fileHashes.lock
Normal file
Binary file not shown.
0
.gradle/6.7/gc.properties
Normal file
0
.gradle/6.7/gc.properties
Normal file
BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock
Normal file
BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock
Normal file
Binary file not shown.
2
.gradle/buildOutputCleanup/cache.properties
Normal file
2
.gradle/buildOutputCleanup/cache.properties
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#Fri Feb 26 21:25:37 PST 2021
|
||||||
|
gradle.version=6.7
|
||||||
BIN
.gradle/checksums/checksums.lock
Normal file
BIN
.gradle/checksums/checksums.lock
Normal file
Binary file not shown.
0
.gradle/configuration-cache/gc.properties
Normal file
0
.gradle/configuration-cache/gc.properties
Normal file
0
.gradle/vcs-1/gc.properties
Normal file
0
.gradle/vcs-1/gc.properties
Normal file
64
pom.xml
Normal file
64
pom.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.swg</groupId>
|
||||||
|
<artifactId>swg-api</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>swg-api</name>
|
||||||
|
<description>API for SWG</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.11</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle.database.jdbc</groupId>
|
||||||
|
<artifactId>ojdbc10</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<executable>true</executable>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
13
src/main/java/swg/SwgRestApiApplication.java
Normal file
13
src/main/java/swg/SwgRestApiApplication.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/swg/controller/AccountController.java
Normal file
25
src/main/java/swg/controller/AccountController.java
Normal file
@@ -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<Account> getAllAccounts() {
|
||||||
|
return accountService.getAllAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{stationId}", method = RequestMethod.GET)
|
||||||
|
public Account getByStationId(@PathVariable("stationId") Long stationId) {
|
||||||
|
return accountService.getAccountByStationId(stationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/main/java/swg/dao/AccountDao.java
Normal file
12
src/main/java/swg/dao/AccountDao.java
Normal file
@@ -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<Account, Integer> {
|
||||||
|
public Account findByStationId(Long stationId);
|
||||||
|
}
|
||||||
79
src/main/java/swg/entity/Account.java
Normal file
79
src/main/java/swg/entity/Account.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/main/java/swg/service/AccountService.java
Normal file
22
src/main/java/swg/service/AccountService.java
Normal file
@@ -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<Account> getAllAccounts() {
|
||||||
|
return this.accountDao.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account getAccountByStationId(Long stationId) {
|
||||||
|
return this.accountDao.findByStationId(stationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/main/resources/application.properties
Normal file
10
src/main/resources/application.properties
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user