Skip to content

Commit

Permalink
PR#1 of issue #2
Browse files Browse the repository at this point in the history
- Fixed up the `AssignmentEnrollment` entity
- Created `AssignmentEnrollmentRepository`
- Created `AssignmentEnrollmentPage` model
- added test data to `bootstrap_data.sql`
  • Loading branch information
youcefs21 committed Sep 27, 2021
1 parent 9b1b5d4 commit 8b4d34b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
Expand All @@ -12,6 +14,8 @@
* Models the enrollment of a user in a course
*/
@Data
@RequiredArgsConstructor
@AllArgsConstructor
@ApiModel(value = "AssignmentEnrollment", description = "Enrollment of a user in a assignment")
@Entity
@Table(name = "ASSIGNMENT_ENROLLMENT")
Expand All @@ -30,10 +34,10 @@ public class AssignmentEnrollment {
private int id;

// Assignment user is enrolled in
// @ApiModelProperty(value = "Enrolled assignment")
// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "ASSIGNMENT_ID", referencedColumnName = "ID")
// private Assignment course;
@ApiModelProperty(value = "Enrolled assignment")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ASSIGNMENT_ID", referencedColumnName = "ID")
private Assignment course;

// User id
@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.unityTest.courseManagement.models.api.response.page;

import com.unityTest.courseManagement.entity.AssignmentEnrollment;
import io.swagger.annotations.ApiModel;
import org.springframework.data.domain.Page;

@ApiModel(value = "AssignmentEnrollmentPage", description = "Page request for enrollment of assignments")
public class AssignmentEnrollmentPage extends BasePage<AssignmentEnrollment> {
public AssignmentEnrollmentPage(Page<AssignmentEnrollment> page) {
super(page);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.unityTest.courseManagement.repository;

import com.unityTest.courseManagement.entity.AssignmentEnrollment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

@Repository
public interface AssignmentEnrollmentRepository
extends JpaRepository<AssignmentEnrollment, Integer>, JpaSpecificationExecutor<AssignmentEnrollment> {
}
8 changes: 8 additions & 0 deletions src/main/resources/db/h2/bootstrap_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ VALUES
(2, 'CASE', 1000, 'X02', 'How about being positive? :smile:', 0),

(3, 'CASE', 1001, 'X03', 'Should we have done this instead? `x = 3`?', 1);

INSERT INTO ASSIGNMENT_ENROLLMENT (ID, ASSIGNMENT_ID, USER_ID, PINNED)
VALUES
(1, 1, 'X01', false),
(2, 2, 'X02', false),
(3, 1, 'X02', true),
(4, 2, 'X01', true),
(5, 1, 'X03', false);

0 comments on commit 8b4d34b

Please sign in to comment.