Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.history news #38

Merged
merged 10 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions VNH.Application/Common/Contants/SystemConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ public static class SystemConstants
{
public const string Token = "Token";
public const string BaseAddress = "BaseAddress";
// public const string UrlWeb = "https://vuanhpham25-001-site1.gtempurl.com/";
public const string UrlWeb = "https://localhost:7138/";
// public const string ConnectString = "Data Source=SQL5111.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;UserShort Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai";
public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory_2;Integrated Security=True;Encrypt=true;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 UrlWeb = "https://localhost:7138/";
//public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;";
}
}
7 changes: 1 addition & 6 deletions VNH.Application/DTOs/Catalog/Document/DocumentReponseDto.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VNH.Application.DTOs.Catalog.Users;
using VNH.Application.DTOs.Catalog.Users;

namespace VNH.Application.DTOs.Catalog.Document
{
Expand Down
3 changes: 3 additions & 0 deletions VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ namespace VNH.Application.DTOs.Catalog.Forum.Answer
{
public class AnswerFpkDto
{
public string QuestionId { get; set; } = string.Empty;
public string AnswerId { get; set; } = string.Empty;
public string UserId { get; set; } = string.Empty;
public string QuestionUserId { get; set; } = string.Empty;

}
}
23 changes: 9 additions & 14 deletions VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using VNH.Application.DTOs.Catalog.Users;

namespace VNH.Application.DTOs.Catalog.Forum.Answer
{
public class AnswerQuestionDto
{

public Guid Id { get; set; } = Guid.NewGuid();
public Guid? Id { get; set; } = Guid.NewGuid();
public Guid? AuthorId { get; set; }

public string QuestionId { get; set; } = string.Empty;
public UserShortDto? UserShort { get; set; }
public string Content { get; set; } = String.Empty;
public DateTime PubDate { get; set; }
public DateTime? UpdateAt { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool Confirm { get; set; } = false;
public bool MostConfirm { get; set; } = false;
public List<SubAnswerQuestionDto>? SubAnswer { get; set; }
public int VoteNumber { get; set; } = 0;
public List<SubAnswerQuestionDto>? SubAnswer { get; set; } = new();

}

public class SubAnswerQuestionDto
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid? Id { get; set; } = Guid.NewGuid();
public Guid PreAnswerId { get; set; }
public Guid AuthorId { get; set; }
public string Content { get; set; } = string.Empty;
[Column(TypeName = "datetime")]
public DateTime? PubDate { get; set; }
public DateTime? CreatedAt { get; set; }
[Column(TypeName = "datetime")]
public DateTime? UpdateAt { get; set; }
public DateTime? UpdatedAt { get; set; }

public UserShortDto? UserShort { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class AnswerResponseDto
public string QuestionId { get; set; } = string.Empty;

[Column(TypeName = "datetime")]
public DateTime? PubDate { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public UserShortDto UserShort { get; set; } = new UserShortDto();
public bool Confirm { get; set; }
public bool MostConfirm { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace VNH.Application.DTOs.Catalog.Forum.Question
public class CreateQuestionDto
{
public Guid? Id { get; set; } = Guid.NewGuid();

public string? SubId { get; set; } = string.Empty;
public string? Title { get; set; } = string.Empty;
public string? Content { get; set; } = string.Empty;
public List<string>? Tag { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNH.Application.DTOs.Catalog.Forum.Question
namespace VNH.Application.DTOs.Catalog.Forum.Question
{
public class QuestionFpkDto
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ namespace VNH.Application.DTOs.Catalog.Forum.Question
{
public class QuestionResponseDto
{
public string Id { get; set; } =string.Empty;
public string Id { get; set; } = string.Empty;
public string? SubId { get; set; }
public string Title { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public DateTime? CreateAt { get; set; }
public DateTime? UpdateAt { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public List<TagDto> Tags { get; set; } = new List<TagDto>();
public UserShortDto UserShort { get; set; } = new UserShortDto();

public int ViewNumber { get; set; } = 0;
public int CommentNumber { get; set; } = 0;
public int SaveNumber { get; set; } = 0;
public int LikeNumber { get; set; } = 0;

}
}
12 changes: 12 additions & 0 deletions VNH.Application/DTOs/Catalog/Forum/Question/ReportQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace VNH.Application.DTOs.Catalog.Forum.Question
{
public class ReportQuestionDto
{
public string QuestionId { get; set; } = string.Empty;
public Guid UserId { get; set; }
public Guid ReportId { get; set; }
public string? Description { get; set; } = string.Empty;
public DateTime ReportDate { get; set; } = DateTime.Now;
public bool Checked { get; set; } = false;
}
}
2 changes: 1 addition & 1 deletion VNH.Application/DTOs/Catalog/Posts/CommentPostDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CommentPostDto
public string PostId { get; set; } = String.Empty;
public UserShortDto? UserShort { get; set; }
public string Content { get; set; } = String.Empty;
public DateTime CreatedAt { get; set; }
public DateTime? CreatedAt { get; set; } = DateTime.Now;
public DateTime? UpdatedAt { get; set; }
public List<SubCommentDto>? SubComment { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion VNH.Application/DTOs/Catalog/Posts/CreatePostDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CreatePostDto
public string? Id { get; set; } = Guid.NewGuid().ToString();
public string Title { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public IFormFile Image { get; set; }
public IFormFile? Image { get; set; }
public Guid TopicId { get; set; }
public List<string>? Tag { get; set; } = new List<string>();
}
Expand Down
8 changes: 2 additions & 6 deletions VNH.Application/DTOs/Catalog/Posts/PostResponseDto.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.ComponentModel.DataAnnotations.Schema;
using VNH.Application.DTOs.Catalog.HashTags;
using VNH.Application.DTOs.Catalog.HashTags;
using VNH.Application.DTOs.Catalog.Users;
using VNH.Domain;

namespace VNH.Application.DTOs.Catalog.Posts
{
Expand All @@ -16,7 +12,7 @@ public class PostResponseDto
public string Image { get; set; } = string.Empty;
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public string TopicName { get; set; } = string.Empty;
public string? TopicName { get; set; } = string.Empty;
public List<TagDto> Tags { get; set; } = new List<TagDto>();
public UserShortDto UserShort { get; set; } = new UserShortDto();
public int ViewNumber { get; set; } = 0;
Expand Down
14 changes: 14 additions & 0 deletions VNH.Application/DTOs/Common/NumberReponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VNH.Application.DTOs.Common
{
public class NumberReponse
{
public bool Check { get; set; }
public int Quantity { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public interface IDocumentService
Task<ApiResult<bool>> GetSave(DocumentFpkDto docsFpk);

Task<ApiResult<int>> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk);

Task<ApiResult<List<DocumentReponseDto>>> Search(string keyWord);
}
}
9 changes: 5 additions & 4 deletions VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using VNH.Application.DTOs.Catalog.Forum.Answer;
using VNH.Application.DTOs.Common;
using VNH.Application.DTOs.Common.ResponseNotification;
using VNH.Domain;

Expand All @@ -15,11 +16,11 @@ public interface IAnswerService

Task<ApiResult<string>> CreateSubAnswer(SubAnswerQuestionDto subAnswer);

Task<ApiResult<SubAnswerQuestionDto>> UpdateSubAnswer(SubAnswerQuestionDto answer);
Task<ApiResult<string>> UpdateSubAnswer(SubAnswerQuestionDto answer);
Task<ApiResult<string>> DeteleSubAnswer(string id);

Task<ApiResult<int>> ConfirmOrNoConfirm(AnswerFpkDto answerFpk);


Task<ApiResult<NumberReponse>> ConfirmedByQuestioner(string answerId);
Task<ApiResult<NumberReponse>> VoteConfirmByUser(AnswerFpkDto answer);
Task<ApiResult<NumberReponse>> GetMyVote(string answerId, string userId);
}
}
16 changes: 12 additions & 4 deletions VNH.Application/Interfaces/Catalog/Forum/IQuestionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
using VNH.Application.DTOs.Catalog.Forum.Question;
using VNH.Application.DTOs.Catalog.HashTags;
using VNH.Application.DTOs.Catalog.Posts;
using VNH.Application.DTOs.Common;
using VNH.Application.DTOs.Common.ResponseNotification;

namespace VNH.Application.Interfaces.Catalog.Forum
{
public interface IQuestionService
{

Task<ApiResult<QuestionResponseDto>> Create(CreateQuestionDto requestDto, string name);
Task<ApiResult<QuestionResponseDto>> Update(CreateQuestionDto requestDto, string name);

Task<ApiResult<QuestionResponseDto>> Detail(string Id);
Task<ApiResult<List<QuestionResponseDto>>> GetAll();
Task<ApiResult<string>> Delete(string id, string email);
Task<ApiResult<int>> AddOrRemoveSaveQuestion(QuestionFpkDto questionFpk);
Task<ApiResult<NumberReponse>> AddOrRemoveSaveQuestion(QuestionFpkDto questionFpk);

Task<ApiResult<bool>> GetSave(QuestionFpkDto questionFpk);
Task<ApiResult<NumberReponse>> GetSave(QuestionFpkDto questionFpk);

Task<ApiResult<List<string>>> GetAllTag(int numberTag);
Task<ApiResult<List<QuestionResponseDto>>> GetQuestionByTag(string tag);


Task<ApiResult<QuestionResponseDto>> SubDetail(string subId);
Task<ApiResult<NumberReponse>> GetLike(QuestionFpkDto questionFpk);
Task<ApiResult<NumberReponse>> AddOrUnLikeQuestion(QuestionFpkDto questionFpk);
Task<ApiResult<List<QuestionResponseDto>>> GetMyQuestion(string id);
Task<ApiResult<string>> ReportQuestion(ReportQuestionDto reportquestionDto);
Task<ApiResult<List<ReportQuestionDto>>> GetReport();
Task<ApiResult<List<QuestionResponseDto>>> SearchQuestions(string keyWord);
Task<ApiResult<List<QuestionResponseDto>>> GetMyQuestionSaved(string id);
}
}
11 changes: 11 additions & 0 deletions VNH.Application/Interfaces/Catalog/NewsHistory/INewsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using VNH.Application.DTOs.Common.ResponseNotification;
using VNH.Domain;

namespace VNH.Application.Interfaces.Catalog.NewsHistory
{
public interface INewsService
{
Task<ApiResult<int>> CrawlNews(string url);
Task<ApiResult<List<News>>> GetNews();
}
}
17 changes: 11 additions & 6 deletions VNH.Application/Interfaces/Catalog/Posts/IPostService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using VNH.Application.DTOs.Catalog.HashTags;
using VNH.Application.DTOs.Catalog.Posts;
using VNH.Application.DTOs.Common;
using VNH.Application.DTOs.Common.ResponseNotification;

namespace VNH.Application.Interfaces.Posts
Expand All @@ -14,18 +15,22 @@ public interface IPostService
Task<ApiResult<string>> DeleteAdmin(string id);


Task<ApiResult<int>> AddOrUnLikePost(PostFpkDto postFpk);
Task<ApiResult<int>> AddOrRemoveSavePost(PostFpkDto postFpk);
Task<ApiResult<NumberReponse>> AddOrUnLikePost(PostFpkDto postFpk);
Task<ApiResult<NumberReponse>> AddOrRemoveSavePost(PostFpkDto postFpk);
Task<ApiResult<string>> ReportPost(ReportPostDto reportPostDto);
Task<List<ReportPostDto>> GetReport();
Task<ApiResult<bool>> GetLike(PostFpkDto postFpk);
Task<ApiResult<bool>> GetSave(PostFpkDto postFpk);
Task<ApiResult<List<ReportPostDto>>> GetReport();
Task<ApiResult<NumberReponse>> GetLike(PostFpkDto postFpk);
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>>> UpdateComment(CommentPostDto comment);
Task<ApiResult<string>> DeteleComment(string id);
Task<ApiResult<List<CommentPostDto>>> DeteleComment(string id);
Task<ApiResult<List<PostResponseDto>>> GetMyPostSaved(string id);
Task<ApiResult<List<PostResponseDto>>> GetMyPost(string id);
Task<ApiResult<List<PostResponseDto>>> SearchPosts(string keyWord);
Task<ApiResult<List<PostResponseDto>>> GetAllMobile();
Task<ApiResult<List<PostResponseDto>>> GetRandomPost(int quantity);
Task<ApiResult<List<PostResponseDto>>> FindByTopic(string topicName);
}
}
1 change: 1 addition & 0 deletions VNH.Application/Interfaces/Catalog/Topics/ITopicService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public interface ITopicService
Task<ApiResult<bool>> DeleteTopic(Guid topicId);
Task<ApiResult<List<TopicReponseDto>>> CreateTopic(string topic, string userEmail);
Task<ApiResult<bool>> UpdateTopic(Guid topicId, string topic);
Task<ApiResult<TopicReponseDto>> GetById(string idTopic);
}
}
3 changes: 1 addition & 2 deletions VNH.Application/Mappers/PostMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public PostMapper()
CreateMap<CreatePostDto, Post>()
.ForMember(dest => dest.Image, opt => opt.Ignore());

CreateMap<Post, PostResponseDto>()
.ForMember(dest => dest.Image, opt => opt.Ignore());
CreateMap<Post, PostResponseDto>().ReverseMap();

CreateMap<ReportPostDto, PostReportDetail>().ReverseMap();

Expand Down
5 changes: 2 additions & 3 deletions VNH.Application/Mappers/QuestionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ public QuestionMapper()
{

CreateMap<CreateQuestionDto, Question>().ReverseMap();

CreateMap<QuestionResponseDto, Question>().ReverseMap();

CreateMap<QuestionResponseDto, Question>().ReverseMap();
CreateMap<ReportQuestionDto, QuestionReportDetail>().ReverseMap();

}
}
Expand Down
4 changes: 4 additions & 0 deletions VNH.Application/Mappers/ReportMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VNH.Application.DTOs.Catalog.Forum.Question;
using VNH.Application.DTOs.Catalog.Posts;
using VNH.Application.DTOs.Catalog.Reports;
using VNH.Domain;
Expand All @@ -14,6 +15,9 @@ public class ReportMapper : Profile
{
public ReportMapper() {
CreateMap<ReportDto, Report>().ReverseMap();
CreateMap<ReportPostDto, PostReportDetail>().ReverseMap();
CreateMap<ReportQuestionDto, QuestionReportDetail>().ReverseMap();

}
}
}
7 changes: 4 additions & 3 deletions VNH.Domain/Entities/Answer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ public Answer()
AnswerVotes = new HashSet<AnswerVote>();
SubAnswers = new HashSet<SubAnswer>();
}

[Key]
public Guid Id { get; set; }
public Guid QuestionId { get; set; }
public string Content { get; set; }
public Guid? AuthorId { get; set; }
[Column(TypeName = "datetime")]
public DateTime? PubDate { get; set; }
public DateTime? CreatedAt { get; set; }

[Column(TypeName = "datetime")]
public DateTime? UpdateAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool? Confirm { get; set; }
public bool? MostConfirm { get; set; }
public bool IsDeleted { get; set; } = false;

[ForeignKey("AuthorId")]
[InverseProperty("Answers")]
Expand Down
Loading
Loading