-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added react, bootstrap, and api controllers
- Loading branch information
Showing
25 changed files
with
4,789 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
HELP.md | ||
|
||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/unit3project/demo/AuthenticationFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.unit3project.demo; | ||
|
||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
public class AuthenticationFilter implements HandlerInterceptor { | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/unit3project/demo/Controllers/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.unit3project.demo.Controllers; | ||
|
||
import com.unit3project.demo.Models.Data.UserRepository; | ||
import com.unit3project.demo.Models.User; | ||
import jakarta.servlet.http.HttpSession; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import java.util.Optional; | ||
|
||
@Controller | ||
public class AuthController { | ||
|
||
@Autowired | ||
private UserRepository userRepository; | ||
|
||
private static final String userSessionKey = "user"; | ||
|
||
private static void setUserInSession(HttpSession session, User user) { | ||
session.setAttribute(userSessionKey,user.getId()); | ||
} | ||
|
||
public User getUserFromSession(HttpSession session) { | ||
Integer userId = (Integer) session.getAttribute(userSessionKey); | ||
|
||
if (userId == null) { | ||
return null; | ||
} | ||
|
||
Optional<User> userOpt = userRepository.findById(userId); | ||
|
||
if(userOpt.isEmpty()) { | ||
return null; | ||
} | ||
|
||
return userOpt.get(); | ||
} | ||
|
||
//@GetMapping("/register") | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/unit3project/demo/Controllers/api/authApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.unit3project.demo.Controllers.api; | ||
|
||
import com.unit3project.demo.Controllers.AuthController; | ||
import com.unit3project.demo.Models.User; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@CrossOrigin(origins = "http://localhost:5173", maxAge = 3600) | ||
@RestController | ||
@RequestMapping("/api") | ||
public class authApiController extends AuthController { | ||
@GetMapping("/user") | ||
public List<User> getTestList() { | ||
List<User> tester = new ArrayList<>(); | ||
tester.add(new User("eric", "123456")); | ||
tester.add(new User("karl", "654321")); | ||
return tester; | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/unit3project/demo/Models/DTO/LogInDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.unit3project.demo.Models.DTO; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public class LogInDTO { | ||
|
||
@NotBlank(message = "Username is required") | ||
@Size(min = 3, max = 30, message = "Username must be 3-30 character long") | ||
private String username; | ||
|
||
@NotBlank(message = "Username is required") | ||
@Size(min = 6, max = 30, message = "Username must be 6-30 character long") | ||
private String password; | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/unit3project/demo/Models/DTO/RegisterDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.unit3project.demo.Models.DTO; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public class RegisterDTO extends LogInDTO { | ||
|
||
@NotBlank(message = "Username is required") | ||
@Size(min = 6, max = 30, message = "Username must be 6-30 character long") | ||
private String verifyPassword; | ||
|
||
public String getVerifyPassword() { | ||
return verifyPassword; | ||
} | ||
|
||
public void setVerifyPassword(String verifyPassword) { | ||
this.verifyPassword = verifyPassword; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
spring.application.name=Demo | ||
spring.datasource.url=jdbc:mysql://localhost:3306/nationalparkapp | ||
spring.datasource.username=nationalparkapp | ||
spring.datasource.password=115650Ejs | ||
|
||
# Specify the DBMS | ||
spring.jpa.database = MYSQL | ||
|
||
# Show or not log for each sql query | ||
spring.jpa.show-sql = false | ||
|
||
# Hibernate ddl auto (create, create-drop, update) | ||
spring.jpa.hibernate.ddl-auto = update | ||
|
||
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is | ||
# stripped before adding them to the entity manager) | ||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect | ||
|
||
#change the root URI for the api | ||
spring.data.rest.base-path=/api |
21 changes: 21 additions & 0 deletions
21
src/main/resources/static/js/national-park-app/.eslintrc.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, | ||
settings: { react: { version: '18.2' } }, | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react/jsx-no-target-blank': 'off', | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# React + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.