[👷🏻] 채팅(Base) 수정 2차 & 로컬 맥 데이터 머지 작업

Signed-off-by: seonkyu.kim <sean.kk@daum.net>
This commit is contained in:
김선규 2025-02-17 22:52:44 +09:00
parent 6f06f3b39c
commit ab045e6eb8
11 changed files with 157 additions and 34 deletions

View File

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />

View File

@ -80,7 +80,7 @@ builder.Services.AddCors(option =>
option.AddPolicy("CorsPolicy", builder =>
{
builder
.AllowAnyOrigin()
// .AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()

View File

@ -10,5 +10,17 @@ public class AppDbContext: DbContext
{
}
public DbSet<Version> Versions { get; set; }
//MARK: Program
public DbSet<Version> Version { get; set; }
public DbSet<Academy> Academy { get; set; }
//MARK: USER
public DbSet<Login> Login { get; set; }
public DbSet<User_Academy> UserAcademy { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User_Academy>()
.HasKey(ua => new { ua.uid, ua.bid });
}
}

View File

@ -30,7 +30,7 @@ public class AppController : ControllerBase
try
{
var version = _dbContext.Versions.FirstOrDefault(v => v.os_type == (type == "I" ? "VO01" : "VO02"));
var version = _dbContext.Version.FirstOrDefault(v => v.os_type == (type == "I" ? "VO01" : "VO02"));
if (version == null)
{
@ -61,6 +61,7 @@ public class AppController : ControllerBase
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");
return StatusCode(500, DefaultResponse.UnknownError);
}
}

View File

@ -1,9 +1,9 @@
using System.Text;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authentication;
using System.Text.Json;
using AcaMate.Common.Data;
using AcaMate.Common.Models;
using AcaMate.V1.Models;
using AcaMate.V1.Services;
namespace AcaMate.V1.Controllers;
@ -13,34 +13,65 @@ namespace AcaMate.V1.Controllers;
[ApiExplorerSettings(GroupName = "사용자")]
public class UserController: ControllerBase
{
// private readonly UserController _userController;
// private readonly UserService _userService;
//
// public UserController(UserService userService)
// {
// _userService = userService;
// }
[HttpGet("snsLogin")]
public IActionResult SNSLogin()
private readonly AppDbContext _dbContext;
public UserController(AppDbContext dbContext)
{
var response = new
{
status = new
{
code = "000",
message = "정상"
},
data = new
{
uid = "AC0000"
}
};
_dbContext = dbContext;
}
string jsonString = JsonSerializer.Serialize(response);
[HttpGet("login")]
[CustomOperation("SNS 로그인", "로그인 후 회원이 있는지 확인", "사용자")]
public IActionResult SNSLogin(string acctype,string sns_id)
{
return Ok(jsonString);
if (string.IsNullOrEmpty(acctype) && string.IsNullOrEmpty(sns_id))
{
return BadRequest(DefaultResponse.InvalidInputError);
}
try
{
var login = _dbContext.Login.FirstOrDefault(l => l.sns_type == acctype && l.sns_id == sns_id);
string uid = "";
List<string> bids = new List<string>();
if (login != null)
{
uid = login.uid;
var userAcademy = _dbContext.UserAcademy.Where(u => u.uid == uid).ToList();
foreach(User_Academy userData in userAcademy)
{
Console.WriteLine($"uid: {userData.uid} || bid: {userData.bid}");
bids.Add(userData.bid);
}
}
else
{
return StatusCode(002, DefaultResponse.NotFoundError);
}
var response = new APIResponseStatus<dynamic>
{
status = new Status()
{
code = "000",
message = "정상"
},
data = new
{
uid = $"{uid}",
bid = bids
}
};
return Ok(response.JsonToString());
}
catch (Exception ex)
{
return StatusCode(500, DefaultResponse.UnknownError);
}
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AcaMate.V1.Models;
[Table("academy")]
public class Academy
{
[Key]
public string bid { get; set; }
public string business_name { get; set; }
public string business_ownder { get; set; }
public string business_number { get; set; }
public DateTime business_date { get; set; }
public string business_address { get; set; }
public string business_contact { get; set; }
public string uid { get; set; }
}

View File

@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AcaMate.V1.Models;
[Table("login")]
public class Login
{
[Key]
[MaxLength(100)]
public string sns_id {get; set;}
[MaxLength(70)]
public string uid {get; set;}
[MaxLength(4)]
public string sns_type {get; set;}
[MaxLength(255)]
public string sns_token {get; set;}
[MaxLength(100)]
public string sns_email {get; set;}
}
[Table("user_academy")]
public class User_Academy
{
[Key]
public string uid { get; set; }
public string bid { get; set; }
public DateTime register_date { get; set; }
public bool status { get; set; }
}

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using AcaMate.Common.Data;
using AcaMate.Common.Models;
using AcaMate.V1.Models;
namespace AcaMate.V1.Repositories;
public class UserRepository
{
private readonly AppDbContext _context;
public UserRepository(AppDbContext context) {
_context = context;
}
/*
public async Task<IEnumerable<UserAcademyResult>> GetUserAcademyInfoBySnsIdAsync(string snsId)
{
}*/
}

View File

@ -14,6 +14,7 @@ public class ApnsPushService
private readonly string _p12Path;
private readonly string _p12PWPath;
private readonly string _apnsTopic;
public ApnsPushService(string uri,string p12Path, string p12PWPath, string apnsTopic)
{
@ -32,7 +33,7 @@ public class ApnsPushService
Console.WriteLine($"File not found: {_p12PWPath}");
return new APIResult
{
Success = false,
Success = false ,
Code = "003",
Message = "서버 오류 : p12 PW 파일 확인 필요"
};
@ -68,7 +69,6 @@ public class ApnsPushService
// 필수 헤더 추가
request.Headers.Add("apns-topic", _apnsTopic);
request.Headers.Add("apns-push-type", "alert");
Console.WriteLine($"Send -> Payload: {jsonPayload}");

View File

@ -3,4 +3,5 @@ namespace AcaMate.V1.Services;
public class UserService
{
// priva
}

View File

@ -13,3 +13,4 @@
| 2 | Microsoft.EntityFrameworkCore | 8.0.10 | 데이터베이스 작업을 간편하게 수행하기 위해 사용 |
| 3 | Pomelo.EntityFrameworkCore.MySql | 8.0.2 | MariaDB 연결 |
| 4 |Microsoft.AspNetCore.Authentication.JwtBearer| 8.0.10 | |
| 5 |Dapper|2.1.35|SQL 직접 작성|