1
This commit is contained in:
@@ -31,6 +31,7 @@ namespace Vote.Services.ApiController
|
||||
[Route("/gb/yjb/api/outsidewall")]
|
||||
public class OutsideWallService : IDynamicApiController
|
||||
{
|
||||
private readonly SqlSugarRepository<Entities.Experts> _repoutsideExperts;
|
||||
private readonly SqlSugarRepository<Entities.outside_wall> repoutside_wall;
|
||||
private readonly SqlSugarRepository<Entities.outside_wall_building> repoutside_wall_building;
|
||||
private readonly SqlSugarRepository<Entities.outside_wall_building_photo> repoutside_wall_building_photo;
|
||||
@@ -46,8 +47,9 @@ namespace Vote.Services.ApiController
|
||||
/// <param name="_repoutside_wall_building_photo"></param>
|
||||
/// <param name="_repoutside_wall_photo"></param>
|
||||
/// <param name="memoryCache"></param>
|
||||
public OutsideWallService(SqlSugarRepository<Entities.outside_wall> _repoutside_wall, SqlSugarRepository<Entities.outside_wall_building> _repoutside_wall_building, SqlSugarRepository<Entities.outside_wall_building_photo> _repoutside_wall_building_photo, SqlSugarRepository<Entities.outside_wall_photo> _repoutside_wall_photo, IMemoryCache memoryCache, SqlSugarRepository<SysFile> _rep_SysFile, IOptions<UploadFileOptions> options)
|
||||
public OutsideWallService(SqlSugarRepository<Entities.Experts> repoutsideExperts, SqlSugarRepository<Entities.outside_wall> _repoutside_wall, SqlSugarRepository<Entities.outside_wall_building> _repoutside_wall_building, SqlSugarRepository<Entities.outside_wall_building_photo> _repoutside_wall_building_photo, SqlSugarRepository<Entities.outside_wall_photo> _repoutside_wall_photo, IMemoryCache memoryCache, SqlSugarRepository<SysFile> _rep_SysFile, IOptions<UploadFileOptions> options)
|
||||
{
|
||||
_repoutsideExperts = repoutsideExperts;
|
||||
repoutside_wall = _repoutside_wall;
|
||||
repoutside_wall_building = _repoutside_wall_building;
|
||||
repoutside_wall_building_photo = _repoutside_wall_building_photo;
|
||||
@@ -139,6 +141,7 @@ namespace Vote.Services.ApiController
|
||||
var entity = await repoutside_wall.AsQueryable()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.communityId), a => a.communityId == args.communityId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.submitCode), a => a.submitCode == args.submitCode)
|
||||
.OrderByDescending(a=>a.createtime).OrderBy(a=>a.communityName)
|
||||
.WithCache(60 * 60).ToListAsync();
|
||||
var ids = entity.Select(a => a.Id).ToArray();
|
||||
var photos = await repoutside_wall_photo.AsQueryable()
|
||||
@@ -186,57 +189,7 @@ namespace Vote.Services.ApiController
|
||||
//}
|
||||
return entity;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("communitys")]
|
||||
public async Task<List<SanjuCommunity>> GetCommunitys(string searchkey)
|
||||
{
|
||||
var cacheKey = "cache_GetCommunitys";
|
||||
List<SanjuCommunity> Communitys = null;
|
||||
Communitys = _memoryCache.Get<List<SanjuCommunity>>(cacheKey);
|
||||
if (Communitys == null || Communitys.Count == 0)
|
||||
{
|
||||
//var aaaaaaaaaaaaaa = repoutside_wall.AsQueryable().ToList();
|
||||
var SanjuKey = App.GetConfig<string>("OutsideWallSetting:SanjuKey");
|
||||
var timeStamp = GetTimeStamp();
|
||||
var sign = (SanjuKey + timeStamp).ToMD5Encrypt();
|
||||
var GetCommunitysUrl = App.GetConfig<string>("OutsideWallSetting:GetCommunitys");
|
||||
var GetHouseInfoCitysByCommunityUrl = App.GetConfig<string>("OutsideWallSetting:GetHouseInfoCitysByCommunity");
|
||||
Communitys = await string.Format(GetCommunitysUrl, "")
|
||||
.SetHeaders(new Dictionary<string, object> { { "sign", sign }, { "timeStamp", timeStamp } })
|
||||
.GetAsAsync<List<SanjuCommunity>>();
|
||||
_memoryCache.Set(cacheKey, Communitys, DateTime.Now.AddHours(1));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchkey))
|
||||
return Communitys.Where(a => a.Name.Contains(searchkey)).ToList();
|
||||
return Communitys;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("community/{id}")]
|
||||
public async Task<dynamic> GetCommunityInfo(string id)
|
||||
{
|
||||
var cacheKey = "cache_building_" + id;
|
||||
List<SanjuBuilding> building = _memoryCache.Get<List<SanjuBuilding>>(cacheKey);
|
||||
if (building == null)
|
||||
{
|
||||
var SanjuKey = App.GetConfig<string>("OutsideWallSetting:SanjuKey");
|
||||
var timeStamp = GetTimeStamp();
|
||||
var sign = (SanjuKey + timeStamp).ToMD5Encrypt();
|
||||
var GetHouseInfoCitysByCommunityUrl = App.GetConfig<string>("OutsideWallSetting:GetHouseInfoCitysByCommunity");
|
||||
building = await string.Format(GetHouseInfoCitysByCommunityUrl, id)
|
||||
.SetHeaders(new Dictionary<string, object> { { "sign", sign }, { "timeStamp", timeStamp } })
|
||||
.GetAsAsync<List<SanjuBuilding>>();
|
||||
_memoryCache.Set(cacheKey, building, DateTime.Now.AddHours(1));
|
||||
}
|
||||
return building;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取时间戳
|
||||
@@ -359,6 +312,71 @@ namespace Vote.Services.ApiController
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 调查页
|
||||
/// <summary>
|
||||
/// 授权验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("VerifyKey")]
|
||||
[AllowAnonymous]
|
||||
public async Task<bool> VerifyKey([FromQuery] string key)
|
||||
{
|
||||
return await _repoutsideExperts.IsExistsAsync(f => f.login_code.ToUpper() == key.ToUpper());
|
||||
//return await Task.FromResult(false);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("communitys")]
|
||||
public async Task<List<SanjuCommunity>> GetCommunitys(string searchkey)
|
||||
{
|
||||
var cacheKey = "cache_GetCommunitys";
|
||||
List<SanjuCommunity> Communitys = null;
|
||||
Communitys = _memoryCache.Get<List<SanjuCommunity>>(cacheKey);
|
||||
if (Communitys == null || Communitys.Count == 0)
|
||||
{
|
||||
//var aaaaaaaaaaaaaa = repoutside_wall.AsQueryable().ToList();
|
||||
var SanjuKey = App.GetConfig<string>("OutsideWallSetting:SanjuKey");
|
||||
var timeStamp = GetTimeStamp();
|
||||
var sign = (SanjuKey + timeStamp).ToMD5Encrypt();
|
||||
var GetCommunitysUrl = App.GetConfig<string>("OutsideWallSetting:GetCommunitys");
|
||||
var GetHouseInfoCitysByCommunityUrl = App.GetConfig<string>("OutsideWallSetting:GetHouseInfoCitysByCommunity");
|
||||
Communitys = await string.Format(GetCommunitysUrl, "")
|
||||
.SetHeaders(new Dictionary<string, object> { { "sign", sign }, { "timeStamp", timeStamp } })
|
||||
.GetAsAsync<List<SanjuCommunity>>();
|
||||
_memoryCache.Set(cacheKey, Communitys, DateTime.Now.AddHours(1));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(searchkey))
|
||||
return Communitys.Where(a => a.Name.Contains(searchkey)).ToList();
|
||||
return Communitys;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("community/{id}")]
|
||||
public async Task<dynamic> GetCommunityInfo(string id)
|
||||
{
|
||||
var cacheKey = "cache_building_" + id;
|
||||
List<SanjuBuilding> building = _memoryCache.Get<List<SanjuBuilding>>(cacheKey);
|
||||
if (building == null)
|
||||
{
|
||||
var SanjuKey = App.GetConfig<string>("OutsideWallSetting:SanjuKey");
|
||||
var timeStamp = GetTimeStamp();
|
||||
var sign = (SanjuKey + timeStamp).ToMD5Encrypt();
|
||||
var GetHouseInfoCitysByCommunityUrl = App.GetConfig<string>("OutsideWallSetting:GetHouseInfoCitysByCommunity");
|
||||
building = await string.Format(GetHouseInfoCitysByCommunityUrl, id)
|
||||
.SetHeaders(new Dictionary<string, object> { { "sign", sign }, { "timeStamp", timeStamp } })
|
||||
.GetAsAsync<List<SanjuBuilding>>();
|
||||
_memoryCache.Set(cacheKey, building, DateTime.Now.AddHours(1));
|
||||
}
|
||||
return building;
|
||||
}
|
||||
/// <summary>
|
||||
/// 提交
|
||||
/// </summary>
|
||||
@@ -366,14 +384,19 @@ namespace Vote.Services.ApiController
|
||||
[Consumes("application/json", "multipart/form-data")]
|
||||
[HttpPost("submit")]
|
||||
[AllowAnonymous]
|
||||
public async Task<dynamic> Submit([FromForm] OutsideWallInput args)
|
||||
public async Task<dynamic> Submit([FromForm] OutsideWallInput args, [FromQuery] string key)
|
||||
{
|
||||
var verifyKey = await _repoutsideExperts.IsExistsAsync(f => f.login_code.ToUpper() == key.ToUpper());
|
||||
if (!verifyKey)
|
||||
{
|
||||
throw Oops.Oh("授权码错误");
|
||||
}
|
||||
try
|
||||
{
|
||||
string code = GetCode(6, true);
|
||||
//string key = GetCode(6, true);
|
||||
repoutside_wall.Ado.BeginTran();
|
||||
var wall = args.Adapt<outside_wall>();
|
||||
wall.submitCode = code;
|
||||
wall.submitCode = key;
|
||||
wall.Id = Guid.NewGuid().ToString();
|
||||
wall.createtime = DateTime.Now;
|
||||
wall.isdeleted = 0;
|
||||
@@ -413,7 +436,7 @@ namespace Vote.Services.ApiController
|
||||
}
|
||||
}
|
||||
repoutside_wall.Ado.CommitTran();
|
||||
return code;
|
||||
return key;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -451,5 +474,6 @@ namespace Vote.Services.ApiController
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endregion 调查页
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user