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 UserPrincipal{ | |
private String getPrincipal(){ | |
String userName = null; | |
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | |
if (principal instanceof UserDetails) { | |
userName = ((UserDetails)principal).getUsername(); | |
} else { | |
userName = principal.toString(); |
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
@Controller | |
@RequestMapping("/users") | |
public class UserController { | |
@PreAuthorize("hasRole('ADMIN')") | |
@GetMapping("/{codigo}") | |
public ModelAndView editar(@PathVariable Long codigo){ | |
Users user = usersService.findOne(codigo); | |
return novo(user); |
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 MovimentacaoService{ | |
public void salvar(List<ItemMovimentacao> listItens ){ | |
//Para cada Item do meu DTO ItemMovimentacao, transforme para Movimentacao, retornando uma list | |
//do tipo Movimentacao. | |
List<Movimentacao> mv = listItens | |
.stream() | |
.map(l -> getMovimentacao(l)) | |
.collect(Collectors.toList()); |
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
@Controller | |
@RequestMapping("/users") | |
public class UserController { | |
@Autowired UserService userService; | |
@Autowired RolesRepository roleRepository; | |
@PreAuthorize("hasAnyRole('ADMIN')") | |
@PostMapping("/novo") | |
public ModelAndView salvar(@Valid @ModelAttribute("usuario") Users user, BindingResult result, |
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
<div class="col-sm-2 padding-left"> | |
<div class="form-group"> | |
<button class="btn btn-info" type="button" | |
data-toggle="modal" data-target="#modalProduto"> | |
Adicionar | |
<i class="fa fa-plus-circle" aria-hidden="true"></i> | |
</button> | |
</div> | |
</div> |
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
@Controller | |
public class LoginController { | |
/*Mapeamento para a rota padrão*/ | |
@RequestMapping(value= {"/", "/login"}) | |
public String login(@AuthenticationPrincipal Principal user){ | |
if(user != null) | |
return "redirect:/home"; | |
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 | |
@Table(name="roles") | |
public class Role{ | |
public Role(){}; | |
public Role(Long cod, String role){ | |
this.codigo = cod; | |
this.descricao = role; | |
}; |
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
const groupBy = (xs, key) => xs.reduce((rv, x) => { | |
(rv[x[key]] = rv[x[key]] || []).push(x); | |
return rv; | |
}, {}); |
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
const arrObj = [ | |
//Primeiro element | |
[{ | |
"name": "Distri Equipamente Cirurgicos", | |
"data": 18 | |
}, | |
{ | |
"name": "DNAPet", | |
"data": 70 | |
} |
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
//Array de 4 elementos | |
var Json = [ | |
//Primeiro elemento | |
[{ | |
"name":"Distri Equipamente Cirurgicos", | |
"data":18 | |
}, | |
{ | |
"name":"DNAPet", | |
"data":70 |