mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
added needed fields in models and needed libraries for frontend (#67)
This commit is contained in:
@@ -289,6 +289,19 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/unreadCount")
|
||||
@ApiOperation(value = "Get unread count for feed subscriptions", responseClass = "List[com.commafeed.frontend.model.UnreadCount]")
|
||||
public Response getUnreadCount() {
|
||||
List<UnreadCount> list = Lists.newArrayList();
|
||||
Map<Long, Long> unreadCount = feedEntryStatusDAO
|
||||
.getUnreadCount(getUser());
|
||||
for (Map.Entry<Long, Long> e : unreadCount.entrySet()) {
|
||||
list.add(new UnreadCount(e.getKey(), e.getValue()));
|
||||
}
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/get")
|
||||
@ApiOperation(value = "Get feed categories", notes = "Get all categories and subscriptions of the user", responseClass = "com.commafeed.frontend.model.Category")
|
||||
@@ -308,19 +321,6 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
return Response.ok(root).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/unreadCount")
|
||||
@ApiOperation(value = "Get unread count for feed subscriptions", responseClass = "List[com.commafeed.frontend.model.UnreadCount]")
|
||||
public Response getUnreadCount() {
|
||||
List<UnreadCount> list = Lists.newArrayList();
|
||||
Map<Long, Long> unreadCount = feedEntryStatusDAO
|
||||
.getUnreadCount(getUser());
|
||||
for (Map.Entry<Long, Long> e : unreadCount.entrySet()) {
|
||||
list.add(new UnreadCount(e.getKey(), e.getValue()));
|
||||
}
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
private Category buildCategory(Long id, List<FeedCategory> categories,
|
||||
List<FeedSubscription> subscriptions, Map<Long, Long> unreadCount) {
|
||||
Category category = new Category();
|
||||
@@ -335,6 +335,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
subscriptions, unreadCount);
|
||||
child.setId(String.valueOf(c.getId()));
|
||||
child.setName(c.getName());
|
||||
child.setPosition(c.getPosition());
|
||||
if (c.getParent() != null && c.getParent().getId() != null) {
|
||||
child.setParentId(String.valueOf(c.getParent().getId()));
|
||||
}
|
||||
@@ -345,7 +346,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
Collections.sort(category.getChildren(), new Comparator<Category>() {
|
||||
@Override
|
||||
public int compare(Category o1, Category o2) {
|
||||
return ObjectUtils.compare(o1.getName(), o2.getName());
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -364,7 +365,7 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
Collections.sort(category.getFeeds(), new Comparator<Subscription>() {
|
||||
@Override
|
||||
public int compare(Subscription o1, Subscription o2) {
|
||||
return ObjectUtils.compare(o1.getName(), o2.getName());
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
return category;
|
||||
|
||||
Reference in New Issue
Block a user