Merge pull request '[👷🏻] 채팅(Base) 수정 2차 & 로컬 맥 데이터 머지 작업' (#22) from seonkyu.kim/AcaMate_API:main into debug
Some checks failed
Back/pipeline/head There was a failure building this commit
Some checks failed
Back/pipeline/head There was a failure building this commit
Reviewed-on: https://git.ipstein.myds.me/AcaMate/AcaMate_API/pulls/22
This commit is contained in:
commit
3b3a196fbc
|
@ -8,6 +8,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8"/>
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||||
|
|
|
@ -80,7 +80,7 @@ builder.Services.AddCors(option =>
|
||||||
option.AddPolicy("CorsPolicy", builder =>
|
option.AddPolicy("CorsPolicy", builder =>
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.AllowAnyOrigin()
|
// .AllowAnyOrigin()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials()
|
.AllowCredentials()
|
||||||
|
|
|
@ -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 });
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ public class AppController : ControllerBase
|
||||||
|
|
||||||
try
|
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)
|
if (version == null)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,7 @@ public class AppController : ControllerBase
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");
|
||||||
return StatusCode(500, DefaultResponse.UnknownError);
|
return StatusCode(500, DefaultResponse.UnknownError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
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;
|
namespace AcaMate.V1.Controllers;
|
||||||
|
|
||||||
|
@ -13,34 +13,65 @@ namespace AcaMate.V1.Controllers;
|
||||||
[ApiExplorerSettings(GroupName = "사용자")]
|
[ApiExplorerSettings(GroupName = "사용자")]
|
||||||
public class UserController: ControllerBase
|
public class UserController: ControllerBase
|
||||||
{
|
{
|
||||||
// private readonly UserController _userController;
|
private readonly AppDbContext _dbContext;
|
||||||
|
public UserController(AppDbContext dbContext)
|
||||||
// private readonly UserService _userService;
|
|
||||||
//
|
|
||||||
// public UserController(UserService userService)
|
|
||||||
// {
|
|
||||||
// _userService = userService;
|
|
||||||
// }
|
|
||||||
|
|
||||||
[HttpGet("snsLogin")]
|
|
||||||
public IActionResult SNSLogin()
|
|
||||||
{
|
{
|
||||||
var response = new
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("login")]
|
||||||
|
[CustomOperation("SNS 로그인", "로그인 후 회원이 있는지 확인", "사용자")]
|
||||||
|
public IActionResult SNSLogin(string acctype,string sns_id)
|
||||||
{
|
{
|
||||||
status = new
|
|
||||||
|
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",
|
code = "000",
|
||||||
message = "정상"
|
message = "정상"
|
||||||
},
|
},
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
uid = "AC0000"
|
uid = $"{uid}",
|
||||||
|
bid = bids
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
string jsonString = JsonSerializer.Serialize(response);
|
return Ok(response.JsonToString());
|
||||||
|
}
|
||||||
return Ok(jsonString);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, DefaultResponse.UnknownError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
18
Program/V1/Models/Academy.cs
Normal file
18
Program/V1/Models/Academy.cs
Normal 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; }
|
||||||
|
}
|
30
Program/V1/Models/Login.cs
Normal file
30
Program/V1/Models/Login.cs
Normal 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; }
|
||||||
|
}
|
28
Program/V1/Repositories/UserRepository.cs
Normal file
28
Program/V1/Repositories/UserRepository.cs
Normal 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ public class ApnsPushService
|
||||||
private readonly string _p12PWPath;
|
private readonly string _p12PWPath;
|
||||||
private readonly string _apnsTopic;
|
private readonly string _apnsTopic;
|
||||||
|
|
||||||
|
|
||||||
public ApnsPushService(string uri,string p12Path, string p12PWPath, string apnsTopic)
|
public ApnsPushService(string uri,string p12Path, string p12PWPath, string apnsTopic)
|
||||||
{
|
{
|
||||||
_uri = uri ?? throw new ArgumentNullException(nameof(uri));
|
_uri = uri ?? throw new ArgumentNullException(nameof(uri));
|
||||||
|
@ -69,7 +70,6 @@ public class ApnsPushService
|
||||||
request.Headers.Add("apns-topic", _apnsTopic);
|
request.Headers.Add("apns-topic", _apnsTopic);
|
||||||
request.Headers.Add("apns-push-type", "alert");
|
request.Headers.Add("apns-push-type", "alert");
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine($"Send -> Payload: {jsonPayload}");
|
Console.WriteLine($"Send -> Payload: {jsonPayload}");
|
||||||
|
|
||||||
var response = await client.SendAsync(request);
|
var response = await client.SendAsync(request);
|
||||||
|
|
|
@ -3,4 +3,5 @@ namespace AcaMate.V1.Services;
|
||||||
public class UserService
|
public class UserService
|
||||||
{
|
{
|
||||||
// priva
|
// priva
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,3 +13,4 @@
|
||||||
| 2 | Microsoft.EntityFrameworkCore | 8.0.10 | 데이터베이스 작업을 간편하게 수행하기 위해 사용 |
|
| 2 | Microsoft.EntityFrameworkCore | 8.0.10 | 데이터베이스 작업을 간편하게 수행하기 위해 사용 |
|
||||||
| 3 | Pomelo.EntityFrameworkCore.MySql | 8.0.2 | MariaDB 연결 |
|
| 3 | Pomelo.EntityFrameworkCore.MySql | 8.0.2 | MariaDB 연결 |
|
||||||
| 4 |Microsoft.AspNetCore.Authentication.JwtBearer| 8.0.10 | |
|
| 4 |Microsoft.AspNetCore.Authentication.JwtBearer| 8.0.10 | |
|
||||||
|
| 5 |Dapper|2.1.35|SQL 직접 작성|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user