mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 07:56:37 +08:00
init
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
package com.admin.controller;
|
||||
|
||||
import com.admin.common.aop.LogAnnotation;
|
||||
import com.admin.common.annotation.RequireRole;
|
||||
import com.admin.common.dto.PageDto;
|
||||
import com.admin.common.dto.TunnelDto;
|
||||
|
||||
import com.admin.common.dto.UserTunnelDto;
|
||||
import com.admin.common.dto.UserTunnelQueryDto;
|
||||
import com.admin.common.dto.UserTunnelUpdateDto;
|
||||
import com.admin.common.lang.R;
|
||||
import com.admin.service.TunnelService;
|
||||
import com.admin.service.UserTunnelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 隧道前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author QAQ
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/v1/tunnel")
|
||||
public class TunnelController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private TunnelService tunnelService;
|
||||
|
||||
@Autowired
|
||||
private UserTunnelService userTunnelService;
|
||||
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/create")
|
||||
public R create(@Validated @RequestBody TunnelDto tunnelDto) {
|
||||
return tunnelService.createTunnel(tunnelDto);
|
||||
}
|
||||
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/list")
|
||||
public R readAll(@RequestBody(required = false) PageDto pageDto) {
|
||||
return tunnelService.getAllTunnels();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/delete")
|
||||
public R delete(@RequestBody Map<String, Object> params) {
|
||||
Long id = Long.valueOf(params.get("id").toString());
|
||||
return tunnelService.deleteTunnel(id);
|
||||
}
|
||||
|
||||
// ============ 用户隧道权限管理相关方法 ============
|
||||
|
||||
/**
|
||||
* 分配用户隧道权限
|
||||
* @param userTunnelDto 用户隧道权限数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/user/assign")
|
||||
public R assignUserTunnel(@Validated @RequestBody UserTunnelDto userTunnelDto) {
|
||||
return userTunnelService.assignUserTunnel(userTunnelDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户隧道权限列表
|
||||
* @param queryDto 查询条件
|
||||
* @return 用户隧道权限列表
|
||||
*/
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/user/list")
|
||||
public R getUserTunnelList(@RequestBody @Validated UserTunnelQueryDto queryDto) {
|
||||
return userTunnelService.getUserTunnelList(queryDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户隧道权限
|
||||
* @param params 包含userId和tunnelId的参数
|
||||
* @return 操作结果
|
||||
*/
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/user/remove")
|
||||
public R removeUserTunnel(@RequestBody Map<String, Object> params) {
|
||||
Integer id = Integer.valueOf(params.get("id").toString());
|
||||
return userTunnelService.removeUserTunnel(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户隧道流量限制
|
||||
* @param params 包含userId、tunnelId和flow的参数
|
||||
* @return 操作结果
|
||||
*/
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/user/updateFlow")
|
||||
public R updateUserTunnelFlow(@RequestBody Map<String, Object> params) {
|
||||
Integer id = Integer.valueOf(params.get("id").toString());
|
||||
Long flow = Long.valueOf(params.get("flow").toString());
|
||||
return userTunnelService.updateUserTunnelFlow(id, flow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户隧道权限(包含流量、流量重置时间、到期时间)
|
||||
* @param updateDto 更新数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@LogAnnotation
|
||||
@RequireRole
|
||||
@PostMapping("/user/update")
|
||||
public R updateUserTunnel(@Validated @RequestBody UserTunnelUpdateDto updateDto) {
|
||||
return userTunnelService.updateUserTunnel(updateDto);
|
||||
}
|
||||
|
||||
|
||||
@LogAnnotation
|
||||
@PostMapping("/user/tunnel")
|
||||
public R userTunnel() {
|
||||
return tunnelService.userTunnel();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user