Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
437 commits
Select commit Hold shift + click to select a range
7d31061
Implement configuration-menu.js
LizChe May 5, 2019
70cc320
Add styles for action form menu in configuration-menu.css
LizChe May 5, 2019
d352df2
Implement mentor.html
LizChe May 7, 2019
ecae3c7
Move view options in mentor to the end of the page
LizChe May 7, 2019
740a33f
Add styles for review options in configuration-menu.css
LizChe May 7, 2019
e3dc62d
Merge pull request #40 from CodecoolGlobal/web
LizChe May 7, 2019
f190e76
Merge pull request #41 from CodecoolGlobal/teamDAO
marekszotek May 13, 2019
0a28146
Merge pull request #42 from CodecoolGlobal/dao
Slonimskaia May 13, 2019
922bfc6
Add Static controller
Slonimskaia May 13, 2019
8d29d15
Merge pull request #43 from CodecoolGlobal/user
Slonimskaia May 13, 2019
7333094
Add template
Slonimskaia May 13, 2019
30292f0
Merge pull request #44 from CodecoolGlobal/user
Slonimskaia May 13, 2019
94f3c7e
Initialize mentor.twig
LizChe May 14, 2019
317faf1
Initialize creepy-guy.twig
LizChe May 14, 2019
658be1f
Realise the login page loading
Slonimskaia May 14, 2019
71bb46e
Move templates folder from static folder
Slonimskaia May 14, 2019
50de482
Add paths for pages
Slonimskaia May 14, 2019
9cda131
Add dependencies
Slonimskaia May 14, 2019
e1b98a3
Merge pull request #45 from CodecoolGlobal/user
Slonimskaia May 14, 2019
5e565ed
Implement creepy-guy.twig
LizChe May 14, 2019
80381e8
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 14, 2019
8c06c0a
Add new session table, add data into user table
Slonimskaia May 14, 2019
4f643ad
Add post method
Slonimskaia May 14, 2019
c0b1138
Merge pull request #46 from CodecoolGlobal/user
Slonimskaia May 14, 2019
8e54910
Add header and footer templates in creepy-guy
LizChe May 14, 2019
1157962
Implement creepy-guy-footer template
LizChe May 14, 2019
8a54e63
Implement creepy-guy-header template
LizChe May 14, 2019
59c8744
Add drop down menu in creepy-guy's header
LizChe May 14, 2019
9c1cec3
Refactor: use one dao for each daoimpl classes
Slonimskaia May 14, 2019
cf56fc6
Add empty class
Slonimskaia May 14, 2019
35678c4
Refactor: rename builder
Slonimskaia May 14, 2019
d01e73e
Add new paths
Slonimskaia May 14, 2019
bb76ea4
Merge pull request #47 from CodecoolGlobal/user
Slonimskaia May 14, 2019
d5a90c7
Add creepy-guy context in Main
LizChe May 14, 2019
dd531c5
Resolve conflict in Main
LizChe May 14, 2019
b764797
Display normal and magic artifacts
marekszotek May 14, 2019
b836be4
Resolve merge conflict in Main
marekszotek May 14, 2019
2e0cdda
Resolve merge conflict
LizChe May 14, 2019
769d78a
Initialize View
LizChe May 14, 2019
9a86f0e
Implement print methods in View
LizChe May 14, 2019
3ff128c
Fix a bug with toggling hide/show action form
LizChe May 14, 2019
6fd4233
Add an icon for the page's tab in creepy-guy.twig
LizChe May 14, 2019
7dc2002
Add favicon.ico for the browser's tab
LizChe May 14, 2019
7acc0f9
Realise adding updating of user session into database
Slonimskaia May 14, 2019
dc0f1d4
Add function into dao for session table
Slonimskaia May 14, 2019
2571713
Change name of table from session to sessions
Slonimskaia May 14, 2019
20e1e1b
Delete forms for users
Slonimskaia May 14, 2019
461fa1e
Change name of table
Slonimskaia May 14, 2019
e3abb51
Merge pull request #48 from CodecoolGlobal/user
Slonimskaia May 14, 2019
cb05782
Implement CreepyGuyService
LizChe May 14, 2019
e13fa70
Refactor: move parse function into ServiceUtility
Slonimskaia May 15, 2019
bee9ab9
Merge pull request #49 from CodecoolGlobal/user
Slonimskaia May 15, 2019
7d22981
Move methods for the session table to SessionDaoImpl
Slonimskaia May 15, 2019
3e16a21
Change takeActionContainer to takeActionButtons
LizChe May 15, 2019
76757d0
Implement setRequiredStatements method, remove duplicated code in cre…
LizChe May 15, 2019
26a36b9
Add name elements to buttons in creepy-guy.twig
LizChe May 15, 2019
0a8966b
Create mentor method now creates the mentor with all required fields
LizChe May 15, 2019
1164e60
Implement handler that handles create mentor POST method
LizChe May 15, 2019
c780569
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 15, 2019
1f8a74c
Merge pull request #51 from CodecoolGlobal/employees
LizChe May 15, 2019
0a198cc
Merge pull request #50 from CodecoolGlobal/user
Slonimskaia May 15, 2019
4c0d4bc
Include artifact Id in html
marekszotek May 15, 2019
5659894
Merge branch 'server' into buyArtifact
marekszotek May 15, 2019
624ab7b
Change LocalDate type of Timestamp from LocalDate to OffsetDateTime
LizChe May 15, 2019
872944a
Correct LocalDate type to OffsetDateTime in TransactionDaoImpl methods
LizChe May 15, 2019
f7aeb21
Merge pull request #52 from CodecoolGlobal/employees
LizChe May 15, 2019
4004e1c
delete ControllerUtility class
marekszotek May 15, 2019
9941497
Change timestamp of LocalDate to OffsetDateTime
LizChe May 15, 2019
e0ce152
Merge pull request #53 from CodecoolGlobal/employees
LizChe May 15, 2019
b5312cc
Merge branch 'server' into buyArtifact
marekszotek May 15, 2019
bf97519
Implemented buy artifact logic for individual buyers
marekszotek May 15, 2019
22bae49
Get user object on main page of user after login
Slonimskaia May 15, 2019
eebdb07
Realise login mechanism
Slonimskaia May 15, 2019
64053c3
Add field for fill user page
Slonimskaia May 15, 2019
c1c64cb
Merge pull request #54 from CodecoolGlobal/user
Slonimskaia May 15, 2019
ceb4e5e
Add cookie to recognise user
Slonimskaia May 15, 2019
babfa11
Rename class StudentService into UserService
Slonimskaia May 15, 2019
bde4893
Merge pull request #55 from CodecoolGlobal/user
Slonimskaia May 15, 2019
bda16c9
Update status_history when transaction is made
marekszotek May 15, 2019
0e996f1
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
marekszotek May 15, 2019
fb14750
Merge branch 'buyArtifact' into server
marekszotek May 15, 2019
f032352
Fix dao PreparedStatement
marekszotek May 15, 2019
84e93b0
Add notification with the message in creepy-guy template
LizChe May 15, 2019
c2a9811
Implement method that handles POST
LizChe May 15, 2019
5c5f7f5
Add functionality for creepy-guy page
LizChe May 15, 2019
0d37598
Add styles for notification with status update
LizChe May 15, 2019
e3bd9c6
Change statement to prepared one in getUsersByType method
LizChe May 15, 2019
44d5e34
Create Context for /mentors page in Main
LizChe May 15, 2019
f893d53
Merge server to employees
LizChe May 15, 2019
075672f
Resolve conflict in CreepyGuyController.java
LizChe May 15, 2019
9372b32
Merge pull request #56 from CodecoolGlobal/employees
LizChe May 15, 2019
2843a57
Create skeleton for Quests controller, refactor
marekszotek May 16, 2019
8fa7f0e
Add visibility for message notification
LizChe May 16, 2019
8f89a0e
Add eventListener for Mentor's message
LizChe May 16, 2019
defccb5
Remove style attribute and p tag from notification-message container
LizChe May 16, 2019
ed994e9
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 16, 2019
5644ff3
Display all quests
marekszotek May 16, 2019
d9c47e3
Change sendResponse of POST method
LizChe May 16, 2019
cb7de5f
Refactor: move some line of code from StudentController to StudentSer…
Slonimskaia May 16, 2019
abaac5f
Merge branch 'server' into user
Slonimskaia May 16, 2019
1636c44
Merge pull request #57 from CodecoolGlobal/user
Slonimskaia May 16, 2019
24f2f8e
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 16, 2019
d393d27
Respond to service claim post method skeleton
marekszotek May 16, 2019
66df959
Refactor creepy guy controller, remove creation of ServiceUtility oob…
LizChe May 16, 2019
f93dcb1
Merge pull request #58 from CodecoolGlobal/employees
LizChe May 16, 2019
ac09932
Refactor static utility classes and localhost links in twig
marekszotek May 16, 2019
c3adbfb
Merge branch 'server' into claimQuest
marekszotek May 16, 2019
bf9f1db
Rename student-team.css to user-team
LizChe May 16, 2019
13755fd
Add styles for dropdown menu from user-team.css
LizChe May 16, 2019
131434f
Remove full path to the page in redirectToMentorsPage method
LizChe May 16, 2019
e12f4dd
Change stylesheet path to user-team.css
LizChe May 16, 2019
0133a76
Implement claim quests
marekszotek May 16, 2019
d8e7690
Create Discount table
marekszotek May 16, 2019
cb29f01
Implement DAO method for discount and apply discount in business logic
marekszotek May 16, 2019
fbc842d
Correct getTypes of result set in 'getUserByTypeId' method
LizChe May 16, 2019
bdfef35
Implement mentors template
LizChe May 16, 2019
a15a20c
Implement MentorsController
LizChe May 16, 2019
cafd068
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 16, 2019
fc8569a
Merge pull request #59 from CodecoolGlobal/employees
LizChe May 16, 2019
2661445
Render discount prices for artifacts
marekszotek May 16, 2019
f3fb0e1
Move functionality of creepy-guy to creepy-guy.js
LizChe May 16, 2019
19a326d
Move functionality of creepy-guy to creepy-guy.js
LizChe May 16, 2019
1f25be9
Remove configuration-menu.js link
LizChe May 16, 2019
010ea2f
Add script to creepy-guy.js
LizChe May 16, 2019
e8b5854
Implement mentor's header
LizChe May 16, 2019
7dec416
Implement mentor's footer
LizChe May 16, 2019
0dbe292
Resolve conflict, add new function
Slonimskaia May 16, 2019
12da1da
Implement mentor.twig
LizChe May 16, 2019
7092c4c
Merge pull request #60 from CodecoolGlobal/user
Slonimskaia May 16, 2019
2dfb0f0
Implement discount update
marekszotek May 16, 2019
5f3ceb6
Resolve conflicts
marekszotek May 16, 2019
a898251
Fix a typo
marekszotek May 16, 2019
ebee55b
Realize displaying of user artifacts and quests on user page
Slonimskaia May 16, 2019
d29f1a9
Refactor: delete unnecessary try/catch scope
Slonimskaia May 16, 2019
a499e1c
Merge pull request #61 from CodecoolGlobal/user
Slonimskaia May 16, 2019
83fee06
Added student footer and header
marekszotek May 16, 2019
64d71a9
Connect header/footer for Quests and Artifacts, Mentor and Student
marekszotek May 16, 2019
8e835ff
Resolve merge conflict
marekszotek May 16, 2019
542dc6a
Merge branch 'server' into headerFooterStudent
marekszotek May 16, 2019
7acfa55
Add wallet on student page
Slonimskaia May 16, 2019
c47a164
Merge pull request #62 from CodecoolGlobal/user
Slonimskaia May 16, 2019
7687f27
Disable quests and artifacts purchase by mentors
marekszotek May 16, 2019
94de4f0
Implement ItemType enum
LizChe May 16, 2019
d493ab2
Implement RoomType enum
LizChe May 16, 2019
a385450
Implement UserDefaultPhoto enum
LizChe May 16, 2019
f6f1f74
Implement UserType enum
LizChe May 16, 2019
93add4a
Implement EmployeeService
LizChe May 16, 2019
34032cd
Implement MentorService
LizChe May 16, 2019
e7785c8
Refactor CreepyGuyService, move user related functionality to Employe…
LizChe May 16, 2019
7c60864
Add Choose Option input for createQuest and createArtifact
LizChe May 16, 2019
2b5229c
Fix TransactionDao sum method
marekszotek May 16, 2019
e6e5618
Implement mentor.js
LizChe May 16, 2019
e4a2c64
Add choose item's type input list for create quest and create artifac…
LizChe May 16, 2019
beeacbd
Assign styles for mentor-notification-message container
LizChe May 16, 2019
6b0e7bd
Make changes related to refactor of CreepyGuyService
LizChe May 16, 2019
62aaed9
Fix quests transactions being loaded with discount
marekszotek May 16, 2019
ab86979
Make changes related to refactor of CreepyGuyService
LizChe May 16, 2019
3643103
Fix display discount form for mentor
marekszotek May 16, 2019
0a169e0
Hide special price when discount is zero
marekszotek May 16, 2019
68b70f8
Implement getPOSTInputs method in ServiceUtility
LizChe May 17, 2019
6a96f63
Implement Mentor Controller
LizChe May 17, 2019
082d776
Add server context for codecoolers page
LizChe May 17, 2019
ed3b417
Add icon for the mentor tab page
LizChe May 17, 2019
bd9102c
Change title of mentors page
LizChe May 17, 2019
7e59a6b
Remove display attribute from action-form-container
LizChe May 17, 2019
f2b4ca2
Refactor Creepy Guy Controller, separate handle method into smaller m…
LizChe May 17, 2019
2dfcc0e
Implement students.twig
LizChe May 17, 2019
a25f268
Implement StudentsController
LizChe May 17, 2019
15033ee
Change script's elements loading attribute from async to defer
LizChe May 17, 2019
136516f
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 17, 2019
750fdd7
Merge pull request #63 from CodecoolGlobal/employees
LizChe May 17, 2019
12f17b5
Refactor Mentors Controller, split handle method into smaller ones
LizChe May 17, 2019
48f3b5e
Change classpath in header from mentor-footer.twig to mentor-header.twig
LizChe May 17, 2019
2b1bc15
Merge pull request #64 from CodecoolGlobal/employees
LizChe May 17, 2019
cb6fb68
Refactor: change magic number on variable
Slonimskaia May 17, 2019
f62f316
Format discount price css
marekszotek May 17, 2019
ad8f0a5
Add logout
Slonimskaia May 17, 2019
d23280a
Add delete session function
Slonimskaia May 17, 2019
d335194
Refactor
Slonimskaia May 17, 2019
f500ee3
Merge pull request #65 from CodecoolGlobal/user
Slonimskaia May 17, 2019
08a29f7
Add logout
Slonimskaia May 21, 2019
b81dca6
Delete logout from the page
Slonimskaia May 21, 2019
40d6fe8
Refactor: delete unnecessary functions
Slonimskaia May 21, 2019
943f602
Refactor: delete unnecessary functions, add conditions for logout fun…
Slonimskaia May 21, 2019
6f915c7
Delete form from twig
Slonimskaia May 21, 2019
73f0875
Refactor: delete unnecessary functions
Slonimskaia May 21, 2019
edc59ea
Merge pull request #66 from CodecoolGlobal/user
Slonimskaia May 21, 2019
bda5d2a
Implement eventListeners for take action containers of creepy-guy.twig
LizChe May 30, 2019
d83ba4e
Add id to every take action container and form of creepy-guy.twig
LizChe May 30, 2019
fdcddde
Rewrite function that is adding edding eventListeners to every take a…
LizChe May 30, 2019
883af44
Add display style for .action-form-container class
LizChe May 30, 2019
dbb016c
Move id of forms from form element to div in mentor.twig
LizChe May 30, 2019
85cc029
Implement eventListeners for take action containers of mentor.js
LizChe May 30, 2019
f56d8f6
Modify the code island for balance of student
LizChe May 30, 2019
f94b5a5
Add userService to balance model in StudentsController
LizChe May 30, 2019
eabc076
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 30, 2019
3d8a393
Merge pull request #67 from CodecoolGlobal/employees
LizChe May 30, 2019
14204fb
Add information about the project
LizChe May 30, 2019
217be06
Merge pull request #68 from CodecoolGlobal/employees
LizChe May 30, 2019
e60c433
Revert "Add information about the project"
LizChe May 30, 2019
8e8d61c
Merge pull request #69 from CodecoolGlobal/revert-68-employees
LizChe May 30, 2019
284fe76
Add information about the project
LizChe May 30, 2019
dfff60f
Add login-page-sample image in resources directory
LizChe May 30, 2019
c39b935
Merge branch 'server' into employees
LizChe May 30, 2019
9460505
Merge pull request #70 from CodecoolGlobal/employees
LizChe May 30, 2019
3da5d2b
Fix a bug with closing forms upon click on them in mentor.twig
LizChe May 30, 2019
0012dbb
Fix a bug with closing forms upon click on them in creepy-guy.twig
LizChe May 30, 2019
acab07f
Improve style of item-cards
LizChe May 30, 2019
e4a6f46
Improve padding of buy and get buttons of artifacts and quests
LizChe May 30, 2019
98c41b9
Remove 'yellow' annotation from discount text
LizChe May 30, 2019
30ba85a
Add 'min' attribute to name type of number in mentor.twig
LizChe May 30, 2019
782ca23
Add styles for discount section of artifacts of mentor page
LizChe May 30, 2019
739f84f
Update document with discount section
LizChe May 30, 2019
7676ed6
Add no-discount-price class tag for price of the artifact
LizChe May 30, 2019
ecc2b14
Add class tags for discount's section elements in artifacts.twig
LizChe May 30, 2019
bae8048
Merge branch 'server' of github.com:CodecoolGlobal/quest_store_tl int…
LizChe May 30, 2019
c3c5a55
Merge pull request #71 from CodecoolGlobal/employees
LizChe May 30, 2019
6db3897
Fix a path to codecoolers page in mentor's header
LizChe May 30, 2019
d808655
Merge pull request #72 from CodecoolGlobal/employees
LizChe May 30, 2019
6ed1979
Remove main from SessionDaoImpl.java
LizChe Jun 2, 2019
4feba97
Remove main from ItemDaoImpl.java
LizChe Jun 2, 2019
0855693
Add top-margin for take-action-container
LizChe Jun 2, 2019
85b9c25
Add query that adds initial value to discount table
LizChe Jun 2, 2019
ab32859
Modify printError method
LizChe Jun 2, 2019
330d5fa
Add getUderTypes() method in UserDao
LizChe Jun 2, 2019
5a42acf
Implement getUserTypes() method in UserDaoImpl
LizChe Jun 2, 2019
091f55b
Implement getUserTypes method, remove printstacktrace from catch block
LizChe Jun 2, 2019
4657db2
Change type of userType from enum to int
LizChe Jun 2, 2019
d0747b7
Change type of userType from enum to int
LizChe Jun 2, 2019
2aeb15f
Change type of userType from enum to int
LizChe Jun 2, 2019
dc2fda9
Change type of userType from enum to int
LizChe Jun 2, 2019
db074d6
Change type of userType from enum to int
LizChe Jun 2, 2019
fa298a5
Remove User variable from handle method
LizChe Jun 2, 2019
d2a18c0
Change 'thing' to 'room'
LizChe Jun 2, 2019
d81348b
Delete RoomType enum
LizChe Jun 2, 2019
4bd9275
Delete Codecooler, CreepyGuy, Mentor models
LizChe Jun 2, 2019
697c4f6
Add getRoomTypes() method in RoomDao interface
LizChe Jun 2, 2019
56cb3a0
Implement getRoomTypes() method in RoomDaoImpl
LizChe Jun 2, 2019
d07789e
Implement getRoomTypes() method in EmployeeService.java
LizChe Jun 2, 2019
0eef517
Delete ItemType enum
LizChe Jun 2, 2019
7515549
Add getItemTypes method in ItemDao interface
LizChe Jun 2, 2019
c878ebc
Implement getItemTypes method in ItemDaoImpl.java
LizChe Jun 2, 2019
b5405a0
Implement getItemType method in ItemService
LizChe Jun 2, 2019
574031e
Change itemType from enum to int
LizChe Jun 2, 2019
af90950
Change itemType from enum to int
LizChe Jun 2, 2019
80095b8
Remove unused User variable
LizChe Jun 2, 2019
3f9ff4a
Merge pull request #73 from CodecoolGlobal/refactor
Slonimskaia Jun 3, 2019
822ea97
Merge pull request #74 from CodecoolGlobal/server
Slonimskaia Jun 24, 2019
8c821a5
Merge pull request #75 from CodecoolGlobal/dev
Slonimskaia Jun 24, 2019
7c15dba
Merge pull request #76 from CodecoolGlobal/server
LizChe Jun 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# System Files

.DS_Store

# IDE specific files

.idea
.vscode
*.iml

# Maven files

/target
*/test
.classpath
.project
.settings

# Utility files
src/main/resources/config.json
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# quest_store_tl
# Quest Store TML Production

#### __Dear Codecoolers__,
The Creepy Guy, a Supreme Necromancer of Codecool Kingdom, has a trouble with economic management of his kingdom.
Incredible expansion of Codecool caused that's really hard to keep distribution national currency (Coolcoins) in analogy system,
based on cash contribution, so he hasn't enough time to creep his mentors... He choose and invoke.
You - the best programmers in the Universe of Code - to implement application, which will help him and mentors with coolcoins managment.

![Login Page Sample](src/main/resources/media/images/login-page-sample.png)
135 changes: 135 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.codecool.quest_store</groupId>
<artifactId>quest_store_tl</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>quest_store_tl</name>
<url>http://maven.apache.org</url>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.2.4</version>
</dependency>

<dependency>
<groupId>org.jtwig</groupId>
<artifactId>jtwig-core</artifactId>
<version>5.87.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.11.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.8.0-beta4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta4</version>
</dependency>

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.codecool.quest_store.main.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.codecool.quest_store.main.Main</mainClass>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.codecool.quest_store.controllers;

import com.codecool.quest_store.model.Item;
import com.codecool.quest_store.model.User;
import com.codecool.quest_store.service.ArtifactsService;
import com.codecool.quest_store.service.ServiceUtility;
import com.codecool.quest_store.service.UserService;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import org.jtwig.JtwigModel;
import org.jtwig.JtwigTemplate;

import java.io.IOException;
import java.util.List;

public class ArtifactsController implements HttpHandler {

private static final String ARTIFACT_CONTEXT_PATH = "/artifacts";
private ArtifactsService artifactsService;
private UserService userService;

public ArtifactsController() {
this.artifactsService = new ArtifactsService();
this.userService = new UserService();
}

@Override
public void handle(HttpExchange httpExchange) throws IOException {

User activeUser = userService.getUserByCookie(httpExchange.getRequestHeaders().get("Cookie").get(0));

String method = httpExchange.getRequestMethod();
if (method.equals("GET")){
renderArtifacts(httpExchange, activeUser);
} else if (method.equals("POST")){
String response = artifactsService.respondToPostMethod(httpExchange, activeUser);
ServiceUtility.redirectToContext(httpExchange, response, ARTIFACT_CONTEXT_PATH);
}
}

private void renderArtifacts(HttpExchange httpExchange, User user) throws IOException {
List<Item> normalArtifacts = artifactsService.getNormalArtifacts();
List<Item> magicArtifacts = artifactsService.getMagicArtifacts();
int discount = artifactsService.getDiscount();


JtwigTemplate template;
template = JtwigTemplate.classpathTemplate("templates/artifacts.twig");

JtwigModel model = JtwigModel.newModel();

model.with("normal_artifacts", normalArtifacts);
model.with("magic_artifacts", magicArtifacts);
model.with("discount", discount);
model.with("user", user);

String response = template.render(model);

ServiceUtility.sendResponse(httpExchange, response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.codecool.quest_store.controllers;

import java.util.Map;

import java.io.IOException;

import org.jtwig.JtwigModel;
import org.jtwig.JtwigTemplate;

import com.codecool.quest_store.model.User;
import com.codecool.quest_store.model.UserDefaultPhoto;

import com.codecool.quest_store.service.CreepyGuyService;
import com.codecool.quest_store.service.EmployeeService;
import com.codecool.quest_store.service.ServiceUtility;
import com.codecool.quest_store.service.UserService;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

public class CreepyGuyController implements HttpHandler {

private EmployeeService employeeService;
private CreepyGuyService creepyGuyService;
private UserService userService;

public CreepyGuyController() {
employeeService = new EmployeeService();
creepyGuyService = new CreepyGuyService();
userService = new UserService();
}

@Override
public void handle(HttpExchange httpExchange) throws IOException {

String method = httpExchange.getRequestMethod();

if (method.equals("GET")) {
userService.getUserByCookie(httpExchange.getRequestHeaders().get("Cookie").get(0));
renderCreepyGuy(httpExchange);
}

if (method.equals("POST")) {
handlePOST(httpExchange);
}
}

private void handlePOST(HttpExchange httpExchange) throws IOException {
Map<String, String> inputs = ServiceUtility.getPOSTInputs(httpExchange);

for (Map.Entry<String, String> entry : inputs.entrySet()) {

if (entry.getKey().contains("recruit-mentor-button")) {
handleCreateMentor(inputs);

} else if (entry.getKey().contains("create-room-button")) {
handleCreateRoom(inputs);
}
}
ServiceUtility.redirectToContext(httpExchange, "", "/creepy-guy");
}

private void renderCreepyGuy(HttpExchange httpExchange) throws IOException {
JtwigTemplate template = JtwigTemplate.classpathTemplate("templates/creepy-guy.twig");
JtwigModel model = JtwigModel.newModel();
String response = template.render(model);
ServiceUtility.sendResponse(httpExchange, response);
}

private void handleCreateMentor(Map<String, String> inputs) {
String name = inputs.get("mentor-name");
String surname = inputs.get("mentor-surname");
String email = inputs.get("mentor-email");
int userType = userService.getUserTypes().get("Mentor");
employeeService.createUser(name, surname, email, userType, UserDefaultPhoto.MENTOR);
}

private void handleCreateRoom(Map<String, String> inputs) {
String name = inputs.get("room-name");
creepyGuyService.createRoom(name);
}
}
Loading
Loading