//[TypeFilter(typeof(CheckPermission), Arguments = new object[] { "FileCallBack" })] public async Task <ResponseMessage> FileCallback(string userId, [FromBody] List <FileInfoCallbackRequest> fileInfoCallbackRequestList) { Logger.Trace($"上传文件信息回调(FileCallback)请求日志,请求参数为:\r\n" + (fileInfoCallbackRequestList != null ? JsonHelper.ToJson(fileInfoCallbackRequestList) : "")); ResponseMessage response = new ResponseMessage(); if (!ModelState.IsValid) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Warn($"上传文件信息回调(FileCallback)模型验证失败:\r\n{response.Message ?? ""},请求参数为:\r\n" + (fileInfoCallbackRequestList != null ? JsonHelper.ToJson(fileInfoCallbackRequestList) : "")); return(response); } try { var fileinfo = fileInfoCallbackRequestList.Where(a => a.Type == "ICON").FirstOrDefault(); if (fileinfo != null) { var buildingfilescope = await _fileScopeManager.FindByBuildingFileGuidAsync(userId, fileinfo.FileGuid); if (buildingfilescope != null) { var building = await _buildingsManager.FindByIdAsync(userId, buildingfilescope.BuildingId); if (string.IsNullOrEmpty(building.Icon)) { building.Icon = fileinfo.FilePath; await _buildingsManager.UpdateAsync(userId, buildingfilescope.BuildingId, _mapper.Map <BuildingRequest>(building)); } } var shopfilescope = await _fileScopeManager.FindByShopsFileGuidAsync(userId, fileinfo.FileGuid); if (shopfilescope != null) { var shops = await _shopsManager.FindByIdAsync(userId, shopfilescope.ShopsId); if (string.IsNullOrEmpty(shops.Icon)) { shops.Icon = fileinfo.FilePath; await _shopsManager.UpdateAsync(userId, shopfilescope.ShopsId, _mapper.Map <ShopsRequest>(shops)); } } } await _fileInfoManager.CreateListAsync(userId, fileInfoCallbackRequestList, HttpContext.RequestAborted); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"上传文件信息回调(FileCallback)模型验证失败:\r\n{e.ToString()},请求参数为:\r\n" + (fileInfoCallbackRequestList != null ? JsonHelper.ToJson(fileInfoCallbackRequestList) : "")); } return(response); }
public async Task <ResponseMessage> PutBuildings(UserInfo user, [FromRoute] string buildingId, [FromBody] BuildingRequest buildingRequest) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})保存楼盘信息(PutBuildings):\r\n请求参数为:\r\n" + buildingRequest != null ? JsonHelper.ToJson(buildingRequest) : ""); ResponseMessage response = new ResponseMessage(); if (!ModelState.IsValid || buildingRequest.Id != buildingId) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})保存楼盘信息(PutBuildings)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + buildingRequest != null ? JsonHelper.ToJson(buildingRequest) : ""); return(response); } try { var dictionaryGroup = await _buildingsManager.FindByIdAsync(user.Id, buildingId, HttpContext.RequestAborted); if (dictionaryGroup == null) { await _buildingsManager.CreateAsync(user.Id, buildingRequest, HttpContext.RequestAborted); } else { await _buildingsManager.UpdateAsync(user.Id, buildingId, buildingRequest, HttpContext.RequestAborted); } } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})保存楼盘信息(PutBuildings)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + buildingRequest != null ? JsonHelper.ToJson(buildingRequest) : ""); } return(response); }