Skip to content

Commit

Permalink
Merge pull request #40 from LuongXuanNhat/16.ChatAI
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
vuanh25 authored Aug 21, 2024
2 parents b25a854 + 6b13ca7 commit 2c4513d
Show file tree
Hide file tree
Showing 85 changed files with 1,742 additions and 9,255 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# VietNamHistory
<h5>The project is in the development stage</h5>
## You can get all my materials for this project here : https://drive.google.com/drive/folders/1EUq5xxeMOWacea59xSQnLhdyWzs5yzZZ?usp=sharing
<br/>
## Description project at youtube: https://www.youtube.com/watch?v=NqTf46UVhHc
39 changes: 39 additions & 0 deletions VNH.Application/Common/Contants/ConstantNofication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNH.Application.Common.Contants
{
public static class ConstantNofication
{
// Post
public static string CommentPost(string name)
{
return "[ "+name+" ]" + " đã bình luận một bài viết của bạn";
}
public static string LikePost(string name)
{
return "[ " + name + " ]" + " đã thích một bài viết của bạn";
}

// Forum
public static string CommentAnswer(string name)
{
return "[ " + name + " ]" + " đã bình luận trong câu hỏi của bạn";
}
public static string AnswerTheQuestion(string name)
{
return "[ " + name + " ]" + " đã 'trả lời' một câu hỏi của bạn";
}
public static string LikeQuestion(string name)
{
return "[ " + name + " ]" + " đã tán thành một câu hỏi của bạn";
}
public static string LikeAnswer(string name)
{
return "[ " + name + " ]" + " đã 'tán thành' một câu trả lời của bạn";
}
}
}
9 changes: 9 additions & 0 deletions VNH.Application/Common/Contants/ConstantUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace VNH.Application.Common.Contants
{
public static class ConstantUrl
{
public const string UrlPostDetail = "/discover/";
public const string UrlQuestionDetail = "/forum/";
}
}
9 changes: 6 additions & 3 deletions VNH.Application/Common/Contants/SystemConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ public static class SystemConstants
public const string Token = "Token";
public const string BaseAddress = "BaseAddress";

public const string UrlWeb = "https://tyls.fun/";
public const string ConnectString = "Data Source=202.92.7.204\\MSSQLSERVER2022, 1438;Initial Catalog=tyls;User Id=toiyeulichsu;Password=MheZDu9$oGbrYlL#S%ApJ^qf;TrustServerCertificate=true; ";

//public const string UrlWeb = "https://vuanhpham25-001-site1.gtempurl.com/";
//public const string ConnectString = "Data Source=SQL5106.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai";
//public const string ConnectString = "Data Source=SQL5112.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai";

public const string UrlWeb = "https://localhost:7138/";
public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;";
//public const string UrlWeb = "https://localhost:7138/";
//public const string ConnectString = "Data Source=.;Initial Catalog=tyls;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CreateExamHistoryDto
public Guid MultipleChoiceId { get; set; }
public Guid UserId { get; set; }

public int Scores { get; set; }
public float Scores { get; set; }

public int CompletionTime { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public class ExamHistoryResponseDto

public UserShortDto? UserShortDto { get; set; } = new UserShortDto();

public int Scores { get; set; }
public int numberQuiz { get; set; } = 0;

public float Scores { get; set; }

public int CompletionTime { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace VNH.Application.DTOs.Catalog.MultipleChoiceDto
public class CreateQuizDto
{
public string? Id { get; set; } = Guid.NewGuid().ToString();

public string Title { get; set; } = string.Empty;

public string Description { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class MultipleChoiceResponseDto
public DateTime? UpdatedAt { get; set; }
public int WorkTime { get; set; }

public int NumberQuiz { get; set; } = 0;


public UserShortDto? UserShort { get; set; } = new UserShortDto();

public List<QuizDto> Quizs { get; set; } = new List<QuizDto>();
Expand Down
20 changes: 20 additions & 0 deletions VNH.Application/DTOs/Catalog/Notifications/NotificationDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNH.Application.DTOs.Catalog.Notifications
{
public class NotificationDto
{
public Guid? Id { get; set; }
public Guid UserId { get; set; }
public Guid? NotificationId { get; set; } = Guid.Empty;
public Guid? IdObject { get; set; }
public string? Content { get; set; }
public DateTime? Date { get; set; }
public string? Url { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using VNH.Application.DTOs.Catalog.Document;
using VNH.Application.DTOs.Catalog.Posts;
using VNH.Application.DTOs.Common;
using VNH.Application.DTOs.Common.ResponseNotification;

namespace VNH.Application.Interfaces.Documents
Expand All @@ -12,11 +13,12 @@ public interface IDocumentService
Task<ApiResult<List<DocumentReponseDto>>> GetAll();
Task<ApiResult<string>> Delete(string id, string email);

Task<ApiResult<bool>> GetSave(DocumentFpkDto docsFpk);
Task<ApiResult<NumberReponse>> GetSave(DocumentFpkDto docsFpk);

Task<ApiResult<int>> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk);
Task<ApiResult<NumberReponse>> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk);
Task<ApiResult<List<DocumentReponseDto>>> Search(string keyWord);
Task<ApiResult<List<DocumentReponseDto>>> GetMyDocument(string userId);
Task<ApiResult<List<DocumentReponseDto>>> GetMySave(string userId);
Task SaveDownloads(Guid documentId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public interface IExamHistoryService
{

Task<ApiResult<ExamHistoryResponseDto>> Create(CreateExamHistoryDto requestDto, string name);
Task<ApiResult<string>> Update(CreateExamHistoryDto requestDto, string name);
Task<ApiResult<ExamHistoryResponseDto>> Update(CreateExamHistoryDto requestDto, string name);

Task<ApiResult<List<ExamHistoryResponseDto>>> GetMyExamHistory(string id);


Task<ApiResult<List<ExamHistoryResponseDto>>> GetExamHistory(string examId);
}
}
2 changes: 1 addition & 1 deletion VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IAnswerService
{

Task<ApiResult<List<AnswerQuestionDto>>> GetAnswer(string questionId);
Task<ApiResult<List<AnswerQuestionDto>>> CreateAnswer(AnswerQuestionDto answer);
Task<ApiResult<List<AnswerQuestionDto>>> CreateAnswer(AnswerQuestionDto answer, string? id);
Task<ApiResult<List<AnswerQuestionDto>>> UpdateAnswer(AnswerQuestionDto answer);
Task<ApiResult<string>> DeteleAnswer(string id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface IMultipleChoiceService
Task<ApiResult<string>> Delete(string id, string userId);

Task<ApiResult<string>> DeleteQuizById(string id);
Task<ApiResult<List<MultipleChoiceResponseDto>>> GetMyMultipleChoice(string id);

Task<ApiResult<List<MultipleChoiceResponseDto>>> Search(string keyWord);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VNH.Application.DTOs.Catalog.Notifications;
using VNH.Application.DTOs.Common.ResponseNotification;
using VNH.Domain.Entities;

namespace VNH.Application.Implement.Catalog.NotificationServices
{
public interface INotificationService
{
Task<ApiResult<List<NotificationDto>>> GetAll(string userId);
Task<ApiResult<NotificationDto>> Add(string title);
Task AddNotificationDetail(NotificationDto notification);
Task<ApiResult<NotificationDto>> Update(NotificationDto notification);
}
}
2 changes: 1 addition & 1 deletion VNH.Application/Interfaces/Catalog/Posts/IPostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface IPostService
Task<ApiResult<NumberReponse>> GetSave(PostFpkDto postFpk);
Task<ApiResult<List<PostResponseDto>>> GetPostByTag(string tag);
Task<ApiResult<List<CommentPostDto>>> GetComment(string postId);
Task<ApiResult<List<CommentPostDto>>> CreateComment(CommentPostDto comment);
Task<ApiResult<List<CommentPostDto>>> CreateComment(CommentPostDto comment, string userId);
Task<ApiResult<List<CommentPostDto>>> UpdateComment(CommentPostDto comment);
Task<ApiResult<List<CommentPostDto>>> DeteleComment(string id);
Task<ApiResult<List<PostResponseDto>>> GetMyPostSaved(string id);
Expand Down
1 change: 1 addition & 0 deletions VNH.Application/Interfaces/Common/IImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace VNH.Application.Interfaces.Common
public interface IImageService
{
Task<string> SaveFile(IFormFile file);
Task<string> SaveImageArticle(IFormFile file);
Task<byte[]> ConvertFormFileToByteArray(IFormFile formFile);
string ConvertByteArrayToString(byte[]? byteArray, Encoding encoding);
byte[] CompressImage(byte[] originalImage, int KbNumber);
Expand Down
1 change: 1 addition & 0 deletions VNH.Application/Interfaces/Common/IStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public interface IStorageService
{
string GetFileUrl(string fileName);
Task SaveFileAsync(Stream mediaBinaryStream, string fileName);
Task SaveImageFileAsync(Stream mediaBinaryStream, string fileName);
Task DeleteFileAsync(string fileName);
Task SaveDocFileAsync(Stream mediaBinaryStream, string fileName);
Task DeleteDocFileAsync(string fileName);
Expand Down
20 changes: 20 additions & 0 deletions VNH.Application/Mappers/NotifiMapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VNH.Application.DTOs.Catalog.MultipleChoiceDto;
using VNH.Domain.Entities;
using VNH.Domain;
using VNH.Application.DTOs.Catalog.Notifications;

namespace VNH.Application.Mappers
{
public class NotifiMapper : Profile
{
public NotifiMapper() {
CreateMap<NotificationDetail, NotificationDto>().ReverseMap();
}
}
}
1 change: 0 additions & 1 deletion VNH.Application/VNH.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<ItemGroup>
<Folder Include="Common\Exceptions\" />
<Folder Include="Common\Contants\" />
<Folder Include="System\" />
</ItemGroup>

Expand Down
5 changes: 2 additions & 3 deletions VNH.Domain/Entities/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ public Document()

[Key]
public Guid Id { get; set; }
[Required]
[StringLength(255)]
public string Title { get; set; }
[StringLength(500)]
public string Description { get; set; }
public string SubId { get; set; }
public bool IsDeleted { get; set; } = false;
Expand All @@ -32,6 +29,8 @@ public Document()
public DateTime CreatedAt { get; set; }
[Column(TypeName = "datetime")]
public DateTime? UpdatedAt { get; set; }
public long ViewNumber { get; set; }
public int DownloadNumber { get; set; }

[ForeignKey("UserId")]
[InverseProperty("Documents")]
Expand Down
14 changes: 2 additions & 12 deletions VNH.Domain/Entities/ExamHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@ public partial class ExamHistory

public Guid UserId { get; set; }

public int Scores { get; set; }

public float Scores { get; set; }

public int CompletionTime { get; set; }

[Column(TypeName = "datetime")]
public DateTime StarDate { get; set; }



[ForeignKey("MultipleChoiceId")]
[InverseProperty("ExamHistory")]
public virtual MultipleChoice MultipleChoice { get; set; }







}
}
20 changes: 20 additions & 0 deletions VNH.Domain/Entities/ExamHistoryMultipleChoice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNH.Domain.Entities
{
public class ExamHistoryMultipleChoice
{
[Key]
public Guid Id { get; set; }
public Guid ExamHistoryId { get; set; }
public ExamHistory ExamHistory { get; set; }

public Guid MultipleChoiceId { get; set; }
public MultipleChoice MultipleChoice { get; set; }
}
}
15 changes: 1 addition & 14 deletions VNH.Domain/Entities/MultipleChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,29 @@ namespace VNH.Domain.Entities
[Table("MultipleChoise")]
public partial class MultipleChoice
{

[Key]
public Guid Id { get; set; }

public string Title { get; set; }
[StringLength(500)]
public string Description { get; set; }
[StringLength(500)]

[Column(TypeName = "datetime")]
public DateTime CreatedAt { get; set; } = DateTime.Now;


[Column(TypeName = "datetime")]
public DateTime? UpdatedAt { get; set; }

public int WorkTime { get; set; }


public Guid UserId { get; set; }




[InverseProperty("MultipleChoice")]
public virtual ICollection<Quiz> Quiz { get; set; }


[ForeignKey("UserId")]
public virtual User User { get; set; }

[InverseProperty("MultipleChoice")]
public virtual ExamHistory ExamHistories { get; set; }




public virtual ICollection<ExamHistory> ExamHistory { get; set; }
}
}
2 changes: 2 additions & 0 deletions VNH.Domain/Entities/NotificationDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ public class NotificationDetail
public Guid Id { get; set; }
public Guid NotificationId { get; set; }
public Guid UserId { get; set; }
public Guid? IdObject { get; set; }
public string? Content { get; set; }
public DateTime Date { get; set; }
public string? Url { get; set; }
public Confirm IsRead { get; set; }


Expand Down
2 changes: 1 addition & 1 deletion VNH.Domain/Entities/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Post()
[Key]
[StringLength(255)]
public string Id { get; set; }
[StringLength(300)]
[StringLength(500)]
public string SubId { get; set; } = string.Empty;
[StringLength(255)]
public string Title { get; set; }
Expand Down
1 change: 0 additions & 1 deletion VNH.Domain/Entities/Question.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public Question()

[Key]
public Guid Id { get; set; }
[StringLength(500)]
public string Title { get; set; }
public string SubId { get; set; }
public string Content { get; set; }
Expand Down
Loading

0 comments on commit 2c4513d

Please sign in to comment.