diff --git a/Program.cs b/Program.cs index 8f4d6bc..73a8134 100644 --- a/Program.cs +++ b/Program.cs @@ -140,10 +140,16 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + // builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + + + // builder.Services.AddScoped(); // // builder.Services.AddScoped(); diff --git a/Program/Common/Auth/DedicateWeb.cs b/Program/Common/Auth/DedicateWeb.cs index 5f2c03e..e3594b0 100644 --- a/Program/Common/Auth/DedicateWeb.cs +++ b/Program/Common/Auth/DedicateWeb.cs @@ -13,8 +13,10 @@ public class DedicateWeb( JwtTokenService _jwtTokenService, IAppService _appService) { + public async Task<(string code, string result)> GetAuthToken() { + var summary = "GetAuthToken"; try { diff --git a/Program/Common/Data/AppDbContext.cs b/Program/Common/Data/AppDbContext.cs index 92b653f..0171c73 100644 --- a/Program/Common/Data/AppDbContext.cs +++ b/Program/Common/Data/AppDbContext.cs @@ -34,6 +34,11 @@ namespace Back.Program.Common.Data public DbSet PushCabinet { get; set; } + //MARK: CLASS + public DbSet Class_Info { get; set; } + public DbSet Class_Attendance { get; set; } + public DbSet Class_Map { get; set; } + //MARK: CHATTING // public DbSet<> @@ -55,6 +60,11 @@ namespace Back.Program.Common.Data .HasKey(p => new { p.bid, p.pid }); // modelBuilder.Entity().HasNoKey(); + + modelBuilder.Entity() + .HasKey(ca => new { ca.cid, ca.uid, ca.attendace_date}); + modelBuilder.Entity() + .HasKey(ca => new { ca.cid, ca.uid}); } } } \ No newline at end of file diff --git a/Program/Controllers/V1/ClassController.cs b/Program/Controllers/V1/ClassController.cs new file mode 100644 index 0000000..7c79a42 --- /dev/null +++ b/Program/Controllers/V1/ClassController.cs @@ -0,0 +1,31 @@ +using Back.Program.Common.Model; +using Microsoft.AspNetCore.Mvc; +using Back.Program.Services.V1.Interfaces; +using Back.Program.Repositories.V1.Interfaces; +using Microsoft.AspNetCore.Http.HttpResults; + +namespace Back.Program.Controllers.V1; +[ApiController] +[Route("/api/v1/in/class")] +[ApiExplorerSettings(GroupName = "수업 관리")] +public class ClassController( + ILogger logger, + // SessionManager sessionManager, + // DedicateWeb dedicateWeb, + IRepositoryService repositoryService, + IClassService classService) + : ControllerBase +{ + // [HttpGet("info")] + [HttpGet] + [CustomOperation("수업 정보 조회", "수업 정보 조회", "수업관리")] + public async Task GetClassInfo(string cid) + { + if (string.IsNullOrEmpty(cid)) return BadRequest(APIResponse.InvalidInputError()); + if (!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError()); + string summary = repositoryService.ReadSummary(typeof(ClassController), "GetClassInfo"); + var result = await classService.GetClassInfo(summary, cid); + + return Ok(result); + } +} \ No newline at end of file diff --git a/Program/Models/Entities/Class.cs b/Program/Models/Entities/Class.cs new file mode 100644 index 0000000..5543d71 --- /dev/null +++ b/Program/Models/Entities/Class.cs @@ -0,0 +1,68 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Back.Program.Models.Entities; + +[Table("class_info")] +public class Class_Info +{ + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(10)] + public required string id { get; set; } // AMC + 4숫자 + 3대문자 + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(100)] + public required string name { get; set; } + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(70)] + public required string uid { get; set; } // 담당 선생님 구분 코드 + + [Required(ErrorMessage = "필수 항목 누락")] + public required DateTime start_date { get; set; } + + public DateTime? end_date { get; set; } + + [Required(ErrorMessage = "필수 항목 누락")] + public required byte day { get; set; } // 수업 요일 비트 (월요일부터 가장 좌측 비트) + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(4)] + public required string start_time { get; set; } // 수업 시작 시간 + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(4)] + public required string end_time { get; set; } // 수업 종료 시간 +} + +[Table("class_map")] +public class Class_Map +{ + [Key] + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(10)] + public required string cid { get; set; } // 강의 구분 코드 + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(70)] + public required string uid { get; set; } // 학생(유저) 구분 코드 +} + +[Table("class_attendance")] +public class Class_Attendance +{ + [Key] + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(10)] + public required string cid { get; set; } // 강의 구분 코드 + + [Required(ErrorMessage = "필수 항목 누락")] + [MaxLength(70)] + public required string uid { get; set; } // 학생(유저) 구분 코드 + + [Required(ErrorMessage = "필수 항목 누락")] + public required DateTime attendace_date { get; set; } // 출석 일자 + + [Required(ErrorMessage = "필수 항목 누락")] + public required byte attendance_state { get; set; } // 출석 상태 (0=출석, 1=결석, 2=지각, 3=조퇴, 4=기타) +} \ No newline at end of file diff --git a/Program/Repositories/V1/ClassRepository.cs b/Program/Repositories/V1/ClassRepository.cs new file mode 100644 index 0000000..6471669 --- /dev/null +++ b/Program/Repositories/V1/ClassRepository.cs @@ -0,0 +1,25 @@ +using Back.Program.Common.Data; +using Back.Program.Models.Entities; +using Back.Program.Repositories.V1.Interfaces; +using Microsoft.EntityFrameworkCore; + +namespace Back.Program.Repositories.V1; + +public class ClassRepository(AppDbContext context): IClassRepository +{ + public async Task FindClassInfo(string cid) + { + return await context.Class_Info.FirstOrDefaultAsync(c => c.id == cid); + } + + //return _context.Login.FirstOrDefaultAsync(l => l.sns_type == accType && l.sns_id == snsId); + public async Task FindClassAttendance(string cid, string uid) + { + throw new NotImplementedException(); + } + + public async Task FindClassMap(string cid) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Program/Repositories/V1/Interfaces/IClassRepository.cs b/Program/Repositories/V1/Interfaces/IClassRepository.cs new file mode 100644 index 0000000..1ed3239 --- /dev/null +++ b/Program/Repositories/V1/Interfaces/IClassRepository.cs @@ -0,0 +1,19 @@ +using Back.Program.Models.Entities; + +namespace Back.Program.Repositories.V1.Interfaces; + +public interface IClassRepository +{ + // 클래스 정보 + // Task GetClassInfo(string cid); + // //학생이 클래스에 참여했는지 여부 + // Task> GetIncludeStudents(string cid); + // // 학생이 클래스에서 했던 모든 출석 + // Task> GetAttendanceOfClass(string cid, string uid); + // // 학생이 특정 날짜에 했던 출석 + // Task> GetAttendanceByDate(string uid, DateTime date); + + Task FindClassInfo(string cid); + Task FindClassAttendance(string cid, string uid); + Task FindClassMap(string cid); +} \ No newline at end of file diff --git a/Program/Services/V1/ClassService.cs b/Program/Services/V1/ClassService.cs new file mode 100644 index 0000000..a869f0d --- /dev/null +++ b/Program/Services/V1/ClassService.cs @@ -0,0 +1,21 @@ +using Back.Program.Common.Model; +using Back.Program.Repositories.V1; +using Back.Program.Repositories.V1.Interfaces; +using Back.Program.Services.V1.Interfaces; + +namespace Back.Program.Services.V1; + +public class ClassService(IClassRepository classRepository): IClassService +{ + public async Task> GetClassInfo(string summary, string cid) + { + var data = await classRepository.FindClassInfo(cid); + return APIResponse.Send("000", "수업 정보 조회 성공", new + { + summary = summary, + data = data + } + ); + + } +} \ No newline at end of file diff --git a/Program/Services/V1/Interfaces/IClassService.cs b/Program/Services/V1/Interfaces/IClassService.cs new file mode 100644 index 0000000..ff27765 --- /dev/null +++ b/Program/Services/V1/Interfaces/IClassService.cs @@ -0,0 +1,8 @@ +using Back.Program.Common.Model; + +namespace Back.Program.Services.V1.Interfaces; + +public interface IClassService +{ + Task> GetClassInfo(string summary, string cid); +} \ No newline at end of file