Browse Source

单表增删改查

gydx_2024_qin 2 tháng trước cách đây
mục cha
commit
979cad7d3d

+ 9 - 4
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/controller/TECompareobjectController.java

@@ -76,10 +76,15 @@ public class TECompareobjectController extends BaseController
     @RequiresPermissions("system.base:compareobject:add")
     @Log(title = "对照-对象", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TECompareobject tECompareobject)
-    {
-        return toAjax(tECompareobjectService.insertTECompareobject(tECompareobject));
-
+    public AjaxResult add(@RequestBody TECompareobject tECompareobject) {
+        int result = tECompareobjectService.insertTECompareobject(tECompareobject);
+        if (result > 0) {
+            // 获取新增数据的 ID,可以从插入的对象中获取
+            String id = tECompareobject.getId();
+            return AjaxResult.success("新增成功", id);
+        } else {
+            return AjaxResult.error("新增失败");
+        }
     }
 
     /**

+ 4 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/service/impl/TECompareobjectDetailServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.enterprise.base.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.common.core.utils.uuid.UUID;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.enterprise.base.mapper.TECompareobjectDetailMapper;
@@ -52,6 +54,8 @@ public class TECompareobjectDetailServiceImpl implements ITECompareobjectDetailS
     @Override
     public int insertTECompareobjectDetail(TECompareobjectDetail tECompareobjectDetail)
     {
+        String ObjectDetailId = UUID.fastUUID().toString();
+        tECompareobjectDetail.setId(ObjectDetailId);
         return tECompareobjectDetailMapper.insertTECompareobjectDetail(tECompareobjectDetail);
     }
 

+ 3 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TECompareobjectInstanceMapper.xml

@@ -45,7 +45,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTECompareobjectInstanceVo"/>
         where id = #{id}
     </select>
-        
+
+
+<!--    新增有问题-->
     <insert id="insertTECompareobjectInstance" parameterType="TECompareobjectInstance">
         insert into t_e_compareobject_instance
         <trim prefix="(" suffix=")" suffixOverrides=",">