126 lines
4.3 KiB
Java
126 lines
4.3 KiB
Java
package com.muyu.controller;
|
||
|
||
import com.muyu.common.core.domain.Result;
|
||
import com.muyu.common.domain.RuleData;
|
||
import com.muyu.common.domain.req.RuleDataAddReq;
|
||
import com.muyu.common.domain.req.RuleDataListReq;
|
||
import com.muyu.common.domain.req.RuleDataUpdReq;
|
||
import com.muyu.common.domain.resp.RuleDataResp;
|
||
import com.muyu.servier.RuleDataService;
|
||
import io.swagger.v3.oas.annotations.Operation;
|
||
import io.swagger.v3.oas.annotations.media.Schema;
|
||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import java.util.List;
|
||
|
||
/**
|
||
* @Author:yang
|
||
* @Package:com.muyu.server.controller
|
||
* @Project:cloud-integration
|
||
* @name:RuleDataController
|
||
* @Date:2024/8/21 20:36
|
||
*/
|
||
@RestController
|
||
@RequestMapping("/rule_data")
|
||
@Tag(name = "规则控制层",description = "进行规则制定,查看等操作")
|
||
public class RuleDataController {
|
||
|
||
@Autowired private RuleDataService ruleDataService;
|
||
|
||
/**
|
||
* 查询所有接口规则
|
||
* @param ruleDataListReq
|
||
* @return 规则列表
|
||
*/
|
||
@RequestMapping(path = "/list",method = RequestMethod.POST)
|
||
@Operation(summary = "查询接口规则",description = "根据规则名称、创建人、启动状态进行规则的筛选")
|
||
public Result<List<RuleDataResp>> selectList(
|
||
@Validated @RequestBody RuleDataListReq ruleDataListReq
|
||
){
|
||
return Result.success(
|
||
ruleDataService.selectList(ruleDataListReq)
|
||
);
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @param ruleDataAddReq
|
||
* @return
|
||
*/
|
||
@PostMapping("/add")
|
||
@Operation(summary = "规则接口添加",description = "根据客户需求创建对应规则")
|
||
public Result<String> add(
|
||
@Validated @RequestBody RuleDataAddReq ruleDataAddReq
|
||
){
|
||
ruleDataService.save(RuleData.addBuild(ruleDataAddReq));
|
||
return Result.success(null,"操作成功");
|
||
}
|
||
|
||
/**
|
||
* 修改接口规则
|
||
* @param ruleId
|
||
* @param ruleDataUpdReq
|
||
* @return 修改结果
|
||
*/
|
||
@PutMapping("/upd/{ruleId}")
|
||
@Operation(summary = "接口规则修改",description = "通过ID修改接口规则信息")
|
||
public Result<String> update(
|
||
@Schema(title = "客户ID",type = "Long",defaultValue = "1",description = "修改接口规则信息需要唯一条件")
|
||
@PathVariable("ruleId") Long ruleId,
|
||
@Validated @RequestBody RuleDataUpdReq ruleDataUpdReq){
|
||
ruleDataService.updateById(RuleData.updBuild(ruleDataUpdReq,() -> ruleId));
|
||
return Result.success(null,"操作成功");
|
||
}
|
||
|
||
/**
|
||
* 删除接口规则
|
||
* @param ruleId 请求ID
|
||
* @return 删除结果
|
||
*/
|
||
@DeleteMapping("/del/{ruleId}")
|
||
@Operation(summary = "接口规则删除",description = "通过ID删除接口规则")
|
||
public Result<String> delete(@PathVariable("ruleId") Long ruleId){
|
||
ruleDataService.getOptById(ruleId);
|
||
return Result.success(null,"操作成功");
|
||
}
|
||
|
||
/**
|
||
* 根据ID获取接口规则信息
|
||
* @param ruleId 请求ID
|
||
* @return 规则信息
|
||
*/
|
||
@GetMapping("/{ruleId}")
|
||
@Operation(summary = "根据ID获取客户信息",description = "通过ID获取接口规则信息")
|
||
public Result<RuleData> findById(@PathVariable("ruleId") Long ruleId){
|
||
return Result.success(ruleDataService.getById(ruleId),"操作成功");
|
||
}
|
||
|
||
/**
|
||
*通过ID禁用规则
|
||
* @param ruleId 请求ID
|
||
* @return 禁用结果
|
||
*/
|
||
@GetMapping("/disable/{ruleId}")
|
||
@Operation(summary = "通过ID禁用规则",description = "通过ID禁用规则之后,禁止用户在使用此规则")
|
||
public Result<String> disable(@PathVariable("ruleId") Long ruleId){
|
||
this.ruleDataService.disable(ruleId);
|
||
return Result.success(null,"操作成功");
|
||
}
|
||
|
||
/**
|
||
*通过ID启动规则
|
||
* @param ruleId 请求ID
|
||
* @return 启动结果
|
||
*/
|
||
@GetMapping("/enable/{ruleId}")
|
||
@Operation(summary = "通过ID启动规则",description = "通过ID禁用规则之后,禁止用户在使用此规则")
|
||
public Result<String> enable(@PathVariable("ruleId") Long ruleId){
|
||
this.ruleDataService.enable(ruleId);
|
||
return Result.success(null,"操作成功");
|
||
}
|
||
|
||
}
|