Reiskuchen 5 anni fa
parent
commit
9d6d31bf0c

+ 37 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/InformationController.java

@@ -0,0 +1,37 @@
+package com.management.platform.controller;
+
+
+import com.management.platform.service.InformationService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-18
+ */
+@RestController
+@RequestMapping("/information")
+public class InformationController {
+    @Autowired
+    private InformationService informationService;
+
+    @RequestMapping("/list")
+    public HttpRespMsg getInformationList(HttpServletRequest request) {
+        return informationService.getInformationList(request);
+    }
+
+    @RequestMapping("/check")
+    public HttpRespMsg checkInformation(@RequestParam Integer id, HttpServletRequest request) {
+        return informationService.checkInformation(id, request);
+    }
+}
+

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -108,10 +108,10 @@ public class ReportController {
     /**
      * 获取所有未审批通过的报告
      */
-    @RequestMapping("/uncensoredList")
-    public HttpRespMsg getUncensoredList(HttpServletRequest request) {
-        return reportService.getUncensoredList(request);
-    }
+//    @RequestMapping("/uncensoredList")
+//    public HttpRespMsg getUncensoredList(HttpServletRequest request) {
+//        return reportService.getUncensoredList(request);
+//    }
 
     /**
      * 审批通过报告

+ 70 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Information.java

@@ -0,0 +1,70 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 提示消息
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class Information extends Model<Information> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 消息所有者
+     */
+    @TableField("user_id")
+    private String userId;
+
+    /**
+     * 类型 0-审批未通过或撤销
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * 具体内容
+     */
+    @TableField("content")
+    private String content;
+
+    /**
+     * 时间
+     */
+    @TableField("time")
+    private LocalDateTime time;
+
+    /**
+     * 是否被查看
+     */
+    @TableField("checked")
+    private Integer checked;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/InformationMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.Information;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-18
+ */
+public interface InformationMapper extends BaseMapper<Information> {
+
+}

+ 21 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/InformationService.java

@@ -0,0 +1,21 @@
+package com.management.platform.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.entity.Information;
+import com.management.platform.util.HttpRespMsg;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-18
+ */
+public interface InformationService extends IService<Information> {
+    HttpRespMsg getInformationList(HttpServletRequest request);
+
+    HttpRespMsg checkInformation(Integer id, HttpServletRequest request);
+}

+ 62 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/InformationServiceImpl.java

@@ -0,0 +1,62 @@
+package com.management.platform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.entity.Information;
+import com.management.platform.mapper.InformationMapper;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.InformationService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-18
+ */
+@Service
+public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements InformationService {
+
+    @Resource
+    private InformationMapper informationMapper;
+
+    @Resource
+    private UserMapper userMapper;
+
+    @Override
+    public HttpRespMsg getInformationList(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            String userId = userMapper.selectById(request.getHeader("Token")).getId();
+            httpRespMsg.data = informationMapper.selectList(new QueryWrapper<Information>()
+                    .eq("user_id", userId).orderByDesc("time").last("LIMIT 10"));
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+
+    @Override
+    public HttpRespMsg checkInformation(Integer id, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            Information information = informationMapper.selectById(id).setChecked(1);
+            if (information != null) {
+                informationMapper.updateById(information);
+            } else {
+                httpRespMsg.setError("未检查到相关信息");
+            }
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+}

+ 3 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -2,10 +2,7 @@ package com.management.platform.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.entity.Project;
-import com.management.platform.entity.Report;
-import com.management.platform.entity.TimeCalculation;
-import com.management.platform.entity.User;
+import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.ReportService;
 import com.management.platform.util.HttpRespMsg;
@@ -44,10 +41,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private TimeCalculationMapper timeCalculationMapper;
     @Resource
     private ProjectMapper projectMapper;
-
     @Resource
-    private TimeCalculationShowMapper timeCalculationShowMapper;
-
+    private InformationMapper informationMapper;
 
     @Value(value = "${upload.path}")
     private String path;
@@ -267,6 +262,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             } else {
                 reportMapper.update(new Report().setState(2),
                         new QueryWrapper<Report>().eq("creator_id", id).eq("create_date", date));
+                informationMapper.insert(new Information().setType(0).setContent(date).setUserId(id));
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CodeGenerator.java

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

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/InformationMapper.xml

@@ -0,0 +1,20 @@
+<?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.management.platform.mapper.InformationMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.Information">
+        <id column="id" property="id" />
+        <result column="user_id" property="userId" />
+        <result column="type" property="type" />
+        <result column="content" property="content" />
+        <result column="time" property="time" />
+        <result column="checked" property="checked" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, user_id, type, content, time, checked
+    </sql>
+
+</mapper>