From d21c693fd8afabbe04d53919b89b355bd2d5301c Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 08 八月 2023 17:07:24 +0800
Subject: [PATCH] 优化代码生成自动插入UUID为主键 修改兴趣点井主键代码生成uuid取消数据库自动生成uuid
---
ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java | 2 ++
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm | 4 ++++
ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java | 2 ++
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
index 5d8528c..b9be340 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
@@ -2,7 +2,9 @@
import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
index 5837b00..e89ccca 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
@@ -14,6 +14,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,6 +96,7 @@
{
throw new RuntimeException("浜曞彿宸插瓨鍦�");
}
+ ardAlarmpointsWell.setId(IdUtils.simpleUUID());
ardAlarmpointsWell.setUserId(SecurityUtils.getUserId());
ardAlarmpointsWell.setCreateBy(SecurityUtils.getUsername());
ardAlarmpointsWell.setCreateTime(DateUtils.getNowDate());
diff --git a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
index 894a508..9e7b90a 100644
--- a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
+++ b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
@@ -8,6 +8,7 @@
#end
#end
+import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#if($table.sub)
@@ -67,6 +68,9 @@
@Override
public int insert${ClassName}(${ClassName} ${className}) {
#foreach ($column in $columns)
+ #if($column.javaField == 'id')
+ ${className}.setId(IdUtils.simpleUUID());
+ #end
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
--
Gitblit v1.9.3