瀏覽代碼

消息列表

quyueting 5 年之前
父節點
當前提交
249fa584ce

+ 2 - 2
.gitignore

@@ -11,5 +11,5 @@ out
 gen
 /.idea/misc.xml
 /.idea/modules.xml
-/.idea/workspace.xml
-/.project
+/.idea/workspace.xml
+/.project

+ 50 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/VnoticeUserController.java

@@ -0,0 +1,50 @@
+package com.hssx.cloudmodel.controller;
+
+
+import com.hssx.cloudmodel.entity.NewsNotice;
+import com.hssx.cloudmodel.entity.VnoticeUser;
+import com.hssx.cloudmodel.service.VnoticeUserService;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * <p>
+ * VIEW 前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-10
+ */
+@RestController
+@RequestMapping("/vnoticeuser")
+public class VnoticeUserController {
+    @Autowired
+    private VnoticeUserService vnoticeUserService;
+
+    /**
+     * 消息通知列表
+     * 默认显示五条的参数:token 登陆者的用户凭证,flag = 0,(默认显示最近五条)
+     * 查看全部时传的参数:token 登陆者的用户凭证,flag = 0,pageNum 当前页码,pageSize 每页条数,
+     * (筛选字段:notice_type 0-审批,1-告警,2-保养)(默认不传)
+     * @return
+     */
+    @ApiOperation("消息通知列表")
+    @RequestMapping("/list")
+    @ResponseBody
+    public HttpRespMsg deleteRole(HttpServletRequest request, String token,
+                                  HttpServletResponse response, PageUtil page, Integer flag) {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = vnoticeUserService.pageList(page, token);
+        return msg;
+    }
+}
+

+ 3 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/MouldFile.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -43,6 +45,7 @@ public class MouldFile extends Model<MouldFile> {
      * 上传时间
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**

+ 9 - 87
cloud-model/src/main/java/com/hssx/cloudmodel/entity/NewsNotice.java

@@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
 import java.io.Serializable;
 
 /**
@@ -16,7 +14,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-08-09
+ * @since 2019-08-10
  */
 @TableName("tb_news_notice")
 public class NewsNotice extends Model<NewsNotice> {
@@ -42,10 +40,10 @@ public class NewsNotice extends Model<NewsNotice> {
     private String projectName;
 
     /**
-     * 模具id(针对消息提醒类型1,2)
+     * 引用的外部表id(模具,文档,设备)
      */
-    @TableField("mould_id")
-    private Integer mouldId;
+    @TableField("ref_id")
+    private Integer refId;
 
     /**
      * 消息提醒类型0-审批,1-保养,2-告警
@@ -59,41 +57,10 @@ public class NewsNotice extends Model<NewsNotice> {
     @TableField("content")
     private String content;
 
-    /**
-     * 模具编号(针对消息提醒类型1)
-     */
-    @TableField("mould_no")
-    private String mouldNo;
-
-    /**
-     * 文件id
-     */
-    @TableField("file_id")
-    private Integer fileId;
-
-    /**
-     * 文件所属类型
-     */
-    @TableField("file_blong_type")
-    private Integer fileBlongType;
-
-    /**
-     * 设备id(针对消息提醒类型2)
-     */
-    @TableField("equipment_id")
-    private Integer equipmentId;
-
-    /**
-     * 设备编号(针对消息提醒类型2)
-     */
-    @TableField("equipment_no")
-    private String equipmentNo;
-
     /**
      * 时间
      */
     @TableField("indate")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
 
@@ -121,12 +88,12 @@ public class NewsNotice extends Model<NewsNotice> {
         this.projectName = projectName;
     }
 
-    public Integer getMouldId() {
-        return mouldId;
+    public Integer getRefId() {
+        return refId;
     }
 
-    public void setMouldId(Integer mouldId) {
-        this.mouldId = mouldId;
+    public void setRefId(Integer refId) {
+        this.refId = refId;
     }
 
     public Integer getNoticeType() {
@@ -145,46 +112,6 @@ public class NewsNotice extends Model<NewsNotice> {
         this.content = content;
     }
 
-    public String getMouldNo() {
-        return mouldNo;
-    }
-
-    public void setMouldNo(String mouldNo) {
-        this.mouldNo = mouldNo;
-    }
-
-    public Integer getFileId() {
-        return fileId;
-    }
-
-    public void setFileId(Integer fileId) {
-        this.fileId = fileId;
-    }
-
-    public Integer getFileBlongType() {
-        return fileBlongType;
-    }
-
-    public void setFileBlongType(Integer fileBlongType) {
-        this.fileBlongType = fileBlongType;
-    }
-
-    public Integer getEquipmentId() {
-        return equipmentId;
-    }
-
-    public void setEquipmentId(Integer equipmentId) {
-        this.equipmentId = equipmentId;
-    }
-
-    public String getEquipmentNo() {
-        return equipmentNo;
-    }
-
-    public void setEquipmentNo(String equipmentNo) {
-        this.equipmentNo = equipmentNo;
-    }
-
     public LocalDateTime getIndate() {
         return indate;
     }
@@ -204,14 +131,9 @@ public class NewsNotice extends Model<NewsNotice> {
         "id=" + id +
         ", projectId=" + projectId +
         ", projectName=" + projectName +
-        ", mouldId=" + mouldId +
+        ", refId=" + refId +
         ", noticeType=" + noticeType +
         ", content=" + content +
-        ", mouldNo=" + mouldNo +
-        ", fileId=" + fileId +
-        ", fileBlongType=" + fileBlongType +
-        ", equipmentId=" + equipmentId +
-        ", equipmentNo=" + equipmentNo +
         ", indate=" + indate +
         "}";
     }

+ 185 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/VnoticeUser.java

@@ -0,0 +1,185 @@
+package com.hssx.cloudmodel.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * VIEW
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-10
+ */
+public class VnoticeUser extends Model<VnoticeUser> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 消息通知者表主键
+     */
+    @TableField("id")
+    private Integer id;
+
+    /**
+     * 通知者id
+     */
+    @TableField("user_id")
+    private Integer userId;
+
+    /**
+     * 是否已读 0-未读,1-已读
+     */
+    @TableField("is_read")
+    private Integer isRead;
+
+    /**
+     * 消息通知表id
+     */
+    @TableField("news_id")
+    private Integer newsId;
+
+    /**
+     * 项目id
+     */
+    @TableField("project_id")
+    private Integer projectId;
+
+    /**
+     * 项目名
+     */
+    @TableField("project_name")
+    private String projectName;
+
+    /**
+     * 消息提醒类型0-审批,1-保养,2-告警
+     */
+    @TableField("notice_type")
+    private Integer noticeType;
+
+    /**
+     * 引用的外部表id(模具,文档,设备)
+     */
+    @TableField("ref_id")
+    private Integer refId;
+
+    /**
+     * 内容
+     */
+    @TableField("content")
+    private String content;
+
+    /**
+     * 时间
+     */
+    @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime indate;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getIsRead() {
+        return isRead;
+    }
+
+    public void setIsRead(Integer isRead) {
+        this.isRead = isRead;
+    }
+
+    public Integer getNewsId() {
+        return newsId;
+    }
+
+    public void setNewsId(Integer newsId) {
+        this.newsId = newsId;
+    }
+
+    public Integer getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Integer projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    public Integer getNoticeType() {
+        return noticeType;
+    }
+
+    public void setNoticeType(Integer noticeType) {
+        this.noticeType = noticeType;
+    }
+
+    public Integer getRefId() {
+        return refId;
+    }
+
+    public void setRefId(Integer refId) {
+        this.refId = refId;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public LocalDateTime getIndate() {
+        return indate;
+    }
+
+    public void setIndate(LocalDateTime indate) {
+        this.indate = indate;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return "VnoticeUser{" +
+        "id=" + id +
+        ", userId=" + userId +
+        ", isRead=" + isRead +
+        ", newsId=" + newsId +
+        ", projectId=" + projectId +
+        ", projectName=" + projectName +
+        ", noticeType=" + noticeType +
+        ", refId=" + refId +
+        ", content=" + content +
+        ", indate=" + indate +
+        "}";
+    }
+}

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/VnoticeUserMapper.java

@@ -0,0 +1,16 @@
+package com.hssx.cloudmodel.mapper;
+
+import com.hssx.cloudmodel.entity.VnoticeUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * VIEW Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-10
+ */
+public interface VnoticeUserMapper extends BaseMapper<VnoticeUser> {
+
+}

+ 20 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/VnoticeUserService.java

@@ -0,0 +1,20 @@
+package com.hssx.cloudmodel.service;
+
+import com.hssx.cloudmodel.entity.NewsNotice;
+import com.hssx.cloudmodel.entity.VnoticeUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
+
+/**
+ * <p>
+ * VIEW 服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-10
+ */
+public interface VnoticeUserService extends IService<VnoticeUser> {
+
+    HttpRespMsg pageList(PageUtil page, String token);
+}

+ 53 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/VnoticeUserServiceImpl.java

@@ -0,0 +1,53 @@
+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.VnoticeUser;
+import com.hssx.cloudmodel.entity.vo.NewsNoticeVO;
+import com.hssx.cloudmodel.mapper.NewsNoticeMapper;
+import com.hssx.cloudmodel.mapper.UserMapper;
+import com.hssx.cloudmodel.mapper.VnoticeUserMapper;
+import com.hssx.cloudmodel.service.VnoticeUserService;
+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>
+ * VIEW 服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-10
+ */
+@Service
+public class VnoticeUserServiceImpl extends ServiceImpl<VnoticeUserMapper, VnoticeUser> implements VnoticeUserService {
+    @Resource
+    VnoticeUserMapper vnoticeUserMapper;
+    @Resource
+    UserMapper userMapper;
+    @Override
+    public HttpRespMsg pageList(PageUtil page, String token) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<VnoticeUser> list = new ArrayList<>();
+        User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl",token));
+        if(user != null){
+            //加载全部
+            PageHelper.startPage(page.getPageNum(),page.getPageSize());
+            list = vnoticeUserMapper.selectList(new QueryWrapper<VnoticeUser>().eq("user_id", user.getId()).orderByDesc("id"));
+            PageInfo<VnoticeUser> pageInfo = new PageInfo<VnoticeUser>(list);
+            msg.data = pageInfo;
+        }else{
+            msg.setError("用户不存在或者未登录");
+        }
+        return msg;
+    }
+}

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

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("tb_news_notice");
+        strategy.setInclude("vnotice_user");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 3 - 63
cloud-model/src/main/resources/mapper/NewsNoticeMapper.xml

@@ -7,75 +7,15 @@
         <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="ref_id" property="refId" />
         <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" />
     </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
+        id, project_id, project_name, ref_id, notice_type, content, 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>

+ 24 - 0
cloud-model/src/main/resources/mapper/VnoticeUserMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.cloudmodel.mapper.VnoticeUserMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.VnoticeUser">
+        <result column="id" property="id" />
+        <result column="user_id" property="userId" />
+        <result column="is_read" property="isRead" />
+        <result column="news_id" property="newsId" />
+        <result column="project_id" property="projectId" />
+        <result column="project_name" property="projectName" />
+        <result column="notice_type" property="noticeType" />
+        <result column="ref_id" property="refId" />
+        <result column="content" property="content" />
+        <result column="indate" property="indate" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, user_id, is_read, news_id, project_id, project_name, notice_type, ref_id, content, indate
+    </sql>
+
+</mapper>