|
@@ -1,5 +1,6 @@
|
|
|
using AutoMapper;
|
|
|
using OASystem.Domain;
|
|
|
+using OASystem.Domain.AesEncryption;
|
|
|
using OASystem.Domain.Dtos.Resource;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.Resource;
|
|
@@ -22,268 +23,210 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
}
|
|
|
public async Task<Result> LocalGuideOperation(LocalGuideOperationDto dto)
|
|
|
{
|
|
|
- Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
- try
|
|
|
- {
|
|
|
- if (dto.Status == 1)//添加
|
|
|
- {
|
|
|
- string selectSql = string.Format(@"select * from Res_LocalGuideData where UnitArea='{0}' and UnitName='{1}' and Contact='{2}' and ContactTel='{3}'"
|
|
|
- , dto.UnitArea, dto.UnitName, dto.Contact, dto.ContactTel);
|
|
|
- var LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(selectSql).FirstAsync();//查询是否存在
|
|
|
- if (LocalGuideData != null)
|
|
|
- {
|
|
|
- return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
-
|
|
|
- }
|
|
|
- else//不存在,可添加
|
|
|
- {
|
|
|
- Res_LocalGuideData _LocalGuideDat = _mapper.Map<Res_LocalGuideData>(dto);
|
|
|
- _LocalGuideDat.LastUpdate = DateTime.Now;
|
|
|
- int id = await AddAsyncReturnId(_LocalGuideDat);
|
|
|
- if (id == 0)
|
|
|
- {
|
|
|
- return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+ var localGuideDat = _mapper.Map<Res_LocalGuideData>(dto);
|
|
|
+ localGuideDat.LastUpdate = DateTime.Now;
|
|
|
+ EncryptionProcessor.EncryptProperties(localGuideDat);
|
|
|
|
|
|
- }
|
|
|
- result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
- }
|
|
|
- }
|
|
|
- else if (dto.Status == 2)//修改
|
|
|
- {
|
|
|
- DateTime dtLastUpdate = DateTime.Now;
|
|
|
- bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_LocalGuideData
|
|
|
- {
|
|
|
- UnitArea = dto.UnitArea,
|
|
|
- UnitName = dto.UnitName,
|
|
|
- Address = dto.Address,
|
|
|
- Contact = dto.Contact,
|
|
|
- ContactTel = dto.ContactTel,
|
|
|
- ContactEmail = dto.ContactEmail,
|
|
|
- ContactFax = dto.ContactFax,
|
|
|
- OtherInfo = dto.OtherInfo,
|
|
|
- Score = dto.Score,
|
|
|
- SuitScore = dto.SuitScore,
|
|
|
- ServeScore = dto.ServeScore,
|
|
|
- TalkProScore = dto.TalkProScore,
|
|
|
- TimeScore = dto.TimeScore,
|
|
|
- FitScore = dto.FitScore,
|
|
|
- StrainScore = dto.StrainScore,
|
|
|
- LocalAndChineseScore = dto.LocalAndChineseScore,
|
|
|
- StaffType = dto.StaffType,
|
|
|
- Remark = dto.Remark,
|
|
|
- LastUpdate = dtLastUpdate
|
|
|
- });
|
|
|
- if (!res)
|
|
|
- {
|
|
|
- return result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
- }
|
|
|
- result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
- }
|
|
|
- else
|
|
|
+ if (dto.Status == 1)//添加
|
|
|
+ {
|
|
|
+ string selectSql = string.Format(@"select * from Res_LocalGuideData where UnitArea='{0}' and UnitName='{1}' and Contact='{2}' and ContactTel='{3}'",
|
|
|
+ AesEncryptionHelper.Encrypt(dto.UnitArea),
|
|
|
+ AesEncryptionHelper.Encrypt(dto.UnitName),
|
|
|
+ AesEncryptionHelper.Encrypt(dto.Contact),
|
|
|
+ AesEncryptionHelper.Encrypt(dto.ContactTel));
|
|
|
+ var LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(selectSql).FirstAsync();//查询是否存在
|
|
|
+ if (LocalGuideData != null) return new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
+ else//不存在,可添加
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
+ int id = await AddAsyncReturnId(localGuideDat);
|
|
|
+ if (id == 0) return new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+ return new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else if (dto.Status == 2)//修改
|
|
|
{
|
|
|
- return result = new Result() { Code = -2, Msg = "程序错误!" };
|
|
|
+ var res = await _sqlSugar.Updateable(localGuideDat).IgnoreColumns(x => new { x.IsDel, x.CreateUserId, x.CreateTime, x.DeleteUserId, x.DeleteTime }).ExecuteCommandAsync();
|
|
|
+
|
|
|
+ if (res < 1)
|
|
|
+ {
|
|
|
+ return new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
+ }
|
|
|
+ return new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
}
|
|
|
- return result;
|
|
|
+
|
|
|
+ return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
}
|
|
|
|
|
|
public async Task<Result> QueryLocalGuide(QueryLocalGuide dto)
|
|
|
{
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
- try
|
|
|
+ string sqlWhere = string.Empty;
|
|
|
+ if (!string.IsNullOrWhiteSpace(dto.UnitName)) sqlWhere += string.Format(@" And UnitName like '%{0}%'", dto.UnitName);
|
|
|
+ if (!string.IsNullOrWhiteSpace(dto.UnitArea) && dto.UnitArea != "全部") sqlWhere += string.Format(@" And UnitArea like '%{0}%'", dto.UnitArea);
|
|
|
+ if (!string.IsNullOrWhiteSpace(dto.Contact)) sqlWhere += string.Format(@" And Contact like '%{0}%'", dto.Contact);
|
|
|
+ if (!string.IsNullOrWhiteSpace(dto.ContactTel)) sqlWhere += string.Format(@" And ContactTel like '%{0}%'", dto.ContactTel);
|
|
|
+ sqlWhere += string.Format(@" And IsDel={0}", 0);
|
|
|
+ if (!string.IsNullOrEmpty(sqlWhere.Trim()))
|
|
|
{
|
|
|
- string sqlWhere = string.Empty;
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.UnitName))
|
|
|
- {
|
|
|
- sqlWhere += string.Format(@" And UnitName like '%{0}%'", dto.UnitName);
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.UnitArea) && dto.UnitArea != "全部")
|
|
|
- {
|
|
|
- sqlWhere += string.Format(@" And UnitArea like '%{0}%'", dto.UnitArea);
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.Contact))
|
|
|
- {
|
|
|
- sqlWhere += string.Format(@" And Contact like '%{0}%'", dto.Contact);
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.ContactTel))
|
|
|
+ Regex r = new Regex("And");
|
|
|
+ sqlWhere = r.Replace(sqlWhere, "Where", 1);
|
|
|
+ }
|
|
|
+ if (dto.PortType == 1)
|
|
|
+ {
|
|
|
+ string sql = string.Format(@"select * from Res_LocalGuideData {0}", sqlWhere);
|
|
|
+ var localGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
+ if (localGuideData.Count == 0)
|
|
|
{
|
|
|
- sqlWhere += string.Format(@" And ContactTel like '%{0}%'", dto.ContactTel);
|
|
|
+ return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
}
|
|
|
- sqlWhere += string.Format(@" And IsDel={0}", 0);
|
|
|
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
|
|
|
+ localGuideData = localGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
+
|
|
|
+ if (dto.PageSize == 0 || dto.PageIndex == 0)
|
|
|
{
|
|
|
- Regex r = new Regex("And");
|
|
|
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
|
|
|
+ foreach (var item in localGuideData) EncryptionProcessor.DecryptProperties(item);
|
|
|
+
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = localGuideData,
|
|
|
+ };
|
|
|
}
|
|
|
- if (dto.PortType == 1)
|
|
|
+ else
|
|
|
{
|
|
|
- string sql = string.Format(@"select * from Res_LocalGuideData {0}", sqlWhere);
|
|
|
- List<Res_LocalGuideData> LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
- if (LocalGuideData.Count == 0)
|
|
|
- {
|
|
|
- return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
- }
|
|
|
- LocalGuideData = LocalGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
+ int count = localGuideData.Count;
|
|
|
+ float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
+ if (totalPage == 0) totalPage = 1;
|
|
|
+ else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
|
|
|
- if (dto.PageSize == 0 || dto.PageIndex == 0)
|
|
|
+ List<Res_LocalGuideData> ListData = new List<Res_LocalGuideData>();
|
|
|
+ for (int i = 0; i < dto.PageSize; i++)
|
|
|
{
|
|
|
- return result = new Result()
|
|
|
+ var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ if (RowIndex < localGuideData.Count)
|
|
|
{
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = LocalGuideData,
|
|
|
- };
|
|
|
+ EncryptionProcessor.DecryptProperties(localGuideData[RowIndex]);
|
|
|
+ ListData.Add(localGuideData[RowIndex]);
|
|
|
+ }
|
|
|
+ else break;
|
|
|
}
|
|
|
- else
|
|
|
+ return result = new Result()
|
|
|
{
|
|
|
- int count = LocalGuideData.Count;
|
|
|
- float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
- if (totalPage == 0) totalPage = 1;
|
|
|
- else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- List<Res_LocalGuideData> ListData = new List<Res_LocalGuideData>();
|
|
|
- for (int i = 0; i < dto.PageSize; i++)
|
|
|
- {
|
|
|
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
- if (RowIndex < LocalGuideData.Count)
|
|
|
- {
|
|
|
- ListData.Add(LocalGuideData[RowIndex]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- return result = new Result()
|
|
|
- {
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
- };
|
|
|
- }
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 2)
|
|
|
+ {
|
|
|
+ string sql = string.Format(@"select * from Res_LocalGuideData {0}", sqlWhere);
|
|
|
+ var localGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
+ //2024-05-11 修改,取消该判断,避免前端报错
|
|
|
+ //if (LocalGuideData.Count == 0)
|
|
|
+ //{
|
|
|
+ // return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
+ //}
|
|
|
+ localGuideData = localGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
|
|
|
+ if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
+ {
|
|
|
+ foreach (var item in localGuideData) EncryptionProcessor.DecryptProperties(item);
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = localGuideData,
|
|
|
+ };
|
|
|
}
|
|
|
- else if (dto.PortType == 2)
|
|
|
+ else
|
|
|
{
|
|
|
- string sql = string.Format(@"select * from Res_LocalGuideData {0}", sqlWhere);
|
|
|
- List<Res_LocalGuideData> LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
- //2024-05-11 修改,取消该判断,避免前端报错
|
|
|
- //if (LocalGuideData.Count == 0)
|
|
|
- //{
|
|
|
- // return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
- //}
|
|
|
- LocalGuideData = LocalGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
+ int count = localGuideData.Count;
|
|
|
+ float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
+ if (totalPage == 0) totalPage = 1;
|
|
|
+ else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
|
|
|
- if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
- {
|
|
|
- return result = new Result()
|
|
|
- {
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = LocalGuideData,
|
|
|
- };
|
|
|
- }
|
|
|
- else
|
|
|
+ List<Res_LocalGuideData> ListData = new List<Res_LocalGuideData>();
|
|
|
+ for (int i = 0; i < dto.PageSize; i++)
|
|
|
{
|
|
|
- int count = LocalGuideData.Count;
|
|
|
- float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
- if (totalPage == 0) totalPage = 1;
|
|
|
- else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
-
|
|
|
- List<Res_LocalGuideData> ListData = new List<Res_LocalGuideData>();
|
|
|
- for (int i = 0; i < dto.PageSize; i++)
|
|
|
+ var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ if (RowIndex < localGuideData.Count)
|
|
|
{
|
|
|
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
- if (RowIndex < LocalGuideData.Count)
|
|
|
- {
|
|
|
- ListData.Add(LocalGuideData[RowIndex]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
+ EncryptionProcessor.DecryptProperties(localGuideData[RowIndex]);
|
|
|
+ ListData.Add(localGuideData[RowIndex]);
|
|
|
}
|
|
|
- return result = new Result()
|
|
|
+ else
|
|
|
{
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
- };
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
+ };
|
|
|
}
|
|
|
- else if (dto.PortType == 3)
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 3)
|
|
|
+ {
|
|
|
+ string sql = string.Format(@"select Id,UnitArea,UnitName,Contact,ContactTel,Score,LastUpdate from Res_LocalGuideData {0}", sqlWhere);
|
|
|
+ var localGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
+ if (localGuideData.Count == 0)
|
|
|
{
|
|
|
- string sql = string.Format(@"select Id,UnitArea,UnitName,Contact,ContactTel,Score,LastUpdate from Res_LocalGuideData {0}", sqlWhere);
|
|
|
- List<Res_LocalGuideData> LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
|
|
|
- if (LocalGuideData.Count == 0)
|
|
|
- {
|
|
|
- return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
- }
|
|
|
- LocalGuideData = LocalGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
+ return result = new Result() { Code = 0, Msg = "暂无数据" };
|
|
|
+ }
|
|
|
+ localGuideData = localGuideData.OrderByDescending(x => x.CreateTime).ToList();
|
|
|
|
|
|
- if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
- {
|
|
|
- return result = new Result()
|
|
|
- {
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = LocalGuideData,
|
|
|
- };
|
|
|
- }
|
|
|
- else
|
|
|
+ if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
+ {
|
|
|
+ foreach (var item in localGuideData) EncryptionProcessor.DecryptProperties(item);
|
|
|
+ return result = new Result()
|
|
|
{
|
|
|
- int count = LocalGuideData.Count;
|
|
|
- float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
- if (totalPage == 0) totalPage = 1;
|
|
|
- else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = localGuideData,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int count = localGuideData.Count;
|
|
|
+ float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
+ if (totalPage == 0) totalPage = 1;
|
|
|
+ else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
|
|
|
- List<Res_LocalGuideData_ListItemView> ListData = new List<Res_LocalGuideData_ListItemView>();
|
|
|
- for (int i = 0; i < dto.PageSize; i++)
|
|
|
+ var ListData = new List<Res_LocalGuideData_ListItemView>();
|
|
|
+ for (int i = 0; i < dto.PageSize; i++)
|
|
|
+ {
|
|
|
+ var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ if (RowIndex < localGuideData.Count)
|
|
|
{
|
|
|
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
- if (RowIndex < LocalGuideData.Count)
|
|
|
+ var temp = new Res_LocalGuideData_ListItemView()
|
|
|
{
|
|
|
- Res_LocalGuideData_ListItemView temp = new Res_LocalGuideData_ListItemView()
|
|
|
- {
|
|
|
- Contact = LocalGuideData[RowIndex].Contact,
|
|
|
- ContactTel = LocalGuideData[RowIndex].ContactTel,
|
|
|
- Id = LocalGuideData[RowIndex].Id,
|
|
|
- Score = LocalGuideData[RowIndex].Score,
|
|
|
- UnitArea = LocalGuideData[RowIndex].UnitArea,
|
|
|
- UnitName = LocalGuideData[RowIndex].UnitName
|
|
|
- };
|
|
|
- temp.LastUpdateStr = LocalGuideData[RowIndex].CreateTime.ToString("yyyy-MM-dd");
|
|
|
-
|
|
|
- ListData.Add(temp);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
+ Contact = localGuideData[RowIndex].Contact,
|
|
|
+ ContactTel = localGuideData[RowIndex].ContactTel,
|
|
|
+ Id = localGuideData[RowIndex].Id,
|
|
|
+ Score = localGuideData[RowIndex].Score,
|
|
|
+ UnitArea = localGuideData[RowIndex].UnitArea,
|
|
|
+ UnitName = localGuideData[RowIndex].UnitName
|
|
|
+ };
|
|
|
+ temp.LastUpdateStr = localGuideData[RowIndex].CreateTime.ToString("yyyy-MM-dd");
|
|
|
+ EncryptionProcessor.DecryptProperties(temp);
|
|
|
+ ListData.Add(temp);
|
|
|
}
|
|
|
- return result = new Result()
|
|
|
- {
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
- };
|
|
|
+ else break;
|
|
|
}
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
|
|
|
+ };
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- return result;
|
|
|
- throw;
|
|
|
}
|
|
|
|
|
|
+ return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };
|
|
|
}
|
|
|
|
|
|
}
|