|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+using System;
|
|
|
2
|
+using System.Collections.Generic;
|
|
|
3
|
+using System.Common;
|
|
|
4
|
+using System.IRepositories;
|
|
|
5
|
+using System.IRepositories.Sys;
|
|
|
6
|
+using System.Linq;
|
|
|
7
|
+using System.Model.Sys;
|
|
|
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 BottomNumberController : BaseController
|
|
|
20
|
+ {
|
|
|
21
|
+ private readonly ISys_BottomNumberRepository _sys_bottomnumberrepository;
|
|
|
22
|
+ private readonly ISys_SeatGroupRepository _sys_seatGroupRepository;
|
|
|
23
|
+ public BottomNumberController(ISys_BottomNumberRepository sys_bottomnumberrepository
|
|
|
24
|
+ , ISys_SeatGroupRepository sys_seatGroupRepository)
|
|
|
25
|
+ {
|
|
|
26
|
+ _sys_bottomnumberrepository = sys_bottomnumberrepository;
|
|
|
27
|
+ _sys_seatGroupRepository = sys_seatGroupRepository;
|
|
|
28
|
+ }
|
|
|
29
|
+ /// <summary>
|
|
|
30
|
+ /// 添加
|
|
|
31
|
+ /// </summary>
|
|
|
32
|
+ /// <param name="input"></param>
|
|
|
33
|
+ /// <returns></returns>
|
|
|
34
|
+ [HttpPost("add")]
|
|
|
35
|
+ public async Task<IActionResult> AddAsync(T_Sys_BottomNumber input)
|
|
|
36
|
+ {
|
|
|
37
|
+ if (string.IsNullOrEmpty(input.F_Name))
|
|
|
38
|
+ return Error("请输入名称");
|
|
|
39
|
+ if (string.IsNullOrEmpty(input.F_ZXZCode))
|
|
|
40
|
+ return Error("请选择坐席组");
|
|
|
41
|
+ if (string.IsNullOrEmpty(input.F_Tel))
|
|
|
42
|
+ return Error("请输入底号");
|
|
|
43
|
+ input.F_CreateOn = DateTime.Now;
|
|
|
44
|
+ input.F_IsDelete = 0;
|
|
|
45
|
+ input.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
46
|
+ var res = await _sys_bottomnumberrepository.Add(input);
|
|
|
47
|
+ if (res > 0)
|
|
|
48
|
+ {
|
|
|
49
|
+ return Success("添加成功");
|
|
|
50
|
+ }
|
|
|
51
|
+ else
|
|
|
52
|
+ {
|
|
|
53
|
+ return Error("添加失败");
|
|
|
54
|
+ }
|
|
|
55
|
+ }
|
|
|
56
|
+ /// <summary>
|
|
|
57
|
+ /// 修改
|
|
|
58
|
+ /// </summary>
|
|
|
59
|
+ [HttpPost("update")]
|
|
|
60
|
+ public async Task<IActionResult> UpdateAsync(T_Sys_BottomNumber input)
|
|
|
61
|
+ {
|
|
|
62
|
+ if (input.F_ID <= 0)
|
|
|
63
|
+ return Error("参数错误");
|
|
|
64
|
+ if (string.IsNullOrEmpty(input.F_Name))
|
|
|
65
|
+ return Error("请输入名称");
|
|
|
66
|
+ if (string.IsNullOrEmpty(input.F_ZXZCode))
|
|
|
67
|
+ return Error("请选择坐席组");
|
|
|
68
|
+ if (string.IsNullOrEmpty(input.F_Tel))
|
|
|
69
|
+ return Error("请输入底号");
|
|
|
70
|
+ var model = await _sys_bottomnumberrepository.GetSingle(x => x.F_ID == input.F_ID);
|
|
|
71
|
+ if (model == null)
|
|
|
72
|
+ return Error("操作失败");
|
|
|
73
|
+ input.F_IsDelete = 0;
|
|
|
74
|
+ input.F_CreateBy = model.F_CreateBy;
|
|
|
75
|
+ input.F_CreateOn = model.F_CreateOn;
|
|
|
76
|
+ model = input;
|
|
|
77
|
+ model.F_LastModifyOn = DateTime.Now;
|
|
|
78
|
+ model.F_LastModifyBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
79
|
+ var b = await _sys_bottomnumberrepository.Update(model);
|
|
|
80
|
+ if (b)
|
|
|
81
|
+ return Success("修改成功");
|
|
|
82
|
+ return Error("修改失败");
|
|
|
83
|
+ }
|
|
|
84
|
+ /// <summary>
|
|
|
85
|
+ /// 删除
|
|
|
86
|
+ /// </summary>
|
|
|
87
|
+ /// <param name="ids"></param>
|
|
|
88
|
+ /// <returns></returns>
|
|
|
89
|
+ [HttpPost("delete")]
|
|
|
90
|
+ public async Task<IActionResult> Remove(int[] ids)
|
|
|
91
|
+ {
|
|
|
92
|
+ var res = 0;
|
|
|
93
|
+ if (ids != null && ids.Length > 0)
|
|
|
94
|
+ {
|
|
|
95
|
+ foreach (var item in ids)
|
|
|
96
|
+ {
|
|
|
97
|
+ var model = await _sys_bottomnumberrepository.GetSingle(x => x.F_ID == item);
|
|
|
98
|
+ model.F_IsDelete = (int)EnumUserCountState.Delete;
|
|
|
99
|
+ model.F_DeleteOn = DateTime.Now.ToLocalTime();
|
|
|
100
|
+ model.F_DeleteBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
|
|
|
101
|
+ if (_sys_bottomnumberrepository.Update(model).Result)
|
|
|
102
|
+ res += 1;
|
|
|
103
|
+ }
|
|
|
104
|
+ if (res == ids.Length)
|
|
|
105
|
+ return Success("删除成功");
|
|
|
106
|
+ else if (res > 0 && res < ids.Length)
|
|
|
107
|
+ return Error("部分删除失败,请查看后重新操作");
|
|
|
108
|
+ else
|
|
|
109
|
+ return Error("删除失败,请查看后重新操作");
|
|
|
110
|
+ }
|
|
|
111
|
+ else
|
|
|
112
|
+ return Error("请选择要删除的记录");
|
|
|
113
|
+ }
|
|
|
114
|
+
|
|
|
115
|
+ /// <summary>
|
|
|
116
|
+ /// 获取列表
|
|
|
117
|
+ /// </summary>
|
|
|
118
|
+ /// <param name="keyword"></param>
|
|
|
119
|
+ /// <param name="pageindex"></param>
|
|
|
120
|
+ /// <param name="pagesize"></param>
|
|
|
121
|
+ /// <returns></returns>
|
|
|
122
|
+ [HttpGet("getlist")]
|
|
|
123
|
+ public async Task<IActionResult> GetLisAsync(string keyword, string code, int pageindex = 1, int pagesize = 20)
|
|
|
124
|
+ {
|
|
|
125
|
+ List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
|
126
|
+ #region 条件筛选
|
|
|
127
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumUserCountState.Enabled).ToString() });
|
|
|
128
|
+ if (!string.IsNullOrEmpty(keyword))
|
|
|
129
|
+ {
|
|
|
130
|
+ conModels.Add(new ConditionalCollections()
|
|
|
131
|
+ {
|
|
|
132
|
+ ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
|
|
133
|
+ {
|
|
|
134
|
+ new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_Tel", ConditionalType = ConditionalType.Like, FieldValue = keyword }),
|
|
|
135
|
+ new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_Name", ConditionalType = ConditionalType.Like, FieldValue = keyword }),
|
|
|
136
|
+ }
|
|
|
137
|
+ });
|
|
|
138
|
+ }
|
|
|
139
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ZXZCode", ConditionalType = ConditionalType.Equal, FieldValue = code });
|
|
|
140
|
+ #endregion
|
|
|
141
|
+ int recordCount = 0;
|
|
|
142
|
+ var list = await _sys_bottomnumberrepository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount });
|
|
|
143
|
+
|
|
|
144
|
+
|
|
|
145
|
+ var obj = new
|
|
|
146
|
+ {
|
|
|
147
|
+ state = "success",
|
|
|
148
|
+ message = "成功",
|
|
|
149
|
+ rows = WokeTimes(list),
|
|
|
150
|
+ total = list.Totals,
|
|
|
151
|
+ };
|
|
|
152
|
+
|
|
|
153
|
+ return Content(obj.ToJson());
|
|
|
154
|
+ }
|
|
|
155
|
+ private PageData<T_Sys_BottomNumber> WokeTimes(PageData<T_Sys_BottomNumber> pageData)
|
|
|
156
|
+
|
|
|
157
|
+ {
|
|
|
158
|
+ foreach (var it in pageData.Rows)
|
|
|
159
|
+ {
|
|
|
160
|
+ it.F_ZXZCode = _sys_seatGroupRepository.GetListALL(x => x.F_ZXZCode == it.F_ZXZCode).Result != null ? _sys_seatGroupRepository.GetListALL(x => x.F_ZXZCode == it.F_ZXZCode).Result.FirstOrDefault().F_ZXZName : "";
|
|
|
161
|
+ }
|
|
|
162
|
+ return pageData;
|
|
|
163
|
+ }
|
|
|
164
|
+ /// <summary>
|
|
|
165
|
+ /// 获取详情
|
|
|
166
|
+ /// </summary>
|
|
|
167
|
+ /// <param name="id">id</param>
|
|
|
168
|
+ /// <returns></returns>
|
|
|
169
|
+ [HttpGet("getdetails")]
|
|
|
170
|
+ public async Task<IActionResult> GetDetailsAsync(int id)
|
|
|
171
|
+ {
|
|
|
172
|
+ if (id <= 0)
|
|
|
173
|
+ return Error("参数错误");
|
|
|
174
|
+
|
|
|
175
|
+ var model = await _sys_bottomnumberrepository.GetSingle(x => x.F_ID == id);
|
|
|
176
|
+ if (model == null)
|
|
|
177
|
+ {
|
|
|
178
|
+ return Error("获取失败");
|
|
|
179
|
+ }
|
|
|
180
|
+
|
|
|
181
|
+ return Success("获取成功!", model);
|
|
|
182
|
+ }
|
|
|
183
|
+ }
|
|
|
184
|
+}
|