Skip to content

Commit

Permalink
Merge pull request #2 from KYJKY/master
Browse files Browse the repository at this point in the history
모델관계 개선, Logger추가, IdentityUser 사용
  • Loading branch information
KYJKY authored Jan 17, 2024
2 parents ad0624c + 54bfd8e commit 7e14d53
Show file tree
Hide file tree
Showing 57 changed files with 2,205 additions and 498 deletions.
2 changes: 1 addition & 1 deletion EveryPinApi.Entites/Entites.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.14" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.15" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions EveryPinApi.Entites/Models/CodeOAuthPlatform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entites.Models
{
public class CodeOAuthPlatform
{
[Column("PlatformCodeId")]
public int Id { get; set; }
[Required]
public string? PlatformName { get; set; }
}
}
12 changes: 9 additions & 3 deletions EveryPinApi.Entites/Models/Comment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ namespace Entites.Models
public class Comment
{
[Column("CommentId")]
public Guid Id { get; set; }
[ForeignKey(nameof(User))]
public Guid UserId { get; set; }
public int Id { get; set; }

public int? PostId { get; set; }
public Post? Post { get; set; }

[ForeignKey("User")]
public required string UserId { get; set; }
public User? User { get; set; }

public string? CommentMessage { get; set; }
public DateTime? CreatedDate { get; set; } = DateTime.Now;
}
Expand Down
12 changes: 9 additions & 3 deletions EveryPinApi.Entites/Models/Like.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ namespace Entites.Models
public class Like
{
[Column("LikeId")]
public Guid Id { get; set; }
[ForeignKey(nameof(User))]
public Guid UserId { get; set; }
public int Id { get; set; }

public int? PostId { get; set; }
public Post? Post { get; set; }

[ForeignKey("User")]
public required string UserId { get; set; }
public User? User { get; set; }

public DateTime? CreatedDate { get; set; } = DateTime.Now;
}
}
17 changes: 6 additions & 11 deletions EveryPinApi.Entites/Models/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ namespace Entites.Models
{
public class Post
{
public Post()
{
this.PostPhotos = new HashSet<PostPhoto>();
this.Likes = new HashSet<Like>();
this.Comments = new HashSet<Comment>();
}

[Column("PostId")]
public Guid PostId { get; set; }
public int PostId { get; set; }
public string? PostContent { get; set; }
public virtual ICollection<PostPhoto> PostPhotos { get; set; }
public virtual ICollection<Like> Likes { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
[ForeignKey("User")]
public required string UserId { get; set; }
public ICollection<PostPhoto> PostPhotos { get; } = new List<PostPhoto>();
public ICollection<Like> Likes { get; } = new List<Like>();
public ICollection<Comment> Comments { get; } = new List<Comment>();
public DateTime? UpdateDate { get; set; } = null;
public DateTime? CreatedDate { get; set; } = DateTime.Now;
}
Expand Down
8 changes: 6 additions & 2 deletions EveryPinApi.Entites/Models/PostPhoto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace Entites.Models
public class PostPhoto
{
[Column("PostPhotoId")]
public Guid Id { get; set; }
public string? photoUrl;
public int Id { get; set; }

public int? PostId { get; set; }
public Post? Post { get; set; }

public string? photoUrl { get; set; }
}
}
10 changes: 7 additions & 3 deletions EveryPinApi.Entites/Models/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ namespace Entites.Models
public class Profile
{
[Column("ProfileId")]
public Guid Id { get; set; }
public int Id { get; set; }

[ForeignKey("User")]
public required string UserId { get; set; }
public User? User { get; set; }

public string? Name { get; set; }
public string? SelfIntroduction { get; set; }
public string? PhotoUrl { get; set; }
[ForeignKey(nameof(User))]
public Guid UserId { get; set; }
public DateTime? UpdatedDate { get; set; } = null;
public DateTime? CreatedDate { get; set; } = DateTime.Now;

}
}
20 changes: 10 additions & 10 deletions EveryPinApi.Entites/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace Entites.Models
{
public class User : IdentityUser
{
[Column("UserId")]
public Guid Id { get; set; }
public string? GoogleId { get; set; }
public string? GoogleName { get; set; }
public string? GoogleEmail { get; set; }
public string? KakaoId { get; set; }
public string? KakaoName { get; set; }
public string? KakaoEmail { get; set; }
[ForeignKey(nameof(Profile))]
public Guid ProfileId { get; set; }
//[Column("UserId")]
//public int Id { get; set; }
public int PlatformCodeId { get; set; }
public Profile? Profile { get; set; }
public ICollection<Like> Like { get; set; } = new List<Like>();
public string? Name { get; set; }
//public string? Email { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime LastLoginDate { get; set; }
public bool DeleteCheck { get; set; }
}
}
45 changes: 37 additions & 8 deletions EveryPinApi.Presentation/Controllers/AuthenticationController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Service.Contracts;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Service.Contracts;
using Shared.DataTransferObject;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,11 +11,37 @@

namespace EveryPinApi.Presentation.Controllers
{
//[Route("api/authentication")]
//[ApiController]
//public class AuthenticationController : ControllerBase
//{
// private readonly IServiceManager _service;
// public AuthenticationController(IServiceManager service) => _service = service;
//}
[Route("api/authentication")]
[ApiController]
public class AuthenticationController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;

public AuthenticationController(ILogger<AuthenticationController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpPost]
//[ServiceFilter(typeof(ValidationFilterAttribute))]
public async Task<IActionResult> RegisterUser([FromBody] RegistUserDto registUserDto)
{
var result = await
_service.AuthenticationService.RegisterUser(registUserDto);

if (!result.Succeeded)
{
foreach (var error in result.Errors)
{
ModelState.TryAddModelError(error.Code, error.Description);
}
return BadRequest(ModelState);
}

return StatusCode(201);
}
}

}
9 changes: 8 additions & 1 deletion EveryPinApi.Presentation/Controllers/CommentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace EveryPinApi.Presentation.Controllers
{
[Route("api/comment")]
[ApiController]
public class CommentController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;
public CommentController(IServiceManager service) => _service = service;

public CommentController(ILogger<CommentController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpGet]
public IActionResult GetAllComment()
Expand Down
9 changes: 8 additions & 1 deletion EveryPinApi.Presentation/Controllers/LikeController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Service.Contracts;
using System;
using System.Collections.Generic;
Expand All @@ -12,8 +13,14 @@ namespace EveryPinApi.Presentation.Controllers
[ApiController]
public class LikeController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;
public LikeController(IServiceManager service) => _service = service;

public LikeController(ILogger<LikeController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpGet]
public IActionResult GetAllLike()
Expand Down
9 changes: 8 additions & 1 deletion EveryPinApi.Presentation/Controllers/PostController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Service.Contracts;
using System;
using System.Collections.Generic;
Expand All @@ -12,8 +13,14 @@ namespace EveryPinApi.Presentation.Controllers
[ApiController]
public class PostController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;
public PostController(IServiceManager service) => _service = service;

public PostController(ILogger<PostController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpGet]
public IActionResult GetAllPost()
Expand Down
9 changes: 8 additions & 1 deletion EveryPinApi.Presentation/Controllers/PostPhotoController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Service.Contracts;
using System;
using System.Collections.Generic;
Expand All @@ -12,8 +13,14 @@ namespace EveryPinApi.Presentation.Controllers
[ApiController]
public class PostPhotoController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;
public PostPhotoController(IServiceManager service) => _service = service;

public PostPhotoController(ILogger<PostPhotoController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpGet]
public IActionResult GetAllPostPhoto()
Expand Down
9 changes: 8 additions & 1 deletion EveryPinApi.Presentation/Controllers/ProfileController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Service.Contracts;
using System;
using System.Collections.Generic;
Expand All @@ -12,8 +13,14 @@ namespace EveryPinApi.Presentation.Controllers
[ApiController]
public class ProfileController : ControllerBase
{
private readonly ILogger _logger;
private readonly IServiceManager _service;
public ProfileController(IServiceManager service) => _service = service;

public ProfileController(ILogger<ProfileController> logger, IServiceManager service)
{
_logger = logger;
_service = service;
}

[HttpGet]
public IActionResult GetAllProfile()
Expand Down
32 changes: 0 additions & 32 deletions EveryPinApi.Presentation/Controllers/UserController.cs

This file was deleted.

8 changes: 7 additions & 1 deletion EveryPinApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Service.Contracts", "Servic
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Service", "Service\Service.csproj", "{767347CD-A22E-4F08-973E-949BA54E4E2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EveryPinApi.Presentation", "EveryPinApi.Presentation\EveryPinApi.Presentation.csproj", "{D42FD03D-81F5-4E10-BF6F-69CF3C5383DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EveryPinApi.Presentation", "EveryPinApi.Presentation\EveryPinApi.Presentation.csproj", "{D42FD03D-81F5-4E10-BF6F-69CF3C5383DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{DA7C6E93-07A1-4EDB-8744-3B17233BFA68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -51,6 +53,10 @@ Global
{D42FD03D-81F5-4E10-BF6F-69CF3C5383DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D42FD03D-81F5-4E10-BF6F-69CF3C5383DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D42FD03D-81F5-4E10-BF6F-69CF3C5383DE}.Release|Any CPU.Build.0 = Release|Any CPU
{DA7C6E93-07A1-4EDB-8744-3B17233BFA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA7C6E93-07A1-4EDB-8744-3B17233BFA68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA7C6E93-07A1-4EDB-8744-3B17233BFA68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA7C6E93-07A1-4EDB-8744-3B17233BFA68}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 8 additions & 2 deletions EveryPinApi/EveryPinApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>8f17b0ff-654c-4ca5-bac4-0c9f6c2f23cb</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.14">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.15">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -25,4 +27,8 @@
<ProjectReference Include="..\Service\Service.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>

</Project>
Loading

0 comments on commit 7e14d53

Please sign in to comment.