Переглянути джерело

1.提交考务学生端调用的相关代码,后台代码未完成,一会继续
2.添加两个待修复的fixme注释
3.修复获取考题接口的一个bug

lideyin 6 роки тому
батько
коміт
7bc8db17f8
15 змінених файлів з 941 додано та 0 видалено
  1. 101 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/NoticeController.java
  2. 103 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/NoticeDomain.java
  3. 47 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/NoticeDomainQuery.java
  4. 102 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/UserNoticeDomain.java
  5. 34 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/UserNoticeDomainQuery.java
  6. 14 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticePublishScheduleRepo.java
  7. 10 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticeReceiverRuleRepo.java
  8. 13 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticeRepo.java
  9. 22 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/UserNoticeRepo.java
  10. 51 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/NoticeService.java
  11. 103 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/NoticeInfo.java
  12. 58 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/NoticeInfoQuery.java
  13. 99 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/UserNoticeInfo.java
  14. 75 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/UserNoticeInfoQuery.java
  15. 109 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/NoticeServiceImpl.java

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

@@ -0,0 +1,101 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:28:03.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.api.controller;
+
+import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.examwork.api.controller.bean.*;
+import cn.com.qmth.examcloud.core.examwork.service.NoticeService;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfoQuery;
+import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfoQuery;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import com.mysql.cj.util.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 考试分数相关接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/8/27
+ */
+@RestController
+@Api(tags = "考试分数相关接口")
+@RequestMapping("${$rmp.ctr.oe}/notice")
+public class NoticeController extends ControllerSupport {
+    @Autowired
+    private NoticeService noticeService;
+
+    @ApiOperation(value = "分页查询消息列表", notes = "带条件带分页")
+    @GetMapping("getPagedNoticeList/{curPage}/{pageSize}")
+    public PageInfo<NoticeDomain> getPagedNoticeList(@PathVariable Integer curPage,
+                                                     @PathVariable Integer pageSize, NoticeDomainQuery query) {
+
+        NoticeInfoQuery infoQuery= new NoticeInfoQuery();
+        PageInfo<NoticeInfo> pagedNoticeInfo =  noticeService.getPagedNoticeList(curPage,pageSize,infoQuery);
+        // TOOD
+        return null;
+    }
+
+    @GetMapping("/getUserNoticeList")
+    @ApiOperation(value = "获取用户公告列表")
+    public List<UserNoticeDomain> getUserNoticeList(UserNoticeDomainQuery query) {
+        List<UserNoticeDomain> resultList = new ArrayList<>();
+        UserNoticeInfoQuery noticeQuery = getNoticeQuery(query);
+
+        List<UserNoticeInfo> noticeInfoList = noticeService.getNoticeList(noticeQuery);
+
+        if (null != noticeInfoList && !noticeInfoList.isEmpty()) {
+            resultList = getNoticeDomainList(noticeInfoList);
+        }
+        return resultList;
+    }
+
+    @PostMapping("/updateNoticeReadStatus")
+    @ApiOperation(value = "更新通知状态为已读")
+    public void updateNoticeReadStatus(@RequestParam(required = true) String noticeId) {
+        if (StringUtils.isNullOrEmpty(noticeId)) {
+            throw new StatusException("100001", "通知id不允许为空");
+        }
+        User user = this.getAccessUser();
+        noticeService.updateNoticeReadStatus(noticeId, user.getUserType(), user.getUserId());
+    }
+
+    private UserNoticeInfoQuery getNoticeQuery(UserNoticeDomainQuery query) {
+        User user = this.getAccessUser();
+        UserNoticeInfoQuery noticeQuery = new UserNoticeInfoQuery();
+        noticeQuery.setRead(query.getRead());
+        noticeQuery.setRootOrgId(user.getRootOrgId());
+        noticeQuery.setUserId(user.getUserId());
+        noticeQuery.setUserType(user.getUserType());
+        return noticeQuery;
+    }
+
+    private List<UserNoticeDomain> getNoticeDomainList(List<UserNoticeInfo> noticeInfoList) {
+        List<UserNoticeDomain> resultList = new ArrayList<>();
+        for (UserNoticeInfo info : noticeInfoList) {
+            UserNoticeDomain domain = new UserNoticeDomain();
+            domain.setContent(info.getContent());
+            domain.setId(info.getId());
+            domain.setPublisher(info.getPublisher());
+            domain.setPublishTime(info.getPublishTime());
+            domain.setRead(info.getRead());
+            domain.setTitle(info.getTitle());
+            resultList.add(domain);
+        }
+        return resultList;
+    }
+}

+ 103 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/NoticeDomain.java

@@ -0,0 +1,103 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:22.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import cn.com.qmth.examcloud.api.commons.enums.PublishStatus;
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * 考试分数信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/8/31
+ */
+public class NoticeDomain implements JsonSerializable {
+
+    private static final long serialVersionUID = -7739022488162924094L;
+    /**
+     * 公告id
+     */
+    @ApiModelProperty("公告id")
+    private Long id;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 发送对象
+     */
+    @ApiModelProperty("发送对象")
+    private String receiverObject;
+    /**
+     * 发布者
+     */
+    @ApiModelProperty("发布者")
+    private String publisher;
+    /**
+     * 发布时间
+     */
+    @ApiModelProperty("发布时间")
+    private Date publishTime;
+    /**
+     * 发送状态
+     */
+    @ApiModelProperty("发送状态")
+    private PublishStatus publishStatus;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getReceiverObject() {
+        return receiverObject;
+    }
+
+    public void setReceiverObject(String receiverObject) {
+        this.receiverObject = receiverObject;
+    }
+
+    public String getPublisher() {
+        return publisher;
+    }
+
+    public void setPublisher(String publisher) {
+        this.publisher = publisher;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public void setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+    }
+
+    public PublishStatus getPublishStatus() {
+        return publishStatus;
+    }
+
+    public void setPublishStatus(PublishStatus publishStatus) {
+        this.publishStatus = publishStatus;
+    }
+}

+ 47 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/NoticeDomainQuery.java

@@ -0,0 +1,47 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:03.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 公告查询类
+ */
+@ApiModel
+public class NoticeDomainQuery implements JsonSerializable {
+
+    private static final long serialVersionUID = -1962646957678995495L;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 是否已读(true,已读;false,未读)
+     */
+    @ApiModelProperty("是否已读")
+    private Boolean read;
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public Boolean getRead() {
+        return read;
+    }
+
+    public void setRead(Boolean read) {
+        this.read = read;
+    }
+}

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

@@ -0,0 +1,102 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:22.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * 考试分数信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/8/31
+ */
+public class UserNoticeDomain implements JsonSerializable {
+
+    private static final long serialVersionUID = -7739022488162924094L;
+    /**
+     * 公告id
+     */
+    @ApiModelProperty("公告id")
+    private Long id;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 内容
+     */
+    @ApiModelProperty("内容")
+    private String content;
+    /**
+     * 发布者
+     */
+    @ApiModelProperty("发布者")
+    private String publisher;
+    /**
+     * 发布时间
+     */
+    @ApiModelProperty("发布时间")
+    private Date publishTime;
+    /**
+     * 读取状态
+     */
+    @ApiModelProperty("读取状态")
+    private Boolean read;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getPublisher() {
+        return publisher;
+    }
+
+    public void setPublisher(String publisher) {
+        this.publisher = publisher;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public void setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+    }
+
+    public Boolean getRead() {
+        return read;
+    }
+
+    public void setRead(Boolean read) {
+        this.read = read;
+    }
+}

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

@@ -0,0 +1,34 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:03.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 公告查询类
+ */
+@ApiModel
+public class UserNoticeDomainQuery implements JsonSerializable {
+
+    private static final long serialVersionUID = -1962646957678995495L;
+    /**
+     * 是否已读(true,已读;false,未读)
+     */
+    @ApiModelProperty("是否已读")
+    private Boolean read;
+
+    public Boolean getRead() {
+        return read;
+    }
+
+    public void setRead(Boolean read) {
+        this.read = read;
+    }
+}

+ 14 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticePublishScheduleRepo.java

@@ -0,0 +1,14 @@
+package cn.com.qmth.examcloud.core.examwork.dao;
+
+import cn.com.qmth.examcloud.api.commons.enums.PublishStatus;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticePublishScheduleEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.List;
+
+public interface NoticePublishScheduleRepo extends JpaRepository<NoticePublishScheduleEntity, Long>,
+        QueryByExampleExecutor<NoticePublishScheduleEntity>, JpaSpecificationExecutor<NoticePublishScheduleEntity> {
+    List<NoticePublishScheduleEntity> findByRootOrgIdAndPublishStatus(Long rootOrgId, PublishStatus publishStatus);
+}

+ 10 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticeReceiverRuleRepo.java

@@ -0,0 +1,10 @@
+package cn.com.qmth.examcloud.core.examwork.dao;
+
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeReceiverRuleEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+public interface NoticeReceiverRuleRepo extends JpaRepository<NoticeReceiverRuleEntity, Long>,
+        QueryByExampleExecutor<NoticeReceiverRuleEntity>, JpaSpecificationExecutor<NoticeReceiverRuleEntity> {
+}

+ 13 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/NoticeRepo.java

@@ -0,0 +1,13 @@
+package cn.com.qmth.examcloud.core.examwork.dao;
+
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.List;
+
+public interface NoticeRepo extends JpaRepository<NoticeEntity, Long>,
+        QueryByExampleExecutor<NoticeEntity>, JpaSpecificationExecutor<NoticeEntity> {
+    List<NoticeEntity> findByIdIn(List<Long> ids);
+}

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

@@ -0,0 +1,22 @@
+package cn.com.qmth.examcloud.core.examwork.dao;
+
+import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.UserNoticeEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.List;
+
+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);
+
+    @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);
+}

+ 51 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/NoticeService.java

@@ -0,0 +1,51 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:28:53.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.service;
+
+import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfoQuery;
+import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfoQuery;
+
+import java.util.List;
+
+/**
+ * 考试分数相关接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/8/31
+ */
+public interface NoticeService {
+
+    /**
+     * 获取用户通知列表
+     * @param query
+     * @return
+     */
+    List<UserNoticeInfo> getNoticeList(UserNoticeInfoQuery query);
+
+    /**
+     *  更新用户的通知状态为已读
+     * @param noticeId  通知id(多个以逗号分隔)
+     * @param userType 用户类型
+     * @param userId 用户id
+     * @return
+     */
+    int updateNoticeReadStatus(String noticeId, UserType userType, Long userId);
+
+    /**
+     * 分页获取通知列表
+     * @param curPage
+     * @param pageSize
+     * @param infoQuery
+     * @return
+     */
+    PageInfo<NoticeInfo> getPagedNoticeList(Integer curPage, Integer pageSize, NoticeInfoQuery infoQuery);
+}

+ 103 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/NoticeInfo.java

@@ -0,0 +1,103 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:22.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.enums.PublishStatus;
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * 考试分数信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/8/31
+ */
+public class NoticeInfo implements JsonSerializable {
+
+    private static final long serialVersionUID = -7739022488162924094L;
+    /**
+     * 公告id
+     */
+    @ApiModelProperty("公告id")
+    private Long id;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 发送对象
+     */
+    @ApiModelProperty("发送对象")
+    private String receiverObject;
+    /**
+     * 发布者
+     */
+    @ApiModelProperty("发布者")
+    private String publisher;
+    /**
+     * 发布时间
+     */
+    @ApiModelProperty("发布时间")
+    private Date publishTime;
+    /**
+     * 发送状态
+     */
+    @ApiModelProperty("发送状态")
+    private PublishStatus publishStatus;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getReceiverObject() {
+        return receiverObject;
+    }
+
+    public void setReceiverObject(String receiverObject) {
+        this.receiverObject = receiverObject;
+    }
+
+    public String getPublisher() {
+        return publisher;
+    }
+
+    public void setPublisher(String publisher) {
+        this.publisher = publisher;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public void setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+    }
+
+    public PublishStatus getPublishStatus() {
+        return publishStatus;
+    }
+
+    public void setPublishStatus(PublishStatus publishStatus) {
+        this.publishStatus = publishStatus;
+    }
+}

+ 58 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/NoticeInfoQuery.java

@@ -0,0 +1,58 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:03.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.enums.PublishStatus;
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 公告查询类
+ */
+@ApiModel
+public class NoticeInfoQuery implements JsonSerializable {
+
+    private static final long serialVersionUID = -1962646957678995495L;
+
+    private Long rootOrgId;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 发送状态
+     */
+    @ApiModelProperty("发送状态")
+    private PublishStatus publishStatus;
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public PublishStatus getPublishStatus() {
+        return publishStatus;
+    }
+
+    public void setPublishStatus(PublishStatus publishStatus) {
+        this.publishStatus = publishStatus;
+    }
+}

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

@@ -0,0 +1,99 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:22.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * 用户通知详情
+ */
+public class UserNoticeInfo implements JsonSerializable {
+
+    private static final long serialVersionUID = -7739022488162924094L;
+    /**
+     * 公告id
+     */
+    @ApiModelProperty("公告id")
+    private Long id;
+    /**
+     * 标题
+     */
+    @ApiModelProperty("标题")
+    private String title;
+    /**
+     * 内容
+     */
+    @ApiModelProperty("内容")
+    private String content;
+    /**
+     * 发布者
+     */
+    @ApiModelProperty("发布者")
+    private String publisher;
+    /**
+     * 发布时间
+     */
+    @ApiModelProperty("发布时间")
+    private Date publishTime;
+    /**
+     * 读取状态
+     */
+    @ApiModelProperty("读取状态")
+    private Boolean read;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getPublisher() {
+        return publisher;
+    }
+
+    public void setPublisher(String publisher) {
+        this.publisher = publisher;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public void setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+    }
+
+    public Boolean getRead() {
+        return read;
+    }
+
+    public void setRead(Boolean read) {
+        this.read = read;
+    }
+}

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

@@ -0,0 +1,75 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-31 09:35:03.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.examwork.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 公告查询类
+ */
+@ApiModel
+public class UserNoticeInfoQuery implements JsonSerializable {
+
+    private static final long serialVersionUID = -1962646957678995495L;
+    /**
+     * 学校id
+     */
+    @ApiModelProperty("学校id")
+    private Long rootOrgId;
+    /**
+     * 用户类型
+     */
+    @ApiModelProperty("用户类型")
+    private UserType userType;
+
+    /**
+     * 用户id
+     */
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+     * 是否已读(true,已读;false,未读)
+     */
+    @ApiModelProperty("是否已读")
+    private Boolean read;
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Boolean getRead() {
+        return read;
+    }
+
+    public void setRead(Boolean read) {
+        this.read = read;
+    }
+
+    public UserType getUserType() {
+        return userType;
+    }
+
+    public void setUserType(UserType userType) {
+        this.userType = userType;
+    }
+}

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

@@ -0,0 +1,109 @@
+package cn.com.qmth.examcloud.core.examwork.service.impl;
+
+import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
+import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.util.DBUtil;
+import cn.com.qmth.examcloud.commons.util.StringUtil;
+import cn.com.qmth.examcloud.core.examwork.dao.NoticePublishScheduleRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.NoticeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.UserNoticeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticeEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.NoticePublishScheduleEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.UserNoticeEntity;
+import cn.com.qmth.examcloud.core.examwork.service.NoticeService;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.NoticeInfoQuery;
+import cn.com.qmth.examcloud.core.examwork.service.bean.UserNoticeInfo;
+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 javax.persistence.criteria.Predicate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * @Description 通知实现类
+ * @Author lideyin
+ * @Date 2019/7/2 17:41
+ * @Version 1.0
+ */
+public class NoticeServiceImpl implements NoticeService {
+    @Autowired
+    private NoticeRepo noticeRepo;
+    @Autowired
+    private UserNoticeRepo userNoticeRepo;
+    @Autowired
+    private NoticePublishScheduleRepo noticePublishScheduleRepo;
+    @Override
+    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());
+        }else {
+            userNoticeList = userNoticeRepo.findByRootOrgIdAndUserTypeAndUserId(query.getRootOrgId(),query.getUserType(), query.getUserId());
+        }
+        if (null!=userNoticeList && !userNoticeList.isEmpty()){
+            List<Long> noticeIdList = userNoticeList.stream().map(UserNoticeEntity::getNoticeId).collect(Collectors.toList());
+            List<NoticeEntity> noticeList = noticeRepo.findByIdIn(noticeIdList);
+            for (UserNoticeEntity un : userNoticeList){
+                NoticeEntity noticeEntity =getNoticeById(noticeList,un.getNoticeId());
+                if (noticeEntity==null){
+                    throw new StatusException("500001","找不到id为:"+un.getNoticeId()+"的通知");
+                }
+                UserNoticeInfo info = new UserNoticeInfo();
+                info.setId(noticeEntity.getId());
+                info.setTitle(noticeEntity.getTitle());
+                info.setContent(noticeEntity.getContent());
+                info.setPublisher(noticeEntity.getPublisher());
+                info.setPublishTime(noticeEntity.getPublishTime());
+                info.setRead(un.getRead());
+                resultList.add(info);
+            }
+        }
+        return resultList;
+    }
+
+    @Override
+    public int updateNoticeReadStatus(String noticeId, UserType userType, Long userId) {
+        return userNoticeRepo.updateNoticeReadStatus(noticeId,userType,userId);
+    }
+
+    @Override
+    public PageInfo<NoticeInfo> getPagedNoticeList(Integer curPage, Integer pageSize, NoticeInfoQuery infoQuery) {
+        Specification<NoticeEntity> specification = (root,query,cb)->{
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(cb.equal(root.get("rootOrgId"),infoQuery.getPublishStatus()));
+            if (!StringUtils.isNullOrEmpty(infoQuery.getTitle())){
+                predicates.add(cb.like(root.get("title"), DBUtil.toSqlSearchPattern(infoQuery.getTitle())));
+            }
+            if(null!=infoQuery.getPublishStatus()){
+                List<NoticePublishScheduleEntity> byPublishStatusNoticeScheduleList = noticePublishScheduleRepo.findByRootOrgIdAndPublishStatus(infoQuery.getRootOrgId(), infoQuery.getPublishStatus());
+                if (null == byPublishStatusNoticeScheduleList || byPublishStatusNoticeScheduleList.isEmpty()){
+                    throw  new StatusException("500001","通知发布状态数据异常");
+                }
+                //获取相应发布状态的通知id集合
+                List<Long> noticeIdList = byPublishStatusNoticeScheduleList.stream().map(NoticePublishScheduleEntity::getNoticeId).collect(Collectors.toList());
+               // predicates.add(cb.in());
+            }
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+        //TODO
+        return  null;
+    }
+
+
+    private NoticeEntity getNoticeById(List<NoticeEntity> noticeList, Long noticeId) {
+        Optional<NoticeEntity> optional = noticeList.stream().filter(p -> p.getId().equals(noticeId)).findFirst();
+        if (optional.isPresent()){
+            return optional.get();
+        }else{
+            return null;
+        }
+    }
+}