2025-12-11 09:44:25 +08:00
|
|
|
package com.ai.da.controller;
|
|
|
|
|
|
|
|
|
|
import com.ai.da.common.response.Response;
|
2025-12-15 18:30:28 +08:00
|
|
|
import com.ai.da.mapper.primary.entity.SubscriptionPlan;
|
2025-12-11 09:44:25 +08:00
|
|
|
import com.ai.da.model.dto.SubscriptionPlanDTO;
|
|
|
|
|
import com.ai.da.model.dto.SubscriptionPlanPageQuery;
|
|
|
|
|
import com.ai.da.model.dto.UpdateSubscriptionPlanDTO;
|
|
|
|
|
import com.ai.da.model.vo.SubscriptionPlanVO;
|
|
|
|
|
import com.ai.da.service.SubscriptionPlanService;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
2025-12-11 16:18:37 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2025-12-11 09:44:25 +08:00
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
2025-12-15 18:30:28 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Tag(name = "订阅计划模块")
|
2025-12-11 09:44:25 +08:00
|
|
|
@Slf4j
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/subscription_plan")
|
|
|
|
|
public class SubscriptionPlanController {
|
|
|
|
|
|
|
|
|
|
private final SubscriptionPlanService subscriptionPlanService;
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "创建订阅计划")
|
2025-12-11 09:44:25 +08:00
|
|
|
@PostMapping("/createPlan")
|
|
|
|
|
public Response<String> createPlan(@Valid @RequestBody SubscriptionPlanDTO subscriptionPlanDTO) {
|
|
|
|
|
subscriptionPlanService.createPlan(subscriptionPlanDTO);
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "更新订阅计划")
|
2025-12-11 09:44:25 +08:00
|
|
|
@PostMapping("/updatePlan")
|
|
|
|
|
public Response<String> updatePlan(@Valid @RequestBody UpdateSubscriptionPlanDTO updateDTO) {
|
|
|
|
|
subscriptionPlanService.updatePlan(updateDTO);
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "搜索订阅计划")
|
2025-12-15 18:30:28 +08:00
|
|
|
@PostMapping("/searchByOrganizationIdAndStatus")
|
|
|
|
|
public Response<List<SubscriptionPlan>> searchByOrganizationIdAndStatus(@Valid @RequestBody SubscriptionPlanPageQuery subscriptionPlanPageQuery) {
|
|
|
|
|
return Response.success(subscriptionPlanService.searchByOrganizationIdAndStatus(subscriptionPlanPageQuery));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "分页搜索订阅计划")
|
2025-12-11 09:44:25 +08:00
|
|
|
@PostMapping("/searchByPage")
|
|
|
|
|
public Response<IPage<SubscriptionPlanVO>> searchByPage(@Valid @RequestBody SubscriptionPlanPageQuery subscriptionPlanPageQuery) {
|
|
|
|
|
IPage<SubscriptionPlanVO> subscriptionPlanVOIPage = subscriptionPlanService.searchByPage(subscriptionPlanPageQuery);
|
|
|
|
|
return Response.success(subscriptionPlanVOIPage);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "删除订阅计划")
|
2025-12-11 09:44:25 +08:00
|
|
|
@GetMapping("/deletePlan")
|
|
|
|
|
public Response<String> deletePlan(@RequestParam Long id) {
|
|
|
|
|
subscriptionPlanService.deletePlan(id);
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "管理员切换订阅计划")
|
2025-12-11 09:44:25 +08:00
|
|
|
@GetMapping("/switchSubscriptionPlan")
|
2025-12-15 18:30:28 +08:00
|
|
|
public Response<String> switchSubscriptionPlan(@RequestParam Long targetSubscriptionPlanId, @RequestParam(required = false) Long adminAccId) {
|
|
|
|
|
subscriptionPlanService.switchSubscriptionPlan(targetSubscriptionPlanId, adminAccId);
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "子账号切换订阅计划")
|
|
|
|
|
@GetMapping("/switchSubAccSubscriptionPlan")
|
|
|
|
|
public Response<String> switchSubAccSubscriptionPlan(@RequestParam Long targetSubscriptionPlanId, @RequestParam Long subAccId) {
|
|
|
|
|
subscriptionPlanService.switchSubAccSubscriptionPlan(targetSubscriptionPlanId, subAccId);
|
2025-12-11 09:44:25 +08:00
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "activeSubscriptionPlan")
|
2025-12-11 15:26:20 +08:00
|
|
|
@GetMapping("/activeSubscriptionPlan")
|
|
|
|
|
public Response<String> activeSubscriptionPlan() {
|
|
|
|
|
subscriptionPlanService.activeSubscriptionPlan();
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 16:18:37 +08:00
|
|
|
@Operation(summary = "expireSubscription")
|
2025-12-11 15:26:20 +08:00
|
|
|
@GetMapping("/expireSubscription")
|
|
|
|
|
public Response<String> expireSubscription() {
|
|
|
|
|
subscriptionPlanService.expireSubscription();
|
|
|
|
|
return Response.success();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 09:44:25 +08:00
|
|
|
|
|
|
|
|
}
|