97 lines
2.7 KiB
Java
97 lines
2.7 KiB
Java
package com.muyu.rule.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.dtflys.forest.annotation.Get;
|
|
import com.muyu.common.core.domain.Result;
|
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
|
import com.muyu.common.log.annotation.Log;
|
|
import com.muyu.common.log.enums.BusinessType;
|
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
|
import com.muyu.common.system.domain.SysUser;
|
|
import com.muyu.rule.service.RuleService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import rule.domain.Rule;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @ClassName RuleController
|
|
* @Description 规则控制层
|
|
* @Author Chen
|
|
* @Date 2024/8/20 14:22
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/rule")
|
|
public class RuleController {
|
|
@Autowired
|
|
private RuleService ruleService;
|
|
|
|
/**
|
|
* 规则列表
|
|
*
|
|
* @return
|
|
*/
|
|
@RequestMapping(path = "/list", method = RequestMethod.POST)
|
|
@Operation(summary = "查看规则", description = "查看规则")
|
|
public Result<List<Rule>> select(Rule rule) {
|
|
return Result.success(ruleService.select(rule));
|
|
}
|
|
|
|
/**
|
|
* 规则删除
|
|
*
|
|
* @return
|
|
*/
|
|
@DeleteMapping("/delete/{id}")
|
|
@Operation(summary = "规则删除", description = "规则删除")
|
|
public Result delete(@PathVariable("id") Integer id) {
|
|
return Result.success(ruleService.removeById(id));
|
|
}
|
|
|
|
/**
|
|
* 规则修改
|
|
*
|
|
* @return
|
|
*/
|
|
@Operation(summary = "规则修改", description = "根据规则的id")
|
|
@PutMapping("/update")
|
|
public Result update(@RequestBody Rule rule) {
|
|
return Result.success(ruleService.updateById(rule));
|
|
}
|
|
|
|
/**
|
|
* 规则添加
|
|
*
|
|
* @return
|
|
*/
|
|
@PostMapping("/insert")
|
|
@Operation(summary = "规则添加", description = "规则添加")
|
|
public Result insert(@RequestBody Rule rule) {
|
|
return Result.success(ruleService.save(rule));
|
|
}
|
|
|
|
/**
|
|
* 导出
|
|
*
|
|
* @param response
|
|
* @param
|
|
*/
|
|
@PostMapping("/export")
|
|
public void export(HttpServletResponse response, Rule rule) {
|
|
List<Rule> list = ruleService.select(rule);
|
|
ExcelUtil<Rule> util = new ExcelUtil<Rule>(Rule.class);
|
|
util.exportExcel(response, list, "规则");
|
|
}
|
|
|
|
@GetMapping("/findById/{id}")
|
|
@Operation(summary = "规则详细", description = "规则详细")
|
|
public Result findById(@PathVariable("id") Long id) {
|
|
return Result.success(ruleService.list(new LambdaQueryWrapper<>() {{
|
|
eq(Rule::getId, id);
|
|
}}));
|
|
}
|
|
}
|