添加实体类

master
陈思豪 2024-08-29 20:50:02 +08:00
parent 4db14d49a4
commit 43135beb53
9 changed files with 108 additions and 11 deletions

View File

@ -65,7 +65,7 @@ public class TaskInputInfo extends BaseEntity {
/** /**
* *
*/ */
private String ableAsField; private String tableAsField;
/** /**
* *

View File

@ -20,12 +20,6 @@ import lombok.NoArgsConstructor;
@Builder @Builder
public class TaskInfoReq { public class TaskInfoReq {
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
/** /**
* *
*/ */

View File

@ -50,7 +50,7 @@ public class TaskController {
public Result<String> addTask( public Result<String> addTask(
@Validated @RequestBody TaskInfo taskInfo) { @Validated @RequestBody TaskInfo taskInfo) {
return Result.success(taskService.addTask(taskInfo),"添加成功"); return Result.success(null,taskService.addTask(taskInfo));
} }
/** /**

View File

@ -0,0 +1,33 @@
package com.muyu.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.TaskInputInfo;
import com.muyu.service.TaskInputService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @PackageName:com.muyu.controller
* @ClassName:TaskInputInfoController
* @Description:
* @author:
* @date: 2024/8/27 21:35
*/
@RestController
@RequestMapping("/taskInput")
public class TaskInputInfoController {
@Autowired
private TaskInputService taskInputService;
@PostMapping(value = "addTaskInput")
public Result<String> addTaskInput(@RequestBody TaskInputInfo taskInputInfo){
return Result.success(null,taskInputService.addTaskInput(taskInputInfo));
}
}

View File

@ -0,0 +1,9 @@
package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.TaskInputInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TaskInputInfoMapper extends BaseMapper<TaskInputInfo> {
}

View File

@ -0,0 +1,9 @@
package com.muyu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.TaskInputInfo;
public interface TaskInputService extends IService<TaskInputInfo> {
String addTaskInput(TaskInputInfo taskInputInfo);
}

View File

@ -36,7 +36,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo
tableInfoCasRespDad.setValue(tableInfo.getId()); tableInfoCasRespDad.setValue(tableInfo.getId());
tableInfoCasRespDad.setLabel(tableInfo.getTableName()); tableInfoCasRespDad.setLabel(tableInfo.getTableName());
LambdaQueryWrapper<TableInfo> queryWrapperC = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TableInfo> queryWrapperC = new LambdaQueryWrapper<>();
queryWrapperC.eq(TableInfo::getParentId,tableInfo.getId()); queryWrapperC.eq(TableInfo::getParentId, tableInfo.getId());
List<TableInfo> list1 = this.list(queryWrapperC); List<TableInfo> list1 = this.list(queryWrapperC);
List<TableInfoCasResp> tableInfoCasRespSon = new ArrayList<>(); List<TableInfoCasResp> tableInfoCasRespSon = new ArrayList<>();
for (TableInfo info : list1) { for (TableInfo info : list1) {
@ -48,6 +48,16 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo
tableInfoCasRespDad.setChildren(tableInfoCasRespSon); tableInfoCasRespDad.setChildren(tableInfoCasRespSon);
tableInfo.setTableInfoList(list1); tableInfo.setTableInfoList(list1);
tableInfoCasResp.add(tableInfoCasRespDad); tableInfoCasResp.add(tableInfoCasRespDad);
// LambdaQueryWrapper<TableInfo> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(TableInfo::getParentId,0);
// List<TableInfo> list = this.list(queryWrapper);
// list.forEach(tableInfo -> {
// LambdaQueryWrapper<TableInfo> queryWrapperC = new LambdaQueryWrapper<>();
// queryWrapperC.eq(TableInfo::getParentId,tableInfo.getId());
// List<TableInfo> list1 = this.list(queryWrapperC);
// tableInfo.setTableInfoList(list1);
// });
}); });
return tableInfoCasResp; return tableInfoCasResp;
} }

View File

@ -0,0 +1,36 @@
package com.muyu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.TaskInputInfo;
import com.muyu.mapper.TaskInputInfoMapper;
import com.muyu.service.TaskInputService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
/**
* @PackageName:com.muyu.service.impl
* @ClassName:TaskInputServOceanServiceImpl
* @Description:
* @author:
* @date: 2024/8/27 21:37
*/
@Service
public class TaskInputInfoServiceImpl extends ServiceImpl<TaskInputInfoMapper, TaskInputInfo> implements TaskInputService {
@Autowired
private TaskInputInfoMapper taskInputInfoMapper;
@Override
public String addTaskInput(TaskInputInfo taskInputInfo) {
int i = taskInputInfoMapper.insert(taskInputInfo);
if(i<=0){
throw new RuntimeException("添加失败");
}
return "添加成功";
}
}

View File

@ -46,7 +46,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskInfo> implement
@Override @Override
public String addTask(TaskInfo taskInfo) { public String addTask(TaskInfo taskInfo) {
this.save(taskInfo); boolean save = this.save(taskInfo);
if(save == false){
throw new RuntimeException("err");
}
return "success"; return "success";
} }
@ -60,7 +63,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskInfo> implement
@Override @Override
public String deleteById(Integer id) { public String deleteById(Integer id) {
TaskMapper taskMapper = this.baseMapper; TaskMapper taskMapper = this.baseMapper;
taskMapper.deleteById(id); int i = taskMapper.deleteById(id);
if(i<=0){
throw new RuntimeException("err");
}
return "success"; return "success";
} }