174 lines
5.9 KiB
C#
174 lines
5.9 KiB
C#
/***********************************************************************
|
||
* Project: CoreCms
|
||
* ProjectName: 核心内容管理系统
|
||
* Web: https://www.corecms.net
|
||
* Author: 大灰灰
|
||
* Email: jianweie@163.com
|
||
* CreateTime: 2025/12/7
|
||
* Description: 站内信消息服务接口
|
||
***********************************************************************/
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq.Expressions;
|
||
using System.Threading.Tasks;
|
||
using CoreCms.Net.Model.Entities;
|
||
using CoreCms.Net.Model.ViewModels.Basics;
|
||
using CoreCms.Net.Model.ViewModels.UI;
|
||
using SqlSugar;
|
||
|
||
namespace CoreCms.Net.IServices
|
||
{
|
||
/// <summary>
|
||
/// 站内信消息服务接口
|
||
/// </summary>
|
||
public interface ISQMessageServices : IBaseServices<SQMessage>
|
||
{
|
||
#region 前端API方法
|
||
|
||
/// <summary>
|
||
/// 获取用户消息列表(包含指定用户消息和全员广播)
|
||
/// </summary>
|
||
/// <param name="userId">用户ID</param>
|
||
/// <param name="messageType">消息类型:0=全部,1=私信</param>
|
||
/// <param name="pageIndex">页码</param>
|
||
/// <param name="pageSize">每页数量</param>
|
||
/// <returns>消息列表</returns>
|
||
Task<List<SQMessageDto>> GetUserMessageListAsync(int userId, int messageType = 0, int pageIndex = 1, int pageSize = 20);
|
||
|
||
/// <summary>
|
||
/// 获取用户未读消息数量
|
||
/// </summary>
|
||
/// <param name="userId">用户ID</param>
|
||
/// <returns>未读数量</returns>
|
||
Task<int> GetUnreadCountAsync(int userId);
|
||
|
||
/// <summary>
|
||
/// 标记用户所有消息为已读
|
||
/// </summary>
|
||
/// <param name="userId">用户ID</param>
|
||
/// <returns>是否成功</returns>
|
||
Task<bool> MarkAllAsReadAsync(int userId);
|
||
|
||
#endregion
|
||
|
||
#region 后台管理方法
|
||
|
||
/// <summary>
|
||
/// 发送消息给指定用户
|
||
/// </summary>
|
||
/// <param name="userId">用户ID</param>
|
||
/// <param name="title">标题</param>
|
||
/// <param name="content">内容</param>
|
||
/// <param name="messageType">消息类型</param>
|
||
/// <param name="senderId">发送者ID</param>
|
||
/// <returns>是否成功</returns>
|
||
Task<bool> SendToUserAsync(int userId, string title, string content, int messageType = 1, int? senderId = null);
|
||
|
||
/// <summary>
|
||
/// 发送消息给多个用户
|
||
/// </summary>
|
||
/// <param name="userIds">用户ID列表</param>
|
||
/// <param name="title">标题</param>
|
||
/// <param name="content">内容</param>
|
||
/// <param name="messageType">消息类型</param>
|
||
/// <param name="senderId">发送者ID</param>
|
||
/// <returns>是否成功</returns>
|
||
Task<bool> SendToUsersAsync(List<int> userIds, string title, string content, int messageType = 1, int? senderId = null);
|
||
|
||
/// <summary>
|
||
/// 发送全员广播消息
|
||
/// </summary>
|
||
/// <param name="title">标题</param>
|
||
/// <param name="content">内容</param>
|
||
/// <param name="senderId">发送者ID</param>
|
||
/// <returns>是否成功</returns>
|
||
Task<bool> SendBroadcastAsync(string title, string content, int? senderId = null);
|
||
|
||
/// <summary>
|
||
/// 发送系统通知(用于业务触发,如组局成功/失败)
|
||
/// </summary>
|
||
/// <param name="userId">用户ID</param>
|
||
/// <param name="title">标题</param>
|
||
/// <param name="content">内容</param>
|
||
/// <param name="relatedType">关联业务类型</param>
|
||
/// <param name="relatedId">关联业务ID</param>
|
||
/// <returns>是否成功</returns>
|
||
Task<bool> SendSystemNoticeAsync(int userId, string title, string content, int? relatedType = null, int? relatedId = null);
|
||
|
||
#endregion
|
||
|
||
#region 重写增删改查操作
|
||
|
||
/// <summary>
|
||
/// 重写异步插入方法
|
||
/// </summary>
|
||
new Task<AdminUiCallBack> InsertAsync(SQMessage entity);
|
||
|
||
/// <summary>
|
||
/// 重写异步更新方法
|
||
/// </summary>
|
||
new Task<AdminUiCallBack> UpdateAsync(SQMessage entity);
|
||
|
||
/// <summary>
|
||
/// 重写删除指定ID的数据
|
||
/// </summary>
|
||
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||
|
||
/// <summary>
|
||
/// 重写删除指定ID集合的数据(批量删除)
|
||
/// </summary>
|
||
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||
|
||
#endregion
|
||
|
||
#region 重写根据条件查询分页数据
|
||
|
||
/// <summary>
|
||
/// 重写根据条件查询分页数据
|
||
/// </summary>
|
||
new Task<IPageList<SQMessage>> QueryPageAsync(
|
||
Expression<Func<SQMessage, bool>> predicate,
|
||
Expression<Func<SQMessage, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||
int pageSize = 20, bool blUseNoLock = false);
|
||
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 消息DTO(前端返回用)
|
||
/// </summary>
|
||
public class SQMessageDto
|
||
{
|
||
/// <summary>
|
||
/// 消息ID
|
||
/// </summary>
|
||
public int id { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息标题
|
||
/// </summary>
|
||
public string title { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息内容
|
||
/// </summary>
|
||
public string content { get; set; }
|
||
|
||
/// <summary>
|
||
/// 创建时间
|
||
/// </summary>
|
||
public string createTime { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息类型:0=系统通知,1=私信
|
||
/// </summary>
|
||
public int messageType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 是否已读
|
||
/// </summary>
|
||
public bool isRead { get; set; }
|
||
}
|
||
}
|