xiongzhu před 3 roky
rodič
revize
5013261fc6

+ 2 - 2
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -67,8 +67,8 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     void addLike(Long id, int num);
 
     @Query(value = "select distinct c from Collection c join Like l on l.collectionId = c.id " +
-            "where l.userId = ?1 and l.del = false and c.del = false")
-    List<Collection> userLikes(Long userId);
+            "where l.userId = ?1 and l.del = false and c.del = false and c.companyId = ?2")
+    List<Collection> userLikes(Long userId, Long companyId);
 
     List<Collection> findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime time);
 

+ 2 - 2
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -124,8 +124,8 @@ public class CollectionController extends BaseController {
 
     @GetMapping("/myLikes")
     @ApiOperation("我收藏的")
-    public List<CollectionDTO> myLikes() {
-        return collectionService.toDTO(collectionRepo.userLikes(SecurityUtils.getAuthenticatedUser().getId()));
+    public List<CollectionDTO> myLikes(@RequestParam(defaultValue = "1") Long companyId) {
+        return collectionService.toDTO(collectionRepo.userLikes(SecurityUtils.getAuthenticatedUser().getId(), companyId));
     }
 
     @PreAuthorize("hasRole('ADMIN')")