public async Task <ActionResult <DiaryDto> > AddEntity(DiaryAddDto diaryAddDto) { MessageInfo <DiaryDto> msge = new MessageInfo <DiaryDto>(); if (string.IsNullOrWhiteSpace(diaryAddDto.DiaryTitle) || string.IsNullOrWhiteSpace(diaryAddDto.DiaryTitleContent)) { msge.Code = 400; msge.Msg = "请填写完善对应信息"; msge.Success = false; return(Ok(msge)); } Diary diary = mapper.Map <Diary>(diaryAddDto); await diaryService.AddEntity(diary); await diaryService.SaveChanges(); DiaryDto toDiaryDto = mapper.Map <DiaryDto>(diary); msge.Code = 201; return(Ok(toDiaryDto)); }