|
|
@@ -1,11 +1,16 @@
|
|
1
|
1
|
using System;
|
|
2
|
2
|
using System.Collections.Generic;
|
|
3
|
3
|
using System.Common;
|
|
|
4
|
+using System.Common.Helpers;
|
|
4
|
5
|
using System.IRepositories;
|
|
5
|
6
|
using System.Linq;
|
|
|
7
|
+using System.Linq.Expressions;
|
|
|
8
|
+using System.Model;
|
|
6
|
9
|
using System.Threading.Tasks;
|
|
7
|
10
|
using Microsoft.AspNetCore.Authorization;
|
|
8
|
11
|
using Microsoft.AspNetCore.Mvc;
|
|
|
12
|
+using SqlSugar;
|
|
|
13
|
+using TVShoppingCallCenter_ZLJ.Models.Inputs;
|
|
9
|
14
|
|
|
10
|
15
|
namespace TVShoppingCallCenter_ZLJ.Controllers.SMS
|
|
11
|
16
|
{
|
|
|
@@ -27,10 +32,149 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.SMS
|
|
27
|
32
|
{
|
|
28
|
33
|
bus_SMSTemplateRepository = _bus_SMSTemplateRepository;
|
|
29
|
34
|
bus_SMSLogRepository = _bus_SMSLogRepository;
|
|
|
35
|
+ }
|
|
|
36
|
+
|
|
|
37
|
+ #region 短信模板
|
|
|
38
|
+
|
|
|
39
|
+ /// <summary>
|
|
|
40
|
+ /// 新增
|
|
|
41
|
+ /// </summary>
|
|
|
42
|
+ /// <param name="input"></param>
|
|
|
43
|
+ /// <returns></returns>
|
|
|
44
|
+ [HttpPost("addtemplate")]
|
|
|
45
|
+ public async Task<IActionResult> AddTemplate(SMSTemplateInput input)
|
|
|
46
|
+ {
|
|
|
47
|
+
|
|
|
48
|
+ #region 验证 参数
|
|
|
49
|
+
|
|
|
50
|
+
|
|
|
51
|
+ if (string.IsNullOrEmpty(input.F_Content))
|
|
|
52
|
+ return Error("请输入模板内容");
|
|
|
53
|
+ if (string.IsNullOrEmpty(input.F_ModelName))
|
|
|
54
|
+ return Error("请输入模板名称");
|
|
|
55
|
+ if (string.IsNullOrEmpty(input.F_Tel))
|
|
|
56
|
+ return Error("请输入要绑定400电话");
|
|
|
57
|
+
|
|
30
|
58
|
|
|
|
59
|
+ #endregion
|
|
31
|
60
|
|
|
|
61
|
+ if (await bus_SMSTemplateRepository.GetCount(a => a.F_ModelName == input.F_ModelName) > 0)
|
|
|
62
|
+ {
|
|
|
63
|
+ return Error("模板名称不能重复");
|
|
|
64
|
+ }
|
|
|
65
|
+ T_Bus_SMSTemplate ModelAdd = new T_Bus_SMSTemplate();
|
|
|
66
|
+ ModelConvertHelper<T_Bus_SMSTemplate, SMSTemplateInput>.ModeToModelDefault(ModelAdd, input);
|
|
|
67
|
+ ModelAdd.F_AddUser = UserLogin.UserId.ObjToInt();
|
|
|
68
|
+ ModelAdd.F_AddUserName = UserLogin.UserName;
|
|
|
69
|
+ ModelAdd.F_AddTime = DateTime.Now;
|
|
|
70
|
+
|
|
|
71
|
+ if (await bus_SMSTemplateRepository.Add(ModelAdd) > 0)
|
|
|
72
|
+ {
|
|
|
73
|
+ return Success("新增成功");
|
|
|
74
|
+ }
|
|
|
75
|
+ else
|
|
|
76
|
+ {
|
|
|
77
|
+ return Error("新增失败,请重试!");
|
|
|
78
|
+ }
|
|
32
|
79
|
}
|
|
33
|
80
|
|
|
34
|
81
|
|
|
|
82
|
+ /// <summary>
|
|
|
83
|
+ /// 更新
|
|
|
84
|
+ /// </summary>
|
|
|
85
|
+ /// <param name="input"></param>
|
|
|
86
|
+ /// <returns></returns>
|
|
|
87
|
+ [HttpPost("updatetemplate")]
|
|
|
88
|
+ public async Task<IActionResult> UpdateTemplate(SMSTemplateInput input)
|
|
|
89
|
+ {
|
|
|
90
|
+
|
|
|
91
|
+ #region 验证 参数
|
|
|
92
|
+
|
|
|
93
|
+
|
|
|
94
|
+ if (string.IsNullOrEmpty(input.F_Content))
|
|
|
95
|
+ return Error("请输入模板内容");
|
|
|
96
|
+ if (string.IsNullOrEmpty(input.F_ModelName))
|
|
|
97
|
+ return Error("请输入模板名称");
|
|
|
98
|
+ if (string.IsNullOrEmpty(input.F_Tel))
|
|
|
99
|
+ return Error("请输入要绑定400电话");
|
|
|
100
|
+ if (input.F_Id<1)
|
|
|
101
|
+ return Error("参数缺失");
|
|
|
102
|
+
|
|
|
103
|
+ #endregion
|
|
|
104
|
+
|
|
|
105
|
+ if (await bus_SMSTemplateRepository.GetCount(q => q.F_ModelName == input.F_ModelName&&q.F_Id!= input.F_Id) > 0)
|
|
|
106
|
+ {
|
|
|
107
|
+ return Error("模板名称不能重复");
|
|
|
108
|
+ }
|
|
|
109
|
+ input.F_AddTime = DateTime.Now;
|
|
|
110
|
+ T_Bus_SMSTemplate ModelAdd = await bus_SMSTemplateRepository.GetSingle(q=>q.F_Id==input.F_Id);
|
|
|
111
|
+ ModelConvertHelper<T_Bus_SMSTemplate, SMSTemplateInput>.ModeToModelDefault(ModelAdd, input);
|
|
|
112
|
+ ModelAdd.F_AddUser = UserLogin.UserId.ObjToInt();
|
|
|
113
|
+ ModelAdd.F_AddUserName = UserLogin.UserName;
|
|
|
114
|
+
|
|
|
115
|
+ if (await bus_SMSTemplateRepository.Update(ModelAdd))
|
|
|
116
|
+ {
|
|
|
117
|
+ return Success("保存成功");
|
|
|
118
|
+ }
|
|
|
119
|
+
|
|
|
120
|
+ return Error("保存失败,请重试!");
|
|
|
121
|
+
|
|
|
122
|
+ }
|
|
|
123
|
+
|
|
|
124
|
+ /// <summary>
|
|
|
125
|
+ /// 删除
|
|
|
126
|
+ /// </summary>
|
|
|
127
|
+ /// <param name="ids">格式 1,2,3,4</param>
|
|
|
128
|
+ /// <returns></returns>
|
|
|
129
|
+ [HttpPost("deletetemplate")]
|
|
|
130
|
+ public async Task<IActionResult> DeleteTemplate(string ids)
|
|
|
131
|
+ {
|
|
|
132
|
+ if (string.IsNullOrEmpty(ids))
|
|
|
133
|
+ return Error("请输入删除id");
|
|
|
134
|
+ ids = ids.Trim(',');
|
|
|
135
|
+ if (string.IsNullOrEmpty(ids))
|
|
|
136
|
+ return Error("请输入删除id");
|
|
|
137
|
+ string[] idsArry = ids.Split(',');
|
|
|
138
|
+ if (await bus_SMSTemplateRepository.Delete(q => idsArry.Contains( q.F_Id.ToString())))
|
|
|
139
|
+ {
|
|
|
140
|
+ return Success("删除成功");
|
|
|
141
|
+ }
|
|
|
142
|
+ else
|
|
|
143
|
+ {
|
|
|
144
|
+ return Error("删除失败,请重试!");
|
|
|
145
|
+ }
|
|
|
146
|
+ }
|
|
|
147
|
+
|
|
|
148
|
+ /// <summary>
|
|
|
149
|
+ /// 分页查询
|
|
|
150
|
+ /// </summary>
|
|
|
151
|
+ /// <param name="input"></param>
|
|
|
152
|
+ /// <returns></returns>
|
|
|
153
|
+ [HttpPost("gettemplatebypage")]
|
|
|
154
|
+ public async Task<IActionResult> ProductClassList(SMSTemplateInput input)
|
|
|
155
|
+ {
|
|
|
156
|
+
|
|
|
157
|
+ List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
|
158
|
+ #region 条件筛选
|
|
|
159
|
+ if (!string.IsNullOrEmpty(input.F_ModelName))
|
|
|
160
|
+ {
|
|
|
161
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ModelName", ConditionalType = ConditionalType.Like, FieldValue = input.F_ModelName });
|
|
|
162
|
+ }
|
|
|
163
|
+ if (!string.IsNullOrEmpty(input.F_Tel))
|
|
|
164
|
+ {
|
|
|
165
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_Tel", ConditionalType = ConditionalType.Like, FieldValue = input.F_Tel });
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+ #endregion
|
|
|
169
|
+ int count = 0;
|
|
|
170
|
+ PageData<T_Bus_SMSTemplate> productClasselist = await bus_SMSTemplateRepository.GetListByPage(conModels, new MyPageModel() { PageIndex = input.pageindex, PageSize = input.pagesize, PageCount = count });
|
|
|
171
|
+
|
|
|
172
|
+ return Success("成功", productClasselist);
|
|
|
173
|
+ }
|
|
|
174
|
+
|
|
|
175
|
+
|
|
|
176
|
+ #endregion
|
|
|
177
|
+
|
|
|
178
|
+
|
|
35
|
179
|
}
|
|
36
|
180
|
}
|