- 新增 PLATFORM_OVERVIEW.md 文档,包含仓库索引、整体架构、核心概念等 - 实现 XuqmImServerSdk 类,提供完整的 IM 功能接口 - 添加登录认证、消息发送、会话管理、好友关系等核心功能 - 实现群组管理、关键词过滤、全局禁言等高级功能 - 提供配置管理和统计查询等管理功能
57 行
1.9 KiB
Java
57 行
1.9 KiB
Java
package com.xuqm.im.service;
|
|
|
|
import com.xuqm.common.exception.BusinessException;
|
|
import com.xuqm.im.entity.WebhookConfigEntity;
|
|
import com.xuqm.im.repository.WebhookConfigRepository;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
@Service
|
|
public class WebhookConfigService {
|
|
|
|
private final WebhookConfigRepository repository;
|
|
|
|
public WebhookConfigService(WebhookConfigRepository repository) {
|
|
this.repository = repository;
|
|
}
|
|
|
|
public List<WebhookConfigEntity> list(String appId) {
|
|
return repository.findByAppId(appId);
|
|
}
|
|
|
|
public WebhookConfigEntity create(String appId, String url, String secret, Boolean enabled) {
|
|
WebhookConfigEntity entity = new WebhookConfigEntity();
|
|
entity.setId(UUID.randomUUID().toString());
|
|
entity.setAppId(appId);
|
|
entity.setUrl(url);
|
|
entity.setSecret(secret);
|
|
entity.setEnabled(enabled == null || enabled);
|
|
entity.setCreatedAt(LocalDateTime.now());
|
|
return repository.save(entity);
|
|
}
|
|
|
|
public WebhookConfigEntity update(String appId, String id, String url, String secret, Boolean enabled) {
|
|
WebhookConfigEntity entity = repository.findByIdAndAppId(id, appId)
|
|
.orElseThrow(() -> new BusinessException(404, "回调配置不存在"));
|
|
if (url != null) {
|
|
entity.setUrl(url);
|
|
}
|
|
if (secret != null) {
|
|
entity.setSecret(secret);
|
|
}
|
|
if (enabled != null) {
|
|
entity.setEnabled(enabled);
|
|
}
|
|
return repository.save(entity);
|
|
}
|
|
|
|
public void delete(String appId, String id) {
|
|
WebhookConfigEntity entity = repository.findByIdAndAppId(id, appId)
|
|
.orElseThrow(() -> new BusinessException(404, "回调配置不存在"));
|
|
repository.delete(entity);
|
|
}
|
|
}
|