Skip to content

Commit

Permalink
Merge pull request #5 from MJU-Iced-Americano/feature/2
Browse files Browse the repository at this point in the history
[#3] feat : Entity 생성
  • Loading branch information
sangminee authored Apr 8, 2023
2 parents 25ff5f6 + 7a4a00f commit edcedcb
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 122 deletions.
17 changes: 0 additions & 17 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

1 change: 0 additions & 1 deletion README.md

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/com/mju/course/CourseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableDiscoveryClient
@EnableJpaAuditing
public class CourseApplication {

public static void main(String[] args) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/mju/course/application/CourseService.java
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 src/main/java/com/mju/course/application/CourseServiceImpl.java
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 src/main/java/com/mju/course/appliocation/CompanyService.java

This file was deleted.

25 changes: 0 additions & 25 deletions src/main/java/com/mju/course/appliocation/CompanyServiceImpl.java

This file was deleted.

24 changes: 24 additions & 0 deletions src/main/java/com/mju/course/domain/model/BaseTimeEntity.java
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;
}
27 changes: 0 additions & 27 deletions src/main/java/com/mju/course/domain/model/Company.java

This file was deleted.

50 changes: 50 additions & 0 deletions src/main/java/com/mju/course/domain/model/Course.java
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 src/main/java/com/mju/course/domain/model/CoursePhoto.java
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;

}
27 changes: 27 additions & 0 deletions src/main/java/com/mju/course/domain/model/Curriculum.java
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;

}
36 changes: 36 additions & 0 deletions src/main/java/com/mju/course/domain/model/Lecture.java
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;

}
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> {

}

This file was deleted.

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";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@

@Getter
@AllArgsConstructor
public class CompanyEnrollmentDto {
private String name;
private String url;
public class PostCourseDto {
}
13 changes: 0 additions & 13 deletions src/test/java/com/mju/company/CourseApplicationTests.java
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);
}

}

0 comments on commit edcedcb

Please sign in to comment.