use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class CarController method showCarsByMake.
@GetMapping("/cars/filter")
public String showCarsByMake(@PageableDefault Pageable pageable, @RequestParam("search") String search, Model model) {
CarFilter filter = null;
if (search != null) {
filter = new CarFilter(search);
}
Page<Car> cars = carService.findAllCarsByMake(pageable, filter);
model.addAttribute("carsList", cars.getContent());
return "car/cars";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class CarController method generateRandomCars.
@GetMapping("sachascjksacnk/generate/random")
public String generateRandomCars() {
for (int i = 0; i < 800; i++) {
Car car = new Car();
car.setMake("CarMake #" + i);
car.setModel("CarModel #" + i);
car.setColor(colorService.findColorById(1));
carService.saveCar(car);
}
return "redirect:/car/cars";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class CourseController method generateRandomCourses.
@GetMapping("jhvbdsjvbdsjvbdsj/generate/random")
public String generateRandomCourses() {
for (int i = 1; i < 1000; i++) {
Course course = new Course();
course.setTitle("Course #" + i * 100);
course.setDescription("Course Description #" + i);
course.setPrice(new BigDecimal(i * 10 + ".00"));
courseService.saveCourse(course);
}
return "course/pageable-courses";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UploadFileController method showImageFromProjectDirectory.
@GetMapping("/file-from-project")
public String showImageFromProjectDirectory(Model model) throws IOException {
String rootPath = System.getProperty("user.dir");
File uploadDir = new File(rootPath + File.separator + "src" + File.separator + "main" + File.separator + "webapp" + File.separator + "upload" + File.separator + "maxresdefault.jpg");
byte[] fileToByteArray = Base64.encodeBase64(FileUtils.readFileToByteArray(uploadDir));
String encodedByte = new String(fileToByteArray);
model.addAttribute("imageFromProject", encodedByte);
return "file/preview";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class BaseController method verifyUser.
@GetMapping("/verify")
public String verifyUser(@RequestParam("token") String token, @RequestParam("userid") String userIdStr) {
int userId = Integer.valueOf(userIdStr);
UserEntity user = userService.findUserById(userId);
if (user.getToken().equals(token)) {
user.setToken("");
user.setActivated(true);
userService.updateUser(user);
}
return "redirect:/login";
}
Aggregations