99 lines
2.4 KiB
Java
99 lines
2.4 KiB
Java
|
|
package com.ruoyi.device.controller;
|
||
|
|
|
||
|
|
import com.ruoyi.common.core.domain.R;
|
||
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||
|
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||
|
|
import com.ruoyi.device.api.domain.DockVO;
|
||
|
|
import com.ruoyi.device.api.domain.GroupVO;
|
||
|
|
import com.ruoyi.device.service.api.IGroupService;
|
||
|
|
import com.ruoyi.device.service.dto.GroupDTO;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 分组Controller
|
||
|
|
*
|
||
|
|
* @author ruoyi
|
||
|
|
* @date 2026-01-20
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/group")
|
||
|
|
public class GroupController extends BaseController
|
||
|
|
{
|
||
|
|
@Autowired
|
||
|
|
private IGroupService groupService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 创建分组
|
||
|
|
*
|
||
|
|
* @param groupVO 分组信息
|
||
|
|
* @return 分组ID
|
||
|
|
*/
|
||
|
|
@InnerAuth
|
||
|
|
@PostMapping("/create")
|
||
|
|
public R<Long> createGroup(@RequestBody GroupVO groupVO)
|
||
|
|
{
|
||
|
|
GroupDTO dto = new GroupDTO();
|
||
|
|
dto.setGroupName(groupVO.getGroupName());
|
||
|
|
Long groupId = groupService.createGroup(dto);
|
||
|
|
return R.ok(groupId);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 删除分组
|
||
|
|
*
|
||
|
|
* @param groupId 分组ID
|
||
|
|
* @return 结果
|
||
|
|
*/
|
||
|
|
@InnerAuth
|
||
|
|
@DeleteMapping("/delete/{groupId}")
|
||
|
|
public R<Void> deleteGroup(@PathVariable("groupId") Long groupId)
|
||
|
|
{
|
||
|
|
groupService.deleteGroup(groupId);
|
||
|
|
return R.ok();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 切换机场所在的分组
|
||
|
|
*
|
||
|
|
* @param dockId 机场ID
|
||
|
|
* @param groupId 分组ID
|
||
|
|
* @return 结果
|
||
|
|
*/
|
||
|
|
@InnerAuth
|
||
|
|
@PutMapping("/switch/{dockId}/{groupId}")
|
||
|
|
public R<Void> switchDockGroup(@PathVariable("dockId") Long dockId, @PathVariable("groupId") Long groupId)
|
||
|
|
{
|
||
|
|
groupService.switchDockGroup(dockId, groupId);
|
||
|
|
return R.ok();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查看分组下的机场
|
||
|
|
*
|
||
|
|
* @param groupId 分组ID
|
||
|
|
* @return 机场列表
|
||
|
|
*/
|
||
|
|
@InnerAuth
|
||
|
|
@GetMapping("/docks/{groupId}")
|
||
|
|
public R<List<DockVO>> getDocksByGroupId(@PathVariable("groupId") Long groupId)
|
||
|
|
{
|
||
|
|
List<DockVO> dockList = groupService.getDocksByGroupId(groupId);
|
||
|
|
return R.ok(dockList);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查看所有分组
|
||
|
|
*
|
||
|
|
* @return 分组ID列表
|
||
|
|
*/
|
||
|
|
@InnerAuth
|
||
|
|
@GetMapping("/list")
|
||
|
|
public R<List<Long>> getAllGroupIds()
|
||
|
|
{
|
||
|
|
List<Long> groupIds = groupService.getAllGroupIds();
|
||
|
|
return R.ok(groupIds);
|
||
|
|
}
|
||
|
|
}
|