|
@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Resource;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.Resource;
|
|
|
using OASystem.Domain.ViewModels.Resource;
|
|
|
+using SqlSugar.Extensions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -17,7 +18,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
private readonly IMapper _mapper;
|
|
|
public LocalGuideDataRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
|
|
|
{
|
|
|
- _mapper=mapper;
|
|
|
+ _mapper = mapper;
|
|
|
}
|
|
|
public async Task<Result> LocalGuideOperation(LocalGuideOperationDto dto)
|
|
|
{
|
|
@@ -31,23 +32,25 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
var LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(selectSql).FirstAsync();//查询是否存在
|
|
|
if (LocalGuideData != null)
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
-
|
|
|
+ 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 = "添加失败!" };
|
|
|
|
|
|
}
|
|
|
- result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
}
|
|
|
}
|
|
|
- else if(dto.Status == 2)//修改
|
|
|
+ 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,
|
|
@@ -66,8 +69,9 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
FitScore = dto.FitScore,
|
|
|
StrainScore = dto.StrainScore,
|
|
|
LocalAndChineseScore = dto.LocalAndChineseScore,
|
|
|
- StaffType=dto.StaffType,
|
|
|
+ StaffType = dto.StaffType,
|
|
|
Remark = dto.Remark,
|
|
|
+ LastUpdate = dtLastUpdate
|
|
|
});
|
|
|
if (!res)
|
|
|
{
|
|
@@ -77,7 +81,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
+ return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -210,6 +214,64 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
+ else if (dto.PortType == 3)
|
|
|
+ {
|
|
|
+ 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();
|
|
|
+
|
|
|
+ if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
+ {
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ 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 RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ if (RowIndex < LocalGuideData.Count)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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" };
|