Skip to content

Instantly share code, notes, and snippets.

View alexandre-jacquot-ptl's full-sized avatar

Alexandre JACQUOT alexandre-jacquot-ptl

View GitHub Profile
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemController.java
Last active May 23, 2021 12:50
r2dbc ItemController update
@RestController
@RequestMapping(value = "/items")
public class ItemController {
private final ItemService itemService;
private final ItemMapper itemMapper;
...
@ApiOperation("Update an existing item")
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemService.java
Created May 23, 2021 12:30
r2dbc ItemService delete
@Service
@RequiredArgsConstructor
public class ItemService {
private final ItemRepository itemRepository;
private final ItemTagRepository itemTagRepository;
...
@Transactional
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemController.java
Created May 23, 2021 12:28
r2dbc ItemController delete
@RestController
@RequestMapping(value = "/items")
public class ItemController {
private final ItemService itemService;
...
@ApiOperation("Delete an item")
@DeleteMapping("/{id}")
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemService.java
Last active June 7, 2021 15:00
r2dbc ItemService findbyid
@Service
@RequiredArgsConstructor
public class ItemService {
private final ItemRepository itemRepository;
...
/**
* Find an item
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemController.java
Created May 23, 2021 12:17
r2dbc ItemController find by id
@RestController
@RequestMapping(value = "/items")
public class ItemController {
private final ItemService itemService;
private final ItemMapper itemMapper;
...
@ApiOperation("Find an item by its id")
@Repository
public interface TagRepository extends ReactiveSortingRepository<Tag, Long> {
@Query("select t.* from tag t join item_tag it on t.id = it.tag_id where it.item_id = :item_id order by t.name")
Flux<Tag> findTagsByItemId(Long itemId);
}
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemService.java
Last active June 7, 2021 14:59
r2dbc itemservice find all
@Service
@RequiredArgsConstructor
public class ItemService {
private static final Sort DEFAULT_SORT = Sort.by(Sort.Order.by("lastModifiedDate"));
private final NotificationService notificationService;
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
@Data
@Accessors(chain = true)
public class ItemResource {
private Long id;
private Long version;
private String description;
private ItemStatus status;
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / ItemController.java
Created May 23, 2021 11:30
r2dbc read all controller
@RestController
@RequestMapping(value = "/items")
public class ItemController {
private final ItemService itemService;
private final ItemMapper itemMapper;
...
@ApiOperation("Get the list of items")
@alexandre-jacquot-ptl
alexandre-jacquot-ptl / application.properties
Created May 23, 2021 11:25
r2dbc application config main
spring.r2dbc.url=r2dbc:postgresql:////127.0.0.1:5432/todolist
spring.r2dbc.username=admin
spring.r2dbc.password=password