|
|
@@ -1,32 +1,47 @@
|
|
1
|
|
-using CallCenterApi.DB;
|
|
2
|
|
-using System;
|
|
3
|
|
-using System.Collections.Generic;
|
|
|
1
|
+using System;
|
|
4
|
2
|
using System.Data;
|
|
5
|
|
-using System.Data.SqlClient;
|
|
6
|
|
-using System.Linq;
|
|
7
|
3
|
using System.Text;
|
|
8
|
|
-using System.Threading.Tasks;
|
|
|
4
|
+using System.Data.SqlClient;
|
|
|
5
|
+using CallCenterApi.DB;
|
|
9
|
6
|
|
|
10
|
7
|
namespace CallCenterApi.DAL
|
|
11
|
8
|
{
|
|
|
9
|
+ /// <summary>
|
|
|
10
|
+ /// 数据访问类:T_Msg_Chat_Map
|
|
|
11
|
+ /// </summary>
|
|
12
|
12
|
public partial class T_Msg_Chat_Map
|
|
13
|
13
|
{
|
|
14
|
14
|
public T_Msg_Chat_Map()
|
|
15
|
15
|
{ }
|
|
16
|
16
|
#region BasicMethod
|
|
|
17
|
+ /// <summary>
|
|
|
18
|
+ /// 是否存在该记录
|
|
|
19
|
+ /// </summary>
|
|
|
20
|
+ public bool Exists(int Id)
|
|
|
21
|
+ {
|
|
|
22
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
23
|
+ strSql.Append("select count(1) from T_Msg_Chat_Map");
|
|
|
24
|
+ strSql.Append(" where Id=@Id");
|
|
|
25
|
+ SqlParameter[] parameters = {
|
|
|
26
|
+ new SqlParameter("@Id", SqlDbType.Int,4)
|
|
|
27
|
+ };
|
|
|
28
|
+ parameters[0].Value = Id;
|
|
17
|
29
|
|
|
|
30
|
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
|
|
|
31
|
+ }
|
|
18
|
32
|
|
|
19
|
33
|
|
|
20
|
34
|
/// <summary>
|
|
21
|
35
|
/// 增加一条数据
|
|
22
|
36
|
/// </summary>
|
|
23
|
|
- public bool Add(Model.T_Msg_Chat_Map model)
|
|
|
37
|
+ public int Add(CallCenterApi.Model.T_Msg_Chat_Map model)
|
|
24
|
38
|
{
|
|
25
|
39
|
StringBuilder strSql = new StringBuilder();
|
|
26
|
40
|
strSql.Append("insert into T_Msg_Chat_Map(");
|
|
27
|
41
|
strSql.Append("ChatId,FromUserId,ToUserId,CreateDate,IsRead)");
|
|
28
|
42
|
strSql.Append(" values (");
|
|
29
|
43
|
strSql.Append("@ChatId,@FromUserId,@ToUserId,@CreateDate,@IsRead)");
|
|
|
44
|
+ strSql.Append(";select @@IDENTITY");
|
|
30
|
45
|
SqlParameter[] parameters = {
|
|
31
|
46
|
new SqlParameter("@ChatId", SqlDbType.Int,4),
|
|
32
|
47
|
new SqlParameter("@FromUserId", SqlDbType.Int,4),
|
|
|
@@ -39,20 +54,20 @@ namespace CallCenterApi.DAL
|
|
39
|
54
|
parameters[3].Value = model.CreateDate;
|
|
40
|
55
|
parameters[4].Value = model.IsRead;
|
|
41
|
56
|
|
|
42
|
|
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
43
|
|
- if (rows > 0)
|
|
|
57
|
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
|
|
|
58
|
+ if (obj == null)
|
|
44
|
59
|
{
|
|
45
|
|
- return true;
|
|
|
60
|
+ return 0;
|
|
46
|
61
|
}
|
|
47
|
62
|
else
|
|
48
|
63
|
{
|
|
49
|
|
- return false;
|
|
|
64
|
+ return Convert.ToInt32(obj);
|
|
50
|
65
|
}
|
|
51
|
66
|
}
|
|
52
|
67
|
/// <summary>
|
|
53
|
68
|
/// 更新一条数据
|
|
54
|
69
|
/// </summary>
|
|
55
|
|
- public bool Update(Model.T_Msg_Chat_Map model)
|
|
|
70
|
+ public bool Update(CallCenterApi.Model.T_Msg_Chat_Map model)
|
|
56
|
71
|
{
|
|
57
|
72
|
StringBuilder strSql = new StringBuilder();
|
|
58
|
73
|
strSql.Append("update T_Msg_Chat_Map set ");
|
|
|
@@ -61,18 +76,20 @@ namespace CallCenterApi.DAL
|
|
61
|
76
|
strSql.Append("ToUserId=@ToUserId,");
|
|
62
|
77
|
strSql.Append("CreateDate=@CreateDate,");
|
|
63
|
78
|
strSql.Append("IsRead=@IsRead");
|
|
64
|
|
- strSql.Append(" where ");
|
|
|
79
|
+ strSql.Append(" where Id=@Id");
|
|
65
|
80
|
SqlParameter[] parameters = {
|
|
66
|
81
|
new SqlParameter("@ChatId", SqlDbType.Int,4),
|
|
67
|
82
|
new SqlParameter("@FromUserId", SqlDbType.Int,4),
|
|
68
|
83
|
new SqlParameter("@ToUserId", SqlDbType.Int,4),
|
|
69
|
84
|
new SqlParameter("@CreateDate", SqlDbType.DateTime),
|
|
70
|
|
- new SqlParameter("@IsRead", SqlDbType.Int,4)};
|
|
|
85
|
+ new SqlParameter("@IsRead", SqlDbType.Int,4),
|
|
|
86
|
+ new SqlParameter("@Id", SqlDbType.Int,4)};
|
|
71
|
87
|
parameters[0].Value = model.ChatId;
|
|
72
|
88
|
parameters[1].Value = model.FromUserId;
|
|
73
|
89
|
parameters[2].Value = model.ToUserId;
|
|
74
|
90
|
parameters[3].Value = model.CreateDate;
|
|
75
|
91
|
parameters[4].Value = model.IsRead;
|
|
|
92
|
+ parameters[5].Value = model.Id;
|
|
76
|
93
|
|
|
77
|
94
|
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
78
|
95
|
if (rows > 0)
|
|
|
@@ -88,14 +105,16 @@ namespace CallCenterApi.DAL
|
|
88
|
105
|
/// <summary>
|
|
89
|
106
|
/// 删除一条数据
|
|
90
|
107
|
/// </summary>
|
|
91
|
|
- public bool Delete()
|
|
|
108
|
+ public bool Delete(int Id)
|
|
92
|
109
|
{
|
|
93
|
|
- //该表无主键信息,请自定义主键/条件字段
|
|
|
110
|
+
|
|
94
|
111
|
StringBuilder strSql = new StringBuilder();
|
|
95
|
112
|
strSql.Append("delete from T_Msg_Chat_Map ");
|
|
96
|
|
- strSql.Append(" where ");
|
|
|
113
|
+ strSql.Append(" where Id=@Id");
|
|
97
|
114
|
SqlParameter[] parameters = {
|
|
|
115
|
+ new SqlParameter("@Id", SqlDbType.Int,4)
|
|
98
|
116
|
};
|
|
|
117
|
+ parameters[0].Value = Id;
|
|
99
|
118
|
|
|
100
|
119
|
int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
101
|
120
|
if (rows > 0)
|
|
|
@@ -107,21 +126,41 @@ namespace CallCenterApi.DAL
|
|
107
|
126
|
return false;
|
|
108
|
127
|
}
|
|
109
|
128
|
}
|
|
|
129
|
+ /// <summary>
|
|
|
130
|
+ /// 批量删除数据
|
|
|
131
|
+ /// </summary>
|
|
|
132
|
+ public bool DeleteList(string Idlist)
|
|
|
133
|
+ {
|
|
|
134
|
+ StringBuilder strSql = new StringBuilder();
|
|
|
135
|
+ strSql.Append("delete from T_Msg_Chat_Map ");
|
|
|
136
|
+ strSql.Append(" where Id in (" + Idlist + ") ");
|
|
|
137
|
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
|
|
|
138
|
+ if (rows > 0)
|
|
|
139
|
+ {
|
|
|
140
|
+ return true;
|
|
|
141
|
+ }
|
|
|
142
|
+ else
|
|
|
143
|
+ {
|
|
|
144
|
+ return false;
|
|
|
145
|
+ }
|
|
|
146
|
+ }
|
|
110
|
147
|
|
|
111
|
148
|
|
|
112
|
149
|
/// <summary>
|
|
113
|
150
|
/// 得到一个对象实体
|
|
114
|
151
|
/// </summary>
|
|
115
|
|
- public Model.T_Msg_Chat_Map GetModel()
|
|
|
152
|
+ public CallCenterApi.Model.T_Msg_Chat_Map GetModel(int Id)
|
|
116
|
153
|
{
|
|
117
|
|
- //该表无主键信息,请自定义主键/条件字段
|
|
|
154
|
+
|
|
118
|
155
|
StringBuilder strSql = new StringBuilder();
|
|
119
|
|
- strSql.Append("select top 1 ChatId,FromUserId,ToUserId,CreateDate,IsRead from T_Msg_Chat_Map ");
|
|
120
|
|
- strSql.Append(" where ");
|
|
|
156
|
+ strSql.Append("select top 1 ChatId,FromUserId,ToUserId,CreateDate,IsRead,Id from T_Msg_Chat_Map ");
|
|
|
157
|
+ strSql.Append(" where Id=@Id");
|
|
121
|
158
|
SqlParameter[] parameters = {
|
|
|
159
|
+ new SqlParameter("@Id", SqlDbType.Int,4)
|
|
122
|
160
|
};
|
|
|
161
|
+ parameters[0].Value = Id;
|
|
123
|
162
|
|
|
124
|
|
- Model.T_Msg_Chat_Map model = new Model.T_Msg_Chat_Map();
|
|
|
163
|
+ CallCenterApi.Model.T_Msg_Chat_Map model = new CallCenterApi.Model.T_Msg_Chat_Map();
|
|
125
|
164
|
DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
|
|
126
|
165
|
if (ds.Tables[0].Rows.Count > 0)
|
|
127
|
166
|
{
|
|
|
@@ -137,9 +176,9 @@ namespace CallCenterApi.DAL
|
|
137
|
176
|
/// <summary>
|
|
138
|
177
|
/// 得到一个对象实体
|
|
139
|
178
|
/// </summary>
|
|
140
|
|
- public Model.T_Msg_Chat_Map DataRowToModel(DataRow row)
|
|
|
179
|
+ public CallCenterApi.Model.T_Msg_Chat_Map DataRowToModel(DataRow row)
|
|
141
|
180
|
{
|
|
142
|
|
- Model.T_Msg_Chat_Map model = new Model.T_Msg_Chat_Map();
|
|
|
181
|
+ CallCenterApi.Model.T_Msg_Chat_Map model = new CallCenterApi.Model.T_Msg_Chat_Map();
|
|
143
|
182
|
if (row != null)
|
|
144
|
183
|
{
|
|
145
|
184
|
if (row["ChatId"] != null && row["ChatId"].ToString() != "")
|
|
|
@@ -162,6 +201,10 @@ namespace CallCenterApi.DAL
|
|
162
|
201
|
{
|
|
163
|
202
|
model.IsRead = int.Parse(row["IsRead"].ToString());
|
|
164
|
203
|
}
|
|
|
204
|
+ if (row["Id"] != null && row["Id"].ToString() != "")
|
|
|
205
|
+ {
|
|
|
206
|
+ model.Id = int.Parse(row["Id"].ToString());
|
|
|
207
|
+ }
|
|
165
|
208
|
}
|
|
166
|
209
|
return model;
|
|
167
|
210
|
}
|
|
|
@@ -172,7 +215,7 @@ namespace CallCenterApi.DAL
|
|
172
|
215
|
public DataSet GetList(string strWhere)
|
|
173
|
216
|
{
|
|
174
|
217
|
StringBuilder strSql = new StringBuilder();
|
|
175
|
|
- strSql.Append("select ChatId,FromUserId,ToUserId,CreateDate,IsRead ");
|
|
|
218
|
+ strSql.Append("select ChatId,FromUserId,ToUserId,CreateDate,IsRead,Id ");
|
|
176
|
219
|
strSql.Append(" FROM T_Msg_Chat_Map ");
|
|
177
|
220
|
if (strWhere.Trim() != "")
|
|
178
|
221
|
{
|
|
|
@@ -192,7 +235,7 @@ namespace CallCenterApi.DAL
|
|
192
|
235
|
{
|
|
193
|
236
|
strSql.Append(" top " + Top.ToString());
|
|
194
|
237
|
}
|
|
195
|
|
- strSql.Append(" ChatId,FromUserId,ToUserId,CreateDate,IsRead ");
|
|
|
238
|
+ strSql.Append(" ChatId,FromUserId,ToUserId,CreateDate,IsRead,Id ");
|
|
196
|
239
|
strSql.Append(" FROM T_Msg_Chat_Map ");
|
|
197
|
240
|
if (strWhere.Trim() != "")
|
|
198
|
241
|
{
|
|
|
@@ -237,7 +280,7 @@ namespace CallCenterApi.DAL
|
|
237
|
280
|
}
|
|
238
|
281
|
else
|
|
239
|
282
|
{
|
|
240
|
|
- strSql.Append("order by T. desc");
|
|
|
283
|
+ strSql.Append("order by T.Id desc");
|
|
241
|
284
|
}
|
|
242
|
285
|
strSql.Append(")AS Row, T.* from T_Msg_Chat_Map T ");
|
|
243
|
286
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
|
@@ -265,7 +308,7 @@ namespace CallCenterApi.DAL
|
|
265
|
308
|
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
|
|
266
|
309
|
};
|
|
267
|
310
|
parameters[0].Value = "T_Msg_Chat_Map";
|
|
268
|
|
- parameters[1].Value = "";
|
|
|
311
|
+ parameters[1].Value = "Id";
|
|
269
|
312
|
parameters[2].Value = PageSize;
|
|
270
|
313
|
parameters[3].Value = PageIndex;
|
|
271
|
314
|
parameters[4].Value = 0;
|
|
|
@@ -280,3 +323,4 @@ namespace CallCenterApi.DAL
|
|
280
|
323
|
#endregion ExtensionMethod
|
|
281
|
324
|
}
|
|
282
|
325
|
}
|
|
|
326
|
+
|