修改BUG:站内消息字段转换异常,更改数据库结构,增加数据默认值

This commit is contained in:
Argo-Lenovo 2016-11-15 15:00:17 +08:00
parent 270d70b538
commit d191da612c
3 changed files with 83 additions and 72 deletions

View File

@ -1,62 +1,64 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary> /// <summary>
/// 消息表实体 /// 消息表实体
/// author:liuchun /// author:liuchun
/// date:2016.11.12 /// date:2016.11.12
/// </summary> /// </summary>
public class Message public class Message
{ {
/// <summary> /// <summary>
/// 消息主键 数据库自增 /// 消息主键 数据库自增
/// </summary> /// </summary>
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
/// 标题 /// 标题
/// </summary> /// </summary>
public string Title { get; set; } public string Title { get; set; }
/// <summary> /// <summary>
/// 内容 /// 内容
/// </summary> /// </summary>
public string Content { get; set; } public string Content { get; set; }
/// <summary> /// <summary>
/// 发消息人 /// 发消息人
/// </summary> /// </summary>
public string From { get; set; } public string From { get; set; }
/// <summary> /// <summary>
/// 收消息人 /// 收消息人
/// </summary> /// </summary>
public string To { get; set; } public string To { get; set; }
/// <summary> /// <summary>
/// 消息发送时间 /// 消息发送时间
/// </summary> /// </summary>
public DateTime SendTime { get; set; } public DateTime SendTime { get; set; }
/// <summary> /// <summary>
/// 消息状态0-未读1-已读 /// 消息状态0-未读1-已读 和Dict表的通知消息关联
/// 和Dict表的通知消息关联 /// </summary>
/// </summary> public string Status { get; set; }
public string Status { get; set; } /// <summary>
/// <summary> /// 标旗状态0-未标旗1-已标旗
/// 标旗状态0-未标旗1-已标旗 /// </summary>
/// </summary> public int Mark { get; set; }
public int Mark { get; set; } /// <summary>
/// <summary> /// 删除状态0-未删除1-已删除
/// 删除状态0-未删除1-已删除 /// </summary>
/// </summary> public int IsDelete { get; set; }
public int IsDelete { get; set; } /// <summary>
/// <summary> /// 消息标签0-一般1-紧要 和Dict表的消息标签关联
/// 消息标签0-一般1-紧要 /// </summary>
/// 和Dict表的消息标签关联 public string Label { get; set; }
/// </summary> /// <summary>
public string Label { get; set; } /// 获得/设置 标签名称
/// <summary> /// </summary>
/// 获得/设置 时间描述 2分钟内为刚刚 public string LabelName { get; set; }
/// </summary> /// <summary>
public string Period { get; set; } /// 获得/设置 时间描述 2分钟内为刚刚
} /// </summary>
} public string Period { get; set; }
}
}

View File

@ -27,7 +27,7 @@ namespace Bootstrap.DataAccess
{ {
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key => var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
{ {
string sql = "select * from [Messages] where [To]=@UserName or [From]=@UserName"; string sql = "select m.*, d.Name from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息状态' and d.Define = 0 where[To] = @UserName or [From] = @UserName";
List<Message> messages = new List<Message>(); List<Message> messages = new List<Message>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
@ -46,10 +46,10 @@ namespace Bootstrap.DataAccess
To = (string)reader[4], To = (string)reader[4],
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue), SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
Status = (string)reader[6], Status = (string)reader[6],
Mark=(int)reader[7], Mark = (int)reader[7],
IsDelete=(int)reader[8], IsDelete = (int)reader[8],
Label=(string)reader[9] Label = (string)reader[9],
LabelName = LgbConvert.ReadValue(reader[10], string.Empty)
}); });
} }
} }
@ -64,7 +64,7 @@ namespace Bootstrap.DataAccess
/// 收件箱 /// 收件箱
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
public static IEnumerable<Message> Inbox(string userName) public static IEnumerable<Message> Inbox(string userName)
{ {
var messageRet = RetrieveMessages(userName); var messageRet = RetrieveMessages(userName);
@ -88,7 +88,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable<Message> Trash(string userName) public static IEnumerable<Message> Trash(string userName)
{ {
var messageRet = RetrieveMessages(userName); var messageRet = RetrieveMessages(userName);
return messageRet.Where(n => n.IsDelete==1).Select(n => n); return messageRet.Where(n => n.IsDelete == 1).Select(n => n);
} }
/// <summary> /// <summary>
/// 标旗 /// 标旗
@ -98,7 +98,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable<Message> Mark(string userName) public static IEnumerable<Message> Mark(string userName)
{ {
var messageRet = RetrieveMessages(userName); var messageRet = RetrieveMessages(userName);
return messageRet.Where(n => n.Mark==1).Select(n => n); return messageRet.Where(n => n.Mark == 1).Select(n => n);
} }
/// <summary> /// <summary>
/// 获取Header处显示的消息列表 /// 获取Header处显示的消息列表

View File

@ -331,7 +331,7 @@ CREATE TABLE [dbo].[Messages](
[To] [varchar](50) NOT NULL, [To] [varchar](50) NOT NULL,
[SendTime] [datetime] NOT NULL, [SendTime] [datetime] NOT NULL,
[Status] [nvarchar](50) NOT NULL, [Status] [nvarchar](50) NOT NULL,
[Mark] [nvarchar](50) NOT NULL, [Flag] [int] NOT NULL,
[IsDelete] [int] NOT NULL, [IsDelete] [int] NOT NULL,
[Label] [nvarchar](50) NOT NULL, [Label] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED
@ -343,4 +343,13 @@ CREATE TABLE [dbo].[Messages](
GO GO
SET ANSI_PADDING OFF SET ANSI_PADDING OFF
GO GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_Mark] DEFAULT ((0)) FOR [Flag]
GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_IsDelete] DEFAULT ((0)) FOR [IsDelete]
GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_Label] DEFAULT ((0)) FOR [Label]
GO