public async Task <ResponseMessage <BuildingNoticeResponse> > GetBuildingNotice(UserInfo user, [FromRoute] string noticeId) { ResponseMessage <BuildingNoticeResponse> response = new ResponseMessage <BuildingNoticeResponse>(); try { response.Extension = await _buildingNoticeManager.FindByIdAsync(noticeId, HttpContext.RequestAborted); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})通过跑马灯Id获取跑马灯内容(GetBuildingNotice)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n(noticeId){noticeId ?? ""}"); } return(response); }
public async Task <ResponseMessage> UploadIcon(UserInfo user, [FromBody] string iconPath, [FromRoute] string dest, [FromRoute] string buildingId) { ResponseMessage response = new ResponseMessage(); if (string.IsNullOrEmpty(iconPath) || string.IsNullOrEmpty(dest) || string.IsNullOrEmpty(buildingId)) { response.Code = ResponseCodeDefines.ArgumentNullError; response.Message = "参数不能为空"; Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})更新缩略图(UploadIcon)参数验证错误:参数不能为空,请求参数为:\r\n(iconPath){iconPath ?? ""},(dest){dest ?? ""},(buildingId){buildingId ?? ""}"); return(response); } try { if (dest == "building") { var building = await _buildingsManager.FindByIdAsync(user.Id, buildingId); if (building != null) { building.Icon = iconPath; await _buildingsManager.UpdateAsync(user.Id, buildingId, _mapper.Map <BuildingRequest>(building)); } } else if (dest == "shops") { var shops = await _shopsManager.FindByIdAsync(user.Id, buildingId); if (shops != null) { shops.Icon = iconPath; await _shopsManager.UpdateAsync(user.Id, buildingId, _mapper.Map <ShopsRequest>(shops)); } } else if (dest == "updaterecord") { var records = await _updateRecordManager.FindByIdAsync(buildingId); if (records != null) { records.Icon = iconPath; await _shopsManager.UpdateAsync(user.Id, buildingId, _mapper.Map <ShopsRequest>(records)); } } else if (dest == "buildingnotice") { var notice = await _buildingNoticeManager.FindByIdAsync(buildingId); if (notice != null) { notice.Icon = iconPath; await _buildingNoticeManager.UpdateAsync(buildingId, _mapper.Map <BuildingNoticeRequest>(notice)); } } } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})更新缩略图(UploadIcon)报错:\r\n{e.ToString()},请求参数为:\r\n(iconPath){iconPath ?? ""},(dest){dest ?? ""},(buildingId){buildingId ?? ""}"); } return(response); }