-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from MJU-Iced-Americano/feature/2
[#3] feat : Entity 생성
- Loading branch information
Showing
18 changed files
with
221 additions
and
122 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mju.course.application; | ||
|
||
import com.mju.course.domain.model.other.Result.CommonResult; | ||
import com.mju.course.presentation.dto.PostCourseDto; | ||
|
||
public interface CourseService { | ||
CommonResult createCourse(PostCourseDto postCourseDto); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mju/course/application/CourseServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mju.course.application; | ||
|
||
import com.mju.course.domain.model.other.Result.CommonResult; | ||
import com.mju.course.domain.repository.CourseRepository; | ||
import com.mju.course.domain.service.ResponseService; | ||
import com.mju.course.presentation.dto.PostCourseDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CourseServiceImpl implements CourseService{ | ||
|
||
private final CourseRepository courseRepository; | ||
private final ResponseService responseService; | ||
|
||
@Override | ||
public CommonResult createCourse(PostCourseDto postCourseDto) { | ||
return responseService.getSuccessfulResult(); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
src/main/java/com/mju/course/appliocation/CompanyService.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/main/java/com/mju/course/appliocation/CompanyServiceImpl.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/com/mju/course/domain/model/BaseTimeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mju.course.domain.model; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
@Column(updatable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.mju.course.domain.model; | ||
|
||
import com.mju.course.domain.model.enums.CourseState; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Course extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "course_index") | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
// 유저 - 강사진 | ||
|
||
@Column(name = "category") | ||
private String category; | ||
|
||
@Column(name = "course_name") | ||
private String course_name; | ||
|
||
@Column(name = "price") | ||
private String price; | ||
|
||
@Column(name = "course_description") | ||
private String course_description; | ||
|
||
@Column(name = "difficulty") | ||
private String difficulty; | ||
|
||
@Column(name = "course_time") | ||
private String course_time; | ||
|
||
@Column(name = "skill") | ||
private String skill; | ||
|
||
@Column(name = "hits") | ||
private Long hits; | ||
|
||
@Column(name = "course_period") | ||
private String course_period; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private CourseState status; | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/mju/course/domain/model/CoursePhoto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mju.course.domain.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class CoursePhoto extends BaseTimeEntity{ | ||
|
||
@Id | ||
@Column(name = "course_photo_index") | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="course_index") | ||
private Course course; | ||
|
||
@Column(name = "course_photo_url") | ||
private String course_photo_url; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.mju.course.domain.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Curriculum extends BaseTimeEntity{ | ||
|
||
@Id | ||
@Column(name = "curriculum_index") | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="course_index") | ||
private Course course; | ||
|
||
@Column(name = "chapter") | ||
private int chapter; | ||
|
||
@Column(name = "curriculum_title") | ||
private String curriculum_title; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mju.course.domain.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class Lecture extends BaseTimeEntity{ | ||
|
||
@Id | ||
@Column(name = "lecture_index") | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="curriculum_index") | ||
private Curriculum curriculum; | ||
|
||
@Column(name = "lecture_sequence") | ||
private int lecture_sequence; | ||
|
||
@Column(name = "lecture_title") | ||
private String lecture_title; | ||
|
||
@Column(name = "lecture_time") | ||
private int lecture_time; | ||
|
||
@Column(name = "lecture_url") | ||
private String lecture_url; | ||
|
||
@Column(name = "lecture_description") | ||
private String lecture_description; | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
.../domain/repository/CompanyRepository.java → ...e/domain/repository/CourseRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package com.mju.course.domain.repository; | ||
|
||
import com.mju.course.domain.model.Company; | ||
import com.mju.course.domain.model.Course; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CompanyRepository extends JpaRepository<Company, Long> { | ||
public interface CourseRepository extends JpaRepository<Course, Long> { | ||
|
||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/com/mju/course/presentation/controller/CompanyController.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/mju/course/presentation/controller/CourseLecturerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mju.course.presentation.controller; | ||
|
||
import com.mju.course.application.CourseService; | ||
import com.mju.course.domain.model.other.Result.CommonResult; | ||
import com.mju.course.presentation.dto.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/course-service") | ||
public class CourseLecturerController { | ||
|
||
private final CourseService courseService; | ||
|
||
@PostMapping("/course") | ||
public CommonResult createCourse(@RequestBody PostCourseDto postCourseDto){ | ||
return courseService.createCourse(postCourseDto); | ||
} | ||
|
||
@GetMapping("/ping") | ||
public String ping() { | ||
return "pong"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,8 @@ | ||
package com.mju.company; | ||
|
||
import com.mju.course.domain.model.Company; | ||
import com.mju.course.domain.repository.CompanyRepository; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class CourseApplicationTests { | ||
|
||
@Autowired | ||
CompanyRepository companyRepository; | ||
|
||
@Test | ||
void contextLoads() { | ||
Company company = new Company("test", "test"); | ||
companyRepository.save(company); | ||
} | ||
|
||
} |