-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
11,563 additions
and
2,014 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
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 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
wrapperVersion=3.3.2 | ||
distributionType=only-script | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip |
Large diffs are not rendered by default.
Oops, something went wrong.
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,12 +1,24 @@ | ||
package com.alkewallet6; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
@SpringBootApplication | ||
public class Alkewallet6Application { | ||
public class AlkeWallet6Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Alkewallet6Application.class, args); | ||
|
||
ApplicationContext ctx = SpringApplication.run(AlkeWallet6Application.class, args); | ||
|
||
System.out.println("Let's inspect the beans provided by Spring Boot:"); | ||
|
||
String[] beanNames = ctx.getBeanDefinitionNames(); | ||
Arrays.sort(beanNames); | ||
for (String beanName : beanNames) { | ||
System.out.println(beanName); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
src/main/java/com/alkewallet6/connection/DBConnection.java
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
src/main/java/com/alkewallet6/controller/ContactController.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,48 @@ | ||
package com.alkewallet6.controller; | ||
|
||
import com.alkewallet6.model.DTO.ContactDTO; | ||
import com.alkewallet6.model.entity.ContactEntity; | ||
import com.alkewallet6.service.interfaces.IContactService; | ||
import jakarta.servlet.http.HttpSession; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.servlet.mvc.support.RedirectAttributes; | ||
|
||
@Controller | ||
public class ContactController { | ||
|
||
@Autowired | ||
private IContactService contactService; | ||
|
||
@PostMapping("/registerContact") | ||
public String createContact(@ModelAttribute("contactDTO")ContactDTO contactDTO, @RequestParam("userId") Long userId,RedirectAttributes redirectAttributes){ | ||
try{ | ||
contactService.save(contactDTO, userId); | ||
redirectAttributes.addFlashAttribute("message","Contacto Registrado"); | ||
}catch (RuntimeException e){ | ||
redirectAttributes.addFlashAttribute("messageContact",e.getMessage()); | ||
} | ||
redirectAttributes.addAttribute("id",userId); | ||
return "redirect:/transfer/{id}"; | ||
} | ||
|
||
@PostMapping("/selectContact/{userId}") | ||
public String manageContact(@PathVariable Long userId, @RequestParam(value = "selectedContactId", required = false) Long selectedContactId, @RequestParam(value = "deleteContact", required = false) String deleteContact, RedirectAttributes redirectAttributes,HttpSession session) { | ||
if ("delete".equals(deleteContact)) { | ||
if (selectedContactId != null) { | ||
contactService.deleteContact(selectedContactId); | ||
redirectAttributes.addFlashAttribute("message", "Contacto eliminado correctamente"); | ||
} else { | ||
redirectAttributes.addFlashAttribute("messageContact", "Debe seleccionar un contacto para eliminar"); | ||
} | ||
} else { | ||
ContactEntity selectedContact = contactService.getById(selectedContactId); | ||
session.setAttribute("selectedContact", selectedContact); | ||
boolean needsRecharge = !selectedContact.isUser(); | ||
redirectAttributes.addFlashAttribute("contactMessage",needsRecharge?"Se hará un recargo de $300 pesos por transferencia a este contacto.":"Pertenece a la familia Alke-Wallet"); | ||
} | ||
redirectAttributes.addAttribute("id", userId); | ||
return "redirect:/transfer/{id}"; | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/main/java/com/alkewallet6/controller/HomeController.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,104 @@ | ||
package com.alkewallet6.controller; | ||
|
||
import com.alkewallet6.model.DTO.ContactDTO; | ||
import com.alkewallet6.model.entity.ContactEntity; | ||
import com.alkewallet6.model.entity.TransactionEntity; | ||
import com.alkewallet6.model.entity.UserEntity; | ||
import com.alkewallet6.model.enums.TransactionType; | ||
import com.alkewallet6.service.interfaces.IContactService; | ||
import com.alkewallet6.service.interfaces.ITransactionService; | ||
import com.alkewallet6.service.interfaces.IUserService; | ||
import jakarta.servlet.http.HttpSession; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Controller | ||
public class HomeController { | ||
|
||
@Autowired | ||
private IUserService userService; | ||
@Autowired | ||
private ITransactionService transactionService; | ||
@Autowired | ||
private IContactService contactService; | ||
|
||
@GetMapping("/deposit/{id}") | ||
public String depositView(@PathVariable Long id, Model model) { | ||
UserEntity user = userService.getById(id); | ||
|
||
if (user == null){ | ||
return "redirect:/?error=true"; | ||
} | ||
|
||
System.out.println("User ID: " + id); | ||
model.addAttribute("user",user); | ||
model.addAttribute("userId", id); | ||
return "deposit"; | ||
} | ||
|
||
@GetMapping("/withdraw/{id}") | ||
public String withdrawView(@PathVariable Long id, Model model) { | ||
UserEntity user = userService.getById(id); | ||
if (user == null){ | ||
return "redirect:/?error=true"; | ||
} | ||
|
||
model.addAttribute("user",user); | ||
model.addAttribute("userId", id); | ||
return "withdraw"; | ||
} | ||
|
||
@GetMapping("/transfer/{id}") | ||
String transferView(@PathVariable Long id, Model model, HttpSession session) { | ||
UserEntity user = userService.getById(id); | ||
if (user == null){ | ||
return "redirect:/?error=true"; | ||
} | ||
|
||
ContactDTO contactDTO = new ContactDTO(); | ||
List<ContactEntity> contacts = contactService.getByUserEntityId(id).stream() | ||
.filter(ContactEntity::isActive) | ||
.collect(Collectors.toList()); | ||
|
||
ContactEntity selectedContact = (ContactEntity) session.getAttribute("selectedContact"); | ||
|
||
model.addAttribute("user",user); | ||
model.addAttribute("userId", user.getId()); | ||
model.addAttribute("contactDTO", contactDTO); | ||
model.addAttribute("contacts", contacts); | ||
|
||
if (selectedContact != null) { | ||
model.addAttribute("selectedContact", selectedContact); | ||
} | ||
|
||
return "transfer"; | ||
} | ||
|
||
@GetMapping("/transactionList") | ||
public String transactionView(@RequestParam(value = "transactionType", required = false) TransactionType transactionType, Model model, HttpSession session){ | ||
Long userId = (Long) session.getAttribute("userId"); | ||
UserEntity user = userService.getById(userId); | ||
if (user == null){ | ||
return "redirect:/?error=true"; | ||
} | ||
|
||
List<TransactionEntity> transactionEntityList = transactionService.getByUserEntityId(userId); | ||
List<TransactionEntity> filteredTransactionList; | ||
if (transactionType == null) { | ||
filteredTransactionList = transactionEntityList; | ||
} else { | ||
filteredTransactionList = transactionEntityList.stream() | ||
.filter(t -> t.getType().equals(transactionType)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
model.addAttribute("user", user); | ||
model.addAttribute("filteredTransactionList", filteredTransactionList); | ||
return "transaction"; | ||
} | ||
} |
Oops, something went wrong.