公告修改

This commit is contained in:
zyh
2025-08-29 23:04:47 +08:00
parent 19d9fa3e9e
commit 2c72161efa
7 changed files with 141 additions and 8 deletions

View File

@@ -91,4 +91,39 @@ public class AnnouncementService {
public boolean announcementExists(Long id) {
return getAnnouncementById(id) != null;
}
/**
* 根据归属ID获取公告分页
*/
public List<Announcement> getAnnouncementsByBelongId(Integer belongId, int size, int offset) {
return announcementMapper.findByBelongId(belongId, size, offset);
}
/**
* 根据归属ID获取公告数量
*/
public long getAnnouncementCountByBelongId(Integer belongId) {
return announcementMapper.countByBelongId(belongId);
}
/**
* 根据归属ID和启用状态获取公告分页
*/
public List<Announcement> getAnnouncementsByBelongIdAndEnabled(Integer belongId, Boolean enabled, int size, int offset) {
return announcementMapper.findByBelongIdAndEnabled(belongId, enabled, size, offset);
}
/**
* 根据归属ID和启用状态获取公告数量
*/
public long getAnnouncementCountByBelongIdAndEnabled(Integer belongId, Boolean enabled) {
return announcementMapper.countByBelongIdAndEnabled(belongId, enabled);
}
/**
* 获取指定归属ID的启用公告用于前端显示
*/
public List<Announcement> getEnabledAnnouncementsByBelongId(Integer belongId) {
return announcementMapper.findByBelongIdAndEnabled(belongId, true, 10, 0); // 最多返回10条启用的公告
}
}