|
@@ -12,6 +12,8 @@ using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using OASystem.Domain.Attributes;
|
|
|
using EyeSoft.Extensions;
|
|
|
+using OASystem.RedisRepository;
|
|
|
+using System.Linq.Expressions;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -23,6 +25,7 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
private readonly NewClientDataRepository _clientDataRepository;
|
|
|
private readonly SqlSugarClient _sqlSugar;
|
|
|
+ private string keyName = "newClient_SearchKey";
|
|
|
|
|
|
|
|
|
|
|
@@ -190,6 +193,10 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return Ok(JsonView(true, result.Msg + "Id:" + dto.Id));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -234,6 +241,10 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return Ok(JsonView(true, "删除成功!"));
|
|
|
}
|
|
|
|
|
@@ -1097,5 +1108,74 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
}
|
|
|
|
|
|
+ [HttpPost]
|
|
|
+ public async Task<IActionResult> SearchClientByKeyword(SearchClientByKeywordDto dto)
|
|
|
+ {
|
|
|
+ var jw = JsonView(true);
|
|
|
+ var expression = Expressionable.Create<Crm_NewClientData>()
|
|
|
+ .And(x=>x.IsDel == 0);
|
|
|
+ this.keyName += "_" + dto.UserId;
|
|
|
+
|
|
|
+ if (dto.UserId != 21)
|
|
|
+ {
|
|
|
+ var userList = _clientDataRepository.GetNewExistClient(dto.UserId).Select(x=>x.Id);
|
|
|
+ var newClientData = _sqlSugar.Queryable<Crm_ClientDataAndUser>()
|
|
|
+ .Where(x => x.IsDel == 0 && userList.Contains(x.usersId))
|
|
|
+ .Select(x=>x.NewClientDataId)
|
|
|
+ .Distinct()
|
|
|
+ .ToList();
|
|
|
+ expression = expression.And(x=> newClientData.Contains(x.Id));
|
|
|
+ }
|
|
|
+
|
|
|
+ var exists = false;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!exists)
|
|
|
+ {
|
|
|
+ string field = "Id,Client";
|
|
|
+ var newClitnData = _sqlSugar.Queryable<Crm_NewClientData>()
|
|
|
+ .Where(expression.ToExpression())
|
|
|
+ .Select(field)
|
|
|
+ .ToList();
|
|
|
+ foreach (var item in newClitnData)
|
|
|
+ {
|
|
|
+ EncryptionProcessor.DecryptProperties(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ var keywordArray = dto.Keyword.ToCharArray();
|
|
|
+ var matches = newClitnData
|
|
|
+ .Where(fullString => !string.IsNullOrWhiteSpace(fullString.Client) &&
|
|
|
+ keywordArray.All(keyword => fullString.Client.Contains(keyword)))
|
|
|
+ .Select(x=> new
|
|
|
+ {
|
|
|
+ x.Client,
|
|
|
+ x.Id
|
|
|
+ })
|
|
|
+ .DistinctBy(x=>x.Client)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ if (matches.Any())
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ jw.Data = matches;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jw.Code = 201;
|
|
|
+ jw.Msg = "empty list";
|
|
|
+ jw.Data = new List<string>(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jw.Data = await RedisFactory.CreateRedisRepository().HashGetAsync<List<string>>(keyName, dto.Keyword);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|