Guest User

Untitled

a guest
Mar 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. package com.github.ajanthan.pizza.shack.MenuService;
  2.  
  3. import com.github.ajanthan.pizza.shack.MenuService.dao.MenuItemRepository;
  4. import com.github.ajanthan.pizza.shack.MenuService.model.MenuItem;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.boot.CommandLineRunner;
  8. import org.springframework.boot.SpringApplication;
  9. import org.springframework.boot.autoconfigure.SpringBootApplication;
  10. import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
  11. import org.springframework.context.annotation.Bean;
  12.  
  13. @SpringBootApplication
  14. @EnableOAuth2Sso
  15. public class MenuServiceApplication {
  16. private static final Logger log = LoggerFactory.getLogger(MenuServiceApplication.class);
  17.  
  18. public static void main(String[] args) {
  19. SpringApplication.run(MenuServiceApplication.class, args);
  20. }
  21.  
  22. @Bean
  23. public CommandLineRunner demo(MenuItemRepository menuItemRepository) {
  24. return args -> {
  25. //save couple of menu items
  26. MenuItem item1 = new MenuItem();
  27. item1.setName("Chicken Parmesan");
  28. item1.setDescription("Grilled chicken, fresh tomatoes, feta and mozzarella cheese");
  29. item1.setPrice(12.09);
  30. item1.setImage("000001");
  31. menuItemRepository.save(item1);
  32.  
  33. MenuItem item2 = new MenuItem();
  34. item2.setName("Spicy Italian");
  35. item2.setDescription("Pepperoni and a double portion of spicy Italian sausage");
  36. item2.setPrice(11.23);
  37. item2.setImage("000002");
  38. menuItemRepository.save(item2);
  39.  
  40. MenuItem item3 = new MenuItem();
  41. item3.setName("Garden Fresh");
  42. item3.setDescription("Slices onions and green peppers, gourmet " +
  43. "mushrooms, black olives and ripe Roma tomatoes");
  44. item3.setPrice(13.00);
  45. item3.setImage("000003");
  46. menuItemRepository.save(item3);
  47.  
  48. MenuItem item4 = new MenuItem();
  49. item4.setName("Tuscan Six Cheese");
  50. item4.setDescription("Six cheese blend of mozzarella, Parmesan, Romano, Asiago and Fontina");
  51. item4.setPrice(10.22);
  52. item4.setImage("000004");
  53. menuItemRepository.save(item4);
  54.  
  55. MenuItem item5 = new MenuItem();
  56. item5.setName("Spinach Alfredo");
  57. item5.setDescription("Rich and creamy blend of spinach and garlic Parmesan with Alfredo sauce");
  58. item5.setPrice(9.98);
  59. item5.setImage("000005");
  60. menuItemRepository.save(item5);
  61.  
  62. log.info("Getting all menu");
  63.  
  64. for (MenuItem menuItem : menuItemRepository.findAll()) {
  65. log.info("Menu item :" + menuItem.toString());
  66. }
  67.  
  68. };
  69. }
  70. }
Add Comment
Please, Sign In to add comment