forked from AcaMate/AcaMate_API
[✨] 유저 데이터 불러오기 API 추가 + 아카데미 이름 불러오기 API 추가
This commit is contained in:
parent
41c8d94001
commit
b2e72a2f9c
|
@ -17,6 +17,7 @@ public class AppDbContext: DbContext
|
|||
//MARK: USER
|
||||
public DbSet<Login> Login { get; set; }
|
||||
public DbSet<User_Academy> UserAcademy { get; set; }
|
||||
public DbSet<User> User { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Text.Json;
|
|||
|
||||
namespace AcaMate.Common.Models;
|
||||
|
||||
public class APIResponseStatus<T>
|
||||
public class APIResponseStatus<T>
|
||||
{
|
||||
public Status status { get; set; }
|
||||
public T? data { get; set; }
|
||||
|
|
|
@ -27,27 +27,6 @@ public class MemberController: ControllerBase
|
|||
return Ok("DB 참조");
|
||||
}
|
||||
|
||||
[HttpPost("academy")]
|
||||
[CustomOperation("앱 버전 확인","앱 버전을 확인해서 업데이트 여부 판단", "시스템")]
|
||||
public IActionResult ReadAcademyInfo([FromBody] RequestAcademy request)
|
||||
{
|
||||
if (request.bids == null || !request.bids.Any())
|
||||
{
|
||||
var response = DefaultResponse.InvalidInputError;
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
var academies = _dbContext
|
||||
.Academy
|
||||
.Where(a => request.bids.Contains(a.bid))
|
||||
.Select(a => new AcademyName
|
||||
{
|
||||
bid = a.bid,
|
||||
name = a.business_name
|
||||
})
|
||||
.ToList();
|
||||
return Ok(academies);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,9 +19,51 @@ public class UserController: ControllerBase
|
|||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
[CustomOperation("회원 정보 조회", "회원 정보 조회", "사용자")]
|
||||
public IActionResult GetUserData(string uid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uid))
|
||||
{
|
||||
return BadRequest(DefaultResponse.InvalidInputError);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var user = _dbContext.User
|
||||
.Where(u => u.uid == uid)
|
||||
.Select(u => new User
|
||||
{
|
||||
uid = u.uid,
|
||||
name = u.name,
|
||||
auto_login_yn = u.auto_login_yn,
|
||||
birth = u.birth,
|
||||
device_id = u.device_id,
|
||||
login_date = u.login_date,
|
||||
type = u.type,
|
||||
})
|
||||
.FirstOrDefault();
|
||||
|
||||
var response = new APIResponseStatus<User>
|
||||
{
|
||||
status = new Status()
|
||||
{
|
||||
code = "000",
|
||||
message = "정상"
|
||||
},
|
||||
data = user
|
||||
};
|
||||
return Ok(response.JsonToString());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return StatusCode(500, DefaultResponse.UnknownError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("login")]
|
||||
[CustomOperation("SNS 로그인", "로그인 후 회원이 있는지 확인", "사용자")]
|
||||
public IActionResult SNSLogin(string acctype,string sns_id)
|
||||
public IActionResult SNSLogin(string acctype, string sns_id)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(acctype) && string.IsNullOrEmpty(sns_id))
|
||||
|
@ -74,4 +116,37 @@ public class UserController: ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
[HttpPost("academy")]
|
||||
[CustomOperation("학원 리스트 확인","등록된 학원 리스트 확인", "사용자")]
|
||||
public IActionResult ReadAcademyInfo([FromBody] RequestAcademy request)
|
||||
{
|
||||
if (!request.bids.Any())
|
||||
{
|
||||
var error = DefaultResponse.InvalidInputError;
|
||||
return Ok(error);
|
||||
}
|
||||
|
||||
var academies = _dbContext
|
||||
.Academy
|
||||
.Where(a => request.bids.Contains(a.bid))
|
||||
.Select(a => new AcademyName
|
||||
{
|
||||
bid = a.bid,
|
||||
name = a.business_name
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var response = new APIResponseStatus<List<AcademyName>>
|
||||
{
|
||||
status = new Status()
|
||||
{
|
||||
code = "000",
|
||||
message = "정상"
|
||||
},
|
||||
data = academies
|
||||
};
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
|
||||
namespace AcaMate.V1.Models;
|
||||
|
||||
|
@ -13,7 +14,7 @@ public class Login
|
|||
public string uid {get; set;}
|
||||
[MaxLength(4)]
|
||||
public string sns_type {get; set;}
|
||||
[MaxLength(255)]
|
||||
[MaxLength(255)]
|
||||
public string sns_token {get; set;}
|
||||
[MaxLength(100)]
|
||||
public string sns_email {get; set;}
|
||||
|
@ -27,4 +28,17 @@ public class User_Academy
|
|||
public string bid { get; set; }
|
||||
public DateTime register_date { get; set; }
|
||||
public bool status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[Table("user")]
|
||||
public class User
|
||||
{
|
||||
[Key]
|
||||
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; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user