huangjn 3 роки тому
батько
коміт
8601dfb3b2

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/WeatherInfo.java

@@ -47,7 +47,7 @@ public class WeatherInfo implements Serializable {
 
     private Long createUser;
 
-    private Long createDept;
+    private String createDept;
 
     private Date createTime;
 

+ 22 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/WeatherController.java

@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
@@ -15,6 +17,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springblade.core.mp.support.Condition;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,6 +50,9 @@ public class WeatherController {
      */
     @PostMapping(value = "updateWeatherById")
     public R<Boolean> updateWeatherById(@RequestBody WeatherInfo weatherInfo){
+        //记录修改时间及修改人
+        setUserData(weatherInfo, true);
+
         return R.status(this.weatherInfoService.updateById(weatherInfo));
     }
 
@@ -121,6 +127,8 @@ public class WeatherController {
 
             WeatherInfo weatherInfo = new WeatherInfo();
             BeanUtils.copyProperties(weatherInfoVo, weatherInfo);
+            //设置用户信息
+            setUserData(weatherInfo, false);
             weatherInfo.setRecordTime(DateUtil.parse(weatherInfoVo.getRecordTime(), "yyyy-MM-dd"));
 
             //之后需要通过session获取当前账号信息,当前暂时不填
@@ -131,4 +139,18 @@ public class WeatherController {
         return R.status(false);
     }
 
+    //设置登录用户信息
+    private void setUserData(WeatherInfo weatherInfo, boolean isUpd){
+        //获取当前登录人
+        BladeUser user = AuthUtil.getUser();
+        //记录修改时间及修改人
+        if(isUpd){
+            weatherInfo.setUpdateUser(user.getUserId());
+            weatherInfo.setUpdateTime(new Date());
+        } else {
+            weatherInfo.setCreateUser(user.getUserId());
+            weatherInfo.setCreateDept(user.getDeptId());
+        }
+    }
+
 }

+ 2 - 2
blade-service/blade-business/src/main/java/sql/u_construction_ledger.sql

@@ -36,11 +36,11 @@ CREATE TABLE `u_construction_ledger`  (
   `contract_id` bigint(64) NULL DEFAULT NULL COMMENT '合同段ID',
   `create_user` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
   `create_dept` bigint(64) NULL DEFAULT NULL COMMENT '创建人所在部门',
-  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
+  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `update_user` bigint(64) NULL DEFAULT NULL COMMENT '修改人',
   `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
   `status` int(10) NULL DEFAULT NULL COMMENT '状态',
-  `is_deleted` int(10) NULL DEFAULT NULL COMMENT '是否已删除',
+  `is_deleted` int(10) NOT NULL DEFAULT 0 COMMENT '是否已删除',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
 

+ 1 - 1
blade-service/blade-business/src/main/java/sql/u_weather_info.sql

@@ -31,7 +31,7 @@ CREATE TABLE `u_weather_info`  (
   `temp_low` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最低气温',
   `wind_level` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '风力等级',
   `create_user` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
-  `create_dept` bigint(64) NULL DEFAULT NULL COMMENT '创建人部门',
+  `create_dept` varchar(64) NULL DEFAULT NULL COMMENT '创建人部门',
   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `update_user` bigint(64) NULL DEFAULT NULL COMMENT '修改人',
   `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',