Exemplo n.º 1
0
  @RequestMapping(value = "/users", method = RequestMethod.POST)
  public User userCreate(@RequestHeader("x-token") String securitytoken, @RequestBody User user) {

    User authUser = userService.pass(securitytoken);

    if (authUser.getId() > 0 && authUser.getLevel() > 0) {
      userService.create(user);
    }

    return user;
  }
Exemplo n.º 2
0
  @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
  public User userObject(
      @PathVariable("userId") int id, @RequestHeader("x-token") String securitytoken) {
    User user = new User();

    User authUser = userService.pass(securitytoken);

    if (authUser.getId() > 0) {
      user = userService.findById(id);
    }

    return user;
  }
Exemplo n.º 3
0
  @RequestMapping(value = "/users", method = RequestMethod.GET)
  public List<User> userList(@RequestHeader("x-token") String securitytoken) {

    List<User> userList = new ArrayList<>();

    User authUser = userService.pass(securitytoken);

    if (authUser.getId() > 0) {
      userList = userService.findAll();
    }

    return userList;
  }
Exemplo n.º 4
0
  @RequestMapping(value = "/users/pingpong", method = RequestMethod.GET)
  public User userPing(@RequestHeader("x-token") String securitytoken) {

    User user = new User();
    try {
      User authUser = userService.pass(securitytoken);

      if (authUser.getId() > 0) {
        user = authUser;
      }
    } catch (Exception e) {

    }

    return user;
  }
Exemplo n.º 5
0
  @RequestMapping(value = "/users/{userId}", method = RequestMethod.DELETE)
  public User userDelete(
      @PathVariable("userId") int id, @RequestHeader("x-token") String securitytoken) {
    User deletedUser = new User();

    User authUser = userService.pass(securitytoken);
    if (authUser.getId() > 0 && authUser.getLevel() > 10) {
      deletedUser = userService.findById(id);

      if (deletedUser.getId() > 0) {
        deletedUser = userService.delete(id);
      }
    }

    return deletedUser;
  }
Exemplo n.º 6
0
  @RequestMapping(value = "/users/{userId}", method = RequestMethod.POST)
  public User userUpdate(
      @PathVariable("userId") int id,
      @RequestBody User user,
      @RequestHeader("x-token") String securitytoken) {
    User updatedUser = user;

    User authUser = userService.pass(securitytoken);
    if (authUser.getId() > 0) {
      updatedUser = userService.findById(id);

      if (updatedUser.getId() > 0 && authUser.getLevel() > 0) {
        updatedUser.setLogin(user.getLogin());
        updatedUser.setPasswd(user.getPasswd());
        updatedUser.setFirstName(user.getFirstName());
        updatedUser.setLastName(user.getLastName());
        updatedUser.setLevel(user.getLevel());

        updatedUser = userService.update(updatedUser);
      }
    }

    return updatedUser;
  }