Selaa lähdekoodia

修改短消息bug,增加主键,否则分页有问题

zhoufan 8 vuotta sitten
vanhempi
commit
bcaec5641a

+ 33 - 42
CallCenterApi/CallCenterApi.BLL/T_Msg_Chat_Map.cs

@@ -1,23 +1,30 @@
1 1
 using System;
2
-using System.Collections.Generic;
3 2
 using System.Data;
4
-using System.Linq;
5
-using System.Text;
6
-using System.Threading.Tasks;
7
-
3
+using System.Collections.Generic;
4
+using CallCenterApi.Model;
8 5
 namespace CallCenterApi.BLL
9 6
 {
7
+    /// <summary>
8
+    /// T_Msg_Chat_Map
9
+    /// </summary>
10 10
     public partial class T_Msg_Chat_Map
11 11
     {
12
-        private readonly DAL.T_Msg_Chat_Map dal = new DAL.T_Msg_Chat_Map();
12
+        private readonly CallCenterApi.DAL.T_Msg_Chat_Map dal = new CallCenterApi.DAL.T_Msg_Chat_Map();
13 13
         public T_Msg_Chat_Map()
14 14
         { }
15 15
         #region  BasicMethod
16
+        /// <summary>
17
+        /// 是否存在该记录
18
+        /// </summary>
19
+        public bool Exists(int Id)
20
+        {
21
+            return dal.Exists(Id);
22
+        }
16 23
 
17 24
         /// <summary>
18 25
         /// 增加一条数据
19 26
         /// </summary>
20
-        public bool Add(Model.T_Msg_Chat_Map model)
27
+        public int Add(CallCenterApi.Model.T_Msg_Chat_Map model)
21 28
         {
22 29
             return dal.Add(model);
23 30
         }
@@ -25,7 +32,7 @@ namespace CallCenterApi.BLL
25 32
         /// <summary>
26 33
         /// 更新一条数据
27 34
         /// </summary>
28
-        public bool Update(Model.T_Msg_Chat_Map model)
35
+        public bool Update(CallCenterApi.Model.T_Msg_Chat_Map model)
29 36
         {
30 37
             return dal.Update(model);
31 38
         }
@@ -33,44 +40,27 @@ namespace CallCenterApi.BLL
33 40
         /// <summary>
34 41
         /// 删除一条数据
35 42
         /// </summary>
36
-        public bool Delete()
43
+        public bool Delete(int Id)
44
+        {
45
+
46
+            return dal.Delete(Id);
47
+        }
48
+        /// <summary>
49
+        /// 删除一条数据
50
+        /// </summary>
51
+        public bool DeleteList(string Idlist)
37 52
         {
38
-            //该表无主键信息,请自定义主键/条件字段
39
-            return dal.Delete();
53
+            return dal.DeleteList(Idlist);
40 54
         }
41 55
 
42 56
         /// <summary>
43 57
         /// 得到一个对象实体
44 58
         /// </summary>
45
-        public Model.T_Msg_Chat_Map GetModel()
59
+        public CallCenterApi.Model.T_Msg_Chat_Map GetModel(int Id)
46 60
         {
47
-            //该表无主键信息,请自定义主键/条件字段
48
-            return dal.GetModel();
49
-        }
50 61
 
51
-        ///// <summary>
52
-        ///// 得到一个对象实体,从缓存中
53
-        ///// </summary>
54
-        //public Model.T_Msg_Chat_Map GetModelByCache()
55
-        //{
56
-        //    //该表无主键信息,请自定义主键/条件字段
57
-        //    string CacheKey = "T_Msg_Chat_MapModel-";
58
-        //    object objModel = Common.DataCache.GetCache(CacheKey);
59
-        //    if (objModel == null)
60
-        //    {
61
-        //        try
62
-        //        {
63
-        //            objModel = dal.GetModel();
64
-        //            if (objModel != null)
65
-        //            {
66
-        //                int ModelCache = Common.ConfigHelper.GetConfigInt("ModelCache");
67
-        //                Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
68
-        //            }
69
-        //        }
70
-        //        catch { }
71
-        //    }
72
-        //    return (Model.T_Msg_Chat_Map)objModel;
73
-        //}
62
+            return dal.GetModel(Id);
63
+        }
74 64
 
75 65
         /// <summary>
76 66
         /// 获得数据列表
@@ -89,7 +79,7 @@ namespace CallCenterApi.BLL
89 79
         /// <summary>
90 80
         /// 获得数据列表
91 81
         /// </summary>
92
-        public List<Model.T_Msg_Chat_Map> GetModelList(string strWhere)
82
+        public List<CallCenterApi.Model.T_Msg_Chat_Map> GetModelList(string strWhere)
93 83
         {
94 84
             DataSet ds = dal.GetList(strWhere);
95 85
             return DataTableToList(ds.Tables[0]);
@@ -97,13 +87,13 @@ namespace CallCenterApi.BLL
97 87
         /// <summary>
98 88
         /// 获得数据列表
99 89
         /// </summary>
100
-        public List<Model.T_Msg_Chat_Map> DataTableToList(DataTable dt)
90
+        public List<CallCenterApi.Model.T_Msg_Chat_Map> DataTableToList(DataTable dt)
101 91
         {
102
-            List<Model.T_Msg_Chat_Map> modelList = new List<Model.T_Msg_Chat_Map>();
92
+            List<CallCenterApi.Model.T_Msg_Chat_Map> modelList = new List<CallCenterApi.Model.T_Msg_Chat_Map>();
103 93
             int rowsCount = dt.Rows.Count;
104 94
             if (rowsCount > 0)
105 95
             {
106
-                Model.T_Msg_Chat_Map model;
96
+                CallCenterApi.Model.T_Msg_Chat_Map model;
107 97
                 for (int n = 0; n < rowsCount; n++)
108 98
                 {
109 99
                     model = dal.DataRowToModel(dt.Rows[n]);
@@ -152,3 +142,4 @@ namespace CallCenterApi.BLL
152 142
         #endregion  ExtensionMethod
153 143
     }
154 144
 }
145
+

+ 72 - 28
CallCenterApi/CallCenterApi.DAL/T_Msg_Chat_Map.cs

@@ -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
+

+ 2 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IndexController.cs

@@ -800,8 +800,8 @@ namespace CallCenterApi.Interface.Controllers
800 800
             int recordCount = 0;
801 801
             var col = "a.Id,b.FromUserId,b.ToUserId,a.Content,a.IsToAll,a.CreateDate,b.IsRead,c.F_UserName,c.F_UserCode,c.F_RoleId,d.F_UserName AS ToUserName,d.F_UserCode AS ToUserCode,d.F_RoleId AS ToRoleId";
802 802
             dt = BLL.PagerBLL.GetListPager(
803
-                    " dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = a.FromUserId LEFT JOIN dbo.T_Sys_UserAccount d ON d.F_UserId = a.ToUserId ",
804
-                    "a.Id",
803
+                    " dbo.T_Msg_Chat a RIGHT JOIN dbo.T_Msg_Chat_Map b ON b.ChatId = a.Id LEFT JOIN dbo.T_Sys_UserAccount c ON c.F_UserId = b.FromUserId LEFT JOIN dbo.T_Sys_UserAccount d ON d.F_UserId = b.ToUserId ",
804
+                    "b.Id",
805 805
                     col,
806 806
                     sql,
807 807
                     " ORDER BY a.CreateDate ASC",

+ 15 - 5
CallCenterApi/CallCenterApi.Model/T_Msg_Chat_Map.cs

@@ -1,11 +1,10 @@
1 1
 using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-
7 2
 namespace CallCenterApi.Model
8 3
 {
4
+    /// <summary>
5
+    /// T_Msg_Chat_Map:实体类(属性说明自动提取数据库字段的描述信息)
6
+    /// </summary>
7
+    [Serializable]
9 8
     public partial class T_Msg_Chat_Map
10 9
     {
11 10
         public T_Msg_Chat_Map()
@@ -16,6 +15,7 @@ namespace CallCenterApi.Model
16 15
         private int? _touserid;
17 16
         private DateTime? _createdate = DateTime.Now;
18 17
         private int? _isread;
18
+        private int _id;
19 19
         /// <summary>
20 20
         /// ChatId
21 21
         /// </summary>
@@ -56,6 +56,16 @@ namespace CallCenterApi.Model
56 56
             set { _isread = value; }
57 57
             get { return _isread; }
58 58
         }
59
+        /// <summary>
60
+        /// 
61
+        /// </summary>
62
+        public int Id
63
+        {
64
+            set { _id = value; }
65
+            get { return _id; }
66
+        }
59 67
         #endregion Model
68
+
60 69
     }
61 70
 }
71
+