|
@@ -272,14 +272,21 @@ public class ThemeServiceImpl implements ThemeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<OperationCourse> getOperationCourseList(Pageable pageable, Long userId, Long ownerId, String operation, Map<String, String> extraCondition, String keyword) {
|
|
|
+ public Page<OperationCourse> getCustomizeCourseList(Pageable pageable, Long userId, Long ownerId, String operation, Map<String, String> extraCondition, String keyword) {
|
|
|
Specifications<OperationCourse> where = Specifications.where(this.getWhereClause(OperationCourse.class, userId, ownerId, operation, extraCondition, keyword));
|
|
|
return operationCourseDao.findAll(where, pageable);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<OperationCourse> getAuthorizedCourseList(Pageable pageable, Long userId, Long ownerId, String operation, Map<String, String> extraCondition, String keyword) {
|
|
|
+ Specifications<OperationCourse> where = Specifications.where(this.getOperationWhereClause(OperationCourse.class, userId, ownerId, operation, extraCondition, keyword));
|
|
|
+ return operationCourseDao.findAll(where, pageable);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<OperationCourse> getOperationCourseList(Long userId, String operation) {
|
|
|
- return operationCourseDao.findAllByUserIdAndOperationAndIsDeleted(userId, operation, 0);
|
|
|
+ return operationCourseDao.findAllByUserIdAndOperationNotAndIsDeleted(userId, operation, 0);
|
|
|
}
|
|
|
|
|
|
private <T> Specification<T> getWhereClause(Class<T> model, Long userId, Long ownerId, String operation, Map<String, String> extraCondition, String keyword) {
|
|
@@ -324,6 +331,48 @@ public class ThemeServiceImpl implements ThemeService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ private <T> Specification<T> getOperationWhereClause(Class<T> model, Long userId, Long ownerId, String operation, Map<String, String> extraCondition, String keyword) {
|
|
|
+ return (root, query, builder) -> {
|
|
|
+ Predicate predicate = builder.conjunction();
|
|
|
+ try {
|
|
|
+ model.getDeclaredField("isDeleted");
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.equal(root.<Long>get("isDeleted"), 0)
|
|
|
+ );
|
|
|
+ } catch (NoSuchFieldException e) {
|
|
|
+ //do nothing
|
|
|
+ }
|
|
|
+ if (userId != null) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.equal(root.<Long>get("userId"), userId)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (ownerId != null) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.equal(root.<Long>get("ownerId"), ownerId)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (operation != null) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.notEqual(root.<Long>get("operation"), operation)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (extraCondition != null){
|
|
|
+ for(String key:extraCondition.keySet()) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.equal(root.get(key), extraCondition.get(key))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (keyword != null) {
|
|
|
+ predicate.getExpressions().add(
|
|
|
+ builder.like(root.get("title"), "%" + StringUtils.trim(keyword) + "%")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return predicate;
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
public boolean isUserJoinCourse(Long courseId, Long participantId) {
|
|
|
return participantCourseDao.findByIdAndParticipantId(courseId, participantId)!=null;
|
|
|
}
|