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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
while (true) | |
{ | |
Console.WriteLine("Escolha uma opção:"); | |
Console.WriteLine("1. A) Apresentar todos os valores numéricos inteiros ímpares situados na faixa de 0 a 40."); | |
Console.WriteLine("2. B) Apresentar o total da soma dos 100 primeiros números inteiros."); |
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
[{ | |
"_id": { | |
"$oid": "663537143703c155de7cd0a7" | |
}, | |
"NOME": "João", | |
"CLIENTE_VIP": 1, | |
"EMAIL": "joao@email.com", | |
"TELEFONE": [ | |
"9999-1111", | |
"8888-1111" |
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
'-' | |
' ' | |
'&' | |
'^' | |
'*' | |
' or ''-' | |
' or '' ' | |
' or ''&' | |
' or ''^' | |
' or ''*' |
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
public class Main { | |
public static void main(String[] args) { | |
String fileName = "nomes.txt"; | |
String baseUrl = "http://localhost:8080/api/user/search?name="; | |
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { | |
String line; | |
while ((line = br.readLine()) != null) { | |
String urlWithParam = baseUrl + line.trim(); | |
System.out.println("Fazendo requisição para: " + urlWithParam); |
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
public interface IUserRepository extends JpaRepository<User, Integer> { | |
@Query(value = "SELECT * FROM User WHERE name = '?1'", nativeQuery = true) | |
User getUserByName(String name); | |
} |
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
public interface IUserRepository extends JpaRepository<User, Integer> { | |
@Query(value = "SELECT * FROM User WHERE name = ?1", nativeQuery = true) | |
User getUserByName(String name); | |
} |
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
public interface IUserRepository extends JpaRepository<User, Integer> { | |
@Query("select u from User u where u.name =:nome ") | |
User getUserByName(String nome); | |
} |
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
@Entity | |
public class User { | |
public User() {} | |
@Id | |
private int id; | |
private String name; | |
@Enumerated(EnumType.STRING) | |
private Status isActive; |
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
@RestController | |
@RequestMapping("/api/user") | |
public class UserController { | |
@Autowired | |
private IUserRepository repository; | |
@GetMapping(value = "/search") | |
public ResponseEntity<User> findByName(@RequestParam String name) { | |
var user = repository.getUserByName(name); |
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
import static java.lang.String.format; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
import java.lang.reflect.ParameterizedType; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Set; |
NewerOlder