- 新增 PLATFORM_OVERVIEW.md 文档,包含仓库索引、整体架构、核心概念等 - 实现 XuqmImServerSdk 类,提供完整的 IM 功能接口 - 添加登录认证、消息发送、会话管理、好友关系等核心功能 - 实现群组管理、关键词过滤、全局禁言等高级功能 - 提供配置管理和统计查询等管理功能
48 行
1.6 KiB
Java
48 行
1.6 KiB
Java
package com.xuqm.im.service;
|
|
|
|
import com.xuqm.im.entity.ImGlobalMuteEntity;
|
|
import com.xuqm.im.repository.ImGlobalMuteRepository;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.util.UUID;
|
|
|
|
@Service
|
|
public class GlobalMuteService {
|
|
|
|
private final ImGlobalMuteRepository repository;
|
|
|
|
public GlobalMuteService(ImGlobalMuteRepository repository) {
|
|
this.repository = repository;
|
|
}
|
|
|
|
public boolean isEnabled(String appId) {
|
|
return repository.findByAppId(appId).map(ImGlobalMuteEntity::isEnabled).orElse(false);
|
|
}
|
|
|
|
public ImGlobalMuteEntity get(String appId) {
|
|
return repository.findByAppId(appId).orElseGet(() -> {
|
|
ImGlobalMuteEntity entity = new ImGlobalMuteEntity();
|
|
entity.setId(UUID.randomUUID().toString());
|
|
entity.setAppId(appId);
|
|
entity.setEnabled(false);
|
|
entity.setCreatedAt(LocalDateTime.now());
|
|
entity.setUpdatedAt(LocalDateTime.now());
|
|
return entity;
|
|
});
|
|
}
|
|
|
|
public ImGlobalMuteEntity setEnabled(String appId, boolean enabled) {
|
|
ImGlobalMuteEntity entity = repository.findByAppId(appId).orElseGet(() -> {
|
|
ImGlobalMuteEntity created = new ImGlobalMuteEntity();
|
|
created.setId(UUID.randomUUID().toString());
|
|
created.setAppId(appId);
|
|
created.setCreatedAt(LocalDateTime.now());
|
|
return created;
|
|
});
|
|
entity.setEnabled(enabled);
|
|
entity.setUpdatedAt(LocalDateTime.now());
|
|
return repository.save(entity);
|
|
}
|
|
}
|