-
Notifications
You must be signed in to change notification settings - Fork 1
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 #40 from elwyncrestha/feature/appointment-report
Feature: Added APIs for AppointmentReport
- Loading branch information
Showing
8 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
pemits-api/src/main/java/com/pemits/webcare/api/appointment/entity/AppointmentReport.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,27 @@ | ||
package com.pemits.webcare.api.appointment.entity; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.OneToOne; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import com.pemits.webcare.core.entity.BaseEntity; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
@Entity | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = true) | ||
public class AppointmentReport extends BaseEntity<Long> { | ||
|
||
@OneToOne | ||
private Appointment appointment; | ||
|
||
private String data; | ||
} |
14 changes: 14 additions & 0 deletions
14
.../main/java/com/pemits/webcare/api/appointment/repository/AppointmentReportRepository.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,14 @@ | ||
package com.pemits.webcare.api.appointment.repository; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
import com.pemits.webcare.core.repository.BaseRepository; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
@Repository | ||
public interface AppointmentReportRepository extends BaseRepository<AppointmentReport, Long> { | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...c/main/java/com/pemits/webcare/api/appointment/repository/spec/AppointmentReportSpec.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,38 @@ | ||
package com.pemits.webcare.api.appointment.repository.spec; | ||
|
||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Predicate; | ||
import javax.persistence.criteria.Root; | ||
|
||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
public class AppointmentReportSpec implements Specification<AppointmentReport> { | ||
|
||
private static final String FILTER_BY_APPOINTMENT_ID = "appointment.id"; | ||
|
||
private final String property; | ||
private final String value; | ||
|
||
public AppointmentReportSpec(String property, String value) { | ||
this.property = property; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Predicate toPredicate(Root<AppointmentReport> root, CriteriaQuery<?> criteriaQuery, | ||
CriteriaBuilder criteriaBuilder) { | ||
switch (property) { | ||
case FILTER_BY_APPOINTMENT_ID: | ||
return criteriaBuilder | ||
.equal(root.join("appointment").get("id"), Long.valueOf(value)); | ||
default: | ||
return null; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...java/com/pemits/webcare/api/appointment/repository/spec/AppointmentReportSpecBuilder.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.pemits.webcare.api.appointment.repository.spec; | ||
|
||
import java.util.Map; | ||
|
||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
import com.pemits.webcare.core.repository.BaseSpecBuilder; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
public class AppointmentReportSpecBuilder extends BaseSpecBuilder<AppointmentReport> { | ||
|
||
public AppointmentReportSpecBuilder(Map<String, String> params) { | ||
super(params); | ||
} | ||
|
||
@Override | ||
protected Specification<AppointmentReport> getSpecification(String property, | ||
String filterValue) { | ||
return new AppointmentReportSpec(property, filterValue); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...pi/src/main/java/com/pemits/webcare/api/appointment/service/AppointmentReportService.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,11 @@ | ||
package com.pemits.webcare.api.appointment.service; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
import com.pemits.webcare.core.service.BaseService; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
public interface AppointmentReportService extends BaseService<AppointmentReport, Long> { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...rc/main/java/com/pemits/webcare/api/appointment/service/AppointmentReportServiceImpl.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,28 @@ | ||
package com.pemits.webcare.api.appointment.service; | ||
|
||
import java.util.Map; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
import com.pemits.webcare.api.appointment.repository.AppointmentReportRepository; | ||
import com.pemits.webcare.api.appointment.repository.spec.AppointmentReportSpecBuilder; | ||
import com.pemits.webcare.core.repository.BaseSpecBuilder; | ||
import com.pemits.webcare.core.service.BaseServiceImpl; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
@Service | ||
public class AppointmentReportServiceImpl extends BaseServiceImpl<AppointmentReport, Long> implements AppointmentReportService { | ||
|
||
protected AppointmentReportServiceImpl( | ||
AppointmentReportRepository repository) { | ||
super(repository); | ||
} | ||
|
||
@Override | ||
protected BaseSpecBuilder<AppointmentReport> getSpec(Map<String, String> filterParams) { | ||
return new AppointmentReportSpecBuilder(filterParams); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
pemits-web/src/main/java/com/pemits/webcare/web/appointment/AppointmentReportController.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,25 @@ | ||
package com.pemits.webcare.web.appointment; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.pemits.webcare.api.appointment.entity.AppointmentReport; | ||
import com.pemits.webcare.api.appointment.service.AppointmentReportService; | ||
import com.pemits.webcare.core.controller.BaseController; | ||
|
||
/** | ||
* @author Elvin Shrestha on 7/19/2020 | ||
*/ | ||
@RestController | ||
@RequestMapping(AppointmentReportController.URL) | ||
@Slf4j | ||
public class AppointmentReportController extends BaseController<AppointmentReport, Long> { | ||
|
||
static final String URL = "/v1/appointment-report"; | ||
|
||
protected AppointmentReportController( | ||
AppointmentReportService service) { | ||
super(service, log.getClass()); | ||
} | ||
} |
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