Search in sources :

Example 1 with PutMapping

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;
}
Also used : Product(com.wooyoo.learning.dao.domain.Product) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 2 with PutMapping

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);
}
Also used : User(com.mapia.domain.User) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 3 with PutMapping

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);
}
Also used : Claims(io.jsonwebtoken.Claims) Usuario(sic.modelo.Usuario) JwtException(io.jsonwebtoken.JwtException) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 4 with PutMapping

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);
}
Also used : Rubro(sic.modelo.Rubro) Proveedor(sic.modelo.Proveedor) Medida(sic.modelo.Medida) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Aggregations

PutMapping (org.springframework.web.bind.annotation.PutMapping)4 User (com.mapia.domain.User)1 Product (com.wooyoo.learning.dao.domain.Product)1 Claims (io.jsonwebtoken.Claims)1 JwtException (io.jsonwebtoken.JwtException)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 Medida (sic.modelo.Medida)1 Proveedor (sic.modelo.Proveedor)1 Rubro (sic.modelo.Rubro)1 Usuario (sic.modelo.Usuario)1