use of org.springframework.web.bind.annotation.PutMapping in project spring-boot-mybatis-with-redis by Lovelcp.
the class ProductController method updateProductInfo.
@PutMapping("/{id}")
public Product updateProductInfo(@PathVariable("id") Long productId, @RequestBody Product newProduct) {
Product product = productMapper.select(productId);
if (product == null) {
throw new ProductNotFoundException(productId);
}
product.setName(newProduct.getName());
product.setPrice(newProduct.getPrice());
productMapper.update(product);
return product;
}
use of org.springframework.web.bind.annotation.PutMapping in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ApiUserController method update.
@PutMapping("/user")
public UpdateUserResult update(HttpSession session, String nickname) {
logger.debug("update nickname to {}", nickname);
if (!HttpSessionUtils.isLoginUser(session)) {
return UpdateUserResult.invalidAccess();
}
if (userRepository.findUserByNickname(nickname) != null) {
return UpdateUserResult.nicknameExist();
}
User sessionedUser = (User) session.getAttribute(HttpSessionUtils.USER_SESSION_KEY);
userRepository.updateUserNicknameByNickname(sessionedUser.getNickname(), nickname);
User user = userRepository.findUserByNickname(nickname);
session.setAttribute(HttpSessionUtils.USER_SESSION_KEY, user);
return UpdateUserResult.ok(user);
}
use of org.springframework.web.bind.annotation.PutMapping in project sic by belluccifranco.
the class AuthController method logout.
@PutMapping("/logout")
public void logout(HttpServletRequest request) {
final String authHeader = request.getHeader("Authorization");
if (authHeader == null || !authHeader.startsWith("Bearer ")) {
throw new UnauthorizedException(ResourceBundle.getBundle("Mensajes").getString("mensaje_error_token_vacio_invalido"));
}
// The part after "Bearer "
final String token = authHeader.substring(7);
Claims claims;
try {
claims = Jwts.parser().setSigningKey(secretkey).parseClaimsJws(token).getBody();
request.setAttribute("claims", claims);
} catch (JwtException ex) {
throw new UnauthorizedException(ResourceBundle.getBundle("Mensajes").getString("mensaje_error_token_vacio_invalido"), ex);
}
long idUsuario = (int) claims.get("idUsuario");
Usuario usuario = usuarioService.getUsuarioPorId(idUsuario);
usuario.setToken("");
usuarioService.actualizar(usuario);
}
use of org.springframework.web.bind.annotation.PutMapping in project sic by belluccifranco.
the class ProductoController method modificarMultiplesProductos.
@PutMapping("/productos/multiples")
@ResponseStatus(HttpStatus.OK)
public void modificarMultiplesProductos(@RequestParam long[] idProducto, @RequestParam(required = false) Long idMedida, @RequestParam(required = false) Long idRubro, @RequestParam(required = false) Long idProveedor, @RequestParam(required = false) Double gananciaNeto, @RequestParam(required = false) Double gananciaPorcentaje, @RequestParam(defaultValue = "0", required = false) Double impuestoInternoNeto, @RequestParam(defaultValue = "0", required = false) Double impuestoInternoPorcentaje, @RequestParam(required = false) Double IVANeto, @RequestParam(required = false) Double IVAPorcentaje, @RequestParam(required = false) Double precioCosto, @RequestParam(required = false) Double precioLista, @RequestParam(required = false) Double precioVentaPublico) {
boolean actualizaPrecios = false;
if (gananciaNeto != null && gananciaPorcentaje != null && impuestoInternoNeto != null && impuestoInternoPorcentaje != null && IVANeto != null && IVAPorcentaje != null && precioCosto != null && precioLista != null && precioVentaPublico != null) {
actualizaPrecios = true;
}
Medida medida = null;
if (idMedida != null) {
medida = medidaService.getMedidaPorId(idMedida);
}
Rubro rubro = null;
if (idRubro != null) {
rubro = rubroService.getRubroPorId(idRubro);
}
Proveedor proveedor = null;
if (idProveedor != null) {
proveedor = proveedorService.getProveedorPorId(idProveedor);
}
productoService.modificarMultiplesProductos(idProducto, actualizaPrecios, gananciaNeto, gananciaPorcentaje, impuestoInternoNeto, impuestoInternoPorcentaje, IVANeto, IVAPorcentaje, precioCosto, precioLista, precioVentaPublico, (idMedida != null), medida, (idRubro != null), rubro, (idProveedor != null), proveedor);
}
Aggregations