陪练代码框架
This commit is contained in:
380
src/main/java/com/rj/controller/TrainingItemController.java
Normal file
380
src/main/java/com/rj/controller/TrainingItemController.java
Normal file
@@ -0,0 +1,380 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rj.entity.TrainingItem;
|
||||
import com.rj.service.ITrainingItemService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练子表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/trainingItem")
|
||||
@Tag(name = "陪练子表管理", description = "陪练子表相关接口")
|
||||
public class TrainingItemController {
|
||||
|
||||
@Autowired
|
||||
private ITrainingItemService trainingItemService;
|
||||
|
||||
/**
|
||||
* 新增陪练子表记录
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增陪练子表记录", description = "添加新的陪练子表记录")
|
||||
public ResponseEntity<Map<String, Object>> addTrainingItem(
|
||||
@Parameter(description = "陪练子表信息", required = true)
|
||||
@RequestBody TrainingItem trainingItem) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (trainingItem.getId() == null || trainingItem.getId().trim().isEmpty()) {
|
||||
trainingItem.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
trainingItem.setCreateTime(LocalDateTime.now());
|
||||
boolean success = trainingItemService.save(trainingItem);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练子表记录添加成功");
|
||||
result.put("data", trainingItem);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表记录添加失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表记录添加异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询陪练子表记录
|
||||
*/
|
||||
@GetMapping("/get/{id}")
|
||||
@Operation(summary = "根据ID查询陪练子表记录", description = "根据陪练子表ID获取详细信息")
|
||||
public ResponseEntity<Map<String, Object>> getTrainingItemById(
|
||||
@Parameter(description = "陪练子表ID", required = true)
|
||||
@PathVariable String id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
TrainingItem trainingItem = trainingItemService.getById(id);
|
||||
if (trainingItem != null) {
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingItem);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表记录不存在");
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父ID查询陪练子表列表
|
||||
*/
|
||||
@GetMapping("/getByParentId")
|
||||
@Operation(summary = "根据父ID查询陪练子表", description = "根据父ID查询子陪练子表列表")
|
||||
public ResponseEntity<Map<String, Object>> getTrainingItemsByParentId(
|
||||
@Parameter(description = "父ID", required = true)
|
||||
@RequestParam String parentId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
LambdaQueryWrapper<TrainingItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TrainingItem::getParentId, parentId);
|
||||
queryWrapper.orderByDesc(TrainingItem::getCreateTime);
|
||||
List<TrainingItem> trainingItems = trainingItemService.list(queryWrapper);
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingItems);
|
||||
result.put("count", trainingItems.size());
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询陪练子表列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询陪练子表列表", description = "分页查询陪练子表信息列表")
|
||||
public ResponseEntity<Map<String, Object>> getTrainingItemList(
|
||||
@Parameter(description = "页码", example = "1")
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@Parameter(description = "每页大小", example = "10")
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@Parameter(description = "父ID(精确查询)")
|
||||
@RequestParam(required = false) String parentId,
|
||||
@Parameter(description = "租户ID(精确查询)")
|
||||
@RequestParam(required = false) String tenantId,
|
||||
@Parameter(description = "题目(模糊查询)")
|
||||
@RequestParam(required = false) String question,
|
||||
@Parameter(description = "题目答案(模糊查询)")
|
||||
@RequestParam(required = false) String answer,
|
||||
@Parameter(description = "创建开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String createStartTime,
|
||||
@Parameter(description = "创建结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String createEndTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
Page<TrainingItem> page = new Page<>(current, size);
|
||||
LambdaQueryWrapper<TrainingItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加查询条件
|
||||
if (parentId != null && !parentId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingItem::getParentId, parentId);
|
||||
}
|
||||
if (tenantId != null && !tenantId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingItem::getTenantId, tenantId);
|
||||
}
|
||||
if (question != null && !question.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingItem::getQuestion, question);
|
||||
}
|
||||
if (answer != null && !answer.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingItem::getAnswer, answer);
|
||||
}
|
||||
|
||||
// 添加时间范围查询条件
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (createStartTime != null && !createStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(createStartTime, formatter);
|
||||
queryWrapper.ge(TrainingItem::getCreateTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (createEndTime != null && !createEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(createEndTime, formatter);
|
||||
queryWrapper.le(TrainingItem::getCreateTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 按创建时间倒序排列
|
||||
queryWrapper.orderByDesc(TrainingItem::getCreateTime);
|
||||
|
||||
Page<TrainingItem> trainingItemPage = trainingItemService.page(page, queryWrapper);
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingItemPage.getRecords());
|
||||
result.put("total", trainingItemPage.getTotal());
|
||||
result.put("current", trainingItemPage.getCurrent());
|
||||
result.put("size", trainingItemPage.getSize());
|
||||
result.put("pages", trainingItemPage.getPages());
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件不分页查询陪练子表列表
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
@Operation(summary = "按条件不分页查询陪练子表列表", description = "按条件查询所有陪练子表信息列表(不分页)")
|
||||
public ResponseEntity<Map<String, Object>> getAllTrainingItemList(
|
||||
@Parameter(description = "父ID(精确查询)")
|
||||
@RequestParam(required = false) String parentId,
|
||||
@Parameter(description = "租户ID(精确查询)")
|
||||
@RequestParam(required = false) String tenantId,
|
||||
@Parameter(description = "题目(模糊查询)")
|
||||
@RequestParam(required = false) String question,
|
||||
@Parameter(description = "题目答案(模糊查询)")
|
||||
@RequestParam(required = false) String answer,
|
||||
@Parameter(description = "创建开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String createStartTime,
|
||||
@Parameter(description = "创建结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String createEndTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
LambdaQueryWrapper<TrainingItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加查询条件
|
||||
if (parentId != null && !parentId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingItem::getParentId, parentId);
|
||||
}
|
||||
if (tenantId != null && !tenantId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingItem::getTenantId, tenantId);
|
||||
}
|
||||
if (question != null && !question.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingItem::getQuestion, question);
|
||||
}
|
||||
if (answer != null && !answer.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingItem::getAnswer, answer);
|
||||
}
|
||||
|
||||
// 添加时间范围查询条件
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (createStartTime != null && !createStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(createStartTime, formatter);
|
||||
queryWrapper.ge(TrainingItem::getCreateTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (createEndTime != null && !createEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(createEndTime, formatter);
|
||||
queryWrapper.le(TrainingItem::getCreateTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 按创建时间倒序排列
|
||||
queryWrapper.orderByDesc(TrainingItem::getCreateTime);
|
||||
|
||||
List<TrainingItem> trainingItemList = trainingItemService.list(queryWrapper);
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingItemList);
|
||||
result.put("count", trainingItemList.size());
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新陪练子表信息
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新陪练子表信息", description = "更新陪练子表详细信息")
|
||||
public ResponseEntity<Map<String, Object>> updateTrainingItem(
|
||||
@Parameter(description = "陪练子表信息", required = true)
|
||||
@RequestBody TrainingItem trainingItem) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (trainingItem.getId() == null || trainingItem.getId().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表ID不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
boolean success = trainingItemService.updateById(trainingItem);
|
||||
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练子表信息更新成功");
|
||||
result.put("data", trainingItem);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表信息更新失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "更新异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除陪练子表记录
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "删除陪练子表记录", description = "根据陪练子表ID删除陪练子表信息")
|
||||
public ResponseEntity<Map<String, Object>> deleteTrainingItem(
|
||||
@Parameter(description = "陪练子表ID", required = true)
|
||||
@PathVariable String id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean success = trainingItemService.removeById(id);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练子表记录删除成功");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表记录删除失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "删除异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除陪练子表记录
|
||||
*/
|
||||
@DeleteMapping("/batchDelete")
|
||||
@Operation(summary = "批量删除陪练子表记录", description = "根据陪练子表ID列表批量删除陪练子表信息")
|
||||
public ResponseEntity<Map<String, Object>> batchDeleteTrainingItems(
|
||||
@Parameter(description = "陪练子表ID列表", required = true)
|
||||
@RequestBody List<String> ids) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练子表ID列表不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
boolean success = trainingItemService.removeByIds(ids);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "批量删除成功,共删除 " + ids.size() + " 条记录");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "批量删除失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "批量删除异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
412
src/main/java/com/rj/controller/TrainingMainController.java
Normal file
412
src/main/java/com/rj/controller/TrainingMainController.java
Normal file
@@ -0,0 +1,412 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rj.entity.TrainingMain;
|
||||
import com.rj.service.ITrainingMainService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练主表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/trainingMain")
|
||||
@Tag(name = "陪练主表管理", description = "陪练主表相关接口")
|
||||
public class TrainingMainController {
|
||||
|
||||
@Autowired
|
||||
private ITrainingMainService trainingMainService;
|
||||
|
||||
/**
|
||||
* 新增陪练主表记录
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增陪练主表记录", description = "添加新的陪练主表记录")
|
||||
public ResponseEntity<Map<String, Object>> addTrainingMain(
|
||||
@Parameter(description = "陪练主表信息", required = true)
|
||||
@RequestBody TrainingMain trainingMain) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (trainingMain.getId() == null || trainingMain.getId().trim().isEmpty()) {
|
||||
trainingMain.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
trainingMain.setCreateTime(LocalDateTime.now());
|
||||
boolean success = trainingMainService.save(trainingMain);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练主表记录添加成功");
|
||||
result.put("data", trainingMain);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表记录添加失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表记录添加异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询陪练主表记录
|
||||
*/
|
||||
@GetMapping("/get/{id}")
|
||||
@Operation(summary = "根据ID查询陪练主表记录", description = "根据陪练主表ID获取详细信息")
|
||||
public ResponseEntity<Map<String, Object>> getTrainingMainById(
|
||||
@Parameter(description = "陪练主表ID", required = true)
|
||||
@PathVariable String id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
TrainingMain trainingMain = trainingMainService.getById(id);
|
||||
if (trainingMain != null) {
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingMain);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表记录不存在");
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询陪练主表列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询陪练主表列表", description = "分页查询陪练主表信息列表")
|
||||
public ResponseEntity<Map<String, Object>> getTrainingMainList(
|
||||
@Parameter(description = "页码", example = "1")
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@Parameter(description = "每页大小", example = "10")
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@Parameter(description = "租户ID(精确查询)")
|
||||
@RequestParam(required = false) String tenantId,
|
||||
@Parameter(description = "陪练标题(模糊查询)")
|
||||
@RequestParam(required = false) String title,
|
||||
@Parameter(description = "陪练的场景(模糊查询)")
|
||||
@RequestParam(required = false) String scenario,
|
||||
@Parameter(description = "参与人姓名(模糊查询)")
|
||||
@RequestParam(required = false) String participantName,
|
||||
@Parameter(description = "参与人电话(模糊查询)")
|
||||
@RequestParam(required = false) String participantPhone,
|
||||
@Parameter(description = "创建开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String createStartTime,
|
||||
@Parameter(description = "创建结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String createEndTime,
|
||||
@Parameter(description = "结束开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String endStartTime,
|
||||
@Parameter(description = "结束结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String endEndTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
Page<TrainingMain> page = new Page<>(current, size);
|
||||
LambdaQueryWrapper<TrainingMain> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加查询条件
|
||||
if (tenantId != null && !tenantId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingMain::getTenantId, tenantId);
|
||||
}
|
||||
if (title != null && !title.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getTitle, title);
|
||||
}
|
||||
if (scenario != null && !scenario.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getScenario, scenario);
|
||||
}
|
||||
if (participantName != null && !participantName.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getParticipantName, participantName);
|
||||
}
|
||||
if (participantPhone != null && !participantPhone.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getParticipantPhone, participantPhone);
|
||||
}
|
||||
|
||||
// 添加时间范围查询条件
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (createStartTime != null && !createStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(createStartTime, formatter);
|
||||
queryWrapper.ge(TrainingMain::getCreateTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (createEndTime != null && !createEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(createEndTime, formatter);
|
||||
queryWrapper.le(TrainingMain::getCreateTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (endStartTime != null && !endStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(endStartTime, formatter);
|
||||
queryWrapper.ge(TrainingMain::getEndTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "结束开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (endEndTime != null && !endEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(endEndTime, formatter);
|
||||
queryWrapper.le(TrainingMain::getEndTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "结束结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 按创建时间倒序排列
|
||||
queryWrapper.orderByDesc(TrainingMain::getCreateTime);
|
||||
|
||||
Page<TrainingMain> trainingMainPage = trainingMainService.page(page, queryWrapper);
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingMainPage.getRecords());
|
||||
result.put("total", trainingMainPage.getTotal());
|
||||
result.put("current", trainingMainPage.getCurrent());
|
||||
result.put("size", trainingMainPage.getSize());
|
||||
result.put("pages", trainingMainPage.getPages());
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件不分页查询陪练主表列表
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
@Operation(summary = "按条件不分页查询陪练主表列表", description = "按条件查询所有陪练主表信息列表(不分页)")
|
||||
public ResponseEntity<Map<String, Object>> getAllTrainingMainList(
|
||||
@Parameter(description = "租户ID(精确查询)")
|
||||
@RequestParam(required = false) String tenantId,
|
||||
@Parameter(description = "陪练标题(模糊查询)")
|
||||
@RequestParam(required = false) String title,
|
||||
@Parameter(description = "陪练的场景(模糊查询)")
|
||||
@RequestParam(required = false) String scenario,
|
||||
@Parameter(description = "参与人姓名(模糊查询)")
|
||||
@RequestParam(required = false) String participantName,
|
||||
@Parameter(description = "参与人电话(模糊查询)")
|
||||
@RequestParam(required = false) String participantPhone,
|
||||
@Parameter(description = "创建开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String createStartTime,
|
||||
@Parameter(description = "创建结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String createEndTime,
|
||||
@Parameter(description = "结束开始时间", example = "2025-01-01 00:00:00")
|
||||
@RequestParam(required = false) String endStartTime,
|
||||
@Parameter(description = "结束结束时间", example = "2025-12-31 23:59:59")
|
||||
@RequestParam(required = false) String endEndTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
LambdaQueryWrapper<TrainingMain> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加查询条件
|
||||
if (tenantId != null && !tenantId.trim().isEmpty()) {
|
||||
queryWrapper.eq(TrainingMain::getTenantId, tenantId);
|
||||
}
|
||||
if (title != null && !title.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getTitle, title);
|
||||
}
|
||||
if (scenario != null && !scenario.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getScenario, scenario);
|
||||
}
|
||||
if (participantName != null && !participantName.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getParticipantName, participantName);
|
||||
}
|
||||
if (participantPhone != null && !participantPhone.trim().isEmpty()) {
|
||||
queryWrapper.like(TrainingMain::getParticipantPhone, participantPhone);
|
||||
}
|
||||
|
||||
// 添加时间范围查询条件
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (createStartTime != null && !createStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(createStartTime, formatter);
|
||||
queryWrapper.ge(TrainingMain::getCreateTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (createEndTime != null && !createEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(createEndTime, formatter);
|
||||
queryWrapper.le(TrainingMain::getCreateTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "创建结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (endStartTime != null && !endStartTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime startTime = LocalDateTime.parse(endStartTime, formatter);
|
||||
queryWrapper.ge(TrainingMain::getEndTime, startTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "结束开始时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
if (endEndTime != null && !endEndTime.trim().isEmpty()) {
|
||||
try {
|
||||
LocalDateTime endTime = LocalDateTime.parse(endEndTime, formatter);
|
||||
queryWrapper.le(TrainingMain::getEndTime, endTime);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "结束结束时间格式错误,请使用格式:yyyy-MM-dd HH:mm:ss");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 按创建时间倒序排列
|
||||
queryWrapper.orderByDesc(TrainingMain::getCreateTime);
|
||||
|
||||
List<TrainingMain> trainingMainList = trainingMainService.list(queryWrapper);
|
||||
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", trainingMainList);
|
||||
result.put("count", trainingMainList.size());
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "查询异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新陪练主表信息
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新陪练主表信息", description = "更新陪练主表详细信息")
|
||||
public ResponseEntity<Map<String, Object>> updateTrainingMain(
|
||||
@Parameter(description = "陪练主表信息", required = true)
|
||||
@RequestBody TrainingMain trainingMain) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (trainingMain.getId() == null || trainingMain.getId().trim().isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表ID不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
boolean success = trainingMainService.updateById(trainingMain);
|
||||
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练主表信息更新成功");
|
||||
result.put("data", trainingMain);
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表信息更新失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "更新异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除陪练主表记录
|
||||
*/
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@Operation(summary = "删除陪练主表记录", description = "根据陪练主表ID删除陪练主表信息")
|
||||
public ResponseEntity<Map<String, Object>> deleteTrainingMain(
|
||||
@Parameter(description = "陪练主表ID", required = true)
|
||||
@PathVariable String id) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
boolean success = trainingMainService.removeById(id);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "陪练主表记录删除成功");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表记录删除失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "删除异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除陪练主表记录
|
||||
*/
|
||||
@DeleteMapping("/batchDelete")
|
||||
@Operation(summary = "批量删除陪练主表记录", description = "根据陪练主表ID列表批量删除陪练主表信息")
|
||||
public ResponseEntity<Map<String, Object>> batchDeleteTrainingMains(
|
||||
@Parameter(description = "陪练主表ID列表", required = true)
|
||||
@RequestBody List<String> ids) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
result.put("success", false);
|
||||
result.put("message", "陪练主表ID列表不能为空");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
boolean success = trainingMainService.removeByIds(ids);
|
||||
if (success) {
|
||||
result.put("success", true);
|
||||
result.put("message", "批量删除成功,共删除 " + ids.size() + " 条记录");
|
||||
return ResponseEntity.ok(result);
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("message", "批量删除失败");
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("message", "批量删除异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
src/main/java/com/rj/entity/TrainingItem.java
Normal file
52
src/main/java/com/rj/entity/TrainingItem.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.rj.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练子表
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("training_item")
|
||||
@Schema(description = "陪练子表")
|
||||
public class TrainingItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键,UUID")
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "父ID,关联陪练主表ID")
|
||||
@TableField("parent_id")
|
||||
private String parentId;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "题目")
|
||||
@TableField("question")
|
||||
private String question;
|
||||
|
||||
@Schema(description = "题目答案")
|
||||
@TableField("answer")
|
||||
private String answer;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
60
src/main/java/com/rj/entity/TrainingMain.java
Normal file
60
src/main/java/com/rj/entity/TrainingMain.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.rj.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练主表
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("training_main")
|
||||
@Schema(description = "陪练主表")
|
||||
public class TrainingMain implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键,UUID")
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "陪练标题")
|
||||
@TableField("title")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "陪练的场景")
|
||||
@TableField("scenario")
|
||||
private String scenario;
|
||||
|
||||
@Schema(description = "参与人姓名")
|
||||
@TableField("participant_name")
|
||||
private String participantName;
|
||||
|
||||
@Schema(description = "参与人电话")
|
||||
@TableField("participant_phone")
|
||||
private String participantPhone;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
17
src/main/java/com/rj/mapper/TrainingItemMapper.java
Normal file
17
src/main/java/com/rj/mapper/TrainingItemMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.rj.mapper;
|
||||
|
||||
import com.rj.entity.TrainingItem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练子表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
public interface TrainingItemMapper extends BaseMapper<TrainingItem> {
|
||||
|
||||
}
|
||||
|
||||
17
src/main/java/com/rj/mapper/TrainingMainMapper.java
Normal file
17
src/main/java/com/rj/mapper/TrainingMainMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.rj.mapper;
|
||||
|
||||
import com.rj.entity.TrainingMain;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练主表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
public interface TrainingMainMapper extends BaseMapper<TrainingMain> {
|
||||
|
||||
}
|
||||
|
||||
17
src/main/java/com/rj/service/ITrainingItemService.java
Normal file
17
src/main/java/com/rj/service/ITrainingItemService.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.rj.service;
|
||||
|
||||
import com.rj.entity.TrainingItem;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练子表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
public interface ITrainingItemService extends IService<TrainingItem> {
|
||||
|
||||
}
|
||||
|
||||
17
src/main/java/com/rj/service/ITrainingMainService.java
Normal file
17
src/main/java/com/rj/service/ITrainingMainService.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.rj.service;
|
||||
|
||||
import com.rj.entity.TrainingMain;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练主表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
public interface ITrainingMainService extends IService<TrainingMain> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.rj.service.impl;
|
||||
|
||||
import com.rj.entity.TrainingItem;
|
||||
import com.rj.mapper.TrainingItemMapper;
|
||||
import com.rj.service.ITrainingItemService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练子表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@Service
|
||||
public class TrainingItemServiceImpl extends ServiceImpl<TrainingItemMapper, TrainingItem> implements ITrainingItemService {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.rj.service.impl;
|
||||
|
||||
import com.rj.entity.TrainingMain;
|
||||
import com.rj.mapper.TrainingMainMapper;
|
||||
import com.rj.service.ITrainingMainService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 陪练主表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2025-01-XX
|
||||
*/
|
||||
@Service
|
||||
public class TrainingMainServiceImpl extends ServiceImpl<TrainingMainMapper, TrainingMain> implements ITrainingMainService {
|
||||
|
||||
}
|
||||
|
||||
33
src/main/sql/training_item.sql
Normal file
33
src/main/sql/training_item.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80042
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80042
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2025-01-XX
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for training_item
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `training_item`;
|
||||
CREATE TABLE `training_item` (
|
||||
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键,UUID',
|
||||
`parent_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '父ID,关联陪练主表ID',
|
||||
`tenant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '租户ID',
|
||||
`question` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '题目',
|
||||
`answer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '题目答案',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_parent_id`(`parent_id`) USING BTREE COMMENT '父ID索引',
|
||||
INDEX `idx_tenant_id`(`tenant_id`) USING BTREE COMMENT '租户ID索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '陪练子表' ROW_FORMAT = Dynamic;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
35
src/main/sql/training_main.sql
Normal file
35
src/main/sql/training_main.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80042
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80042
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2025-01-XX
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for training_main
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `training_main`;
|
||||
CREATE TABLE `training_main` (
|
||||
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键,UUID',
|
||||
`tenant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '租户ID',
|
||||
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '陪练标题',
|
||||
`scenario` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '陪练的场景',
|
||||
`participant_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参与人姓名',
|
||||
`participant_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参与人电话',
|
||||
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_tenant_id`(`tenant_id`) USING BTREE COMMENT '租户ID索引',
|
||||
INDEX `idx_practice_date`(`end_time`) USING BTREE COMMENT '日期索引'
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '陪练主表' ROW_FORMAT = Dynamic;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
陪练主表包括的字段:
|
||||
id(uuid)主键, 租户id,陪练标题,陪练的场景,参与人姓名, 参与人电话, 日期,创建时间
|
||||
id(uuid)主键, 租户id,陪练标题,陪练的场景,参与人姓名, 参与人电话, 结束时间,创建时间
|
||||
|
||||
陪练子表包括的字段:
|
||||
id(uuid)主键,父id(uuid), 租户id,题目,题目答案 ,创建时间
|
||||
|
||||
Reference in New Issue
Block a user