forked from AcaMate/AcaMate_API
[[✨] 로그인 관련(회원가입, 회원조회) 부분 API 작업중
This commit is contained in:
parent
b2e72a2f9c
commit
cebf5a42cb
10
Program.cs
10
Program.cs
|
@ -38,7 +38,15 @@ var dbString = builder.Configuration.GetConnectionString("MariaDbConnection");
|
|||
var userString = builder.Configuration.GetConnectionString("DBAccount");
|
||||
|
||||
// JWT 설정부 시작
|
||||
builder.Configuration.AddJsonFile("private/jwtSetting.json", optional: true, reloadOnChange: true);
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
builder.Configuration.AddJsonFile("private/jwtSetting.Development.json", optional: true, reloadOnChange: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Configuration.AddJsonFile("private/jwtSetting.json", optional: true, reloadOnChange: true);
|
||||
}
|
||||
|
||||
builder.Services.Configure<JwtSettings>(builder.Configuration.GetSection("JwtSettings"));
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
|
|
|
@ -3,7 +3,8 @@ using System.Text.Json;
|
|||
using AcaMate.Common.Data;
|
||||
using AcaMate.Common.Models;
|
||||
using AcaMate.V1.Models;
|
||||
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace AcaMate.V1.Controllers;
|
||||
|
||||
|
@ -63,7 +64,7 @@ public class UserController: ControllerBase
|
|||
|
||||
[HttpGet("login")]
|
||||
[CustomOperation("SNS 로그인", "로그인 후 회원이 있는지 확인", "사용자")]
|
||||
public IActionResult SNSLogin(string acctype, string sns_id)
|
||||
public IActionResult Login(string acctype, string sns_id)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(acctype) && string.IsNullOrEmpty(sns_id))
|
||||
|
@ -74,41 +75,61 @@ public class UserController: ControllerBase
|
|||
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();
|
||||
|
||||
var user = _dbContext.User.FirstOrDefault(user => user.uid == uid);
|
||||
if (user != null)
|
||||
{
|
||||
user.login_date = DateTime.Now;
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
var response = new APIResponseStatus<dynamic>
|
||||
{
|
||||
status = new Status()
|
||||
{
|
||||
code = "000",
|
||||
message = "정상"
|
||||
},
|
||||
data = new
|
||||
{
|
||||
uid = $"{uid}",
|
||||
bid = bids
|
||||
}
|
||||
};
|
||||
|
||||
return Ok(response.JsonToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatusCode(002, DefaultResponse.NotFoundError);
|
||||
// 계정이 없다는 거
|
||||
var response = new APIResponseStatus<dynamic>
|
||||
{
|
||||
status = new Status()
|
||||
{
|
||||
code = "010",
|
||||
message = "정상"
|
||||
},
|
||||
data = new
|
||||
{
|
||||
uid = "",
|
||||
bid = new string[]{}
|
||||
}
|
||||
};
|
||||
return Ok(response.JsonToString());
|
||||
}
|
||||
|
||||
var response = new APIResponseStatus<dynamic>
|
||||
{
|
||||
status = new Status()
|
||||
{
|
||||
code = "000",
|
||||
message = "정상"
|
||||
},
|
||||
data = new
|
||||
{
|
||||
uid = $"{uid}",
|
||||
bid = bids
|
||||
}
|
||||
};
|
||||
|
||||
return Ok(response.JsonToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -148,5 +169,19 @@ public class UserController: ControllerBase
|
|||
return Ok(response);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("register")]
|
||||
[CustomOperation("회원 가입", "사용자 회원 가입", "사용자")]
|
||||
public IActionResult UserRegister([FromBody] User request)
|
||||
{
|
||||
if (request.uid.IsNullOrEmpty())
|
||||
{
|
||||
var error = DefaultResponse.InvalidInputError;
|
||||
return Ok(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok("회원가입");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,8 @@ public class Academy
|
|||
public string uid { get; set; }
|
||||
}
|
||||
|
||||
// -- -- -- -- -- DB 테이블 -- -- -- -- -- //
|
||||
|
||||
public class AcademyName
|
||||
{
|
||||
public string bid { get; set; }
|
||||
|
|
|
@ -14,10 +14,6 @@ public class Login
|
|||
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")]
|
||||
|
@ -42,3 +38,76 @@ public class User
|
|||
public int auto_login_yn { get; set; }
|
||||
public DateTime login_date { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[Table("permission")]
|
||||
public class Permission
|
||||
{
|
||||
[Key]
|
||||
public string uid { get; set; }
|
||||
|
||||
public bool location_yn {get; set;}
|
||||
public bool camera_yn {get; set;}
|
||||
public bool photo_yn {get; set;}
|
||||
public bool push_yn {get; set;}
|
||||
public bool market_app_yn {get; set;}
|
||||
public bool market_sms_yn {get; set;}
|
||||
public bool market_email_yn {get; set;}
|
||||
}
|
||||
|
||||
[Table("token")]
|
||||
public class Token
|
||||
{
|
||||
[Key]
|
||||
public string uid { get; set; }
|
||||
public string refresh_token { get; set; }
|
||||
public DateTime create_date { get; set; }
|
||||
public DateTime expires_date { get; set; }
|
||||
public DateTime revoke_date { get; set; }
|
||||
}
|
||||
|
||||
[Table("location")]
|
||||
public class Location
|
||||
{
|
||||
[Key]
|
||||
public string uid { get; set; }
|
||||
public string lat { get; set; }
|
||||
public string lng { get; set; }
|
||||
}
|
||||
|
||||
[Table("contact")]
|
||||
public class Contact
|
||||
{
|
||||
[Key]
|
||||
public string uid { get; set; }
|
||||
public string email { get; set; }
|
||||
public string phone { get; set; }
|
||||
}
|
||||
|
||||
// -- -- -- -- -- DB 테이블 -- -- -- -- -- //
|
||||
|
||||
public class UserAll
|
||||
{
|
||||
public string uid { get; set; }
|
||||
public string name { get; set; }
|
||||
public DateTime birth { get; set; }
|
||||
public string type { get; set; }
|
||||
public string device_id { get; set; }
|
||||
public int auto_login_yn { get; set; }
|
||||
public DateTime login_date { get; set; }
|
||||
|
||||
public string email { get; set; }
|
||||
public string phone { get; set; }
|
||||
|
||||
public bool location_yn {get; set;}
|
||||
public bool camera_yn {get; set;}
|
||||
public bool photo_yn {get; set;}
|
||||
public bool push_yn {get; set;}
|
||||
public bool market_app_yn {get; set;}
|
||||
public bool market_sms_yn {get; set;}
|
||||
public bool market_email_yn {get; set;}
|
||||
|
||||
public string sns_id {get; set;}
|
||||
public string sns_type {get; set;}
|
||||
public string sns_email {get; set;}
|
||||
}
|
Loading…
Reference in New Issue
Block a user