Parcourir la source

时间标签的添加

il y a 5 ans
Parent
commit
9c19416f86

+ 8 - 4
cloud-model/src/main/java/com/hssx/cloudmodel/controller/NewsNoticeUserController.java

@@ -1,7 +1,9 @@
 package com.hssx.cloudmodel.controller;
 
 
+import com.hssx.cloudmodel.entity.NewsNotice;
 import com.hssx.cloudmodel.entity.NewsNoticeUser;
+import com.hssx.cloudmodel.entity.vo.NewsNoticeVO;
 import com.hssx.cloudmodel.service.NewsNoticeService;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import com.hssx.cloudmodel.util.PageUtil;
@@ -29,16 +31,18 @@ public class NewsNoticeUserController {
 
     /**
      * 消息通知列表
-     * 参数:id 登陆者的用户ID
+     * 默认显示五条的参数:token 登陆者的用户凭证,flag = 0,(默认显示最近五条)
+     * 查看全部时传的参数:token 登陆者的用户凭证,flag = 0,pageNum 当前页码,pageSize 每页条数,
+     * (筛选字段:notice_type 0-审批,1-告警,2-保养)(默认不传)
      * @return
      */
     @ApiOperation("消息通知列表")
     @RequestMapping("/list")
     @ResponseBody
-    public HttpRespMsg deleteRole(@RequestParam(required = false)String keyName, HttpServletRequest request,
-                                  HttpServletResponse response, PageUtil page, @RequestParam(required = false)Integer companyType) {
+    public HttpRespMsg deleteRole(NewsNotice newsNotice, HttpServletRequest request,String token,
+                                  HttpServletResponse response, PageUtil page,Integer flag) {
         HttpRespMsg msg = new HttpRespMsg();
-//        msg = companyService.pageList(page,keyName,companyType);
+        msg = newsNoticeService.pageList(newsNotice,page,flag,token);
         return msg;
     }
 

+ 30 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/NewsNoticeVO.java

@@ -0,0 +1,30 @@
+package com.hssx.cloudmodel.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.hssx.cloudmodel.entity.NewsNotice;
+import lombok.Data;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 08 - 10 9:12
+ * Description:<描述>
+ * Version: 1.0
+ */
+@Data
+public class NewsNoticeVO extends NewsNotice {
+    /**
+     * 通知者id
+     */
+    private Integer userId;
+
+    /**
+     * 是否已读 0-未读,1-已读
+     */
+    private Integer isRead;
+
+    /**
+     * 消息通知表id
+     */
+    private Integer newsId;
+
+}

+ 8 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/NewsNoticeMapper.java

@@ -2,6 +2,11 @@ package com.hssx.cloudmodel.mapper;
 
 import com.hssx.cloudmodel.entity.NewsNotice;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.entity.vo.NewsNoticeVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface NewsNoticeMapper extends BaseMapper<NewsNotice> {
 
+    List<NewsNoticeVO> selectNewestFiveUnreadNewsByUserId(@Param("user") User user);
+
+    List<NewsNoticeVO> selectAllUnreadNewsByUserId(@Param("user")User user, @Param("newsNotice")NewsNotice newsNotice);
 }

+ 3 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/NewsNoticeService.java

@@ -2,6 +2,8 @@ package com.hssx.cloudmodel.service;
 
 import com.hssx.cloudmodel.entity.NewsNotice;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
 
 /**
  * <p>
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface NewsNoticeService extends IService<NewsNotice> {
 
+    HttpRespMsg pageList(NewsNotice newsNotice,PageUtil page,Integer flag,String token);
 }

+ 38 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/NewsNoticeServiceImpl.java

@@ -1,11 +1,23 @@
 package com.hssx.cloudmodel.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.hssx.cloudmodel.entity.NewsNotice;
+import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.entity.vo.NewsNoticeVO;
 import com.hssx.cloudmodel.mapper.NewsNoticeMapper;
+import com.hssx.cloudmodel.mapper.UserMapper;
 import com.hssx.cloudmodel.service.NewsNoticeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -16,5 +28,31 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class NewsNoticeServiceImpl extends ServiceImpl<NewsNoticeMapper, NewsNotice> implements NewsNoticeService {
+    @Resource
+    NewsNoticeMapper newsNoticeMapper;
+    @Resource
+    UserMapper userMapper;
 
+    @Override
+    public HttpRespMsg pageList(NewsNotice newsNotice,PageUtil page,Integer flag,String token) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<NewsNoticeVO> list = new ArrayList<>();
+        User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl",token));
+        if(user != null){
+            if(flag == 0){
+                //显示最近五条的未读消息
+                list = newsNoticeMapper.selectNewestFiveUnreadNewsByUserId(user);
+                msg.data = list;
+            }else if(flag == 1){
+                //加载全部
+                PageHelper.startPage(page.getPageNum(),page.getPageSize());
+                list = newsNoticeMapper.selectAllUnreadNewsByUserId(user,newsNotice);
+                PageInfo<NewsNoticeVO> pageInfo = new PageInfo<>(list);
+                msg.data = pageInfo;
+            }
+        }else{
+            msg.setError("用户不存在或者未登录");
+        }
+        return msg;
+    }
 }

+ 1 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/util/NewsNoticeTemplate.java

@@ -7,4 +7,5 @@ package com.hssx.cloudmodel.util;
  * Version: 1.0
  */
 public class NewsNoticeTemplate {
+
 }

+ 56 - 1
cloud-model/src/main/resources/mapper/NewsNoticeMapper.xml

@@ -17,10 +17,65 @@
         <result column="equipment_no" property="equipmentNo" />
         <result column="indate" property="indate" />
     </resultMap>
+    <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.NewsNoticeVO">
+        <id column="id" property="id" />
+        <result column="project_id" property="projectId" />
+        <result column="project_name" property="projectName" />
+        <result column="mould_id" property="mouldId" />
+        <result column="notice_type" property="noticeType" />
+        <result column="content" property="content" />
+        <result column="mould_no" property="mouldNo" />
+        <result column="file_id" property="fileId" />
+        <result column="file_blong_type" property="fileBlongType" />
+        <result column="equipment_id" property="equipmentId" />
+        <result column="equipment_no" property="equipmentNo" />
+        <result column="indate" property="indate" />
+        <result column="user_id" property="userId" />
+        <result column="is_read" property="isRead" />
+    </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, project_id, project_name, mould_id, notice_type, content, mould_no, file_id, file_blong_type, equipment_id, equipment_no, indate
     </sql>
-
+<!--未读的最新五条消息-->
+    <select id="selectNewestFiveUnreadNewsByUserId" resultMap="BaseResultMapVO">
+        select
+        tnn.id, tnn.project_id, tnn.project_name, tnn.mould_id, tnn.notice_type,
+        tnn.content, tnn.mould_no, tnn.file_id, tnn.file_blong_type,
+        tnn.equipment_id, tnn.equipment_no, tnn.indate,tnnu.user_id,tnnu.is_read
+        from
+          tb_news_notice tnn
+        left join
+          tb_news_notice_user tnnu
+        on
+          tnn.id = tnnu.news_id
+        where
+          tnnu.user_id = #{user.id}
+        and
+          tnnu.is_read = 0
+        limit
+          0,5
+    </select>
+    <!--未读的全部消息-->
+    <select id="selectAllUnreadNewsByUserId" resultMap="BaseResultMapVO">
+        select
+        tnn.id, tnn.project_id, tnn.project_name, tnn.mould_id, tnn.notice_type,
+        tnn.content, tnn.mould_no, tnn.file_id, tnn.file_blong_type,
+        tnn.equipment_id, tnn.equipment_no, tnn.indate,tnnu.user_id,tnnu.is_read
+        from
+          tb_news_notice tnn
+        left join
+          tb_news_notice_user tnnu
+        on
+          tnn.id = tnnu.news_id
+        <where>
+              tnnu.user_id = #{user.id}
+            and
+              tnnu.is_read = 0
+            <if test="newsNotice.noticeType != null">
+               and tnn.notice_type = #{newsNotice.noticeType}
+            </if>
+        </where>
+    </select>
 </mapper>