forked from duyanming/Viper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformModule.cs
More file actions
431 lines (421 loc) · 16 KB
/
Copy pathPlatformModule.cs
File metadata and controls
431 lines (421 loc) · 16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
using System;
using System.Collections.Generic;
using Anno.Model;
using System.Linq.Expressions;
using Anno.Command;
using Anno.Const.Attribute;
using Anno.Domain.Dto;
using Anno.Domain.Member;
using Anno.EngineData;
using Anno.QueryServices.Member;
using Anno.Const.Enum;
using Anno.Infrastructure;
using Anno.QueryServices.Platform;
namespace Anno.Plugs.LogicService
{
using Anno.CommandBus;
using Anno.Plugs.LogicService.Filters;
public class PlatformModule : BaseModule
{
private readonly IMemberQuery _memberQuery;
private readonly IMemberService _memberService;
private readonly IPlatformQuery _platformQuery;
public PlatformModule()
{
_memberQuery = this.Resolve<IMemberQuery>();
_memberService = this.Resolve<IMemberService>();
_platformQuery = this.Resolve<IPlatformQuery>();
}
/// <summary>
/// 获取首页数据集
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取会员列表信息")]
public ActionResult GetList_IndexViewModel()
{
var list = _memberQuery.GetMemberListModel();
return new ActionResult(true, list, null, null);
}
/// <summary>
/// 根据会员ID 获取会员信息
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "根据会员ID 获取会员信息")]
public ActionResult GetMemberModel()
{
var dto = this.Request<GetMemberModelInputDto>("dto");
var outputDto = _memberQuery.GetMemberModel(dto);
return new ActionResult(true, outputDto, null, null);
}
/// <summary>
/// 修改密码
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "修改密码")]
[NotChangePassword("anno","yrm")]
public ActionResult ChangePwd()
{
var dto = this.Request<ChangePwdInputDto>("dto");
var rlt = false;
try
{
var command = new ChangePwdCommand(dto.ID, 1, dto.pwd, dto.oldPwd);
CommandBus.Instance.Send(command);
rlt = command.Result.Status;
}
catch (Exception ex)
{
return new ActionResult(false, null, null, ex.Message);
}
return new ActionResult(true, rlt, null, null);
}
/// <summary>
/// 重置用户密码
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "重置用户密码")]
[Authorization]
public ActionResult ReSetpwd()
{
if (Profile != null)
{
var id = this.RequestInt64("ID") ?? -1;
var command = new ReSetPwdCommand(id, 1);
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
else
{
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
}
/// <summary>
/// 用户启用禁用
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "用户启用禁用")]
[Authorization]
public ActionResult EditState()
{
if (Profile != null)
{
var id = this.RequestInt64("ID") ?? -1;
var state = (UserState)(this.RequestInt16("state") ?? 0);
var command = new EnableUserCommand(id, 1, state);
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
else
{
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
}
[AnnoInfo(Desc = "保存用户角色")]
[Authorization]
public ActionResult SaveCurRoles()
{
if (Profile != null)
{
var uid = RequestInt64("uid");
var link = Request<List<UserRoleDto>>("inputData");
SaveUserRoleCommand command = new SaveUserRoleCommand(uid ?? -1, link, 1);
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
[AnnoInfo(Desc = "添加系统角色")]
[Authorization]
public ActionResult AddRole()
{
if (Profile != null)
{
var name = RequestString("Name");
AddRoleCommand command = new AddRoleCommand(name, -1, 1);
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, new { ID = command.Id }, null, command.Result.Msg);
}
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
[AnnoInfo(Desc = "删除系统角色")]
[Authorization]
public ActionResult DelRole()
{
if (Profile != null)
{
var rid = RequestInt64("ID");
DelRoleCommand command = new DelRoleCommand(rid ?? -1, 1);
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
[AnnoInfo(Desc = "修改功能角色关系")]
[Authorization]
public ActionResult ModifyRoleLink()
{
if (Profile != null)
{
var frl = Request<List<sys_func_roles_link>>("inputData");
var rid = RequestInt64("rid");
if (frl.Count > 0)
{
ModifyRoleFuncLinkCommand command = new ModifyRoleFuncLinkCommand(rid ?? -1, 1);
frl.ForEach(f =>
{
if (f.fid != null)
{
command.FidList.Add(f.fid ?? -1);
}
});
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, DbInstance.Db.Queryable<sys_func_roles_link>().ToList(), null, command.Result.Msg);
}
else
{
return new ActionResult(false, null, null, "角色功能列表至少1条!");
}
}
return new ActionResult(false, null, null, "无权操作,你的IP我们已经记录!");
}
[AnnoInfo(Desc = "服务InvokeTest调用服务InvokeTest1")]
public ActionResult InvokeTest()
{
/*测试全局函数调用*/
var gRlt = InvokeProcessor(RequestString(Eng.NAMESPACE), RequestString(Eng.CLASS), "InvokeTest1",
Input);
return Newtonsoft.Json.JsonConvert.DeserializeObject<ActionResult>(gRlt);
}
[AnnoInfo(Desc = "服务InvokeTest1多线程同时调用多个服务接口")]
public ActionResult InvokeTest1()
{
/*测试全局函数调用*/
var gRlt = InvokeProcessorAsync(RequestString(Eng.NAMESPACE), RequestString(Eng.CLASS), "GetList_IndexViewModel",
Input);
var sdaNum = InvokeProcessorAsync("Anno.Plugs.SerialRule", "RuleFactory", "CreateSdaNum", Input);
var action = Newtonsoft.Json.JsonConvert.DeserializeObject<ActionResult>(gRlt.Result);
action.Msg = Newtonsoft.Json.JsonConvert.DeserializeObject<ActionResult>(sdaNum.Result).OutputData.ToString();
return action;
}
/// <summary>
/// 修改功能树
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "修改系统功能")]
[Authorization]
public ActionResult EditFunc()
{
var func = Request<sys_func>("inputData");
var type = RequestInt32("type") ?? 4;
SysFuncCommand command = new SysFuncCommand(func.ID, 1);
command.Mapp(func);
Enum.TryParse(type.ToString(), out SysType systype);
command.SysType = systype;
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
[AnnoInfo(Desc = "添加系统用户")]
[Authorization]
public ActionResult AddUser()
{
AddUserCommand command = new AddUserCommand(IdWorker.NextId(), 1);
#region 接收数据
var m = Request<sys_member>("ubase");
var lr = Request<List<sys_roles>>("uroles");
command.Mapp(m);
command.rdt = DateTime.Now;
lr?.ForEach(r =>
{
command.RolesCmd.Add(new RoleCommand()
{
id = r.ID,
name = r.name
});
});
#endregion
CommandBus.Instance.Send(command);
return new ActionResult(command.Result.Status, null, null, command.Result.Msg);
}
#region 20180215
[AnnoInfo(Desc = "登录")]
public ActionResult Login()
{
var rlt = _platformQuery.Login(this.RequestString("account"), this.RequestString("pwd"));
if (rlt.Status)
{
var sysMembe = rlt.OutputData as sys_member;
if (Const.RedisConfigure.Default().Switch)
{
//Redis.RedisHelper.Set("sys_member:" + sysMembe.account, sysMembe, Const.RedisConfigure.Default().ExpiryDate.Minutes);
}
var command = new LoginRecordCommand(sysMembe.ID, sysMembe.profile, 1);
CommandBus.Instance.Send(command);
}
return rlt;
}
/// <summary>
/// 获取权限根节点
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取用户功能根")]
public ActionResult GetUsrFc()
{
return _platformQuery.GetUsrFc(Profile);
}
/// <summary>
/// 获取用户功能
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取用户功能")]
public ActionResult GetFunc()
{
return _platformQuery.GetFunc(Profile);
}
/// <summary>
/// 会员信息
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "会员信息")]
public ActionResult PCenter()
{
if (Profile != null)
{
sys_member member = null;
if (RequestContainsKey("type") && RequestContainsKey("id"))
{
member = DbInstance.Db.Queryable<sys_member>().Where(m => (m.ID == RequestInt64("id"))).First();
}
else
{
member = DbInstance.Db.Queryable<sys_member>().Where(m => (m.ID == Profile.ID)).First();
}
return new ActionResult(true, member);
}
else
{
return new ActionResult(false, null, null, "未授权的访问");
}
}
[AnnoInfo(Desc = "获取公司信息")]
public ActionResult GetAllbif_company()
{
PageParameter pageParameter = new PageParameter
{
Page = RequestInt32("page") ?? 1,
Pagesize = RequestInt32("pagesize") ?? 20,
SortName = RequestString("sortname") ?? "rdt",
SortOrder = RequestString("sortorder") ?? "desc",
Where = Filter()
};
var allCompany = _platformQuery.GetAllCompany(pageParameter);
return allCompany;
}
[AnnoInfo(Desc = "获取系统会员信息")]
public ActionResult GetAllsys_member()
{
PageParameter pageParameter = new PageParameter
{
Page = RequestInt32("page") ?? 1,
Pagesize = RequestInt32("pagesize") ?? 20,
SortName = RequestString("sortname") ?? "rdt",
SortOrder = RequestString("sortorder") ?? "desc",
Where = Filter()
};
var allUser = _platformQuery.GetAllUser(pageParameter);
return allUser;
}
/// <summary>
/// 获取所有功能点
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取所有功能点")]
public ActionResult Get_all_power()
{
return _platformQuery.Get_all_power();
}
/// <summary>
/// 获取用户角色列表
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取用户角色列表")]
public ActionResult GetcurRoles()
{
return _platformQuery.GetcurRoles(RequestString("uid") ?? Profile.ID.ToString());
}
/// <summary>
/// 获取功能集合
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取功能集合")]
public ActionResult Get_rfs()
{
return _platformQuery.Get_rfs();
}
/// <summary>
/// 获取角色分页数据
/// </summary>
/// <returns></returns>
[AnnoInfo(Desc = "获取角色分页数据")]
public ActionResult GetRolePage()
{
PageParameter pageParameter = new PageParameter
{
Page = RequestInt32("page") ?? 1,
Pagesize = RequestInt32("pagesize") ?? 20,
SortName = RequestString("sortname") ?? "id",
SortOrder = RequestString("sortorder") ?? "asc",
Where = Filter()
};
string roleName = RequestString("roleName");
pageParameter.SortName?.Replace(Table, ".");
pageParameter.SortOrder?.Replace(Table, ".");
var totalNumber = 0;
if (string.IsNullOrWhiteSpace(pageParameter.SortName))
{
pageParameter.SortName = "id";
}
if (string.IsNullOrWhiteSpace(pageParameter.SortOrder))
{
pageParameter.SortOrder = "asc";
}
var dt = DbInstance.Db.Queryable<sys_roles>()
.WhereIF(!string.IsNullOrWhiteSpace(roleName),it=>it.name.Contains(roleName))
.OrderBy($"{pageParameter.SortName} {pageParameter.SortOrder}")
.ToPageList(pageParameter.Page, pageParameter.Pagesize, ref totalNumber);
var output = new Dictionary<string, object> { { "Total", totalNumber }, { "Data", dt } };
return new ActionResult(true, output);
}
#endregion
#region 事件处理
/// <summary>
/// 修改个人密码
/// </summary>
/// <returns></returns>
public ActionResult EditPersonalPwd()
{
var changePwdCommand = new ChangePwdCommand(Profile.ID, 1, RequestString("pwd"), RequestString("opwd"));
CommandBus.Instance.Send(changePwdCommand);
return new ActionResult(changePwdCommand.Result.Status);
}
#endregion
#region Module 初始化
/// <summary>
/// 身份认证服务
/// </summary>
/// <returns></returns>
public ActionResult Identity()
{
return new ActionResult(true, Profile, null, null);
}
public override bool Init(Dictionary<string, string> input)
{
base.Init(input);
if (RequestString("method") != "Login")
{
Profile = _platformQuery.Identity(this.RequestString("profile"));
}
return true;
}
#endregion
}
}