|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+using System;
|
|
|
2
|
+using System.Collections.Generic;
|
|
|
3
|
+using System.Common;
|
|
|
4
|
+using System.IRepositories;
|
|
|
5
|
+using System.Linq;
|
|
|
6
|
+using System.Linq.Expressions;
|
|
|
7
|
+using System.Model;
|
|
|
8
|
+using System.Security.Claims;
|
|
|
9
|
+using System.Threading.Tasks;
|
|
|
10
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
11
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
12
|
+using SqlSugar;
|
|
|
13
|
+
|
|
|
14
|
+namespace TVShoppingCallCenter_ZLJ.Controllers.System
|
|
|
15
|
+{
|
|
|
16
|
+ [Authorize]
|
|
|
17
|
+ [Produces("application/json")]
|
|
|
18
|
+ [Route("api/[controller]")]
|
|
|
19
|
+ public class SeatGroupController : BaseController
|
|
|
20
|
+ {
|
|
|
21
|
+ private readonly ISys_SeatGroupRepository _sys_seatgroupRepository;
|
|
|
22
|
+ public SeatGroupController(ISys_SeatGroupRepository sys_seatgroupRepository)
|
|
|
23
|
+ {
|
|
|
24
|
+ _sys_seatgroupRepository = sys_seatgroupRepository;
|
|
|
25
|
+ }
|
|
|
26
|
+ /// <summary>
|
|
|
27
|
+ /// 获取坐席组列表
|
|
|
28
|
+ /// </summary>
|
|
|
29
|
+ /// <param name="filter"></param>
|
|
|
30
|
+ /// <returns></returns>
|
|
|
31
|
+ [Authorize]
|
|
|
32
|
+ [HttpGet("getlistbypage")]
|
|
|
33
|
+ public async Task<IActionResult> GetListsByPage(string key, int pageindex = 1, int pagesize = 10)
|
|
|
34
|
+ {
|
|
|
35
|
+ List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
|
36
|
+ #region 条件筛选
|
|
|
37
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
|
|
|
38
|
+
|
|
|
39
|
+ List<IConditionalModel> conModels1 = new List<IConditionalModel>();
|
|
|
40
|
+ if (!string.IsNullOrEmpty(key))
|
|
|
41
|
+ {
|
|
|
42
|
+ conModels.Add(new ConditionalCollections()
|
|
|
43
|
+ {
|
|
|
44
|
+ ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
|
|
45
|
+ {
|
|
|
46
|
+ new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_ZXZName", ConditionalType = ConditionalType.Like, FieldValue = key }),
|
|
|
47
|
+ new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_ZXZCode", ConditionalType = ConditionalType.Like, FieldValue = key }),
|
|
|
48
|
+ new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or, new ConditionalModel() { FieldName = "F_ZXAtt", ConditionalType = ConditionalType.Like, FieldValue = key })
|
|
|
49
|
+ }
|
|
|
50
|
+ });
|
|
|
51
|
+ }
|
|
|
52
|
+ #endregion
|
|
|
53
|
+ int recordCount = 0;
|
|
|
54
|
+ var list = await _sys_seatgroupRepository.GetListByPage(conModels, new PageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount }, "F_CreateOn desc");
|
|
|
55
|
+
|
|
|
56
|
+ return Success("成功", list);
|
|
|
57
|
+ }
|
|
|
58
|
+
|
|
|
59
|
+ [Authorize]
|
|
|
60
|
+ [HttpGet("getlist")]
|
|
|
61
|
+ public async Task<IActionResult> GetList(string key)
|
|
|
62
|
+ {
|
|
|
63
|
+ List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
|
64
|
+ #region 条件筛选
|
|
|
65
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
|
|
|
66
|
+
|
|
|
67
|
+ if (!string.IsNullOrEmpty(key))
|
|
|
68
|
+ {
|
|
|
69
|
+ conModels.Add(new ConditionalCollections()
|
|
|
70
|
+ {
|
|
|
71
|
+ ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
|
|
72
|
+ {
|
|
|
73
|
+ new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_ZXZCode", ConditionalType = ConditionalType.Like, FieldValue = key }),
|
|
|
74
|
+ new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel() { FieldName = "F_ZXZName", ConditionalType = ConditionalType.Like, FieldValue = key }),
|
|
|
75
|
+ new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or, new ConditionalModel() { FieldName = "F_ZXAtt", ConditionalType = ConditionalType.Like, FieldValue = key })
|
|
|
76
|
+ }
|
|
|
77
|
+ });
|
|
|
78
|
+
|
|
|
79
|
+ }
|
|
|
80
|
+ #endregion
|
|
|
81
|
+ var list = await _sys_seatgroupRepository.GetListALL(conModels, "F_CreateOn desc");
|
|
|
82
|
+
|
|
|
83
|
+ return Success("根据条件获取数据成功", list);
|
|
|
84
|
+ }
|
|
|
85
|
+
|
|
|
86
|
+ /// <summary>
|
|
|
87
|
+ /// 获取实体
|
|
|
88
|
+ /// </summary>
|
|
|
89
|
+ [Authorize]
|
|
|
90
|
+ [HttpGet("getsingle")]
|
|
|
91
|
+ public async Task<IActionResult> GetSingle(int id)
|
|
|
92
|
+ {
|
|
|
93
|
+ if (id > 0)
|
|
|
94
|
+ {
|
|
|
95
|
+ var dModel = await _sys_seatgroupRepository.GetSingle(x => x.F_ZXZID == id);
|
|
|
96
|
+
|
|
|
97
|
+ if (dModel != null)
|
|
|
98
|
+ {
|
|
|
99
|
+ return Success("获取坐席组成功", dModel);
|
|
|
100
|
+ }
|
|
|
101
|
+ else
|
|
|
102
|
+ {
|
|
|
103
|
+ return Error("获取坐席组失败");
|
|
|
104
|
+ }
|
|
|
105
|
+ }
|
|
|
106
|
+ else
|
|
|
107
|
+ {
|
|
|
108
|
+ return Error("获取参数失败");
|
|
|
109
|
+ }
|
|
|
110
|
+ }
|
|
|
111
|
+
|
|
|
112
|
+ /// <summary>
|
|
|
113
|
+ /// 添加坐席组
|
|
|
114
|
+ /// </summary>
|
|
|
115
|
+ [Authorize]
|
|
|
116
|
+ [HttpPost("add")]
|
|
|
117
|
+ public async Task<IActionResult> Add(string zxzcode, string zxzname, string zxatt,
|
|
|
118
|
+ string whwdkey, string whbdkey, int ivrkey, string outcallnum, string des)
|
|
|
119
|
+ {
|
|
|
120
|
+ T_Sys_SeatGroup clmodel = new T_Sys_SeatGroup();
|
|
|
121
|
+ if (await GetExistByCodeAsync(zxzcode, 0) || await GetExistByNameAsync(zxzname, 0))
|
|
|
122
|
+ {
|
|
|
123
|
+ return Error("坐席组编号和名称必须唯一,请重新输入!");
|
|
|
124
|
+ }
|
|
|
125
|
+ if (!string.IsNullOrWhiteSpace(zxzcode))
|
|
|
126
|
+ clmodel.F_ZXZCode = zxzcode.Trim();
|
|
|
127
|
+ else
|
|
|
128
|
+ {
|
|
|
129
|
+ return Error("编号不能为空");
|
|
|
130
|
+ }
|
|
|
131
|
+ if (!string.IsNullOrWhiteSpace(zxzname))
|
|
|
132
|
+ clmodel.F_ZXZName = zxzname.Trim();
|
|
|
133
|
+ else
|
|
|
134
|
+ {
|
|
|
135
|
+ return Error("名称不能为空");
|
|
|
136
|
+ }
|
|
|
137
|
+ if (!string.IsNullOrWhiteSpace(zxatt))
|
|
|
138
|
+ clmodel.F_ZXAtt = zxatt.Trim();
|
|
|
139
|
+ else
|
|
|
140
|
+ {
|
|
|
141
|
+ return Error("坐席地区号不能为空");
|
|
|
142
|
+ }
|
|
|
143
|
+ if (!string.IsNullOrWhiteSpace(whwdkey))
|
|
|
144
|
+ clmodel.F_WHWDKey = whwdkey.Trim();
|
|
|
145
|
+ else
|
|
|
146
|
+ {
|
|
|
147
|
+ return Error("外呼外地前缀不能为空");
|
|
|
148
|
+ }
|
|
|
149
|
+ if (!string.IsNullOrWhiteSpace(whbdkey))
|
|
|
150
|
+ clmodel.F_WHBDKey = whbdkey.Trim();
|
|
|
151
|
+ else
|
|
|
152
|
+ {
|
|
|
153
|
+ return Error("外呼本地前缀不能为空");
|
|
|
154
|
+ }
|
|
|
155
|
+ if (!ValidateString.IsNumberStr(whwdkey.Trim().ToString()))
|
|
|
156
|
+ {
|
|
|
157
|
+ return Error("外呼外地前缀必须为数字");
|
|
|
158
|
+ }
|
|
|
159
|
+ if (!ValidateString.IsNumberStr(whbdkey.Trim().ToString()))
|
|
|
160
|
+ {
|
|
|
161
|
+ return Error("外呼本地前缀必须为数字");
|
|
|
162
|
+ }
|
|
|
163
|
+
|
|
|
164
|
+ clmodel.F_IVRKey = ivrkey;
|
|
|
165
|
+ clmodel.F_Des = des;
|
|
|
166
|
+ clmodel.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value; //"8000";
|
|
|
167
|
+ clmodel.F_CreateOn = DateTime.Now;
|
|
|
168
|
+ clmodel.F_State = (int)EnumDelState.Enabled;
|
|
|
169
|
+
|
|
|
170
|
+ var res = await _sys_seatgroupRepository.Add(clmodel);
|
|
|
171
|
+ if (res > 0)
|
|
|
172
|
+ return Success("坐席组保存成功");
|
|
|
173
|
+ else
|
|
|
174
|
+ {
|
|
|
175
|
+ return Error("坐席组保存失败");
|
|
|
176
|
+ }
|
|
|
177
|
+ }
|
|
|
178
|
+
|
|
|
179
|
+ /// <summary>
|
|
|
180
|
+ /// 修改坐席组
|
|
|
181
|
+ /// </summary>
|
|
|
182
|
+ [Authorize]
|
|
|
183
|
+ [HttpPost("update")]
|
|
|
184
|
+ public async Task<IActionResult> Edit(int id, string zxzcode, string zxzname, string zxatt,
|
|
|
185
|
+ string whwdkey, string whbdkey, int ivrkey, string outcallnum, string des)
|
|
|
186
|
+ {
|
|
|
187
|
+ if (id > 0)
|
|
|
188
|
+ {
|
|
|
189
|
+ if (await GetExistByCodeAsync(zxzcode, id) || await GetExistByNameAsync(zxzname, id))
|
|
|
190
|
+ {
|
|
|
191
|
+ return Error("坐席组编号和名称必须唯一,请重新输入!");
|
|
|
192
|
+ }
|
|
|
193
|
+ if (string.IsNullOrWhiteSpace(whwdkey))
|
|
|
194
|
+ return Error("外呼外地前缀不能为空");
|
|
|
195
|
+ if (string.IsNullOrWhiteSpace(whbdkey))
|
|
|
196
|
+ return Error("外呼本地前缀不能为空");
|
|
|
197
|
+
|
|
|
198
|
+ if (!ValidateString.IsNumberStr(whwdkey.Trim().ToString()))
|
|
|
199
|
+ {
|
|
|
200
|
+ return Error("外呼外地前缀必须为数字");
|
|
|
201
|
+ }
|
|
|
202
|
+ if (!ValidateString.IsNumberStr(whbdkey.Trim().ToString()))
|
|
|
203
|
+ {
|
|
|
204
|
+ return Error("外呼本地前缀必须为数字");
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ var res = false;
|
|
|
208
|
+ var clmodel = await _sys_seatgroupRepository.GetSingle(x => x.F_ZXZID == id);
|
|
|
209
|
+ if (clmodel != null)
|
|
|
210
|
+ {
|
|
|
211
|
+ if (!string.IsNullOrWhiteSpace(zxzcode))
|
|
|
212
|
+ clmodel.F_ZXZCode = zxzcode.Trim();
|
|
|
213
|
+ if (!string.IsNullOrWhiteSpace(zxzname))
|
|
|
214
|
+ clmodel.F_ZXZName = zxzname.Trim();
|
|
|
215
|
+ if (!string.IsNullOrWhiteSpace(zxatt))
|
|
|
216
|
+ clmodel.F_ZXAtt = zxatt.Trim();
|
|
|
217
|
+ if (!string.IsNullOrWhiteSpace(whwdkey))
|
|
|
218
|
+ clmodel.F_WHWDKey = whwdkey.Trim();
|
|
|
219
|
+ if (!string.IsNullOrWhiteSpace(whbdkey))
|
|
|
220
|
+ clmodel.F_WHBDKey = whbdkey.Trim();
|
|
|
221
|
+
|
|
|
222
|
+ clmodel.F_IVRKey = ivrkey;
|
|
|
223
|
+ if (!string.IsNullOrWhiteSpace(des))
|
|
|
224
|
+ clmodel.F_Des = des;
|
|
|
225
|
+
|
|
|
226
|
+ clmodel.F_LastModifyBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value; //"8000";
|
|
|
227
|
+ clmodel.F_LastModifyOn = DateTime.Now;
|
|
|
228
|
+
|
|
|
229
|
+ res = await _sys_seatgroupRepository.Update(clmodel);
|
|
|
230
|
+ }
|
|
|
231
|
+ if (res)
|
|
|
232
|
+ return Success("坐席组保存成功");
|
|
|
233
|
+ else
|
|
|
234
|
+ {
|
|
|
235
|
+ return Error("坐席组保存失败");
|
|
|
236
|
+ }
|
|
|
237
|
+ }
|
|
|
238
|
+ else
|
|
|
239
|
+ return Error("请选择要编辑的坐席组");
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+ [Authorize]
|
|
|
243
|
+ [HttpPost("delete")]
|
|
|
244
|
+ public async Task<IActionResult> Remove(int[] ids)
|
|
|
245
|
+ {
|
|
|
246
|
+ //使用逻辑删除
|
|
|
247
|
+ //物理删除的数据无法恢复
|
|
|
248
|
+ var res = 0;
|
|
|
249
|
+ if (ids != null && ids.Length > 0)
|
|
|
250
|
+ {
|
|
|
251
|
+ foreach (var item in ids)
|
|
|
252
|
+ {
|
|
|
253
|
+ var ml = await _sys_seatgroupRepository.GetSingle(x => x.F_ZXZID == item);
|
|
|
254
|
+ ml.F_State = (int)EnumDelState.Delete;
|
|
|
255
|
+ if (await _sys_seatgroupRepository.Update(ml))
|
|
|
256
|
+ res += 1;
|
|
|
257
|
+ }
|
|
|
258
|
+ if (res == ids.Length)
|
|
|
259
|
+ return Success("删除成功");
|
|
|
260
|
+ else if (res > 0 && res < ids.Length)
|
|
|
261
|
+ return Error("部分删除失败,请查看后重新操作");
|
|
|
262
|
+ else
|
|
|
263
|
+ return Error("删除失败,请查看后重新操作");
|
|
|
264
|
+ }
|
|
|
265
|
+ else
|
|
|
266
|
+ return Error("请选择要删除的记录");
|
|
|
267
|
+ }
|
|
|
268
|
+
|
|
|
269
|
+ #region 私有方法
|
|
|
270
|
+ /// <summary>
|
|
|
271
|
+ /// 根据坐席组编号查询是否存在此坐席组编号
|
|
|
272
|
+ /// </summary>
|
|
|
273
|
+ /// <param name="code"></param>
|
|
|
274
|
+ /// <returns></returns>
|
|
|
275
|
+ private async Task<bool> GetExistByCodeAsync(string code, int id)
|
|
|
276
|
+ {
|
|
|
277
|
+ long c = 0;
|
|
|
278
|
+ if (id > 0)
|
|
|
279
|
+ c = await _sys_seatgroupRepository.GetCount(x => x.F_ZXZCode.Equals(code) && x.F_ZXZID != id);
|
|
|
280
|
+ else
|
|
|
281
|
+ c = await _sys_seatgroupRepository.GetCount(x => x.F_ZXZCode.Equals(code));
|
|
|
282
|
+
|
|
|
283
|
+ return c > 0;
|
|
|
284
|
+ }
|
|
|
285
|
+ /// <summary>
|
|
|
286
|
+ /// 根据坐席组名称查询是否存在此坐席组编号
|
|
|
287
|
+ /// </summary>
|
|
|
288
|
+ /// <param name="code"></param>
|
|
|
289
|
+ /// <returns></returns>
|
|
|
290
|
+ private async Task<bool> GetExistByNameAsync(string name, int id)
|
|
|
291
|
+ {
|
|
|
292
|
+ long c = 0;
|
|
|
293
|
+ if (id > 0)
|
|
|
294
|
+ c = await _sys_seatgroupRepository.GetCount(x => x.F_ZXZName.Equals(name) && x.F_ZXZID != id);
|
|
|
295
|
+ else
|
|
|
296
|
+ c = await _sys_seatgroupRepository.GetCount(x => x.F_ZXZName.Equals(name));
|
|
|
297
|
+
|
|
|
298
|
+ return c > 0;
|
|
|
299
|
+ }
|
|
|
300
|
+ #endregion
|
|
|
301
|
+ }
|
|
|
302
|
+}
|