lideyin 6 anni fa
parent
commit
f5188467c2

+ 3 - 3
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/NoticeController.java

@@ -34,7 +34,7 @@ import java.util.List;
  */
 @RestController
 @Api(tags = "考试分数相关接口")
-@RequestMapping("${$rmp.ctr.oe}/notice")
+@RequestMapping("${$rmp.ctr.examwork}/notice")
 public class NoticeController extends ControllerSupport {
     @Autowired
     private NoticeService noticeService;
@@ -77,7 +77,7 @@ public class NoticeController extends ControllerSupport {
     private UserNoticeInfoQuery getNoticeQuery(UserNoticeDomainQuery query) {
         User user = this.getAccessUser();
         UserNoticeInfoQuery noticeQuery = new UserNoticeInfoQuery();
-        noticeQuery.setRead(query.getRead());
+        noticeQuery.setHasRead(query.getHasRead());
         noticeQuery.setRootOrgId(user.getRootOrgId());
         noticeQuery.setUserId(user.getUserId());
         noticeQuery.setUserType(user.getUserType());
@@ -92,7 +92,7 @@ public class NoticeController extends ControllerSupport {
             domain.setId(info.getId());
             domain.setPublisher(info.getPublisher());
             domain.setPublishTime(info.getPublishTime());
-            domain.setRead(info.getRead());
+            domain.setHasRead(info.getHasRead());
             domain.setTitle(info.getTitle());
             resultList.add(domain);
         }

+ 5 - 5
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/UserNoticeDomain.java

@@ -50,7 +50,7 @@ public class UserNoticeDomain implements JsonSerializable {
      * 读取状态
      */
     @ApiModelProperty("读取状态")
-    private Boolean read;
+    private Boolean hasRead;
 
     public Long getId() {
         return id;
@@ -92,11 +92,11 @@ public class UserNoticeDomain implements JsonSerializable {
         this.publishTime = publishTime;
     }
 
-    public Boolean getRead() {
-        return read;
+    public Boolean getHasRead() {
+        return hasRead;
     }
 
-    public void setRead(Boolean read) {
-        this.read = read;
+    public void setHasRead(Boolean hasRead) {
+        this.hasRead = hasRead;
     }
 }

+ 5 - 5
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/UserNoticeDomainQuery.java

@@ -22,13 +22,13 @@ public class UserNoticeDomainQuery implements JsonSerializable {
      * 是否已读(true,已读;false,未读)
      */
     @ApiModelProperty("是否已读")
-    private Boolean read;
+    private Boolean hasRead;
 
-    public Boolean getRead() {
-        return read;
+    public Boolean getHasRead() {
+        return hasRead;
     }
 
-    public void setRead(Boolean read) {
-        this.read = read;
+    public void setHasRead(Boolean hasRead) {
+        this.hasRead = hasRead;
     }
 }

+ 3 - 3
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/UserNoticeRepo.java

@@ -14,9 +14,9 @@ public interface UserNoticeRepo extends JpaRepository<UserNoticeEntity, Long>,
         QueryByExampleExecutor<UserNoticeEntity>, JpaSpecificationExecutor<UserNoticeEntity> {
     List<UserNoticeEntity> findByRootOrgIdAndUserTypeAndUserId(Long rootOrgId,UserType userType,Long userId);
 
-    List<UserNoticeEntity> findByRootOrgIdAndUserTypeAndUserIdAndRead(Long rootOrgId,UserType userType,Long userId,Boolean read);
+    List<UserNoticeEntity> findByRootOrgIdAndUserTypeAndUserIdAndHasRead(Long rootOrgId,UserType userType,Long userId,Boolean hasRead);
 
     @Modifying
-    @Query("update EC_E_USER_NOTICE set read = 1 where notice_id in (?1) and user_type = ?2 and user_id = ?3")
-    int updateNoticeReadStatus(String noticeId, UserType userType, Long UserId);
+    @Query(value = "update EC_E_USER_NOTICE set has_read = 1 where notice_id in ?1 and user_type = ?2 and user_id = ?3",nativeQuery = true)
+    int updateNoticeReadStatus(String noticeId, UserType userType, Long userId);
 }

+ 5 - 6
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/UserNoticeEntity.java

@@ -55,7 +55,7 @@ public class UserNoticeEntity extends WithIdJpaEntity {
 	 * 是否已读
 	 */
 	@Column(nullable = false)
-	private Boolean read;
+	private Boolean hasRead;
 
 	public Long getRootOrgId() {
 		return rootOrgId;
@@ -89,12 +89,11 @@ public class UserNoticeEntity extends WithIdJpaEntity {
 		this.userId = userId;
 	}
 
-	public Boolean getRead() {
-		return read;
+	public Boolean getHasRead() {
+		return hasRead;
 	}
 
-	public void setRead(Boolean read) {
-		this.read = read;
+	public void setHasRead(Boolean hasRead) {
+		this.hasRead = hasRead;
 	}
-
 }

+ 1 - 4
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/NoticeService.java

@@ -17,10 +17,7 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfoQuery;
 import java.util.List;
 
 /**
- * 考试分数相关接口
- *
- * @author: fengdesheng
- * @since: 2018/8/31
+ * 用户通知接口
  */
 public interface NoticeService {
 

+ 5 - 5
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/UserNoticeInfo.java

@@ -47,7 +47,7 @@ public class UserNoticeInfo implements JsonSerializable {
      * 读取状态
      */
     @ApiModelProperty("读取状态")
-    private Boolean read;
+    private Boolean hasRead;
 
     public Long getId() {
         return id;
@@ -89,11 +89,11 @@ public class UserNoticeInfo implements JsonSerializable {
         this.publishTime = publishTime;
     }
 
-    public Boolean getRead() {
-        return read;
+    public Boolean getHasRead() {
+        return hasRead;
     }
 
-    public void setRead(Boolean read) {
-        this.read = read;
+    public void setHasRead(Boolean hasRead) {
+        this.hasRead = hasRead;
     }
 }

+ 5 - 5
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/UserNoticeInfoQuery.java

@@ -39,7 +39,7 @@ public class UserNoticeInfoQuery implements JsonSerializable {
      * 是否已读(true,已读;false,未读)
      */
     @ApiModelProperty("是否已读")
-    private Boolean read;
+    private Boolean hasRead;
 
     public Long getRootOrgId() {
         return rootOrgId;
@@ -57,12 +57,12 @@ public class UserNoticeInfoQuery implements JsonSerializable {
         this.userId = userId;
     }
 
-    public Boolean getRead() {
-        return read;
+    public Boolean getHasRead() {
+        return hasRead;
     }
 
-    public void setRead(Boolean read) {
-        this.read = read;
+    public void setHasRead(Boolean hasRead) {
+        this.hasRead = hasRead;
     }
 
     public UserType getUserType() {

+ 12 - 4
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/NoticeServiceImpl.java

@@ -19,7 +19,9 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfoQuery;
 import com.mysql.cj.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
 
+import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.Predicate;
 import java.util.ArrayList;
 import java.util.List;
@@ -32,6 +34,7 @@ import java.util.stream.Collectors;
  * @Date 2019/7/2 17:41
  * @Version 1.0
  */
+@Service("noticeService")
 public class NoticeServiceImpl implements NoticeService {
     @Autowired
     private NoticeRepo noticeRepo;
@@ -43,8 +46,8 @@ public class NoticeServiceImpl implements NoticeService {
     public List<UserNoticeInfo> getNoticeList(UserNoticeInfoQuery query) {
         List<UserNoticeInfo> resultList = new ArrayList<>();
         List<UserNoticeEntity> userNoticeList;
-        if (query.getRead()!=null){
-            userNoticeList = userNoticeRepo.findByRootOrgIdAndUserTypeAndUserIdAndRead(query.getRootOrgId(),query.getUserType(), query.getUserId(),query.getRead());
+        if (query.getHasRead()!=null){
+            userNoticeList = userNoticeRepo.findByRootOrgIdAndUserTypeAndUserIdAndHasRead(query.getRootOrgId(),query.getUserType(), query.getUserId(),query.getHasRead());
         }else {
             userNoticeList = userNoticeRepo.findByRootOrgIdAndUserTypeAndUserId(query.getRootOrgId(),query.getUserType(), query.getUserId());
         }
@@ -62,7 +65,7 @@ public class NoticeServiceImpl implements NoticeService {
                 info.setContent(noticeEntity.getContent());
                 info.setPublisher(noticeEntity.getPublisher());
                 info.setPublishTime(noticeEntity.getPublishTime());
-                info.setRead(un.getRead());
+                info.setHasRead(un.getHasRead());
                 resultList.add(info);
             }
         }
@@ -89,8 +92,13 @@ public class NoticeServiceImpl implements NoticeService {
                 }
                 //获取相应发布状态的通知id集合
                 List<Long> noticeIdList = byPublishStatusNoticeScheduleList.stream().map(NoticePublishScheduleEntity::getNoticeId).collect(Collectors.toList());
-               // predicates.add(cb.in());
+                CriteriaBuilder.In<Object> inCriteriaBuilder = cb.in(root.get("id"));
+                for (Long nid:noticeIdList){
+                    inCriteriaBuilder.value(nid);
+                }
+                predicates.add(inCriteriaBuilder);
             }
+
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
         //TODO