public async Task <ActionResult <DiaryDto> > DeleteEntity(int?id, int?UserId) { MessageInfo <DiaryDto> msge = new MessageInfo <DiaryDto>(); var isExist = await diaryService.ExistEntity(u => u.DiaryId == id && u.UsersId == UserId); if (!isExist) { msge.Code = 400; msge.Msg = "未找到该用户"; msge.Success = false; return(Ok(msge)); } Diary diary = await diaryService.GetEntitys(u => u.DiaryId == id).FirstOrDefaultAsync(); diaryService.DeleteEntity(diary); await diaryService.SaveChanges(); msge.Code = 204; return(Ok(msge)); }