diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerController.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerController.java
index 915bcb8..12719d9 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerController.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerController.java
@@ -128,9 +128,17 @@ public class SpTableManagerController extends BaseController {
if (CollectionUtil.isEmpty(spTableManagerItems)) {
Result.failure("显示的,详细的字段不可以为空");
} else {
+ iSpTableManagerService.saveOrUpdate(spTableManager);
+ //先删除已有的数据,然后插入
+ if (StringUtils.isNotEmpty(record.getId())) {
+ iSpTableManagerItemService.deleteItemBytableNameId(record.getId());
+ } else {
+ for (SpTableManagerItem spTableManagerItem : spTableManagerItems) {
+ spTableManagerItem.setTableNameId(spTableManager.getId());
+ }
+ }
iSpTableManagerItemService.saveOrUpdateBatch(spTableManagerItems);
}
- iSpTableManagerService.saveOrUpdate(spTableManager);
return Result.success(record.getId());
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerItemController.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerItemController.java
index f1440f4..b102aca 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerItemController.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/controller/SpTableManagerItemController.java
@@ -1,21 +1,54 @@
package com.songpeng.sparchetype.basedata.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.stereotype.Controller;
+import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
+import com.songpeng.sparchetype.basedata.service.ISpTableManagerItemService;
import com.songpeng.sparchetype.common.BaseController;
+import com.songpeng.sparchetype.common.Result;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
/**
*
- * 前端控制器
+ * 前端控制器
*
*
* @author WangZiYang
* @since 2020-03-06
*/
@Controller
-@RequestMapping("/basedata/sp-table-manager-item")
+@RequestMapping("/basedata/manager/item")
public class SpTableManagerItemController extends BaseController {
+
+ /**
+ * 业务表字段明细
+ */
+ @Autowired
+ private ISpTableManagerItemService iSpTableManagerItemService;
+
+ /**
+ * 根据表名称查询该表的全部字段数据库明细
+ *
+ * @param tableNameId 主表ID
+ * @return Result 执行结果
+ */
+ @ApiOperation("根据表名称查询该表的全部字段数据库明细")
+ @ApiImplicitParams({@ApiImplicitParam(name = "tableNameId", value = "主表ID", defaultValue = "请求参数")})
+ @PostMapping("/by/tableNameId")
+ @ResponseBody
+ public Result queryTableFieldByName(@RequestParam(value = "tableNameId") String tableNameId) throws Exception {
+ List result = iSpTableManagerItemService.queryItemBytableNameId(tableNameId);
+ return Result.success(result);
+ }
+
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerItemMapper.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerItemMapper.java
index be08352..91ebc0c 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerItemMapper.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerItemMapper.java
@@ -1,16 +1,32 @@
package com.songpeng.sparchetype.basedata.mapper;
-import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
*
- * Mapper 接口
+ * Mapper 接口
*
*
* @author WangZiYang
* @since 2020-03-06
*/
public interface SpTableManagerItemMapper extends BaseMapper {
+ /**
+ * 根据主表ID 查询该表的明细
+ *
+ * @param tableNameId 关联主表ID
+ * @return 表字段明细
+ */
+ List queryItemBytableNameId(@Param("tableNameId") String tableNameId);
+ /**
+ * 根据主表ID 删除明细
+ *
+ * @param tableNameId 关联主表ID
+ */
+ void deleteItemBytableNameId(@Param("tableNameId") String tableNameId);
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerMapper.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerMapper.java
index 5efc6c2..ae278fd 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerMapper.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/mapper/SpTableManagerMapper.java
@@ -15,6 +15,11 @@ import java.util.List;
* @since 2020-03-06
*/
public interface SpTableManagerMapper extends BaseMapper {
+ /**
+ * 查询表对应的字段
+ *
+ * @param req 表信息
+ * @return 字段信息
+ */
List queryTableFieldByName(SpTableManager req);
-
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerItemService.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerItemService.java
index 5c1f833..445a952 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerItemService.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerItemService.java
@@ -1,16 +1,33 @@
package com.songpeng.sparchetype.basedata.service;
-import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
+
+import java.util.List;
/**
*
- * 服务类
+ * 服务类
*
*
* @author WangZiYang
* @since 2020-03-06
*/
public interface ISpTableManagerItemService extends IService {
+ /**
+ * 根据主表ID 查询该表的明细
+ *
+ * @param tableNameId 关联主表ID
+ * @return 表字段明细
+ */
+ List queryItemBytableNameId(String tableNameId);
+
+ /**
+ * 根据主表ID 删除明细
+ *
+ * @param tableNameId 关联主表ID
+ */
+ void deleteItemBytableNameId(String tableNameId);
+
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerService.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerService.java
index 9891324..4001950 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerService.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/ISpTableManagerService.java
@@ -1,7 +1,6 @@
package com.songpeng.sparchetype.basedata.service;
import com.baomidou.mybatisplus.extension.service.IService;
-import com.songpeng.sparchetype.basedata.dto.SpTableManagerDto;
import com.songpeng.sparchetype.basedata.entity.SpTableManager;
import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerItemServiceImpl.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerItemServiceImpl.java
index efdc691..c3f9f51 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerItemServiceImpl.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerItemServiceImpl.java
@@ -1,14 +1,17 @@
package com.songpeng.sparchetype.basedata.service.impl;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
import com.songpeng.sparchetype.basedata.mapper.SpTableManagerItemMapper;
import com.songpeng.sparchetype.basedata.service.ISpTableManagerItemService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
*
- * 服务实现类
+ * 服务实现类
*
*
* @author WangZiYang
@@ -16,5 +19,31 @@ import org.springframework.stereotype.Service;
*/
@Service
public class SpTableManagerItemServiceImpl extends ServiceImpl implements ISpTableManagerItemService {
+ /**
+ * 表明细mapper
+ */
+ @Autowired
+ public SpTableManagerItemMapper spTableManagerItemMapper;
+ /**
+ * 根据主表ID 查询该表的明细
+ *
+ * @param tableNameId 关联主表ID
+ * @return 表字段明细
+ */
+ @Override
+ public List queryItemBytableNameId(String tableNameId) {
+ return spTableManagerItemMapper.queryItemBytableNameId(tableNameId);
+ }
+
+
+ /**
+ * 根据主表ID 删除明细
+ *
+ * @param tableNameId 关联主表ID
+ */
+ @Override
+ public void deleteItemBytableNameId(String tableNameId) {
+ spTableManagerItemMapper.deleteItemBytableNameId(tableNameId);
+ }
}
diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerServiceImpl.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerServiceImpl.java
index 310d66c..29727dc 100644
--- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerServiceImpl.java
+++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/service/impl/SpTableManagerServiceImpl.java
@@ -6,6 +6,7 @@ import com.songpeng.sparchetype.basedata.entity.SpTableManager;
import com.songpeng.sparchetype.basedata.entity.SpTableManagerItem;
import com.songpeng.sparchetype.basedata.mapper.SpTableManagerMapper;
import com.songpeng.sparchetype.basedata.service.ISpTableManagerService;
+import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -21,10 +22,18 @@ import java.util.List;
*/
@Service
public class SpTableManagerServiceImpl extends ServiceImpl implements ISpTableManagerService {
-
+ /**
+ * 基础管理表mapper
+ */
@Autowired
private SpTableManagerMapper spTableManagerMapper;
+ /**
+ * 查询表对应的字段
+ *
+ * @param req 表信息
+ * @return 字段信息
+ */
@Override
public List queryTableFieldByName(SpTableManager req) throws Exception {
List spTableManagerItems = spTableManagerMapper.queryTableFieldByName(req);
@@ -33,4 +42,6 @@ public class SpTableManagerServiceImpl extends ServiceImpl
+
+
+
+
+
+
+
+
+
+
+
+ DELETE FROM sp_table_manager_item WHERE table_name_id = #{tableNameId}
+
diff --git a/sparchetype/src/main/resources/templates/basedata/manager/addOrUpdate.ftl b/sparchetype/src/main/resources/templates/basedata/manager/addOrUpdate.ftl
index 7f0c666..425e77b 100644
--- a/sparchetype/src/main/resources/templates/basedata/manager/addOrUpdate.ftl
+++ b/sparchetype/src/main/resources/templates/basedata/manager/addOrUpdate.ftl
@@ -18,7 +18,7 @@
@@ -125,7 +125,7 @@