63 lines
2.3 KiB
Java
63 lines
2.3 KiB
Java
|
|
package com.ai.da.controller;
|
||
|
|
|
||
|
|
import com.ai.da.common.response.Response;
|
||
|
|
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;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import jakarta.validation.Valid;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
@Api(tags = "订阅计划模块")
|
||
|
|
@Slf4j
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/subscription_plan")
|
||
|
|
public class SubscriptionPlanController {
|
||
|
|
|
||
|
|
private final SubscriptionPlanService subscriptionPlanService;
|
||
|
|
|
||
|
|
@ApiOperation("创建订阅计划")
|
||
|
|
@PostMapping("/createPlan")
|
||
|
|
public Response<String> createPlan(@Valid @RequestBody SubscriptionPlanDTO subscriptionPlanDTO) {
|
||
|
|
subscriptionPlanService.createPlan(subscriptionPlanDTO);
|
||
|
|
return Response.success();
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation("更新订阅计划")
|
||
|
|
@PostMapping("/updatePlan")
|
||
|
|
public Response<String> updatePlan(@Valid @RequestBody UpdateSubscriptionPlanDTO updateDTO) {
|
||
|
|
subscriptionPlanService.updatePlan(updateDTO);
|
||
|
|
return Response.success();
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation("搜索订阅计划")
|
||
|
|
@PostMapping("/searchByPage")
|
||
|
|
public Response<IPage<SubscriptionPlanVO>> searchByPage(@Valid @RequestBody SubscriptionPlanPageQuery subscriptionPlanPageQuery) {
|
||
|
|
IPage<SubscriptionPlanVO> subscriptionPlanVOIPage = subscriptionPlanService.searchByPage(subscriptionPlanPageQuery);
|
||
|
|
return Response.success(subscriptionPlanVOIPage);
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation("删除订阅计划")
|
||
|
|
@GetMapping("/deletePlan")
|
||
|
|
public Response<String> deletePlan(@RequestParam Long id) {
|
||
|
|
subscriptionPlanService.deletePlan(id);
|
||
|
|
return Response.success();
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation("管理员切换订阅计划")
|
||
|
|
@GetMapping("/switchSubscriptionPlan")
|
||
|
|
public Response<String> switchSubscriptionPlan(@RequestParam Long subscriptionPlanId, @RequestParam Long adminAccId) {
|
||
|
|
subscriptionPlanService.switchSubscriptionPlan(subscriptionPlanId, adminAccId);
|
||
|
|
return Response.success();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|