指挥系统任务创建

This commit is contained in:
liukai
2024-08-28 17:39:23 +08:00
parent 1a4ff9a1ae
commit 02fc8feb0a
4 changed files with 195 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
package com.realtime.protection.server.v1.controller;
import com.realtime.protection.configuration.response.ResponseResult;
import com.realtime.protection.server.v1.entity.TCommandTask;
import com.realtime.protection.server.v1.service.TCommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/t_command")
public class TCommandController {
@Autowired
private TCommandService tCommandService;
@GetMapping("/task_list")
public ResponseResult commandList(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
@RequestParam(value = "page_size", defaultValue = "20") Integer pageSize,
@RequestParam(value = "taskName", required = false) String taskName,
@RequestParam(value = "eventType", required = false) String eventType
) {
TCommandTask tCommandTask = new TCommandTask();
tCommandTask.setTaskName(taskName);
tCommandTask.setEventType(eventType);
Long count = tCommandService.countCommandTasks(tCommandTask);
pageNum = (pageNum - 1) * pageSize;
List<TCommandTask> tCommandTasks = tCommandService.queryCommandTasks(tCommandTask, pageNum, pageSize);
return ResponseResult.ok()
.setData("task_list", tCommandTasks)
.setData("total_num", count);
}
/**
* 查询所有未被关联的任务
*
* @param pageNum
* @param pageSize
* @return
*/
@GetMapping("/task_list_no_verify")
public ResponseResult commandList1(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
@RequestParam(value = "page_size", defaultValue = "20") Integer pageSize,
@RequestParam(value = "taskName", required = false) String taskName,
@RequestParam(value = "eventType", required = false) String eventType) {
TCommandTask tCommandTask = new TCommandTask();
tCommandTask.setTaskName(taskName);
tCommandTask.setEventType(eventType);
Long count = tCommandService.countCommandTasks1(tCommandTask);
pageNum = (pageNum - 1) * pageSize;
List<TCommandTask> tCommandTasks = tCommandService.queryCommandTasks1(tCommandTask, pageNum, pageSize);
return ResponseResult.ok()
.setData("task_list", tCommandTasks)
.setData("total_num", count);
}
}

View File

@@ -0,0 +1,81 @@
package com.realtime.protection.server.v1.mapper;
import com.realtime.protection.server.v1.entity.TCommandTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (TCommandTask)表数据库访问层
*
* @author makejava
* @since 2024-08-27 15:36:46
*/
@Mapper
public interface TCommandTaskMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TCommandTask queryById(Long id);
/**
* 查询指定行数据
*
* @param tCommandTask 查询条件
* @return 对象列表
*/
List<TCommandTask> queryAllByLimit(TCommandTask tCommandTask,
@Param("page") int page,
@Param("pageSize") Integer pageSize);
/**
* 统计总行数
*
* @param tCommandTask 查询条件
* @return 总行数
*/
long count(TCommandTask tCommandTask);
/**
* 新增数据
*
* @param tCommandTask 实例对象
* @return 影响行数
*/
int insert(TCommandTask tCommandTask);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<TCommandTask> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TCommandTask> entities);
/**
* 修改数据
*
* @param tCommandTask 实例对象
* @return 影响行数
*/
int update(TCommandTask tCommandTask);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
Long count1(TCommandTask tCommandTask);
List<TCommandTask> queryAllByLimit1(TCommandTask tCommandTask,
@Param("page") int page,
@Param("pageSize") Integer pageSize);
}

View File

@@ -0,0 +1,16 @@
package com.realtime.protection.server.v1.service;
import com.realtime.protection.server.v1.entity.TCommandTask;
import java.util.List;
public interface TCommandService {
Long countCommandTasks(TCommandTask tCommandTask);
List<TCommandTask> queryCommandTasks(TCommandTask tCommandTask, Integer pageNum, Integer pageSize);
Long countCommandTasks1(TCommandTask tCommandTask);
List<TCommandTask> queryCommandTasks1(TCommandTask tCommandTask, Integer pageNum, Integer pageSize);
}

View File

@@ -0,0 +1,39 @@
package com.realtime.protection.server.v1.service.impl;
import com.realtime.protection.server.v1.entity.TCommandTask;
import com.realtime.protection.server.v1.mapper.TCommandTaskMapper;
import com.realtime.protection.server.v1.service.TCommandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class TCommandServiceImpl implements TCommandService {
@Autowired
private TCommandTaskMapper tCommandTaskMapper;
@Override
public Long countCommandTasks(TCommandTask tCommandTask) {
return tCommandTaskMapper.count(tCommandTask);
}
@Override
public List<TCommandTask> queryCommandTasks(TCommandTask tCommandTask, Integer pageNum, Integer pageSize) {
return tCommandTaskMapper.queryAllByLimit(tCommandTask, pageNum, pageSize);
}
@Override
public Long countCommandTasks1(TCommandTask tCommandTask) {
return tCommandTaskMapper.count1(tCommandTask);
}
@Override
public List<TCommandTask> queryCommandTasks1(TCommandTask tCommandTask, Integer pageNum, Integer pageSize) {
return tCommandTaskMapper.queryAllByLimit1(tCommandTask, pageNum, pageSize);
}
}