Reiskuchen 5 năm trước cách đây
mục cha
commit
a2cc04776b

+ 6 - 16
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java

@@ -1,7 +1,9 @@
 package com.management.platform.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDate;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -44,27 +46,15 @@ public class Report extends Model<Report> {
     private Boolean reportType;
 
     /**
-     * 报告年份
+     * 日期
      */
-    @TableField("year")
-    private Integer year;
-
-    /**
-     * 报告月份
-     */
-    @TableField("month")
-    private Integer month;
-
-    /**
-     * 报告日 月报没有此项
-     */
-    @TableField("day")
-    private Integer day;
+    @TableField("create_date")
+    private LocalDate createDate;
 
     /**
      * 报告内容
      */
-    @TableField("content")
+    @TableField(value = "content", updateStrategy = FieldStrategy.IGNORED)
     private String content;
 
     /**

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -2,6 +2,7 @@ package com.management.platform.service;
 
 import com.management.platform.entity.Report;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.util.HttpRespMsg;
 
 /**
  * <p>
@@ -12,5 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2019-12-31
  */
 public interface ReportService extends IService<Report> {
-
+    HttpRespMsg getReportList(Integer creatorId, Integer reportType, String startDate, String end);
+    HttpRespMsg editReport(Integer reportId, String content);
+    HttpRespMsg deleteReport(Integer reportId);
 }

+ 62 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -1,14 +1,18 @@
 package com.management.platform.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.Report;
 import com.management.platform.mapper.ReportMapper;
 import com.management.platform.service.ReportService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author 吴涛涛
@@ -17,4 +21,61 @@ import org.springframework.stereotype.Service;
 @Service
 public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
 
+    @Resource
+    private ReportMapper reportMapper;
+
+
+    /**
+     * 获取报告列表
+     * 可以基于报告者id 报告种类 报告日期来筛选
+     * @param creatorId
+     * @param reportType
+     * @param startDate
+     * @param end
+     * @return
+     */
+    @Override
+    public HttpRespMsg getReportList(Integer creatorId, Integer reportType, String startDate, String end) {
+        //以上筛选目前都没卵用
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        httpRespMsg.data = reportMapper.selectList(new QueryWrapper<>());
+        return httpRespMsg;
+    }
+
+    /**
+     * 基于id修改报告内容
+     * @param reportId
+     * @param content
+     * @return
+     */
+    @Override
+    public HttpRespMsg editReport(Integer reportId, String content) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        Report report = reportMapper.selectById(reportId);
+        if (report != null) {
+            report.setContent(content);
+            Integer impactedRows = reportMapper.updateById(report);
+            if (impactedRows == 0) {
+                httpRespMsg.setError("操作失败");
+            }
+        } else {
+            httpRespMsg.setError("未找到相应报告");
+        }
+        return httpRespMsg;
+    }
+
+    /**
+     * 基于id删除报告
+     * @param reportId
+     * @return
+     */
+    @Override
+    public HttpRespMsg deleteReport(Integer reportId) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        Integer impactedRows = reportMapper.deleteById(reportId);
+        if (impactedRows == 0) {
+            httpRespMsg.setError("操作失败");
+        }
+        return httpRespMsg;
+    }
 }

+ 13 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -27,24 +27,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     @Resource
     private UserMapper userMapper;
 
-    //登录
+    /**
+     * 管理员登录网页端
+     * @param username
+     * @param password
+     * @return
+     */
     @Override
     public HttpRespMsg login(String username, String password) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
+        //根据电话号码获取账号信息
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("phone", username));
         if (userList.size() == 0) {
+            //未检索到账号时
             httpRespMsg.setError("账号未注册");
         } else if (userList.size() > 1) {
+            //检索到两个及以上账号时
             httpRespMsg.setError("账号重名");
         } else if (userList.get(0).getRole().equals(1)) {
+            //检索的账号role不是1 即不是管理员时
             httpRespMsg.setError("非管理员不能登陆系统");
         } else if (MD5Util.getPassword(password).equals(userList.get(0).getPassword())) {
-            //将信息返回
+            //检测密码正确时
             Map<String, Object> resultMap = new HashMap<>();
             resultMap.put("portraitUrl", userList.get(0).getPortraitUrl());
+            //将头像的url返回回去
             httpRespMsg.data = resultMap;
         } else {
-            httpRespMsg.setError("账号不存在或密码错误");
+            httpRespMsg.setError("密码错误");
         }
         return httpRespMsg;
     }

+ 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("user");
+        strategy.setInclude("report");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-prod.yml

@@ -13,7 +13,7 @@ spring:
       max-request-size: 10000MB
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://118.190.47.230:3306/geminidatabridge_yun?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:mysql://118.190.47.230:3306/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
     password: p011430seya1026
     hikari:

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -13,7 +13,7 @@ spring:
       max-request-size: 10000MB
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://118.190.47.230:3306/geminidatabridge_yun?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:mysql://118.190.47.230:3306/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
     password: p011430seya1026
     hikari:

+ 2 - 4
fhKeeper/src/main/resources/mapper/ReportMapper.xml

@@ -7,16 +7,14 @@
         <id column="id" property="id" />
         <result column="creator_id" property="creatorId" />
         <result column="report_type" property="reportType" />
-        <result column="year" property="year" />
-        <result column="month" property="month" />
-        <result column="day" property="day" />
+        <result column="create_date" property="createDate" />
         <result column="content" property="content" />
         <result column="create_time" property="createTime" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, creator_id, report_type, year, month, day, content, create_time
+        id, creator_id, report_type, create_date, content, create_time
     </sql>
 
 </mapper>