Blame view

netcore/src/Modularity/Extend/NCC.Extend/UserService.cs 10.8 KB
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;
6a89980a   “wangming”   更新多个.DS_Store文件,删...
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
  
  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;
          }
  
          #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...
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
              
              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);
                      }
                  }
              }
              
              if (string.IsNullOrWhiteSpace(input.mdid) && !string.IsNullOrWhiteSpace(input.gw))
              {
                  var currentUser = await _userManager.GetUserInfo();
                  if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.mdid))
                  {
                      input.mdid = currentUser.mdid;
                  }
              }
              
6a89980a   “wangming”   更新多个.DS_Store文件,删...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
              var data = 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)))
                  .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))
                  .WhereIF(!string.IsNullOrEmpty(input.gw), u => u.Gw.Contains(input.gw))
                  .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)
                  .Where(u => u.DeleteMark == null) // 排除已删除的用户
27cb1b80   “wangming”   feat: add F_APPLY...
103
104
105
                  .WhereIF(monthStart.HasValue && monthLast.HasValue, u => 
                      u.EntryDate != null && u.EntryDate <= monthLast.Value &&
                      (u.LeaveDate == null || u.LeaveDate >= monthStart.Value))
6a89980a   “wangming”   更新多个.DS_Store文件,删...
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
                  .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,
                      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,
                      mdmc = "", // 门店名称需要关联门店表获取
                      zw = u.Zw,
                      fyft = u.Fyft,
                      gwfl = u.Gwfl,
                      gw = u.Gw,
                      enabledMark = u.EnabledMark,
                      creatorTime = u.CreatorTime,
27cb1b80   “wangming”   feat: add F_APPLY...
145
146
147
                      creatorUserId = u.CreatorUserId,
                      entryDate = u.EntryDate,
                      leaveDate = u.LeaveDate
6a89980a   “wangming”   更新多个.DS_Store文件,删...
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
                  })
                  .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>
          [HttpGet("Selector")]
20099e65   “wangming”   1111
214
          public async Task<dynamic> GetUserSelector([FromQuery] string mdid = null, [FromQuery] string zw = null, [FromQuery] string gw = null)
6a89980a   “wangming”   更新多个.DS_Store文件,删...
215
216
217
          {
              var data = await _db.Queryable<UserEntity>()
                  .WhereIF(!string.IsNullOrEmpty(mdid), u => u.Mdid == mdid)
20099e65   “wangming”   1111
218
219
                  .WhereIF(!string.IsNullOrEmpty(zw), u => u.Zw != null && u.Zw.Contains(zw))
                  .WhereIF(!string.IsNullOrEmpty(gw), u => u.Gw == gw)
6a89980a   “wangming”   更新多个.DS_Store文件,删...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
                  .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”   更新门店目标设定相关功能,新增字段...
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
    
        #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文件,删...
266
267
      }
  }