public async Task <ApiResult <TestWebModel> > GetById(int id) { var r = new ApiResult <TestWebModel>(); try { var entity = await _testServices.GetById(id); if (entity != null) { r.msg = "查询成功"; r.data = _mapper.Map <TestWebModel>(entity); } else { r.status = 404; r.msg = "未匹配到数据"; } } catch (Exception ex) { r.status = 500; r.msg = ex.Message; } return(r); }
public async Task <MessageModel <TestViewModels> > Get(long id) { var data = new MessageModel <TestViewModels>(); var entity = await _testServices.GetById(id); if (entity != null) { data.success = true; data.msg = "查询成功"; } else { data.status = 204; data.msg = "未匹配到数据"; } data.response = _mapper.Map <TestViewModels>(entity); return(data); }