Skip to content

Commit 7e14d53

Browse files
authored
Merge pull request #2 from KYJKY/master
모델관계 개선, Logger추가, IdentityUser 사용
2 parents ad0624c + 54bfd8e commit 7e14d53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2205
-498
lines changed

EveryPinApi.Entites/Entites.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.14" />
10+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.15" />
1111
</ItemGroup>
1212

1313
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.ComponentModel.DataAnnotations.Schema;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Entites.Models
10+
{
11+
public class CodeOAuthPlatform
12+
{
13+
[Column("PlatformCodeId")]
14+
public int Id { get; set; }
15+
[Required]
16+
public string? PlatformName { get; set; }
17+
}
18+
}

EveryPinApi.Entites/Models/Comment.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ namespace Entites.Models
1010
public class Comment
1111
{
1212
[Column("CommentId")]
13-
public Guid Id { get; set; }
14-
[ForeignKey(nameof(User))]
15-
public Guid UserId { get; set; }
13+
public int Id { get; set; }
14+
15+
public int? PostId { get; set; }
16+
public Post? Post { get; set; }
17+
18+
[ForeignKey("User")]
19+
public required string UserId { get; set; }
20+
public User? User { get; set; }
21+
1622
public string? CommentMessage { get; set; }
1723
public DateTime? CreatedDate { get; set; } = DateTime.Now;
1824
}

EveryPinApi.Entites/Models/Like.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ namespace Entites.Models
1010
public class Like
1111
{
1212
[Column("LikeId")]
13-
public Guid Id { get; set; }
14-
[ForeignKey(nameof(User))]
15-
public Guid UserId { get; set; }
13+
public int Id { get; set; }
14+
15+
public int? PostId { get; set; }
16+
public Post? Post { get; set; }
17+
18+
[ForeignKey("User")]
19+
public required string UserId { get; set; }
20+
public User? User { get; set; }
21+
1622
public DateTime? CreatedDate { get; set; } = DateTime.Now;
1723
}
1824
}

EveryPinApi.Entites/Models/Post.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ namespace Entites.Models
99
{
1010
public class Post
1111
{
12-
public Post()
13-
{
14-
this.PostPhotos = new HashSet<PostPhoto>();
15-
this.Likes = new HashSet<Like>();
16-
this.Comments = new HashSet<Comment>();
17-
}
18-
1912
[Column("PostId")]
20-
public Guid PostId { get; set; }
13+
public int PostId { get; set; }
2114
public string? PostContent { get; set; }
22-
public virtual ICollection<PostPhoto> PostPhotos { get; set; }
23-
public virtual ICollection<Like> Likes { get; set; }
24-
public virtual ICollection<Comment> Comments { get; set; }
15+
[ForeignKey("User")]
16+
public required string UserId { get; set; }
17+
public ICollection<PostPhoto> PostPhotos { get; } = new List<PostPhoto>();
18+
public ICollection<Like> Likes { get; } = new List<Like>();
19+
public ICollection<Comment> Comments { get; } = new List<Comment>();
2520
public DateTime? UpdateDate { get; set; } = null;
2621
public DateTime? CreatedDate { get; set; } = DateTime.Now;
2722
}

EveryPinApi.Entites/Models/PostPhoto.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ namespace Entites.Models
1111
public class PostPhoto
1212
{
1313
[Column("PostPhotoId")]
14-
public Guid Id { get; set; }
15-
public string? photoUrl;
14+
public int Id { get; set; }
15+
16+
public int? PostId { get; set; }
17+
public Post? Post { get; set; }
18+
19+
public string? photoUrl { get; set; }
1620
}
1721
}

EveryPinApi.Entites/Models/Profile.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ namespace Entites.Models
1010
public class Profile
1111
{
1212
[Column("ProfileId")]
13-
public Guid Id { get; set; }
13+
public int Id { get; set; }
14+
15+
[ForeignKey("User")]
16+
public required string UserId { get; set; }
17+
public User? User { get; set; }
18+
1419
public string? Name { get; set; }
1520
public string? SelfIntroduction { get; set; }
1621
public string? PhotoUrl { get; set; }
17-
[ForeignKey(nameof(User))]
18-
public Guid UserId { get; set; }
1922
public DateTime? UpdatedDate { get; set; } = null;
2023
public DateTime? CreatedDate { get; set; } = DateTime.Now;
24+
2125
}
2226
}

EveryPinApi.Entites/Models/User.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ namespace Entites.Models
1010
{
1111
public class User : IdentityUser
1212
{
13-
[Column("UserId")]
14-
public Guid Id { get; set; }
15-
public string? GoogleId { get; set; }
16-
public string? GoogleName { get; set; }
17-
public string? GoogleEmail { get; set; }
18-
public string? KakaoId { get; set; }
19-
public string? KakaoName { get; set; }
20-
public string? KakaoEmail { get; set; }
21-
[ForeignKey(nameof(Profile))]
22-
public Guid ProfileId { get; set; }
13+
//[Column("UserId")]
14+
//public int Id { get; set; }
15+
public int PlatformCodeId { get; set; }
16+
public Profile? Profile { get; set; }
17+
public ICollection<Like> Like { get; set; } = new List<Like>();
18+
public string? Name { get; set; }
19+
//public string? Email { get; set; }
20+
public DateTime CreatedDate { get; set; }
21+
public DateTime LastLoginDate { get; set; }
22+
public bool DeleteCheck { get; set; }
2323
}
2424
}
Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using Service.Contracts;
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.Extensions.Logging;
3+
using Service.Contracts;
4+
using Shared.DataTransferObject;
25
using System;
36
using System.Collections.Generic;
47
using System.Linq;
@@ -8,11 +11,37 @@
811

912
namespace EveryPinApi.Presentation.Controllers
1013
{
11-
//[Route("api/authentication")]
12-
//[ApiController]
13-
//public class AuthenticationController : ControllerBase
14-
//{
15-
// private readonly IServiceManager _service;
16-
// public AuthenticationController(IServiceManager service) => _service = service;
17-
//}
14+
[Route("api/authentication")]
15+
[ApiController]
16+
public class AuthenticationController : ControllerBase
17+
{
18+
private readonly ILogger _logger;
19+
private readonly IServiceManager _service;
20+
21+
public AuthenticationController(ILogger<AuthenticationController> logger, IServiceManager service)
22+
{
23+
_logger = logger;
24+
_service = service;
25+
}
26+
27+
[HttpPost]
28+
//[ServiceFilter(typeof(ValidationFilterAttribute))]
29+
public async Task<IActionResult> RegisterUser([FromBody] RegistUserDto registUserDto)
30+
{
31+
var result = await
32+
_service.AuthenticationService.RegisterUser(registUserDto);
33+
34+
if (!result.Succeeded)
35+
{
36+
foreach (var error in result.Errors)
37+
{
38+
ModelState.TryAddModelError(error.Code, error.Description);
39+
}
40+
return BadRequest(ModelState);
41+
}
42+
43+
return StatusCode(201);
44+
}
45+
}
46+
1847
}

EveryPinApi.Presentation/Controllers/CommentController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77
using System.Runtime.InteropServices;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using Microsoft.Extensions.Logging;
1011

1112
namespace EveryPinApi.Presentation.Controllers
1213
{
1314
[Route("api/comment")]
1415
[ApiController]
1516
public class CommentController : ControllerBase
1617
{
18+
private readonly ILogger _logger;
1719
private readonly IServiceManager _service;
18-
public CommentController(IServiceManager service) => _service = service;
20+
21+
public CommentController(ILogger<CommentController> logger, IServiceManager service)
22+
{
23+
_logger = logger;
24+
_service = service;
25+
}
1926

2027
[HttpGet]
2128
public IActionResult GetAllComment()

0 commit comments

Comments
 (0)