970 changed files with 0 additions and 43585 deletions
Split View
Diff Options
-
0springboot_backend/.metadata/.lock
-
10184springboot_backend/.metadata/.log
-
54springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/10/a0cd36544d1c001c1175ef5c8fe3bc4a
-
26springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/11/e0fa51ab2820001c1fd4fcbaef3ed6f3
-
54springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/12/600672374a1c001c1175ef5c8fe3bc4a
-
70springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/14/b065d7fb7620001c1639f432a894b632
-
3springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/14/d09c1a101e20001c1fd4fcbaef3ed6f3
-
25springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/17/d01cbf402820001c1fd4fcbaef3ed6f3
-
29springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/17/f0c722ff6a22001c17d1e4ac7a211a08
-
65springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/18/10f54a99841c001c1e2b8f537ef912f3
-
79springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/19/301d00902820001c1fd4fcbaef3ed6f3
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1c/20fa1d4a6f20001c18d2b7903485cc51
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1c/30e882aca31c001c1afc8a1edde7498c
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1c/50786ec7e820001c1ad9f76e81c64a6c
-
26springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1d/1071dd372920001c1fd4fcbaef3ed6f3
-
10springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1e/10f615602a20001c1fd4fcbaef3ed6f3
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/1f/d087e071ba1b001c1da2ffc18848673d
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/2/d09e07ff6a22001c17d1e4ac7a211a08
-
6springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/21/b0b4e9d31a20001c1fd4fcbaef3ed6f3
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/23/2082116b1e20001c1fd4fcbaef3ed6f3
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/23/20bce371ba1b001c1da2ffc18848673d
-
2springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/24/106aded31a20001c1fd4fcbaef3ed6f3
-
32springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/24/80bfb9287f20001c1639f432a894b632
-
27springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/24/c0a038e22a20001c1fd4fcbaef3ed6f3
-
62springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/25/a03a65f62920001c1fd4fcbaef3ed6f3
-
109springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/25/e06514b39622001c17d1e4ac7a211a08
-
3springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/27/f08ce0d31a20001c1fd4fcbaef3ed6f3
-
43springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/28/b0d5fba9831c001c1e2b8f537ef912f3
-
33springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/2a/308d91291421001c12d2a58e3b8f44a0
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/2c/708547971d20001c1fd4fcbaef3ed6f3
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/2d/90366dcb1f20001c1fd4fcbaef3ed6f3
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/2f/00fb58532220001c1fd4fcbaef3ed6f3
-
41springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/30/90521f2fab1c001c1ceba011ddc7f939
-
21springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/32/30fa0aff6a22001c17d1e4ac7a211a08
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/32/40185c4bb51b001c1da2ffc18848673d
-
2springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/32/703dced31a20001c1fd4fcbaef3ed6f3
-
62springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/32/e0a2027e2a20001c1fd4fcbaef3ed6f3
-
15springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/32/e0f6e773861c001c1e2b8f537ef912f3
-
68springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/33/30a6a1602820001c1fd4fcbaef3ed6f3
-
18springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/33/c0b804261b21001c12d2a58e3b8f44a0
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/37/9026e7d11d20001c1fd4fcbaef3ed6f3
-
111springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/38/70b8bb272720001c1fd4fcbaef3ed6f3
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/38/e0cdb923b61b001c1da2ffc18848673d
-
28springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/39/c02bc39a2a20001c1fd4fcbaef3ed6f3
-
54springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3a/4028d9654e1c001c1175ef5c8fe3bc4a
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3a/6063503f7f1c001c1e2b8f537ef912f3
-
105springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70be07a12920001c1fd4fcbaef3ed6f3
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3a/a041d05d7320001c1639f432a894b632
-
91springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3b/40aa9a292a20001c1fd4fcbaef3ed6f3
-
3springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3b/8046d3d31a20001c1fd4fcbaef3ed6f3
-
18springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3c/0087222e1421001c12d2a58e3b8f44a0
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3c/f00f35e02720001c1fd4fcbaef3ed6f3
-
43springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3f/208f99af841c001c1e2b8f537ef912f3
-
37springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/3f/c06ef6901221001c12d2a58e3b8f44a0
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/40/a0dd5cf31e20001c1fd4fcbaef3ed6f3
-
43springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/41/00f0b258861c001c1e2b8f537ef912f3
-
19springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/41/a04eed1c481c001c1175ef5c8fe3bc4a
-
0springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/41/f0ad9e8b1f20001c1fd4fcbaef3ed6f3
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/42/001f86c7e820001c1ad9f76e81c64a6c
-
70springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/42/b07930b67720001c1639f432a894b632
-
75springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/44/00842108481c001c1175ef5c8fe3bc4a
-
4springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/44/70bfdb841021001c12d2a58e3b8f44a0
-
100springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/45/604c0e592920001c1fd4fcbaef3ed6f3
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/45/f0e96108ac1c001c1ceba011ddc7f939
-
15springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/47/e077bf5d851c001c1e2b8f537ef912f3
-
155springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/48/a0bd064d2c20001c1fd4fcbaef3ed6f3
-
25springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/48/f0c6588c811c001c1e2b8f537ef912f3
-
69springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/4d/800c8463811c001c1e2b8f537ef912f3
-
27springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/4f/701e18e92a20001c1fd4fcbaef3ed6f3
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/50/f0f3b6ed7720001c1639f432a894b632
-
7springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/52/d0c0ed841021001c12d2a58e3b8f44a0
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/53/a08945971d20001c1fd4fcbaef3ed6f3
-
25springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/55/d0287e097f1c001c1e2b8f537ef912f3
-
3springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/57/0072e4841021001c12d2a58e3b8f44a0
-
65springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/57/200956c2811c001c1e2b8f537ef912f3
-
32springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/57/a05d59007220001c1639f432a894b632
-
2springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/57/d07e1f101e20001c1fd4fcbaef3ed6f3
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/58/4095b7f2a21c001c1afc8a1edde7498c
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/59/704ab3ed7720001c1639f432a894b632
-
8springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5d/a0d1214d2a20001c1fd4fcbaef3ed6f3
-
32springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5d/c03add7fe420001c1ad9f76e81c64a6c
-
23springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5e/c07c6cc9ba1b001c1da2ffc18848673d
-
8springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5e/e00befd31a20001c1fd4fcbaef3ed6f3
-
90springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5f/00ce31622620001c1fd4fcbaef3ed6f3
-
3springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5f/b0a121101e20001c1fd4fcbaef3ed6f3
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5f/b0fc4cada81c001c15eabe5cf52659ba
-
8springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/5f/c00af0841021001c12d2a58e3b8f44a0
-
65springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/6/b06d5c0f801c001c1e2b8f537ef912f3
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/60/809f5596a81c001c15eabe5cf52659ba
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/61/d0dafdfe6a22001c17d1e4ac7a211a08
-
69springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/63/50d1ae58861c001c1e2b8f537ef912f3
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/65/5076df81a51c001c18e2b55ca6c81bda
-
54springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/65/70a90d754a1c001c1175ef5c8fe3bc4a
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/66/c0a652ed1d20001c1fd4fcbaef3ed6f3
-
5springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/68/50d2b89c7c22001c17d1e4ac7a211a08
-
13springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/68/e0ee4a8daf1a001c19bcf3b7e4125f31
-
74springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/6a/20a559847620001c1639f432a894b632
-
4springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/6c/600fe4d31a20001c1fd4fcbaef3ed6f3
-
65springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/6d/2094d5f92720001c1fd4fcbaef3ed6f3
-
100springboot_backend/.metadata/.plugins/org.eclipse.core.resources/.history/7/e084e6cd2820001c1fd4fcbaef3ed6f3
10184
springboot_backend/.metadata/.log
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,54 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.FixMethodOrder; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.junit.runners.MethodSorters; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.test.context.ContextConfiguration; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
import org.springframework.test.web.servlet.MockMvc; |
|||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|||
import org.springframework.web.context.WebApplicationContext; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@ContextConfiguration(classes = UserServiceApplication.class) |
|||
@SpringBootTest |
|||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
|||
public class UserControllerTest { |
|||
|
|||
private MockMvc mockMvc; |
|||
|
|||
@Autowired |
|||
private WebApplicationContext wac; |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); |
|||
} |
|||
@Test |
|||
public void shouldFindMemberById() throws Exception { |
|||
this.mockMvc.perform(MockMvcRequestBuilders.get("/user/" + "2") |
|||
.accept(MediaType.APPLICATION_JSON)) |
|||
.andDo(print()) |
|||
.andExpect(jsonPath("$.id").exists()) |
|||
.andExpect(jsonPath("$.id").value(2)) |
|||
.andExpect(jsonPath("$.name").exists()) |
|||
.andExpect(jsonPath("$.name").value("Mary Brown")) |
|||
.andExpect(jsonPath("$.email").value("mary.b@gmail.com")) |
|||
.andExpect(jsonPath("$.*", hasSize(3))) |
|||
.andReturn(); |
|||
} |
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
|
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Modifying; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
|
|||
|
|||
public interface CartRepo extends JpaRepository<Cart, Long> { |
|||
|
|||
List<Cart> findByUserId(Long uid); |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id = ?1") |
|||
List<Cart> getItems(Long uid); |
|||
|
|||
|
|||
@Modifying |
|||
@Transactional |
|||
@Query("delete from Cart c where c.user.id=?1") |
|||
void deleteItems(Long uid); |
|||
|
|||
} |
|||
@ -1,54 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.FixMethodOrder; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.junit.runners.MethodSorters; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.test.context.ContextConfiguration; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
import org.springframework.test.web.servlet.MockMvc; |
|||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|||
import org.springframework.web.context.WebApplicationContext; |
|||
|
|||
import com.sundaydevblog.springrestapitest.controller.MemberController; |
|||
|
|||
|
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@ContextConfiguration(classes = UserServiceApplication.class) |
|||
@SpringBootTest |
|||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
|||
public class UserControllerTest { |
|||
|
|||
private MockMvc mockMvc; |
|||
|
|||
@Autowired |
|||
private WebApplicationContext wac; |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); |
|||
} |
|||
@Test |
|||
public void shouldFindMemberById() throws Exception { |
|||
this.mockMvc.perform(MockMvcRequestBuilders.get("/userapi/user" + "2") |
|||
.accept(MediaType.APPLICATION_JSON)) |
|||
.andDo(print()) |
|||
.andExpect(jsonPath("$.id").exists()) |
|||
.andExpect(jsonPath("$.id").value(2)) |
|||
.andExpect(jsonPath("$.name").exists()) |
|||
.andExpect(jsonPath("$.name").value("Mary Brown")) |
|||
.andExpect(jsonPath("$.email").value("mary.b@gmail.com")) |
|||
.andExpect(jsonPath("$.*", hasSize(3))) |
|||
.andReturn(); |
|||
} |
|||
} |
|||
@ -1,70 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.example.demo.config.MessagingConfig; |
|||
import com.example.demo.model.Cart; |
|||
import com.example.demo.model.OrderStatus; |
|||
import com.example.demo.model.Orders; |
|||
import com.example.demo.repository.CartRepo; |
|||
import com.example.demo.repository.OrderRepo; |
|||
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class OrderController { |
|||
|
|||
|
|||
@Autowired |
|||
private OrderRepo orderRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
@Autowired |
|||
private RabbitTemplate template; |
|||
|
|||
|
|||
@PostMapping("/addOrder/{uid}") |
|||
public void add(@PathVariable Long uid) { |
|||
|
|||
List<Cart> cart = cartRepository.getItems(uid); |
|||
|
|||
Orders ord = new Orders(); |
|||
for(Cart c : cart) { |
|||
|
|||
ord.setQuantity(c.getQuantity()); |
|||
ord.setTotalPrice(c.getTotalPrice()); |
|||
ord.setUid(c.getUser().getId()); |
|||
ord.setUsername(c.getUser().getUsername()); |
|||
ord.setPid(c.getProduct().getId()); |
|||
ord.setPname(c.getProduct().getName()); |
|||
orderRepository.save(ord); |
|||
OrderStatus orderStatus = new OrderStatus(ord, "PROCESS", "order placed succesfully in " + uid); |
|||
template.convertAndSend(MessagingConfig.EXCHANGE, MessagingConfig.ROUTING_KEY, orderStatus); |
|||
|
|||
} |
|||
|
|||
cartRepository.deleteItems(uid); |
|||
|
|||
|
|||
} |
|||
|
|||
@DeleteMapping("/orders/{oid}") |
|||
public void deleteFromOrder(@PathVariable("oid") Long oid) { |
|||
orderRepository.deleteById(oid); |
|||
} |
|||
} |
|||
|
|||
@ -1,3 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
encoding//src/main/java=UTF-8 |
|||
encoding/<project>=UTF-8 |
|||
@ -1,25 +0,0 @@ |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.security.core.userdetails.UserDetailsService; |
|||
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import com.myrestapp.demo.model.User; |
|||
import com.myrestapp.demo.repository.UserRepo; |
|||
|
|||
|
|||
@Service |
|||
public class MyUserDetailsService implements UserDetailsService |
|||
{ |
|||
@Autowired |
|||
private UserRepo userRepository; |
|||
|
|||
@Override |
|||
public UserDetails loadUserByUsername(String username) |
|||
throws UsernameNotFoundException |
|||
{ |
|||
User user=userRepository.getByUsername(username); |
|||
|
|||
return user; |
|||
} |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
package com.javatechie.rabbitmq.demo.consumer; |
|||
|
|||
import com.javatechie.rabbitmq.demo.config.MessagingConfig; |
|||
import com.javatechie.rabbitmq.demo.dto.OrderStatus; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
import org.bson.Document; |
|||
import com.mongodb.MongoClient; |
|||
import com.mongodb.client.MongoCollection; |
|||
import com.mongodb.client.MongoDatabase; |
|||
|
|||
@Component |
|||
public class User { |
|||
|
|||
@RabbitListener(queues = MessagingConfig.QUEUE) |
|||
public void consumeMessageFromQueue(OrderStatus orderStatus) { |
|||
System.out.println(orderStatus); |
|||
|
|||
MongoClient client = new MongoClient("labs4.koteshwar.com", 27017); |
|||
MongoDatabase db = client.getDatabase("paris"); |
|||
MongoCollection<Document> table = db.getCollection("expressGrocery"); |
|||
Document doc = new Document(); |
|||
doc.append("Order status:", orderStatus); |
|||
table.insertOne(doc); |
|||
client.close(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,65 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
import static org.mockito.BDDMockito.given; |
|||
import static org.mockito.Mockito.times; |
|||
import static org.mockito.Mockito.verify; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import org.mockito.InjectMocks; |
|||
import org.mockito.Mock; |
|||
import org.mockito.MockitoAnnotations; |
|||
|
|||
|
|||
|
|||
public class UserServiceTest { |
|||
|
|||
@Mock |
|||
private UserRepo userRepository; |
|||
|
|||
@InjectMocks |
|||
private UserServiceImpl userService; |
|||
|
|||
private User m1 = new User("Paddy Welbourn", "pwelbourn0@ed.gov"); |
|||
private User m2 = new User("Wren Flori", "wflori2@webeden.co.uk"); |
|||
private User m3 = new User("Ambrosio Smewing", "asmewing4@hostgator.com"); |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
MockitoAnnotations.initMocks(this); |
|||
|
|||
m1.setId(1L); |
|||
m2.setId(2L); |
|||
m3.setId(3L); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testGetUserById() { |
|||
//given |
|||
given(userRepository.findById(1L)).willReturn(Optional.of(m1)); |
|||
|
|||
//calling method under the test |
|||
User result = userService.getUserById(1L); |
|||
|
|||
//assert |
|||
// assertThat(result.isPresent()).isTrue(); |
|||
|
|||
//assert |
|||
// assertUserFields(result.orElseGet(null)); |
|||
|
|||
//verify that repository was called |
|||
verify(userRepository, times(1)).findById(1L); |
|||
} |
|||
|
|||
|
|||
private void assertUserFields(User user) { |
|||
assertThat(user.getId()).isInstanceOf(Long.class); |
|||
assertThat(user.getId()).isEqualTo(1); |
|||
assertThat(user.getUsername()).isEqualTo("Paddy Welbourn"); |
|||
assertThat(user.getEmail()).isEqualTo("pwelbourn0@ed.gov"); |
|||
} |
|||
} |
|||
@ -1,79 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class CartDto { |
|||
private Long cid; |
|||
private double quantity; |
|||
private double totalPrice; |
|||
|
|||
private Long pid; |
|||
private String imag; |
|||
private String name; |
|||
private double price; |
|||
|
|||
private Long uid; |
|||
private String username; |
|||
private String apartments; |
|||
public Long getCid() { |
|||
return cid; |
|||
} |
|||
public void setCid(Long cid) { |
|||
this.cid = cid; |
|||
} |
|||
public double getQuantity() { |
|||
return quantity; |
|||
} |
|||
public void setQuantity(double quantity) { |
|||
this.quantity = quantity; |
|||
} |
|||
public Double getTotalPrice() { |
|||
return totalPrice; |
|||
} |
|||
public void setTotalPrice(Double totalPrice) { |
|||
this.totalPrice = totalPrice; |
|||
} |
|||
public Long getPid() { |
|||
return pid; |
|||
} |
|||
public void setPid(Long pid) { |
|||
this.pid = pid; |
|||
} |
|||
public String getImag() { |
|||
return imag; |
|||
} |
|||
public void setImag(String imag) { |
|||
this.imag = imag; |
|||
} |
|||
public String getName() { |
|||
return name; |
|||
} |
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
public double getPrice() { |
|||
return price; |
|||
} |
|||
public void setPrice(double price) { |
|||
this.price = price; |
|||
} |
|||
public Long getUid() { |
|||
return uid; |
|||
} |
|||
public void setUid(Long uid) { |
|||
this.uid = uid; |
|||
} |
|||
public String getUsername() { |
|||
return username; |
|||
} |
|||
public void setUsername(String username) { |
|||
this.username = username; |
|||
} |
|||
public String getApartments() { |
|||
return apartments; |
|||
} |
|||
public void setApartments(String apartments) { |
|||
this.apartments = apartments; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
|
|||
server.port=59277 |
|||
spring.security.user.name=user |
|||
spring.security.user.password=24gh39ugh0 |
|||
|
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\java\\com\\example"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,13 +0,0 @@ |
|||
server.port=5008 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.26:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/productapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,26 +0,0 @@ |
|||
package com.example.demo.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Modifying; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
|
|||
|
|||
public interface CartRepo extends JpaRepository<Cart, Long> { |
|||
|
|||
List<Cart> findByUserId(Long uid); |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id = ?1") |
|||
List<Cart> getItems(Long uid); |
|||
|
|||
|
|||
@Modifying |
|||
@Transactional |
|||
@Query("delete from Cart c where c.user.id=?1") |
|||
void deleteItems(Long uid); |
|||
|
|||
} |
|||
@ -1,10 +0,0 @@ |
|||
package com.example.demo; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
|
|||
import com.example.demo.model.Orders; |
|||
|
|||
|
|||
public interface OrderRepo extends JpaRepository<Orders, Long> { |
|||
|
|||
|
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class UserServiceImpl { |
|||
|
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
server.port=5008 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.23:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/productapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,6 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
org.eclipse.jdt.core.compiler.release=disabled |
|||
org.eclipse.jdt.core.compiler.source=1.8 |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public interface UserService { |
|||
|
|||
} |
|||
@ -1,2 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,32 +0,0 @@ |
|||
package hello |
|||
|
|||
import scala.concurrent.duration._ |
|||
|
|||
import io.gatling.core.Predef._ |
|||
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder} |
|||
import io.gatling.http.Predef._ |
|||
import io.gatling.http.protocol.HttpProtocolBuilder |
|||
|
|||
class LoadTest extends Simulation { |
|||
|
|||
val httpProtocol: HttpProtocolBuilder = http |
|||
.baseUrl("http://localhost:5007") |
|||
|
|||
object HelloWorldResource { |
|||
val get: ChainBuilder = exec(http("Logging on") |
|||
.get("/login") |
|||
.basicAuth("user", "24gh39ugh0")) |
|||
} |
|||
|
|||
val myScenario: ScenarioBuilder = scenario("RampUpUsers") |
|||
.exec(HelloWorldResource.get) |
|||
|
|||
setUp(myScenario.inject( |
|||
incrementUsersPerSec(20) |
|||
.times(5) |
|||
.eachLevelLasting(5 seconds) |
|||
.separatedByRampsLasting(5 seconds) |
|||
.startingFrom(20) |
|||
)).protocols(httpProtocol) |
|||
.assertions(global.successfulRequests.percent.is(100)) |
|||
} |
|||
@ -1,27 +0,0 @@ |
|||
package com.example.demo.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Modifying; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
|
|||
|
|||
|
|||
public interface CartRepo extends JpaRepository<Cart, Long> { |
|||
|
|||
List<Cart> findByUserId(Long uid); |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id = ?1") |
|||
List<Cart> getItems(Long uid); |
|||
|
|||
|
|||
@Modifying |
|||
@Transactional |
|||
@Query("delete from Cart c where c.user.id=?1") |
|||
void deleteItems(Long uid); |
|||
|
|||
} |
|||
@ -1,62 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class OrderController { |
|||
|
|||
|
|||
@Autowired |
|||
private OrderRepo orderRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
@Autowired |
|||
private RabbitTemplate template; |
|||
|
|||
|
|||
@PostMapping("/addOrder/{uid}") |
|||
public void add(@PathVariable Long uid) { |
|||
|
|||
List<Cart> cart = cartRepository.getItems(uid); |
|||
|
|||
Orders ord = new Orders(); |
|||
for(Cart c : cart) { |
|||
|
|||
ord.setQuantity(c.getQuantity()); |
|||
ord.setTotalPrice(c.getTotalPrice()); |
|||
ord.setUid(c.getUser().getId()); |
|||
ord.setUsername(c.getUser().getUsername()); |
|||
ord.setPid(c.getProduct().getId()); |
|||
ord.setPname(c.getProduct().getName()); |
|||
orderRepository.save(ord); |
|||
OrderStatus orderStatus = new OrderStatus(ord, "PROCESS", "order placed succesfully in " + uid); |
|||
template.convertAndSend(MessagingConfig.EXCHANGE, MessagingConfig.ROUTING_KEY, orderStatus); |
|||
|
|||
} |
|||
|
|||
cartRepository.deleteItems(uid); |
|||
|
|||
|
|||
} |
|||
|
|||
@DeleteMapping("/orders/{oid}") |
|||
public void deleteFromOrder(@PathVariable("oid") Long oid) { |
|||
orderRepository.deleteById(oid); |
|||
} |
|||
} |
|||
|
|||
@ -1,109 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
import com.example.demo.model.Cart; |
|||
import com.example.demo.model.CartDto; |
|||
import com.example.demo.model.Product; |
|||
import com.example.demo.model.User; |
|||
import com.example.demo.repository.CartRepo; |
|||
import com.example.demo.repository.ProductRepo; |
|||
import com.example.demo.repository.UserRepo; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class CartController { |
|||
|
|||
@Autowired |
|||
private UserRepo userRepository; |
|||
@Autowired |
|||
private ProductRepo productRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
|
|||
@PostMapping("/cart/{uid}/{pid}") |
|||
public Cart postCart(@RequestBody Cart cart, @PathVariable("uid") Long uid, @PathVariable("pid") Long pid) { |
|||
Product product = productRepository.getById(pid); |
|||
User user = userRepository.getById(uid); |
|||
cart.setUser(user); |
|||
cart.setProduct(product); |
|||
int q=1; |
|||
cart.setQuantity(q); |
|||
cart.setTotalPrice(cart.getProduct().getPrice()*cart.getQuantity()); |
|||
return cartRepository.save(cart); |
|||
} |
|||
|
|||
@GetMapping("/cartdto/{uid}") |
|||
public List<CartDto> getCartdto(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
List<CartDto> listDto = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
for(Cart c : list) { |
|||
CartDto cartDto = new CartDto(); |
|||
|
|||
cartDto.setCid(c.getId()); |
|||
cartDto.setQuantity(c.getQuantity()); |
|||
cartDto.setTotalPrice(c.getQuantity()*c.getProduct().getPrice()); |
|||
|
|||
cartDto.setPid(c.getProduct().getId()); |
|||
cartDto.setImag(c.getProduct().getImag()); |
|||
cartDto.setName(c.getProduct().getName()); |
|||
cartDto.setPrice(c.getProduct().getPrice()); |
|||
|
|||
cartDto.setUid(c.getUser().getId()); |
|||
cartDto.setUsername(c.getUser().getUsername()); |
|||
cartDto.setApartments(c.getUser().getApartments()); |
|||
|
|||
listDto.add(cartDto); |
|||
} |
|||
return listDto; |
|||
} |
|||
|
|||
@GetMapping("/cart/{uid}") |
|||
public List<Cart> getCartByUser(@PathVariable("uid") Long uid) { |
|||
return cartRepository.findByUserId(uid); |
|||
} |
|||
|
|||
@PostMapping("/cartquant/{cid}/{quantity}") |
|||
public Double addQuantity(@PathVariable("cid") Long cid, @PathVariable("quantity") Double quantity) { |
|||
Cart cart= cartRepository.getById(cid); |
|||
cart.setQuantity(quantity); |
|||
cart.setTotalPrice(quantity*cart.getProduct().getPrice()); |
|||
cartRepository.save(cart); |
|||
return cart.getTotalPrice(); |
|||
} |
|||
|
|||
@PostMapping("/cartsum/{uid}") |
|||
public Double getCartSum(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
Cart cart = new Cart(); |
|||
Double sum = 0.0; |
|||
for(Cart c : list) { |
|||
sum=sum+ c.getTotalPrice(); |
|||
} |
|||
|
|||
return sum; |
|||
} |
|||
|
|||
@DeleteMapping("/cart/{cid}") |
|||
public void deleteFromCart(@PathVariable("cid") Long cid) { |
|||
cartRepository.deleteById(cid); |
|||
} |
|||
} |
|||
|
|||
@ -1,3 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,43 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
@Override |
|||
public User saveUser(User user) { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.save(user); |
|||
} |
|||
|
|||
@Override |
|||
public List<User> findAllAccounts() { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.findAll(); |
|||
} |
|||
|
|||
@Override |
|||
public User getUserById(Long id) { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.findById(id); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
package com.javatechie.rabbitmq.demo.consumer; |
|||
|
|||
import com.javatechie.rabbitmq.demo.config.MessagingConfig; |
|||
import com.javatechie.rabbitmq.demo.dto.OrderStatus; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
import org.bson.Document; |
|||
import com.mongodb.MongoClient; |
|||
import com.mongodb.client.MongoCollection; |
|||
import com.mongodb.client.MongoDatabase; |
|||
|
|||
@Component |
|||
public class User { |
|||
|
|||
@RabbitListener(queues = MessagingConfig.QUEUE) |
|||
public void consumeMessageFromQueue(OrderStatus orderStatus) { |
|||
System.out.println(orderStatus); |
|||
|
|||
MongoClient client = new MongoClient("localhost", 27017); |
|||
MongoDatabase db = client.getDatabase("practice"); |
|||
MongoCollection<Document> table = db.getCollection("employ"); |
|||
Document doc = new Document(); |
|||
doc.append("empno", 10); |
|||
doc.append("name", "Sai Kumar"); |
|||
doc.append("dept", "Java"); |
|||
doc.append("desig", "Programmer"); |
|||
doc.append("basic", 98892); |
|||
table.insertOne(doc); |
|||
client.close(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class Cart { |
|||
|
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class MessagingConfig { |
|||
|
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
public class ProductController { |
|||
|
|||
|
|||
@Autowired |
|||
private ProductRepo productRepository; |
|||
|
|||
|
|||
@GetMapping("/product") |
|||
public List<Product> getAllProducts(){ |
|||
List<Product> list = productRepository.findAll(); |
|||
return list; |
|||
} |
|||
|
|||
@PostMapping("/product") |
|||
public List<Product> postProduct(@RequestBody Product product) { |
|||
List<Product> list = productRepository.save(product); |
|||
return list; |
|||
} |
|||
|
|||
@GetMapping("/product/{category}") |
|||
public List<Product> getAllProductsByCategory(@PathVariable("category") String category) { |
|||
return productRepository.findByCategory(category); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
server.port=5009 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.23:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/orderapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
spring.rabbitmq.host=labs4.koteshwar.com |
|||
|
|||
spring.rabbitmq.password=guest |
|||
spring.rabbitmq.port=5672 |
|||
|
|||
spring.rabbitmq.username=guest |
|||
|
|||
|
|||
@ -1,2 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
encoding/<project>=UTF-8 |
|||
@ -1,62 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class OrderController { |
|||
|
|||
|
|||
@Autowired |
|||
private OrderRepo orderRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
@Autowired |
|||
private RabbitTemplate template; |
|||
|
|||
|
|||
@PostMapping("/addOrder/{uid}") |
|||
public void add(@PathVariable Long uid) { |
|||
|
|||
List<Cart> cart = cartRepository.getItems(uid); |
|||
|
|||
Orders ord = new Orders(); |
|||
for(Cart c : cart) { |
|||
|
|||
ord.setQuantity(c.getQuantity()); |
|||
ord.setTotalPrice(c.getTotalPrice()); |
|||
ord.setUid(c.getUser().getId()); |
|||
ord.setUsername(c.getUser().getUsername()); |
|||
ord.setPid(c.getProduct().getId()); |
|||
ord.setPname(c.getProduct().getName()); |
|||
orderRepository.save(ord); |
|||
OrderStatus orderStatus = new OrderStatus(ord, "PROCESS", "order placed succesfully in " + uid); |
|||
template.convertAndSend(MessagingConfig.EXCHANGE, MessagingConfig.ROUTING_KEY, orderStatus); |
|||
|
|||
} |
|||
|
|||
cartRepository.deleteItems(uid); |
|||
|
|||
|
|||
} |
|||
|
|||
@DeleteMapping("/orders/{oid}") |
|||
public void deleteFromOrder(@PathVariable("oid") Long oid) { |
|||
orderRepository.deleteById(oid); |
|||
} |
|||
} |
|||
|
|||
@ -1,15 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
public interface UserService { |
|||
|
|||
User saveUser(User user); |
|||
|
|||
List<User> findAllAccounts(); |
|||
|
|||
Optional<User> getUserById(Long id); |
|||
|
|||
|
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.OneToOne; |
|||
|
|||
|
|||
@Entity |
|||
public class Cart { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.AUTO) |
|||
private Long id; |
|||
private double quantity; |
|||
private double totalPrice; |
|||
|
|||
@OneToOne |
|||
private Product product; |
|||
|
|||
@OneToOne |
|||
private User user; |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public Product getProduct() { |
|||
return product; |
|||
} |
|||
|
|||
public void setProduct(Product product) { |
|||
this.product = product; |
|||
} |
|||
|
|||
public User getUser() { |
|||
return user; |
|||
} |
|||
|
|||
public void setUser(User user) { |
|||
this.user = user; |
|||
} |
|||
|
|||
public double getQuantity() { |
|||
return quantity; |
|||
} |
|||
|
|||
public void setQuantity(double quantity) { |
|||
this.quantity = quantity; |
|||
} |
|||
|
|||
public double getTotalPrice() { |
|||
return totalPrice; |
|||
} |
|||
|
|||
public void setTotalPrice(double totalPrice) { |
|||
this.totalPrice = totalPrice; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
server.port=58277 |
|||
spring.rabbitmq.host=labs4.koteshwar.com |
|||
|
|||
spring.rabbitmq.password=guest |
|||
spring.rabbitmq.port=5672 |
|||
|
|||
spring.rabbitmq.username=guest |
|||
|
|||
spring.application.name=Mongo DB Example |
|||
|
|||
|
|||
#Mongo Config |
|||
spring.data.mongodb.host=labs4.koteshwar.com |
|||
spring.data.mongodb.port=27017 |
|||
spring.data.mongodb.database=paris |
|||
spring.data.mongodb.repositories.enabled=true |
|||
spring.mongodb.username=parisadmin |
|||
spring.mongodb.password=password |
|||
@ -1,111 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
|
|||
@Entity |
|||
public class User { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.AUTO) |
|||
private Long id; |
|||
private String username; |
|||
private String fullname; |
|||
private String password; |
|||
private String gender; |
|||
private Long phone; |
|||
private String email; |
|||
private String address; |
|||
private String city; |
|||
private String state; |
|||
private int pincode; |
|||
private String apartments; |
|||
public User() { |
|||
super(); |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
|
|||
public User(String username, String email) { |
|||
super(); |
|||
this.username = username; |
|||
this.email = email; |
|||
} |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
public String getUsername() { |
|||
return username; |
|||
} |
|||
public void setUsername(String username) { |
|||
this.username = username; |
|||
} |
|||
public String getFullname() { |
|||
return fullname; |
|||
} |
|||
public void setFullname(String fullname) { |
|||
this.fullname = fullname; |
|||
} |
|||
public String getGender() { |
|||
return gender; |
|||
} |
|||
public void setGender(String gender) { |
|||
this.gender = gender; |
|||
} |
|||
public Long getPhone() { |
|||
return phone; |
|||
} |
|||
public void setPhone(Long phone) { |
|||
this.phone = phone; |
|||
} |
|||
public String getEmail() { |
|||
return email; |
|||
} |
|||
public void setEmail(String email) { |
|||
this.email = email; |
|||
} |
|||
public String getAddress() { |
|||
return address; |
|||
} |
|||
public void setAddress(String address) { |
|||
this.address = address; |
|||
} |
|||
public String getCity() { |
|||
return city; |
|||
} |
|||
public void setCity(String city) { |
|||
this.city = city; |
|||
} |
|||
public String getState() { |
|||
return state; |
|||
} |
|||
public void setState(String state) { |
|||
this.state = state; |
|||
} |
|||
public int getPincode() { |
|||
return pincode; |
|||
} |
|||
public void setPincode(int pincode) { |
|||
this.pincode = pincode; |
|||
} |
|||
public String getApartments() { |
|||
return apartments; |
|||
} |
|||
public void setApartments(String apartments) { |
|||
this.apartments = apartments; |
|||
} |
|||
public String getPassword() { |
|||
return password; |
|||
} |
|||
public void setPassword(String password) { |
|||
this.password = password; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
package com.example.demo.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Modifying; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
import com.example.demo.model.Cart; |
|||
|
|||
|
|||
|
|||
public interface CartRepo extends JpaRepository<Cart, Long> { |
|||
|
|||
List<Cart> findByUserId(Long uid); |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id = ?1") |
|||
List<Cart> getItems(Long uid); |
|||
|
|||
|
|||
@Modifying |
|||
@Transactional |
|||
@Query("delete from Cart c where c.user.id=?1") |
|||
void deleteItems(Long uid); |
|||
|
|||
} |
|||
@ -1,54 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.FixMethodOrder; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.junit.runners.MethodSorters; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.test.context.ContextConfiguration; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
import org.springframework.test.web.servlet.MockMvc; |
|||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|||
import org.springframework.web.context.WebApplicationContext; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@ContextConfiguration(classes = UserServiceApplication.class) |
|||
@SpringBootTest |
|||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
|||
public class UserControllerTest { |
|||
|
|||
private MockMvc mockMvc; |
|||
|
|||
@Autowired |
|||
private WebApplicationContext wac; |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); |
|||
} |
|||
@Test |
|||
public void shouldFindMemberById() throws Exception { |
|||
this.mockMvc.perform(MockMvcRequestBuilders.get("/user/" + "1") |
|||
.accept(MediaType.APPLICATION_JSON)) |
|||
.andDo(print()) |
|||
.andExpect(jsonPath("$.id").exists()) |
|||
.andExpect(jsonPath("$.id").value(2)) |
|||
.andExpect(jsonPath("$.name").exists()) |
|||
.andExpect(jsonPath("$.name").value("Mary Brown")) |
|||
.andExpect(jsonPath("$.email").value("mary.b@gmail.com")) |
|||
.andExpect(jsonPath("$.*", hasSize(3))) |
|||
.andReturn(); |
|||
} |
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
public interface UserService { |
|||
|
|||
Optional<User> getUserById(long id); |
|||
|
|||
User saveUser(User user); |
|||
|
|||
List<User> findAllAccounts(); |
|||
} |
|||
@ -1,105 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.example.demo.dto.CartDto; |
|||
import com.example.demo.model.Cart; |
|||
import com.example.demo.repository.CartRepo; |
|||
import com.example.demo.repository.UserRepo; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class CartController { |
|||
|
|||
@Autowired |
|||
private UserRepo userRepository; |
|||
@Autowired |
|||
private ProductRepo productRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
|
|||
@PostMapping("/cart/{uid}/{pid}") |
|||
public Cart postCart(@RequestBody Cart cart, @PathVariable("uid") Long uid, @PathVariable("pid") Long pid) { |
|||
Product product = productRepository.getById(pid); |
|||
User user = userRepository.getById(uid); |
|||
cart.setUser(user); |
|||
cart.setProduct(product); |
|||
int q=1; |
|||
cart.setQuantity(q); |
|||
cart.setTotalPrice(cart.getProduct().getPrice()*cart.getQuantity()); |
|||
return cartRepository.save(cart); |
|||
} |
|||
|
|||
@GetMapping("/cartdto/{uid}") |
|||
public List<CartDto> getCartdto(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
List<CartDto> listDto = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
for(Cart c : list) { |
|||
CartDto cartDto = new CartDto(); |
|||
|
|||
cartDto.setCid(c.getId()); |
|||
cartDto.setQuantity(c.getQuantity()); |
|||
cartDto.setTotalPrice(c.getQuantity()*c.getProduct().getPrice()); |
|||
|
|||
cartDto.setPid(c.getProduct().getId()); |
|||
cartDto.setImag(c.getProduct().getImag()); |
|||
cartDto.setName(c.getProduct().getName()); |
|||
cartDto.setPrice(c.getProduct().getPrice()); |
|||
|
|||
cartDto.setUid(c.getUser().getId()); |
|||
cartDto.setUsername(c.getUser().getUsername()); |
|||
cartDto.setApartments(c.getUser().getApartments()); |
|||
|
|||
listDto.add(cartDto); |
|||
} |
|||
return listDto; |
|||
} |
|||
|
|||
@GetMapping("/cart/{uid}") |
|||
public List<Cart> getCartByUser(@PathVariable("uid") Long uid) { |
|||
return cartRepository.findByUserId(uid); |
|||
} |
|||
|
|||
@PostMapping("/cartquant/{cid}/{quantity}") |
|||
public Double addQuantity(@PathVariable("cid") Long cid, @PathVariable("quantity") Double quantity) { |
|||
Cart cart= cartRepository.getById(cid); |
|||
cart.setQuantity(quantity); |
|||
cart.setTotalPrice(quantity*cart.getProduct().getPrice()); |
|||
cartRepository.save(cart); |
|||
return cart.getTotalPrice(); |
|||
} |
|||
|
|||
@PostMapping("/cartsum/{uid}") |
|||
public Double getCartSum(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
Cart cart = new Cart(); |
|||
Double sum = 0.0; |
|||
for(Cart c : list) { |
|||
sum=sum+ c.getTotalPrice(); |
|||
} |
|||
|
|||
return sum; |
|||
} |
|||
|
|||
@DeleteMapping("/cart/{cid}") |
|||
public void deleteFromCart(@PathVariable("cid") Long cid) { |
|||
cartRepository.deleteById(cid); |
|||
} |
|||
} |
|||
|
|||
@ -1,13 +0,0 @@ |
|||
server.port=5008 |
|||
|
|||
spring.datasource.url=jdbc:mysql://localhost:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=root |
|||
spring.datasource.password=Password123 |
|||
server.servlet.context-path=/productapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,91 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.OneToOne; |
|||
|
|||
|
|||
@Entity |
|||
public class Orders { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.AUTO) |
|||
private Long id; |
|||
private double quantity; |
|||
private double totalPrice; |
|||
private Long uid; |
|||
private String username; |
|||
private Long pid; |
|||
private String pname; |
|||
public Orders() { |
|||
super(); |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
public Orders(Long id, double quantity, double totalPrice, Long uid, String username, Long pid, String pname) { |
|||
super(); |
|||
this.id = id; |
|||
this.quantity = quantity; |
|||
this.totalPrice = totalPrice; |
|||
this.uid = uid; |
|||
this.username = username; |
|||
this.pid = pid; |
|||
this.pname = pname; |
|||
} |
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
public double getQuantity() { |
|||
return quantity; |
|||
} |
|||
public void setQuantity(double quantity) { |
|||
this.quantity = quantity; |
|||
} |
|||
public double getTotalPrice() { |
|||
return totalPrice; |
|||
} |
|||
public void setTotalPrice(double totalPrice) { |
|||
this.totalPrice = totalPrice; |
|||
} |
|||
public Long getUid() { |
|||
return uid; |
|||
} |
|||
public void setUid(Long uid) { |
|||
this.uid = uid; |
|||
} |
|||
public String getUsername() { |
|||
return username; |
|||
} |
|||
public void setUsername(String username) { |
|||
this.username = username; |
|||
} |
|||
public Long getPid() { |
|||
return pid; |
|||
} |
|||
public void setPid(Long pid) { |
|||
this.pid = pid; |
|||
} |
|||
public String getPname() { |
|||
return pname; |
|||
} |
|||
public void setPname(String pname) { |
|||
this.pname = pname; |
|||
} |
|||
@Override |
|||
public String toString() { |
|||
return "Orders [id=" + id + ", quantity=" + quantity + ", totalPrice=" + totalPrice + ", uid=" + uid |
|||
+ ", username=" + username + ", pid=" + pid + ", pname=" + pname + "]"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
encoding//src/main/java=UTF-8 |
|||
encoding/<project>=UTF-8 |
|||
@ -1,18 +0,0 @@ |
|||
server.port=58277 |
|||
spring.rabbitmq.host=labs4.koteshwar.com |
|||
|
|||
spring.rabbitmq.password=guest |
|||
spring.rabbitmq.port=5672 |
|||
|
|||
spring.rabbitmq.username=guest |
|||
|
|||
spring.application.name=Mongo DB Example |
|||
|
|||
|
|||
#Mongo Config |
|||
spring.data.mongodb.host=labs4.koteshwar.com |
|||
spring.data.mongodb.port=27017 |
|||
spring.data.mongodb.database=mongo |
|||
spring.data.mongodb.repositories.enabled=true |
|||
spring.mongodb.username=parisadmin |
|||
spring.mongodb.password=password |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo.securityfile; |
|||
|
|||
public class MyUsersDetailsService { |
|||
|
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
@Override |
|||
public User saveUser(User user) { |
|||
// TODO Auto-generated method stub |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public List<User> findAllAccounts() { |
|||
// TODO Auto-generated method stub |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public User getUserById(Long id) { |
|||
// TODO Auto-generated method stub |
|||
return null; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
package com.javatechie.rabbitmq.demo.consumer; |
|||
|
|||
import com.javatechie.rabbitmq.demo.config.MessagingConfig; |
|||
import com.javatechie.rabbitmq.demo.dto.OrderStatus; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
import org.bson.Document; |
|||
import com.mongodb.MongoClient; |
|||
import com.mongodb.client.MongoCollection; |
|||
import com.mongodb.client.MongoDatabase; |
|||
|
|||
@Component |
|||
public class User { |
|||
|
|||
@RabbitListener(queues = MessagingConfig.QUEUE) |
|||
public void consumeMessageFromQueue(OrderStatus orderStatus) { |
|||
System.out.println(orderStatus); |
|||
|
|||
public class AddEmploy { |
|||
|
|||
public static void main(String[] args) { |
|||
MongoClient client = new MongoClient("localhost", 27017); |
|||
MongoDatabase db = client.getDatabase("practice"); |
|||
MongoCollection<Document> table = db.getCollection("employ"); |
|||
Document doc = new Document(); |
|||
doc.append("empno", 10); |
|||
doc.append("name", "Sai Kumar"); |
|||
doc.append("dept", "Java"); |
|||
doc.append("desig", "Programmer"); |
|||
doc.append("basic", 98892); |
|||
table.insertOne(doc); |
|||
client.close(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public interface OrderRepo { |
|||
|
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
@Override |
|||
public User saveUser(User user) { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.save(user); |
|||
} |
|||
|
|||
@Override |
|||
public List<User> findAllAccounts() { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.findAll(); |
|||
} |
|||
|
|||
@Override |
|||
public User getUserById(Long id) { |
|||
// TODO Auto-generated method stub |
|||
return userRepository.findById(id); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest |
|||
class UserServiceApplicationTests { |
|||
|
|||
@Test |
|||
void contextLoads() { |
|||
} |
|||
|
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
server.port=5006 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.26:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/cartapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,70 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.example.demo.config.MessagingConfig; |
|||
import com.example.demo.model.Cart; |
|||
import com.example.demo.model.OrderStatus; |
|||
import com.example.demo.model.Orders; |
|||
import com.example.demo.repository.CartRepo; |
|||
import com.example.demo.repository.OrderRepo; |
|||
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class OrderController { |
|||
|
|||
|
|||
@Autowired |
|||
private OrderRepo orderRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
@Autowired |
|||
private RabbitTemplate template; |
|||
|
|||
|
|||
@PostMapping("/addOrder/{uid}") |
|||
public void add(@PathVariable Long uid) { |
|||
|
|||
List<Cart> cart = cartRepository.getItems(uid); |
|||
|
|||
Orders ord = new Orders(); |
|||
for(Cart c : cart) { |
|||
|
|||
ord.setQuantity(c.getQuantity()); |
|||
ord.setTotalPrice(c.getTotalPrice()); |
|||
ord.setUid(c.getUser().getId()); |
|||
ord.setUsername(c.getUser().getUsername()); |
|||
ord.setPid(c.getProduct().getId()); |
|||
ord.setPname(c.getProduct().getName()); |
|||
orderRepository.save(ord); |
|||
// OrderStatus orderStatus = new OrderStatus(ord, "PROCESS", "order placed succesfully in " + uid); |
|||
// template.convertAndSend(MessagingConfig.EXCHANGE, MessagingConfig.ROUTING_KEY, orderStatus); |
|||
|
|||
} |
|||
|
|||
cartRepository.deleteItems(uid); |
|||
|
|||
|
|||
} |
|||
|
|||
@DeleteMapping("/orders/{oid}") |
|||
public void deleteFromOrder(@PathVariable("oid") Long oid) { |
|||
orderRepository.deleteById(oid); |
|||
} |
|||
} |
|||
|
|||
@ -1,75 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-parent</artifactId> |
|||
<version>2.5.4</version> |
|||
<relativePath/> <!-- lookup parent from repository --> |
|||
</parent> |
|||
<groupId>com.example</groupId> |
|||
<artifactId>UserService</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
<name>UserService</name> |
|||
<description>Demo project for Spring Boot</description> |
|||
<properties> |
|||
<java.version>1.8</java.version> |
|||
</properties> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-jpa</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-security</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.junit.vintage</groupId> |
|||
<artifactId>junit-vintage-engine</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-devtools</artifactId> |
|||
<scope>runtime</scope> |
|||
<optional>true</optional> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
<scope>runtime</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.mockito</groupId> |
|||
<artifactId>mockito-all</artifactId> |
|||
<version>1.10.19</version> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.security</groupId> |
|||
<artifactId>spring-security-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
|||
@ -1,4 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
encoding//src/main/java=UTF-8 |
|||
encoding//src/main/resources=UTF-8 |
|||
encoding/<project>=UTF-8 |
|||
@ -1,100 +0,0 @@ |
|||
package com.example.demo.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class CartController { |
|||
|
|||
@Autowired |
|||
private UserRepo userRepository; |
|||
@Autowired |
|||
private ProductRepo productRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
|
|||
@PostMapping("/cart/{uid}/{pid}") |
|||
public Cart postCart(@RequestBody Cart cart, @PathVariable("uid") Long uid, @PathVariable("pid") Long pid) { |
|||
Product product = productRepository.getById(pid); |
|||
User user = userRepository.getById(uid); |
|||
cart.setUser(user); |
|||
cart.setProduct(product); |
|||
int q=1; |
|||
cart.setQuantity(q); |
|||
cart.setTotalPrice(cart.getProduct().getPrice()*cart.getQuantity()); |
|||
return cartRepository.save(cart); |
|||
} |
|||
|
|||
@GetMapping("/cartdto/{uid}") |
|||
public List<CartDto> getCartdto(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
List<CartDto> listDto = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
for(Cart c : list) { |
|||
CartDto cartDto = new CartDto(); |
|||
|
|||
cartDto.setCid(c.getId()); |
|||
cartDto.setQuantity(c.getQuantity()); |
|||
cartDto.setTotalPrice(c.getQuantity()*c.getProduct().getPrice()); |
|||
|
|||
cartDto.setPid(c.getProduct().getId()); |
|||
cartDto.setImag(c.getProduct().getImag()); |
|||
cartDto.setName(c.getProduct().getName()); |
|||
cartDto.setPrice(c.getProduct().getPrice()); |
|||
|
|||
cartDto.setUid(c.getUser().getId()); |
|||
cartDto.setUsername(c.getUser().getUsername()); |
|||
cartDto.setApartments(c.getUser().getApartments()); |
|||
|
|||
listDto.add(cartDto); |
|||
} |
|||
return listDto; |
|||
} |
|||
|
|||
@GetMapping("/cart/{uid}") |
|||
public List<Cart> getCartByUser(@PathVariable("uid") Long uid) { |
|||
return cartRepository.findByUserId(uid); |
|||
} |
|||
|
|||
@PostMapping("/cartquant/{cid}/{quantity}") |
|||
public Double addQuantity(@PathVariable("cid") Long cid, @PathVariable("quantity") Double quantity) { |
|||
Cart cart= cartRepository.getById(cid); |
|||
cart.setQuantity(quantity); |
|||
cart.setTotalPrice(quantity*cart.getProduct().getPrice()); |
|||
cartRepository.save(cart); |
|||
return cart.getTotalPrice(); |
|||
} |
|||
|
|||
@PostMapping("/cartsum/{uid}") |
|||
public Double getCartSum(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
Cart cart = new Cart(); |
|||
Double sum = 0.0; |
|||
for(Cart c : list) { |
|||
sum=sum+ c.getTotalPrice(); |
|||
} |
|||
|
|||
return sum; |
|||
} |
|||
|
|||
@DeleteMapping("/cart/{cid}") |
|||
public void deleteFromCart(@PathVariable("cid") Long cid) { |
|||
cartRepository.deleteById(cid); |
|||
} |
|||
} |
|||
|
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\resources\\generated.json"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,15 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
public interface UserService { |
|||
|
|||
User saveUser(User user); |
|||
|
|||
List<User> findAllAccounts(); |
|||
|
|||
User getUserById(Long id); |
|||
|
|||
|
|||
} |
|||
@ -1,155 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.GenerationType; |
|||
import javax.persistence.Id; |
|||
|
|||
import org.springframework.security.core.GrantedAuthority; |
|||
import org.springframework.security.core.authority.SimpleGrantedAuthority; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
|
|||
@Entity |
|||
public class User implements UserDetails { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy = GenerationType.AUTO) |
|||
private Long id; |
|||
private String username; |
|||
private String password; |
|||
private String fullname; |
|||
private String gender; |
|||
private Long phone; |
|||
private String email; |
|||
private String address; |
|||
private String city; |
|||
private String state; |
|||
private int pincode; |
|||
private String apartments; |
|||
public User() { |
|||
super(); |
|||
// TODO Auto-generated constructor stub |
|||
} |
|||
|
|||
|
|||
public User(String username, String email) { |
|||
super(); |
|||
this.username = username; |
|||
this.email = email; |
|||
} |
|||
|
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
public String getUsername() { |
|||
return username; |
|||
} |
|||
public void setUsername(String username) { |
|||
this.username = username; |
|||
} |
|||
|
|||
public String getPassword() { |
|||
return password; |
|||
} |
|||
public void setPassword(String password) { |
|||
this.password = password; |
|||
} |
|||
public String getFullname() { |
|||
return fullname; |
|||
} |
|||
public void setFullname(String fullname) { |
|||
this.fullname = fullname; |
|||
} |
|||
public String getGender() { |
|||
return gender; |
|||
} |
|||
public void setGender(String gender) { |
|||
this.gender = gender; |
|||
} |
|||
public Long getPhone() { |
|||
return phone; |
|||
} |
|||
public void setPhone(Long phone) { |
|||
this.phone = phone; |
|||
} |
|||
public String getEmail() { |
|||
return email; |
|||
} |
|||
public void setEmail(String email) { |
|||
this.email = email; |
|||
} |
|||
public String getAddress() { |
|||
return address; |
|||
} |
|||
public void setAddress(String address) { |
|||
this.address = address; |
|||
} |
|||
public String getCity() { |
|||
return city; |
|||
} |
|||
public void setCity(String city) { |
|||
this.city = city; |
|||
} |
|||
public String getState() { |
|||
return state; |
|||
} |
|||
public void setState(String state) { |
|||
this.state = state; |
|||
} |
|||
public int getPincode() { |
|||
return pincode; |
|||
} |
|||
public void setPincode(int pincode) { |
|||
this.pincode = pincode; |
|||
} |
|||
public String getApartments() { |
|||
return apartments; |
|||
} |
|||
public void setApartments(String apartments) { |
|||
this.apartments = apartments; |
|||
} |
|||
|
|||
@Override |
|||
public Collection<? extends GrantedAuthority> getAuthorities() { |
|||
List<GrantedAuthority>list=new ArrayList<>(); |
|||
SimpleGrantedAuthority sga = new SimpleGrantedAuthority(username); |
|||
list.add(sga); |
|||
|
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isAccountNonExpired() { |
|||
|
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isAccountNonLocked() { |
|||
|
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isCredentialsNonExpired() { |
|||
|
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isEnabled() { |
|||
|
|||
return true; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
@ -1,25 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,69 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
|
|||
@RestController |
|||
//@RequestMapping("/api/user") |
|||
public class UserController { |
|||
|
|||
// static String URI = "/api/user/"; |
|||
private final UserService userService; |
|||
|
|||
@Autowired |
|||
public UserController(UserService userService) { |
|||
this.userService = userService; |
|||
} |
|||
|
|||
|
|||
@PostMapping("/user") |
|||
public Optional<User> postUser(@RequestBody User user) { |
|||
return userService.saveUser(user); |
|||
} |
|||
|
|||
@GetMapping("/user") |
|||
public List<User> getAllAccounts(){ |
|||
List<User> list = userService.findAllAccounts(); |
|||
return list; |
|||
} |
|||
@GetMapping("/user/{id}") |
|||
public Optional<User> findUserById(@PathVariable("id") Long id) { |
|||
return userService.getUserById(id); |
|||
} |
|||
|
|||
@PutMapping("/user/{id}") |
|||
public Optional<User> updateUser(@PathVariable("id") Long id,@RequestBody User newVal) { |
|||
User userDB = userService.getUserById(id); |
|||
userDB.setUsername(newVal.getUsername()); |
|||
userDB.setFullname(newVal.getFullname()); |
|||
userDB.setGender(newVal.getGender()); |
|||
userDB.setPhone(newVal.getPhone()); |
|||
userDB.setEmail(newVal.getEmail()); |
|||
userDB.setAddress(newVal.getAddress()); |
|||
userDB.setCity(newVal.getCity()); |
|||
userDB.setState(newVal.getState()); |
|||
userDB.setPincode(newVal.getPincode()); |
|||
userDB.setApartments(newVal.getApartments()); |
|||
|
|||
return userService.saveUser(userDB); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,27 +0,0 @@ |
|||
package com.example.demo.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Modifying; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
|
|||
|
|||
|
|||
public interface CartRepo extends JpaRepository<Cart, Long> { |
|||
|
|||
List<Cart> findByUserId(Long uid); |
|||
|
|||
@Query("select c from Cart c join c.user u where u.id = ?1") |
|||
List<Cart> getItems(Long uid); |
|||
|
|||
|
|||
@Modifying |
|||
@Transactional |
|||
@Query("delete from Cart c where c.user.id=?1") |
|||
void deleteItems(Long uid); |
|||
|
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
|
|||
@SpringBootApplication |
|||
public class CartServiceApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(CartServiceApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
org.eclipse.jdt.core.compiler.release=disabled |
|||
org.eclipse.jdt.core.compiler.source=1.8 |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class CartController { |
|||
|
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
@Override |
|||
public Optional<User> getUserById(long id) { |
|||
return userRepository.findById(id); |
|||
} |
|||
|
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,65 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
import static org.mockito.BDDMockito.given; |
|||
import static org.mockito.Mockito.times; |
|||
import static org.mockito.Mockito.verify; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import org.mockito.InjectMocks; |
|||
import org.mockito.Mock; |
|||
import org.mockito.MockitoAnnotations; |
|||
|
|||
|
|||
|
|||
public class UserServiceTest { |
|||
|
|||
@Mock |
|||
private UserRepo userRepository; |
|||
|
|||
@InjectMocks |
|||
private UserServiceImpl userService; |
|||
|
|||
private User m1 = new User("Paddy Welbourn", "pwelbourn0@ed.gov"); |
|||
private User m2 = new User("Wren Flori", "wflori2@webeden.co.uk"); |
|||
private User m3 = new User("Ambrosio Smewing", "asmewing4@hostgator.com"); |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
MockitoAnnotations.initMocks(this); |
|||
|
|||
m1.setId(1L); |
|||
m2.setId(2L); |
|||
m3.setId(3L); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testGetUserById() { |
|||
//given |
|||
given(userRepository.findById(1L)).willReturn(Optional.of(m1)); |
|||
|
|||
//calling method under the test |
|||
Optional<User> result = userService.getUserById(1L); |
|||
|
|||
//assert |
|||
assertThat(result.isPresent()).isTrue(); |
|||
|
|||
//assert |
|||
assertUserFields(result.orElseGet(null)); |
|||
|
|||
//verify that repository was called |
|||
verify(userRepository, times(1)).findById(1L); |
|||
} |
|||
|
|||
|
|||
private void assertUserFields(User user) { |
|||
assertThat(user.getId()).isInstanceOf(Long.class); |
|||
assertThat(user.getId()).isEqualTo(1); |
|||
assertThat(user.getUsername()).isEqualTo("Paddy Welbourn"); |
|||
assertThat(user.getEmail()).isEqualTo("pwelbourn0@ed.gov"); |
|||
} |
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
package hello |
|||
|
|||
import scala.concurrent.duration._ |
|||
|
|||
import io.gatling.core.Predef._ |
|||
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder} |
|||
import io.gatling.http.Predef._ |
|||
import io.gatling.http.protocol.HttpProtocolBuilder |
|||
|
|||
class LoadTest extends Simulation { |
|||
|
|||
val httpProtocol: HttpProtocolBuilder = http |
|||
.baseUrl("http://localhost:59277") |
|||
|
|||
object HelloWorldResource { |
|||
val get: ChainBuilder = exec(http("HelloWorld") |
|||
.get("/") |
|||
.basicAuth("user", "24gh39ugh0")) |
|||
} |
|||
|
|||
val myScenario: ScenarioBuilder = scenario("RampUpUsers") |
|||
.exec(HelloWorldResource.get) |
|||
|
|||
setUp(myScenario.inject( |
|||
incrementUsersPerSec(20) |
|||
.times(5) |
|||
.eachLevelLasting(5 seconds) |
|||
.separatedByRampsLasting(5 seconds) |
|||
.startingFrom(20) |
|||
)).protocols(httpProtocol) |
|||
.assertions(global.successfulRequests.percent.is(100)) |
|||
} |
|||
@ -1,2 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,13 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
|
|||
@SpringBootApplication |
|||
public class OrderServiceApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(OrderServiceApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
package com.example.demo; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
|
|||
|
|||
public interface OrderRepo extends JpaRepository<Orders, Long> { |
|||
|
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
package hello |
|||
|
|||
import scala.concurrent.duration._ |
|||
|
|||
import io.gatling.core.Predef._ |
|||
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder} |
|||
import io.gatling.http.Predef._ |
|||
import io.gatling.http.protocol.HttpProtocolBuilder |
|||
|
|||
class LoadTest extends Simulation { |
|||
|
|||
val httpProtocol: HttpProtocolBuilder = http |
|||
.baseUrl("http://localhost:5007") |
|||
|
|||
object HelloWorldResource { |
|||
val get: ChainBuilder = exec(http("Logging on") |
|||
.get("/userapi/login") |
|||
.basicAuth("nitya", "jain")) |
|||
} |
|||
|
|||
val myScenario: ScenarioBuilder = scenario("RampUpUsers") |
|||
.exec(HelloWorldResource.get) |
|||
|
|||
setUp(myScenario.inject( |
|||
incrementUsersPerSec(1) |
|||
.times(1) |
|||
.eachLevelLasting(5 seconds) |
|||
.separatedByRampsLasting(5 seconds) |
|||
.startingFrom(1) |
|||
)).protocols(httpProtocol) |
|||
.assertions(global.successfulRequests.percent.is(100)) |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
|
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements UserService { |
|||
|
|||
private final UserRepo userRepository; |
|||
|
|||
@Autowired |
|||
public UserServiceImpl(UserRepo userRepository) { |
|||
this.userRepository = userRepository; |
|||
} |
|||
|
|||
@Override |
|||
public User getUserById(long id) { |
|||
return userRepository.findById(id); |
|||
} |
|||
|
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore |
|||
org.eclipse.jdt.core.compiler.release=disabled |
|||
org.eclipse.jdt.core.compiler.source=1.8 |
|||
@ -1,90 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.security.Principal; |
|||
import java.util.Base64; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
|
|||
@RestController |
|||
//@RequestMapping("/api/user") |
|||
public class UserController { |
|||
|
|||
// static String URI = "/api/user/"; |
|||
private final UserService userService; |
|||
|
|||
@Autowired |
|||
public UserController(UserService userService) { |
|||
this.userService = userService; |
|||
} |
|||
|
|||
@PostMapping("/signup") |
|||
public User postUser(@RequestBody User user) { |
|||
String code = user.getUsername(); |
|||
String username = new String(Base64.getDecoder().decode(code)).split(":")[0]; |
|||
String password = new String(Base64.getDecoder().decode(code)).split(":")[1]; |
|||
user.setUsername(username); |
|||
user.setPassword(password); |
|||
String encPassword = passwordEncoder.encode(user.getPassword()); |
|||
user.setPassword(encPassword); |
|||
return userRepository.save(user); |
|||
} |
|||
|
|||
@GetMapping("/login") |
|||
public Principal login(Principal principal) { |
|||
if(principal.getName()==null) |
|||
throw new Error("Invalid Credentials"); |
|||
return principal; |
|||
} |
|||
|
|||
@GetMapping("/user") |
|||
public List<User> getAllAccounts(){ |
|||
List<User> list = userService.findAllAccounts(); |
|||
return list; |
|||
} |
|||
@GetMapping("/user/{id}") |
|||
public Optional<User> findUserById(@PathVariable("id") Long id) { |
|||
return userService.getUserById(id); |
|||
} |
|||
|
|||
@GetMapping("/username/{username}") |
|||
public User getDetails(@PathVariable("username") String username) { |
|||
return userService.getByUsername(username); |
|||
} |
|||
|
|||
@PutMapping("/user/{id}") |
|||
public User updateUser(@PathVariable("id") Long id,@RequestBody User newVal) { |
|||
User userDB = userService.getUsersById(id); |
|||
userDB.setUsername(newVal.getUsername()); |
|||
userDB.setFullname(newVal.getFullname()); |
|||
userDB.setGender(newVal.getGender()); |
|||
userDB.setPhone(newVal.getPhone()); |
|||
userDB.setEmail(newVal.getEmail()); |
|||
userDB.setAddress(newVal.getAddress()); |
|||
userDB.setCity(newVal.getCity()); |
|||
userDB.setState(newVal.getState()); |
|||
userDB.setPincode(newVal.getPincode()); |
|||
userDB.setApartments(newVal.getApartments()); |
|||
|
|||
return userService.saveUser(userDB); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,3 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\resources"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,8 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore |
|||
org.eclipse.jdt.core.compiler.release=disabled |
|||
org.eclipse.jdt.core.compiler.source=1.8 |
|||
@ -1,65 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
import static org.mockito.BDDMockito.given; |
|||
import static org.mockito.Mockito.times; |
|||
import static org.mockito.Mockito.verify; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import org.mockito.InjectMocks; |
|||
import org.mockito.Mock; |
|||
import org.mockito.MockitoAnnotations; |
|||
|
|||
|
|||
|
|||
public class UserServiceTest { |
|||
|
|||
@Mock |
|||
private UserRepo userRepository; |
|||
|
|||
@InjectMocks |
|||
private UserServiceImpl userService; |
|||
|
|||
private User m1 = new User("Paddy Welbourn", "pwelbourn0@ed.gov"); |
|||
private User m2 = new User("Wren Flori", "wflori2@webeden.co.uk"); |
|||
private User m3 = new User("Ambrosio Smewing", "asmewing4@hostgator.com"); |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
MockitoAnnotations.initMocks(this); |
|||
|
|||
m1.setId(1L); |
|||
m2.setId(2L); |
|||
m3.setId(3L); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testGetUserById() { |
|||
//given |
|||
given(userRepository.findById(1L)).willReturn(Optional.of(m1)); |
|||
|
|||
//calling method under the test |
|||
Optional<User> result = userService.getUserById(1L); |
|||
|
|||
//assert |
|||
assertThat(result.isPresent()).isTrue(); |
|||
|
|||
//assert |
|||
assertUserFields(result.orElseGet(null)); |
|||
|
|||
//verify that repository was called |
|||
verify(userRepository, times(1)).findById(1L); |
|||
} |
|||
|
|||
|
|||
private void assertUserFields(User user) { |
|||
assertThat(user.getId()).isInstanceOf(Long.class); |
|||
assertThat(user.getId()).isEqualTo(1); |
|||
assertThat(user.getUsername()).isEqualTo("Paddy Welbourn"); |
|||
assertThat(user.getEmail()).isEqualTo("pwelbourn0@ed.gov"); |
|||
} |
|||
} |
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\resources\\static"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,13 +0,0 @@ |
|||
server.port=5007 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.23:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/userapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,69 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
|
|||
@RestController |
|||
//@RequestMapping("/api/user") |
|||
public class UserController { |
|||
|
|||
// static String URI = "/api/user/"; |
|||
private final UserService userService; |
|||
|
|||
@Autowired |
|||
public UserController(UserService userService) { |
|||
this.userService = userService; |
|||
} |
|||
|
|||
|
|||
@PostMapping("/user") |
|||
public User postUser(@RequestBody User user) { |
|||
return userService.saveUser(user); |
|||
} |
|||
|
|||
@GetMapping("/user") |
|||
public List<User> getAllAccounts(){ |
|||
List<User> list = userService.findAllAccounts(); |
|||
return list; |
|||
} |
|||
@GetMapping("/user/{id}") |
|||
public User findUserById(@PathVariable("id") Long id) { |
|||
return userService.getUserById(id); |
|||
} |
|||
|
|||
@PutMapping("/user/{id}") |
|||
public User updateUser(@PathVariable("id") Long id,@RequestBody User newVal) { |
|||
User userDB = userService.getUserById(id); |
|||
userDB.setUsername(newVal.getUsername()); |
|||
userDB.setFullname(newVal.getFullname()); |
|||
userDB.setGender(newVal.getGender()); |
|||
userDB.setPhone(newVal.getPhone()); |
|||
userDB.setEmail(newVal.getEmail()); |
|||
userDB.setAddress(newVal.getAddress()); |
|||
userDB.setCity(newVal.getCity()); |
|||
userDB.setState(newVal.getState()); |
|||
userDB.setPincode(newVal.getPincode()); |
|||
userDB.setApartments(newVal.getApartments()); |
|||
|
|||
return userService.saveUser(userDB); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\resources"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,54 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|||
|
|||
import org.junit.Before; |
|||
import org.junit.FixMethodOrder; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.junit.runners.MethodSorters; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.test.context.ContextConfiguration; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
import org.springframework.test.web.servlet.MockMvc; |
|||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|||
import org.springframework.web.context.WebApplicationContext; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@ContextConfiguration(classes = UserServiceApplication.class) |
|||
@SpringBootTest |
|||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
|||
public class UserControllerTest { |
|||
|
|||
private MockMvc mockMvc; |
|||
|
|||
@Autowired |
|||
private WebApplicationContext wac; |
|||
|
|||
@Before |
|||
public void setUp() { |
|||
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); |
|||
} |
|||
@Test |
|||
public void shouldFindMemberById() throws Exception { |
|||
this.mockMvc.perform(MockMvcRequestBuilders.get("/userapi/user" + "2") |
|||
.accept(MediaType.APPLICATION_JSON)) |
|||
.andDo(print()) |
|||
.andExpect(jsonPath("$.id").exists()) |
|||
.andExpect(jsonPath("$.id").value(2)) |
|||
.andExpect(jsonPath("$.name").exists()) |
|||
.andExpect(jsonPath("$.name").value("Mary Brown")) |
|||
.andExpect(jsonPath("$.email").value("mary.b@gmail.com")) |
|||
.andExpect(jsonPath("$.*", hasSize(3))) |
|||
.andReturn(); |
|||
} |
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
public class CartDto { |
|||
|
|||
} |
|||
@ -1,5 +0,0 @@ |
|||
package com.example.demo.model; |
|||
|
|||
public class OrderDto { |
|||
|
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
server.port=5002 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.30:3306/grocery_59277?createDatabaseIfNotExist=true |
|||
spring.datasource.username=grocery_59277_user |
|||
spring.datasource.password=PASSWORD123 |
|||
server.servlet.context-path=/productapi |
|||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.jpa.show-sql=false |
|||
spring.jpa.properties.hibernate.format_sql=false |
|||
|
|||
@ -1,74 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import org.springframework.boot.CommandLineRunner; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import java.io.BufferedReader; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
@SpringBootApplication |
|||
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) |
|||
public class ProductServiceApplication implements CommandLineRunner { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ProductServiceApplication.class, args); |
|||
} |
|||
|
|||
@Override |
|||
public void run(String... args) throws Exception{ |
|||
|
|||
URL url = new URL ("http://localhost:5008/productapi/product"); |
|||
|
|||
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
con.setRequestMethod("POST"); |
|||
|
|||
con.setRequestProperty("Content-Type", "application/json; utf-8"); |
|||
con.setRequestProperty("Accept", "application/json"); |
|||
|
|||
con.setDoOutput(true); |
|||
|
|||
//JSON String need to be constructed for the specific resource. |
|||
//We may construct complex JSON using any third-party JSON libraries such as jackson or org.json |
|||
// String jsonInputString = "{\"category\": \"Fruits\", \"imag\": \"applepic\", \"name\": \"apple\", \"price\": \"20\" }"; |
|||
|
|||
try(OutputStream os = con.getOutputStream()){ |
|||
// byte[] input = jsonInputString.getBytes("utf-8"); |
|||
byte[] input = readFile("C:\\Users\\59277\\workgroup\\springboot\\ProductService\\src\\main\\resources\\generated.json"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int code = con.getResponseCode(); |
|||
System.out.println(code); |
|||
|
|||
try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){ |
|||
StringBuilder response = new StringBuilder(); |
|||
String responseLine = null; |
|||
while ((responseLine = br.readLine()) != null) { |
|||
response.append(responseLine.trim()); |
|||
} |
|||
System.out.println(response.toString()); |
|||
} |
|||
} |
|||
|
|||
public static byte[] readFile(String file) throws IOException { |
|||
|
|||
File f = new File(file); |
|||
byte[] buffer = new byte[(int)f.length()]; |
|||
FileInputStream is = new FileInputStream(file); |
|||
is.read(buffer); |
|||
is.close(); |
|||
// TODO Auto-generated method stub |
|||
return buffer; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -1,4 +0,0 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
|||
@ -1,65 +0,0 @@ |
|||
package com.example.demo.securityfile; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Primary; |
|||
import org.springframework.security.authentication.AuthenticationProvider; |
|||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; |
|||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|||
import org.springframework.security.crypto.password.PasswordEncoder; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@Configuration |
|||
@EnableWebSecurity |
|||
public class SecurityConfig extends WebSecurityConfigurerAdapter { |
|||
|
|||
@Autowired |
|||
private MyUserDetailsService myUserDetailsService; |
|||
@Override |
|||
protected void configure(HttpSecurity http) throws Exception { |
|||
http.authorizeRequests() |
|||
// .antMatchers("/home").authenticated() |
|||
// .antMatchers("/account").hasAnyAuthority("ADMIN") |
|||
.antMatchers("/home").permitAll() |
|||
.antMatchers("/account").permitAll() |
|||
.antMatchers("/login").permitAll() |
|||
.antMatchers("/signup").permitAll() |
|||
.antMatchers("/products").permitAll() |
|||
|
|||
.and() |
|||
.httpBasic(); |
|||
|
|||
http.cors(); |
|||
http.csrf().disable(); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
protected void configure(AuthenticationManagerBuilder auth) throws Exception{ |
|||
auth.authenticationProvider(getAuthenticator()); |
|||
} |
|||
|
|||
private DaoAuthenticationProvider getAuthenticator() { |
|||
DaoAuthenticationProvider dao = new DaoAuthenticationProvider(); |
|||
dao.setUserDetailsService(myUserDetailsService); |
|||
dao.setPasswordEncoder(getPasswordEncoder()); |
|||
return dao; |
|||
} |
|||
|
|||
@Primary |
|||
@Bean |
|||
public PasswordEncoder getPasswordEncoder() { |
|||
|
|||
return new BCryptPasswordEncoder(); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -1,100 +0,0 @@ |
|||
package com.example.demo; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
@CrossOrigin(origins = "http://localhost:17599", |
|||
methods = {RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) |
|||
public class CartController { |
|||
|
|||
@Autowired |
|||
private UserRepo userRepository; |
|||
@Autowired |
|||
private ProductRepo productRepository; |
|||
@Autowired |
|||
private CartRepo cartRepository; |
|||
|
|||
@PostMapping("/cart/{uid}/{pid}") |
|||
public Cart postCart(@RequestBody Cart cart, @PathVariable("uid") Long uid, @PathVariable("pid") Long pid) { |
|||
Product product = productRepository.getById(pid); |
|||
User user = userRepository.getById(uid); |
|||
cart.setUser(user); |
|||
cart.setProduct(product); |
|||
int q=1; |
|||
cart.setQuantity(q); |
|||
cart.setTotalPrice(cart.getProduct().getPrice()*cart.getQuantity()); |
|||
return cartRepository.save(cart); |
|||
} |
|||
|
|||
@GetMapping("/cartdto/{uid}") |
|||
public List<CartDto> getCartdto(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
List<CartDto> listDto = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
for(Cart c : list) { |
|||
CartDto cartDto = new CartDto(); |
|||
|
|||
cartDto.setCid(c.getId()); |
|||
cartDto.setQuantity(c.getQuantity()); |
|||
cartDto.setTotalPrice(c.getQuantity()*c.getProduct().getPrice()); |
|||
|
|||
cartDto.setPid(c.getProduct().getId()); |
|||
cartDto.setImag(c.getProduct().getImag()); |
|||
cartDto.setName(c.getProduct().getName()); |
|||
cartDto.setPrice(c.getProduct().getPrice()); |
|||
|
|||
cartDto.setUid(c.getUser().getId()); |
|||
cartDto.setUsername(c.getUser().getUsername()); |
|||
cartDto.setApartments(c.getUser().getApartments()); |
|||
|
|||
listDto.add(cartDto); |
|||
} |
|||
return listDto; |
|||
} |
|||
|
|||
@GetMapping("/cart/{uid}") |
|||
public List<Cart> getCartByUser(@PathVariable("uid") Long uid) { |
|||
return cartRepository.findByUserId(uid); |
|||
} |
|||
|
|||
@PostMapping("/cartquant/{cid}/{quantity}") |
|||
public Double addQuantity(@PathVariable("cid") Long cid, @PathVariable("quantity") Double quantity) { |
|||
Cart cart= cartRepository.getById(cid); |
|||
cart.setQuantity(quantity); |
|||
cart.setTotalPrice(quantity*cart.getProduct().getPrice()); |
|||
cartRepository.save(cart); |
|||
return cart.getTotalPrice(); |
|||
} |
|||
|
|||
@PostMapping("/cartsum/{uid}") |
|||
public Double getCartSum(@PathVariable("uid") Long uid) { |
|||
List<Cart> list = new ArrayList<>(); |
|||
list = cartRepository.findByUserId(uid); |
|||
Cart cart = new Cart(); |
|||
Double sum = 0.0; |
|||
for(Cart c : list) { |
|||
sum=sum+ c.getTotalPrice(); |
|||
} |
|||
|
|||
return sum; |
|||
} |
|||
|
|||
@DeleteMapping("/cart/{cid}") |
|||
public void deleteFromCart(@PathVariable("cid") Long cid) { |
|||
cartRepository.deleteById(cid); |
|||
} |
|||
} |
|||
|
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue