mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-21 14:30:59 +08:00
Compare commits
6 Commits
feature/da
...
codex/rss
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f5b6f84a8 | ||
|
|
cd57d478f2 | ||
|
|
da07313df8 | ||
|
|
c08ecb5e33 | ||
|
|
0a722c81c5 | ||
|
|
15071471b2 |
@@ -1,7 +1,10 @@
|
|||||||
package com.openisle.controller;
|
package com.openisle.controller;
|
||||||
|
|
||||||
import com.openisle.model.Post;
|
import com.openisle.model.Post;
|
||||||
|
import com.openisle.model.Comment;
|
||||||
|
import com.openisle.model.CommentSort;
|
||||||
import com.openisle.service.PostService;
|
import com.openisle.service.PostService;
|
||||||
|
import com.openisle.service.CommentService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@@ -31,6 +34,7 @@ import java.util.regex.Pattern;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RssController {
|
public class RssController {
|
||||||
private final PostService postService;
|
private final PostService postService;
|
||||||
|
private final CommentService commentService;
|
||||||
|
|
||||||
@Value("${app.website-url:https://www.open-isle.com}")
|
@Value("${app.website-url:https://www.open-isle.com}")
|
||||||
private String websiteUrl;
|
private String websiteUrl;
|
||||||
@@ -103,6 +107,19 @@ public class RssController {
|
|||||||
enclosure = absolutifyUrl(enclosure, base);
|
enclosure = absolutifyUrl(enclosure, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Top comments in Markdown
|
||||||
|
List<Comment> topComments = commentService
|
||||||
|
.getCommentsForPost(p.getId(), CommentSort.MOST_INTERACTIONS);
|
||||||
|
topComments = topComments.subList(0, Math.min(10, topComments.size()));
|
||||||
|
StringBuilder commentMd = new StringBuilder();
|
||||||
|
for (Comment c : topComments) {
|
||||||
|
commentMd.append("> @")
|
||||||
|
.append(nullSafe(c.getAuthor().getUsername()))
|
||||||
|
.append(": ")
|
||||||
|
.append(nullSafe(c.getContent()).replace("\r", ""))
|
||||||
|
.append("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append("<item>");
|
sb.append("<item>");
|
||||||
elem(sb, "title", cdata(nullSafe(p.getTitle())));
|
elem(sb, "title", cdata(nullSafe(p.getTitle())));
|
||||||
elem(sb, "link", link);
|
elem(sb, "link", link);
|
||||||
@@ -117,6 +134,11 @@ public class RssController {
|
|||||||
sb.append("<enclosure url=\"").append(escapeXml(enclosure)).append("\" type=\"")
|
sb.append("<enclosure url=\"").append(escapeXml(enclosure)).append("\" type=\"")
|
||||||
.append(getMimeType(enclosure)).append("\" />");
|
.append(getMimeType(enclosure)).append("\" />");
|
||||||
}
|
}
|
||||||
|
// Markdown comments
|
||||||
|
elem(sb, "commentsMarkdown", cdata(commentMd.toString()));
|
||||||
|
// Markdown original link
|
||||||
|
elem(sb, "originalLinkMarkdown", cdata("[原文链接](" + link + ")"));
|
||||||
|
|
||||||
sb.append("</item>");
|
sb.append("</item>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ public enum PointHistoryType {
|
|||||||
POST_LIKED,
|
POST_LIKED,
|
||||||
COMMENT_LIKED,
|
COMMENT_LIKED,
|
||||||
INVITE,
|
INVITE,
|
||||||
SYSTEM_ONLINE
|
SYSTEM_ONLINE,
|
||||||
|
REDEEM
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package com.openisle.service;
|
|||||||
import com.openisle.exception.FieldException;
|
import com.openisle.exception.FieldException;
|
||||||
import com.openisle.exception.NotFoundException;
|
import com.openisle.exception.NotFoundException;
|
||||||
import com.openisle.model.PointGood;
|
import com.openisle.model.PointGood;
|
||||||
|
import com.openisle.model.PointHistory;
|
||||||
|
import com.openisle.model.PointHistoryType;
|
||||||
import com.openisle.model.User;
|
import com.openisle.model.User;
|
||||||
import com.openisle.repository.PointGoodRepository;
|
import com.openisle.repository.PointGoodRepository;
|
||||||
|
import com.openisle.repository.PointHistoryRepository;
|
||||||
import com.openisle.repository.UserRepository;
|
import com.openisle.repository.UserRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -18,6 +21,7 @@ public class PointMallService {
|
|||||||
private final PointGoodRepository pointGoodRepository;
|
private final PointGoodRepository pointGoodRepository;
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final NotificationService notificationService;
|
private final NotificationService notificationService;
|
||||||
|
private final PointHistoryRepository pointHistoryRepository;
|
||||||
|
|
||||||
public List<PointGood> listGoods() {
|
public List<PointGood> listGoods() {
|
||||||
return pointGoodRepository.findAll();
|
return pointGoodRepository.findAll();
|
||||||
@@ -32,6 +36,13 @@ public class PointMallService {
|
|||||||
user.setPoint(user.getPoint() - good.getCost());
|
user.setPoint(user.getPoint() - good.getCost());
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
notificationService.createPointRedeemNotifications(user, good.getName() + ": " + contact);
|
notificationService.createPointRedeemNotifications(user, good.getName() + ": " + contact);
|
||||||
|
PointHistory history = new PointHistory();
|
||||||
|
history.setUser(user);
|
||||||
|
history.setType(PointHistoryType.REDEEM);
|
||||||
|
history.setAmount(-good.getCost());
|
||||||
|
history.setBalance(user.getPoint());
|
||||||
|
history.setCreatedAt(java.time.LocalDateTime.now());
|
||||||
|
pointHistoryRepository.save(history);
|
||||||
return user.getPoint();
|
return user.getPoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,9 @@
|
|||||||
}}</NuxtLink>
|
}}</NuxtLink>
|
||||||
加入社区 🎉,获得 {{ item.amount }} 积分
|
加入社区 🎉,获得 {{ item.amount }} 积分
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="item.type === 'REDEEM'">
|
||||||
|
兑换商品,消耗 {{ -item.amount }} 积分
|
||||||
|
</template>
|
||||||
<template v-else-if="item.type === 'SYSTEM_ONLINE'"> 积分历史系统上线 </template>
|
<template v-else-if="item.type === 'SYSTEM_ONLINE'"> 积分历史系统上线 </template>
|
||||||
<i class="fas fa-coins"></i> 你目前的积分是 {{ item.balance }}
|
<i class="fas fa-coins"></i> 你目前的积分是 {{ item.balance }}
|
||||||
</div>
|
</div>
|
||||||
@@ -188,6 +191,7 @@ const iconMap = {
|
|||||||
COMMENT_LIKED: 'fas fa-thumbs-up',
|
COMMENT_LIKED: 'fas fa-thumbs-up',
|
||||||
INVITE: 'fas fa-user-plus',
|
INVITE: 'fas fa-user-plus',
|
||||||
SYSTEM_ONLINE: 'fas fa-clock',
|
SYSTEM_ONLINE: 'fas fa-clock',
|
||||||
|
REDEEM: 'fas fa-gift',
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|||||||
1
frontend_nuxt/public/tencent2707107139169774686.txt
Normal file
1
frontend_nuxt/public/tencent2707107139169774686.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1839503219847005265
|
||||||
Reference in New Issue
Block a user