init commit
This commit is contained in:
79
20220330_Vote/Ewide.RoadFlow/Data/MessageUser/MessageUser.cs
Normal file
79
20220330_Vote/Ewide.RoadFlow/Data/MessageUser/MessageUser.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class MessageUser: RoadFlowRepository<RoadFlow.Model.rf_messageuser>, IMessageUser, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页已发送消息阅读人员
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_messageuser> GetReadUserList(out int count, int size, int number, string messageId, string order)
|
||||
{
|
||||
int total = 0;
|
||||
var rtn = db.Queryable<Model.rf_messageuser>().Where(x => x.MessageId == messageId)
|
||||
.OrderByIF(!order.IsNullOrEmpty(), order).ToPageList(number, size, ref total).ToList();
|
||||
count = total;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateIsRead(string messageId, string userId)
|
||||
{
|
||||
Model.rf_messageuser tmp = GetOneBy(x => x.MessageId == messageId && x.UserId == userId);
|
||||
if (tmp == null)
|
||||
return 0;
|
||||
tmp.IsRead = 1;
|
||||
tmp.ReadTime = DateExtensions.Now;
|
||||
return Update(tmp);
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新一个人员的所有未读消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageUsers"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateAllIsRead()
|
||||
{
|
||||
IUserManager m = Furion.App.GetService<IUserManager>();
|
||||
return db.Ado.ExecuteCommand("UPDATE RF_MessageUser SET IsRead=1,ReadTime="
|
||||
+ DateExtensions.Now.ToString() + " WHERE IsRead=0 AND UserId="+m.UserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一批消息
|
||||
/// </summary>
|
||||
/// <param name="guids">要删除的id</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns></returns>
|
||||
public int Delete(IEnumerable<string> guids, string userId)
|
||||
{
|
||||
|
||||
var msgs = GetListBy(x => x.UserId == userId && guids.Contains(x.Id));
|
||||
return Delete(msgs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user