added new endpoints delete scanned history, delete all scanned histories, delete bookmarks, delete all bookmarks
This commit is contained in:
@@ -4,6 +4,8 @@ import static com.safeqr.app.constants.APIConstants.*;
|
||||
import static com.safeqr.app.constants.CommonConstants.HEADER_USER_ID;
|
||||
|
||||
import com.safeqr.app.qrcode.entity.QRCodeEntity;
|
||||
import com.safeqr.app.user.dto.BaseResponse;
|
||||
import com.safeqr.app.user.dto.BookmarkRequestDto;
|
||||
import com.safeqr.app.user.dto.UserResponseDto;
|
||||
import com.safeqr.app.user.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
@@ -11,10 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,9 +46,39 @@ public class UserController {
|
||||
return ResponseEntity.ok(userService.getUserScannedHistories(userId));
|
||||
}
|
||||
|
||||
@PutMapping(value = API_URL_USER_DELETE_SCANNED_HISTORIES, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseResponse> deleteScannedHistory(@RequestHeader(name = HEADER_USER_ID) String userId, @RequestBody BookmarkRequestDto bookmarkRequestDto) {
|
||||
logger.info("Invoking PUT Delete Single Scanned History endpoint");
|
||||
return ResponseEntity.ok(userService.deleteScannedHistory(userId, bookmarkRequestDto.getQrCodeId()));
|
||||
}
|
||||
|
||||
@PutMapping(value = API_URL_USER_DELETE_ALL_SCANNED_HISTORIES, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseResponse> deleteAllScannedHistories(@RequestHeader(name = HEADER_USER_ID) String userId) {
|
||||
logger.info("Invoking PUT Delete All Scanned Histories endpoint");
|
||||
return ResponseEntity.ok(userService.deleteAllScannedHistoriesByUserId(userId));
|
||||
}
|
||||
|
||||
@GetMapping(value = API_URL_USER_GET_BOOKMARKS, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<QRCodeEntity>> getUserBookmarks(@RequestHeader(name = HEADER_USER_ID) String userId) {
|
||||
logger.info("Invoking GET User bookmarks endpoint");
|
||||
return ResponseEntity.ok(userService.getUserBookmarks(userId));
|
||||
}
|
||||
|
||||
@PostMapping(value = API_URL_USER_SET_BOOKMARK, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseResponse> setBookmark(@RequestHeader(name = HEADER_USER_ID) String userId, @RequestBody BookmarkRequestDto bookmarkRequestDto) {
|
||||
logger.info("Invoking POST User bookmark endpoint");
|
||||
return ResponseEntity.ok(userService.setBookmark(userId, bookmarkRequestDto.getQrCodeId()));
|
||||
}
|
||||
|
||||
@PutMapping(value = API_URL_USER_DELETE_BOOKMARK, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseResponse> deleteBookmark(@RequestHeader(name = HEADER_USER_ID) String userId, @RequestBody BookmarkRequestDto bookmarkRequestDto) {
|
||||
logger.info("Invoking PUT Delete Single Bookmark endpoint");
|
||||
return ResponseEntity.ok(userService.deleteBookmark(userId, bookmarkRequestDto.getQrCodeId()));
|
||||
}
|
||||
|
||||
@PutMapping(value = API_URL_USER_DELETE_ALL_BOOKMARK, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseResponse> deleteAllBookmark(@RequestHeader(name = HEADER_USER_ID) String userId) {
|
||||
logger.info("Invoking PUT Delete All Bookmark endpoint");
|
||||
return ResponseEntity.ok(userService.deleteAllBookmarkByUserId(userId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user