feat: 增强用户端配置管理功能

主要修改:
1. 在SystemConfigController中完善用户端配置获取和批量更新接口的实现。
2. 优化SystemConfigService,增强配置值验证逻辑,确保配置的准确性和有效性。

技术细节:
- 新增的功能提升了用户端配置的管理灵活性,支持更高效的批量操作。
This commit is contained in:
zyh
2025-08-27 17:25:19 +08:00
parent 429e12cf50
commit b03c58ae1b
6 changed files with 677 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
package com.gameplatform.server.service.admin;
import com.gameplatform.server.mapper.admin.AnnouncementMapper;
import com.gameplatform.server.model.entity.admin.Announcement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class AnnouncementService {
@Autowired
private AnnouncementMapper announcementMapper;
/**
* 创建公告
*/
public boolean createAnnouncement(Announcement announcement) {
return announcementMapper.insert(announcement) > 0;
}
/**
* 根据ID获取公告
*/
public Announcement getAnnouncementById(Long id) {
return announcementMapper.findById(id);
}
/**
* 更新公告
*/
public boolean updateAnnouncement(Announcement announcement) {
return announcementMapper.update(announcement) > 0;
}
/**
* 删除公告
*/
public boolean deleteAnnouncement(Long id) {
return announcementMapper.deleteById(id) > 0;
}
/**
* 获取所有公告(分页)
*/
public List<Announcement> getAllAnnouncements(int size, int offset) {
return announcementMapper.findAll(size, offset);
}
/**
* 获取公告总数
*/
public long getAnnouncementCount() {
return announcementMapper.countAll();
}
/**
* 根据启用状态获取公告(分页)
*/
public List<Announcement> getAnnouncementsByEnabled(Boolean enabled, int size, int offset) {
return announcementMapper.findByEnabled(enabled, size, offset);
}
/**
* 根据启用状态获取公告数量
*/
public long getAnnouncementCountByEnabled(Boolean enabled) {
return announcementMapper.countByEnabled(enabled);
}
/**
* 更新公告启用状态
*/
public boolean updateAnnouncementEnabled(Long id, Boolean enabled) {
return announcementMapper.updateEnabled(id, enabled) > 0;
}
/**
* 获取所有启用的公告(用于前端显示)
*/
public List<Announcement> getEnabledAnnouncements() {
return announcementMapper.findByEnabled(true, 10, 0); // 最多返回10条启用的公告
}
/**
* 检查公告是否存在
*/
public boolean announcementExists(Long id) {
return getAnnouncementById(id) != null;
}
}