6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using NCC.Common.Core.Manager;
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
using NCC.Dependency;
using NCC.DynamicApiController;
using NCC.FriendlyException;
using NCC.Extend.Interfaces.User;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NCC.System.Entitys.Permission;
using NCC.Extend.Entitys.Dto.User;
using NCC.Common.Helper;
using NCC.JsonSerialization;
using NCC.Common.Model.NPOI;
using NCC.Common.Configuration;
using NCC.DataEncryption;
using NCC.ClayObject;
|
06553fb7
“wangming”
1
|
24
|
using NCC.Extend.Entitys.lq_jinsanjiao_user;
|
e1dcb3a0
“wangming”
1
|
25
|
using NCC.Extend.Entitys.lq_mdxx;
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
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
|
namespace NCC.Extend.User
{
/// <summary>
/// 用户服务
/// </summary>
[ApiDescriptionSettings(Tag = "绿纤用户服务", Name = "User", Order = 200)]
[Route("api/Extend/[controller]")]
public class UserService : IUserService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<UserEntity> _userRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
/// <summary>
/// 初始化一个<see cref="UserService"/>类型的新实例
/// </summary>
public UserService(
ISqlSugarRepository<UserEntity> userRepository,
IUserManager userManager)
{
_userRepository = userRepository;
_db = _userRepository.Context;
_userManager = userManager;
}
|
e1dcb3a0
“wangming”
1
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
private static readonly HashSet<string> CrossStoreGwExact = new HashSet<string>(StringComparer.Ordinal)
{
"科技老师",
"总经理",
"经理",
"董事长",
"总裁",
};
/// <summary>
/// 跨店/总部岗位在未传 mdid 时不按当前登录门店自动过滤(如科技老师供各门店选择)
/// </summary>
private static bool ShouldAutoFilterByCurrentStoreMdid(string gw)
{
if (string.IsNullOrWhiteSpace(gw))
return false;
return !CrossStoreGwExact.Contains(gw.Trim());
}
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
71
72
73
74
75
76
77
78
79
|
#region 获取用户列表
/// <summary>
/// 获取用户列表
/// </summary>
[HttpGet("")]
public async Task<dynamic> GetUserList([FromQuery] UserListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
|
27cb1b80
“wangming”
feat: add F_APPLY...
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
DateTime? monthStart = null;
DateTime? monthLast = null;
if (!string.IsNullOrWhiteSpace(input.onJobMonth))
{
var parts = input.onJobMonth.Split('-');
if (parts.Length == 2 && int.TryParse(parts[0], out var year) && int.TryParse(parts[1], out var month))
{
if (month >= 1 && month <= 12)
{
monthStart = new DateTime(year, month, 1);
monthLast = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59);
}
}
}
|
e1dcb3a0
“wangming”
1
|
96
97
98
99
100
101
102
103
104
|
if (input.crossStore == 1)
{
input.mdid = null;
}
if (input.crossStore != 1
&& string.IsNullOrWhiteSpace(input.mdid)
&& !string.IsNullOrWhiteSpace(input.gw)
&& ShouldAutoFilterByCurrentStoreMdid(input.gw))
|
27cb1b80
“wangming”
feat: add F_APPLY...
|
105
106
107
108
109
110
111
|
{
var currentUser = await _userManager.GetUserInfo();
if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.mdid))
{
input.mdid = currentUser.mdid;
}
}
|
e1dcb3a0
“wangming”
1
|
112
113
|
var gwFilter = string.IsNullOrWhiteSpace(input.gw) ? null : input.gw.Trim();
|
27cb1b80
“wangming”
feat: add F_APPLY...
|
114
|
|
e1dcb3a0
“wangming”
1
|
115
|
var data = await _db.Queryable<UserEntity, OrganizeEntity, PositionEntity, RoleEntity, LqMdxxEntity>((u, o, p, r, m) => new JoinQueryInfos(
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
116
117
|
JoinType.Left, o.Id == SqlFunc.ToString(u.OrganizeId),
JoinType.Left, p.Id == SqlFunc.ToString(u.PositionId),
|
e1dcb3a0
“wangming”
1
|
118
119
|
JoinType.Left, r.Id == SqlFunc.ToString(u.RoleId),
JoinType.Left, m.Id == u.Mdid))
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
120
121
122
123
124
125
|
.WhereIF(!string.IsNullOrEmpty(input.id), u => u.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.account), u => u.Account.Contains(input.account))
.WhereIF(!string.IsNullOrEmpty(input.realName), u => u.RealName.Contains(input.realName))
.WhereIF(!string.IsNullOrEmpty(input.mobilePhone), u => u.MobilePhone.Contains(input.mobilePhone))
.WhereIF(!string.IsNullOrEmpty(input.mdid), u => u.Mdid == input.mdid)
.WhereIF(!string.IsNullOrEmpty(input.zw), u => u.Zw.Contains(input.zw))
|
e1dcb3a0
“wangming”
1
|
126
|
.WhereIF(!string.IsNullOrEmpty(gwFilter), u => u.Gw == gwFilter)
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
127
128
129
130
131
132
|
.WhereIF(!string.IsNullOrEmpty(input.gwfl), u => u.Gwfl.Contains(input.gwfl))
.WhereIF(!string.IsNullOrEmpty(input.fyft), u => u.Fyft.Contains(input.fyft))
.WhereIF(!string.IsNullOrEmpty(input.organizeId), u => u.OrganizeId == input.organizeId)
.WhereIF(!string.IsNullOrEmpty(input.positionId), u => u.PositionId == input.positionId)
.WhereIF(!string.IsNullOrEmpty(input.roleId), u => u.RoleId == input.roleId)
.WhereIF(input.enabledMark.HasValue, u => u.EnabledMark == input.enabledMark)
|
e1dcb3a0
“wangming”
1
|
133
|
.WhereIF(input.onlyOnJob == 1, u => SqlFunc.IsNull(u.IsOnJob, 1) == 1)
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
134
|
.Where(u => u.DeleteMark == null) // 排除已删除的用户
|
27cb1b80
“wangming”
feat: add F_APPLY...
|
135
136
137
|
.WhereIF(monthStart.HasValue && monthLast.HasValue, u =>
u.EntryDate != null && u.EntryDate <= monthLast.Value &&
(u.LeaveDate == null || u.LeaveDate >= monthStart.Value))
|
e1dcb3a0
“wangming”
1
|
138
|
.Select((u, o, p, r, m) => new UserListOutput
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
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
|
{
id = u.Id,
account = u.Account,
realName = u.RealName,
nickName = u.NickName,
headIcon = u.HeadIcon,
gender = u.Gender,
birthday = u.Birthday,
mobilePhone = u.MobilePhone,
telePhone = u.TelePhone,
email = u.Email,
urgentContacts = u.UrgentContacts,
urgentTelePhone = u.UrgentTelePhone,
postalAddress = u.PostalAddress,
signature = u.Signature,
firstLogTime = u.FirstLogTime,
prevLogTime = u.PrevLogTime,
isAdministrator = u.IsAdministrator,
description = u.Description,
sortCode = u.SortCode,
managerId = u.ManagerId,
organizeId = u.OrganizeId,
organizeName = o.FullName,
positionId = u.PositionId,
positionName = p.FullName,
roleId = u.RoleId,
roleName = r.FullName,
portalId = u.PortalId,
extensionStr = u.ExtensionStr,
openId = u.OpenId,
mdid = u.Mdid,
|
e1dcb3a0
“wangming”
1
|
170
|
mdmc = m.Dm,
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
171
172
173
174
175
176
|
zw = u.Zw,
fyft = u.Fyft,
gwfl = u.Gwfl,
gw = u.Gw,
enabledMark = u.EnabledMark,
creatorTime = u.CreatorTime,
|
27cb1b80
“wangming”
feat: add F_APPLY...
|
177
178
179
|
creatorUserId = u.CreatorUserId,
entryDate = u.EntryDate,
leaveDate = u.LeaveDate
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
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
|
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<UserListOutput>.SqlSugarPageResult(data);
}
#endregion
#region 获取用户详细信息
/// <summary>
/// 获取用户详细信息
/// </summary>
[HttpGet("{id}")]
public async Task<dynamic> GetUserInfo(string id)
{
var entity = await _db.Queryable<UserEntity, OrganizeEntity, PositionEntity, RoleEntity>((u, o, p, r) => new JoinQueryInfos(
JoinType.Left, o.Id == SqlFunc.ToString(u.OrganizeId),
JoinType.Left, p.Id == SqlFunc.ToString(u.PositionId),
JoinType.Left, r.Id == SqlFunc.ToString(u.RoleId)))
.Where(u => u.Id == id && u.DeleteMark == null)
.Select((u, o, p, r) => new UserListOutput
{
id = u.Id,
account = u.Account,
realName = u.RealName,
nickName = u.NickName,
headIcon = u.HeadIcon,
gender = u.Gender,
birthday = u.Birthday,
mobilePhone = u.MobilePhone,
telePhone = u.TelePhone,
postalAddress = u.PostalAddress,
signature = u.Signature,
firstLogTime = u.FirstLogTime,
prevLogTime = u.PrevLogTime,
description = u.Description,
managerId = u.ManagerId,
organizeId = u.OrganizeId,
organizeName = o.FullName,
positionId = u.PositionId,
positionName = p.FullName,
roleId = u.RoleId,
roleName = r.FullName,
mdid = u.Mdid,
mdmc = "", // 门店名称需要关联门店表获取
zw = u.Zw,
fyft = u.Fyft,
gwfl = u.Gwfl,
gw = u.Gw,
enabledMark = u.EnabledMark
})
.MergeTable()
.FirstAsync();
return entity;
}
#endregion
#region 获取用户下拉选择数据
/// <summary>
/// 获取用户下拉选择数据
/// </summary>
|
e1dcb3a0
“wangming”
1
|
245
246
247
248
|
/// <param name="mdid">门店ID</param>
/// <param name="zw">职位</param>
/// <param name="gw">岗位</param>
/// <param name="onlyOnJob">是否仅在职:1=仅在职</param>
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
249
|
[HttpGet("Selector")]
|
e1dcb3a0
“wangming”
1
|
250
|
public async Task<dynamic> GetUserSelector([FromQuery] string mdid = null, [FromQuery] string zw = null, [FromQuery] string gw = null, [FromQuery] int? onlyOnJob = null)
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
251
252
253
|
{
var data = await _db.Queryable<UserEntity>()
.WhereIF(!string.IsNullOrEmpty(mdid), u => u.Mdid == mdid)
|
20099e65
“wangming”
1111
|
254
255
|
.WhereIF(!string.IsNullOrEmpty(zw), u => u.Zw != null && u.Zw.Contains(zw))
.WhereIF(!string.IsNullOrEmpty(gw), u => u.Gw == gw)
|
e1dcb3a0
“wangming”
1
|
256
|
.WhereIF(onlyOnJob == 1, u => SqlFunc.IsNull(u.IsOnJob, 1) == 1)
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
.Where(u => u.EnabledMark == 1 && u.DeleteMark == null)
.Select(u => new
{
id = u.Id,
account = u.Account,
realName = u.RealName,
mobilePhone = u.MobilePhone,
mdid = u.Mdid,
zw = u.Zw,
gw = u.Gw
})
.OrderBy(u => u.realName)
.ToListAsync();
return data;
}
#endregion
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
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
|
#region 获取总经理、经理下拉选择数据
/// <summary>
/// 获取用户下拉选择数据
/// </summary>
[HttpGet("ManagerSelector")]
public async Task<dynamic> GetManagerSelector()
{
var data = await _db.Queryable<UserEntity>()
.Where(u => u.Gw == "总经理" || u.Gw == "经理")
.Where(u => u.EnabledMark == 1 && u.DeleteMark == null)
.Select(u => new
{
id = u.Id,
account = u.Account,
realName = u.RealName,
mobilePhone = u.MobilePhone,
mdid = u.Mdid,
zw = u.Zw,
gw = u.Gw
})
.OrderBy(u => u.realName)
.ToListAsync();
return data;
}
#endregion
|
6a89980a
“wangming”
更新多个.DS_Store文件,删...
|
303
304
|
}
}
|