mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 使用 @param 注释替换 @Parameter 注解
fix 修复 token 无法传递 与 无法持久化问题
This commit is contained in:
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.email.MailUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -19,25 +18,35 @@ import java.io.File;
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Validated
|
||||
@Tag(name ="邮件发送案例", description = "邮件发送案例")
|
||||
@Tag(name = "邮件发送案例", description = "邮件发送案例")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/mail")
|
||||
public class MailController {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
@GetMapping("/sendSimpleMessage")
|
||||
public R<Void> sendSimpleMessage(@Parameter(name = "接收人") String to,
|
||||
@Parameter(name = "标题") String subject,
|
||||
@Parameter(name = "内容") String text) {
|
||||
public R<Void> sendSimpleMessage(String to, String subject, String text) {
|
||||
MailUtils.sendText(to, subject, text);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件(带附件)
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param filePath 附件路径
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachment")
|
||||
public R<Void> sendMessageWithAttachment(@Parameter(name = "接收人") String to,
|
||||
@Parameter(name = "标题") String subject,
|
||||
@Parameter(name = "内容") String text,
|
||||
@Parameter(name = "附件路径") String filePath) {
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
|
||||
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||
return R.ok();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@ -21,7 +20,7 @@ import java.time.Duration;
|
||||
*/
|
||||
// 类级别 缓存统一配置
|
||||
//@CacheConfig(cacheNames = "redissonCacheMap")
|
||||
@Tag(name ="spring-cache 演示案例", description = "spring-cache 演示案例")
|
||||
@Tag(name = "spring-cache 演示案例", description = "spring-cache 演示案例")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/cache")
|
||||
|
@ -20,7 +20,7 @@ import java.time.LocalTime;
|
||||
*
|
||||
* @author shenxinquan
|
||||
*/
|
||||
@Tag(name ="测试分布式锁的样例", description = "测试分布式锁的样例")
|
||||
@Tag(name = "测试分布式锁的样例", description = "测试分布式锁的样例")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/demo/redisLock")
|
||||
|
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -14,22 +13,33 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Tag(name ="Redis发布订阅 演示案例", description = "Redis发布订阅")
|
||||
@Tag(name = "Redis发布订阅 演示案例", description = "Redis发布订阅")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/redis/pubsub")
|
||||
public class RedisPubSubController {
|
||||
|
||||
/**
|
||||
* 发布消息
|
||||
*
|
||||
* @param key 通道Key
|
||||
* @param value 发送内容
|
||||
*/
|
||||
@GetMapping("/pub")
|
||||
public R<Void> pub(@Parameter(name = "通道Key") String key, @Parameter(name = "发送内容") String value) {
|
||||
public R<Void> pub(String key, String value) {
|
||||
RedisUtils.publish(key, value, consumer -> {
|
||||
System.out.println("发布通道 => " + key + ", 发送值 => " + value);
|
||||
});
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅消息
|
||||
*
|
||||
* @param key 通道Key
|
||||
*/
|
||||
@GetMapping("/sub")
|
||||
public R<Void> sub(@Parameter(name = "通道Key") String key) {
|
||||
public R<Void> sub(String key) {
|
||||
RedisUtils.subscribe(key, String.class, msg -> {
|
||||
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Tag(name ="测试分布式限流样例", description = "测试分布式限流样例")
|
||||
@Tag(name = "测试分布式限流样例", description = "测试分布式限流样例")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/demo/rateLimiter")
|
||||
|
@ -4,7 +4,6 @@ import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.sms.config.properties.SmsProperties;
|
||||
import com.ruoyi.sms.core.SmsTemplate;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -23,7 +22,7 @@ import java.util.Map;
|
||||
* @version 4.2.0
|
||||
*/
|
||||
@Validated
|
||||
@Tag(name ="短信演示案例", description = "短信演示案例")
|
||||
@Tag(name = "短信演示案例", description = "短信演示案例")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/sms")
|
||||
@ -33,9 +32,14 @@ public class SmsController {
|
||||
// private final SmsTemplate smsTemplate; // 可以使用spring注入
|
||||
// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
|
||||
|
||||
/**
|
||||
* 发送短信Aliyun
|
||||
*
|
||||
* @param phones 电话号
|
||||
* @param templateId 模板ID
|
||||
*/
|
||||
@GetMapping("/sendAliyun")
|
||||
public R<Object> sendAliyun(@Parameter(name = "电话号") String phones,
|
||||
@Parameter(name = "模板ID") String templateId) {
|
||||
public R<Object> sendAliyun(String phones, String templateId) {
|
||||
if (!smsProperties.getEnabled()) {
|
||||
return R.fail("当前系统没有开启短信功能!");
|
||||
}
|
||||
@ -49,9 +53,14 @@ public class SmsController {
|
||||
return R.ok(send);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信Tencent
|
||||
*
|
||||
* @param phones 电话号
|
||||
* @param templateId 模板ID
|
||||
*/
|
||||
@GetMapping("/sendTencent")
|
||||
public R<Object> sendTencent(@Parameter(name = "电话号") String phones,
|
||||
@Parameter(name = "模板ID") String templateId) {
|
||||
public R<Object> sendTencent(String phones, String templateId) {
|
||||
if (!smsProperties.getEnabled()) {
|
||||
return R.fail("当前系统没有开启短信功能!");
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
@ -16,7 +14,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Tag(name ="演示swagger3控制器", description = "演示swagger3接口")
|
||||
@Tag(name = "演示swagger3控制器", description = "演示swagger3接口")
|
||||
@RestController
|
||||
@RequestMapping("/swagger/demo")
|
||||
public class Swagger3DemoController {
|
||||
@ -24,11 +22,10 @@ public class Swagger3DemoController {
|
||||
/**
|
||||
* 上传请求
|
||||
* 必须使用 @RequestPart 注解标注为文件
|
||||
*
|
||||
* @param file 文件
|
||||
*/
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "文件", in = ParameterIn.QUERY, required = true)
|
||||
})
|
||||
@PostMapping(value = "/upload")
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<String> upload(@RequestPart("file") MultipartFile file) {
|
||||
return R.ok("操作成功", file.getOriginalFilename());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Tag(name ="测试批量方法", description = "测试批量方法")
|
||||
@Tag(name = "测试批量方法", description = "测试批量方法")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/batch")
|
||||
@ -65,7 +65,8 @@ public class TestBatchController extends BaseController {
|
||||
testDemo.setOrderNum(-1);
|
||||
testDemo.setTestKey("批量新增");
|
||||
testDemo.setValue("测试新增");
|
||||
list.add(testDemo); }
|
||||
list.add(testDemo);
|
||||
}
|
||||
testDemoMapper.insertBatch(list);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TestDemo testDemo = list.get(i);
|
||||
|
@ -20,11 +20,9 @@ import com.ruoyi.demo.domain.bo.TestDemoBo;
|
||||
import com.ruoyi.demo.domain.bo.TestDemoImportVo;
|
||||
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
||||
import com.ruoyi.demo.service.ITestDemoService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -43,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @date 2021-07-26
|
||||
*/
|
||||
@Validated
|
||||
@Tag(name ="测试单表控制器", description = "测试单表管理")
|
||||
@Tag(name = "测试单表控制器", description = "测试单表管理")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/demo")
|
||||
@ -69,12 +67,14 @@ public class TestDemoController extends BaseController {
|
||||
return iTestDemoService.customPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "导入文件", in = ParameterIn.QUERY, required = true),
|
||||
})
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param file 导入文件
|
||||
*/
|
||||
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("demo:demo:import")
|
||||
@PostMapping("/importData")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
||||
List<TestDemoImportVo> volist = excelResult.getList();
|
||||
@ -100,12 +100,13 @@ public class TestDemoController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取测试单表详细信息
|
||||
*
|
||||
* @param id 测试ID
|
||||
*/
|
||||
@SaCheckPermission("demo:demo:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<TestDemoVo> getInfo(@Parameter(name = "测试ID")
|
||||
@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
public R<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return R.ok(iTestDemoService.queryById(id));
|
||||
}
|
||||
|
||||
@ -136,13 +137,14 @@ public class TestDemoController extends BaseController {
|
||||
|
||||
/**
|
||||
* 删除测试单表
|
||||
*
|
||||
* @param ids 测试ID串
|
||||
*/
|
||||
@SaCheckPermission("demo:demo:remove")
|
||||
@Log(title = "测试单表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@Parameter(name = "测试ID串")
|
||||
@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Tag(name ="测试Excel功能", description = "测试Excel功能")
|
||||
@Tag(name = "测试Excel功能", description = "测试Excel功能")
|
||||
@RestController
|
||||
@RequestMapping("/demo/excel")
|
||||
public class TestExcelController {
|
||||
@ -30,18 +30,18 @@ public class TestExcelController {
|
||||
*/
|
||||
@GetMapping("/exportTemplateOne")
|
||||
public void exportTemplateOne(HttpServletResponse response) {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("title","单列表多数据");
|
||||
map.put("test1","数据测试1");
|
||||
map.put("test2","数据测试2");
|
||||
map.put("test3","数据测试3");
|
||||
map.put("test4","数据测试4");
|
||||
map.put("testTest","666");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("title", "单列表多数据");
|
||||
map.put("test1", "数据测试1");
|
||||
map.put("test2", "数据测试2");
|
||||
map.put("test3", "数据测试3");
|
||||
map.put("test4", "数据测试4");
|
||||
map.put("testTest", "666");
|
||||
List<TestObj> list = new ArrayList<>();
|
||||
list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4"));
|
||||
list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8"));
|
||||
list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12"));
|
||||
ExcelUtil.exportTemplate(CollUtil.newArrayList(map,list),"单列表.xlsx", "excel/单列表.xlsx", response);
|
||||
ExcelUtil.exportTemplate(CollUtil.newArrayList(map, list), "单列表.xlsx", "excel/单列表.xlsx", response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,12 +49,12 @@ public class TestExcelController {
|
||||
*/
|
||||
@GetMapping("/exportTemplateMuliti")
|
||||
public void exportTemplateMuliti(HttpServletResponse response) {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("title1","标题1");
|
||||
map.put("title2","标题2");
|
||||
map.put("title3","标题3");
|
||||
map.put("title4","标题4");
|
||||
map.put("author","Lion Li");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("title1", "标题1");
|
||||
map.put("title2", "标题2");
|
||||
map.put("title3", "标题3");
|
||||
map.put("title4", "标题4");
|
||||
map.put("author", "Lion Li");
|
||||
List<TestObj1> list1 = new ArrayList<>();
|
||||
list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3"));
|
||||
list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6"));
|
||||
@ -69,12 +69,12 @@ public class TestExcelController {
|
||||
list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6"));
|
||||
list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9"));
|
||||
list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12"));
|
||||
Map<String,Object> multiListMap = new HashMap<>();
|
||||
multiListMap.put("map",map);
|
||||
multiListMap.put("data1",list1);
|
||||
multiListMap.put("data2",list2);
|
||||
multiListMap.put("data3",list3);
|
||||
multiListMap.put("data4",list4);
|
||||
Map<String, Object> multiListMap = new HashMap<>();
|
||||
multiListMap.put("map", map);
|
||||
multiListMap.put("data1", list1);
|
||||
multiListMap.put("data2", list2);
|
||||
multiListMap.put("data3", list3);
|
||||
multiListMap.put("data4", list4);
|
||||
ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
@ -21,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Validated
|
||||
@Tag(name ="测试国际化控制器", description = "测试国际化管理")
|
||||
@Tag(name = "测试国际化控制器", description = "测试国际化管理")
|
||||
@RestController
|
||||
@RequestMapping("/demo/i18n")
|
||||
public class TestI18nController {
|
||||
@ -31,9 +30,11 @@ public class TestI18nController {
|
||||
* code为 messages.properties 中的 key
|
||||
* <p>
|
||||
* 测试使用 user.register.success
|
||||
*
|
||||
* @param code 国际化code
|
||||
*/
|
||||
@GetMapping()
|
||||
public R<Void> get(@Parameter(name = "国际化code") String code) {
|
||||
public R<Void> get(String code) {
|
||||
return R.ok(MessageUtils.message(code));
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @version 3.6.0
|
||||
* @see com.ruoyi.common.core.service.SensitiveService
|
||||
*/
|
||||
@Tag(name ="测试数据脱敏控制器", description = "测试数据脱敏管理")
|
||||
@Tag(name = "测试数据脱敏控制器", description = "测试数据脱敏管理")
|
||||
@RestController
|
||||
@RequestMapping("/demo/sensitive")
|
||||
public class TestSensitiveController extends BaseController {
|
||||
|
@ -13,7 +13,6 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
||||
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
||||
import com.ruoyi.demo.service.ITestTreeService;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -32,7 +31,7 @@ import java.util.List;
|
||||
* @date 2021-07-26
|
||||
*/
|
||||
@Validated
|
||||
@Tag(name ="测试树表控制器", description = "测试树表管理")
|
||||
@Tag(name = "测试树表控制器", description = "测试树表管理")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/tree")
|
||||
@ -63,12 +62,13 @@ public class TestTreeController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取测试树表详细信息
|
||||
*
|
||||
* @param id 测试树ID
|
||||
*/
|
||||
@SaCheckPermission("demo:tree:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<TestTreeVo> getInfo(@Parameter(name = "测试树ID")
|
||||
@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
public R<TestTreeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return R.ok(iTestTreeService.queryById(id));
|
||||
}
|
||||
|
||||
@ -96,13 +96,14 @@ public class TestTreeController extends BaseController {
|
||||
|
||||
/**
|
||||
* 删除测试树表
|
||||
*
|
||||
* @param ids 测试树ID串
|
||||
*/
|
||||
@SaCheckPermission("demo:tree:remove")
|
||||
@Log(title = "测试树表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@Parameter(name = "测试树ID串")
|
||||
@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller.queue;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -22,16 +21,21 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @version 3.6.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name ="有界队列 演示案例", description = "有界队列")
|
||||
@Tag(name = "有界队列 演示案例", description = "有界队列")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/queue/bounded")
|
||||
public class BoundedQueueController {
|
||||
|
||||
|
||||
/**
|
||||
* 添加队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
* @param capacity 容量
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public R<Void> add(@Parameter(name = "队列名") String queueName,
|
||||
@Parameter(name = "容量") int capacity) {
|
||||
public R<Void> add(String queueName, int capacity) {
|
||||
// 用完了一定要销毁 否则会一直存在
|
||||
boolean b = QueueUtils.destroyBoundedQueueObject(queueName);
|
||||
log.info("通道: {} , 删除: {}", queueName, b);
|
||||
@ -54,8 +58,13 @@ public class BoundedQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/remove")
|
||||
public R<Void> remove(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> remove(String queueName) {
|
||||
String data = "data-" + 5;
|
||||
if (QueueUtils.removeBoundedQueueObject(queueName, data)) {
|
||||
log.info("通道: {} , 删除数据: {}", queueName, data);
|
||||
@ -65,8 +74,13 @@ public class BoundedQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
public R<Void> get(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> get(String queueName) {
|
||||
String data;
|
||||
do {
|
||||
data = QueueUtils.getBoundedQueueObject(queueName);
|
||||
|
@ -2,7 +2,6 @@ package com.ruoyi.demo.controller.queue;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -25,14 +24,19 @@ import java.util.concurrent.TimeUnit;
|
||||
* @version 3.6.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name ="延迟队列 演示案例", description = "延迟队列")
|
||||
@Tag(name = "延迟队列 演示案例", description = "延迟队列")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/queue/delayed")
|
||||
public class DelayedQueueController {
|
||||
|
||||
/**
|
||||
* 订阅队列
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/subscribe")
|
||||
public R<Void> subscribe(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> subscribe(String queueName) {
|
||||
log.info("通道: {} 监听中......", queueName);
|
||||
// 项目初始化设置一次即可
|
||||
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
||||
@ -42,19 +46,29 @@ public class DelayedQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
* @param orderNum 订单号
|
||||
* @param time 延迟时间(秒)
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public R<Void> add(@Parameter(name = "队列名") String queueName,
|
||||
@Parameter(name = "订单号") String orderNum,
|
||||
@Parameter(name = "延迟时间(秒)") Long time) {
|
||||
public R<Void> add(String queueName, String orderNum, Long time) {
|
||||
QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS);
|
||||
// 观察发送时间
|
||||
log.info("通道: {} , 发送数据: {}", queueName, orderNum);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
* @param orderNum 订单号
|
||||
*/
|
||||
@GetMapping("/remove")
|
||||
public R<Void> remove(@Parameter(name = "队列名") String queueName,
|
||||
@Parameter(name = "订单号") String orderNum) {
|
||||
public R<Void> remove(String queueName, String orderNum) {
|
||||
if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) {
|
||||
log.info("通道: {} , 删除数据: {}", queueName, orderNum);
|
||||
} else {
|
||||
@ -63,8 +77,13 @@ public class DelayedQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁队列
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/destroy")
|
||||
public R<Void> destroy(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> destroy(String queueName) {
|
||||
// 用完了一定要销毁 否则会一直存在
|
||||
QueueUtils.destroyDelayedQueue(queueName);
|
||||
return R.ok("操作成功");
|
||||
|
@ -3,7 +3,6 @@ package com.ruoyi.demo.controller.queue;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.redis.QueueUtils;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -23,14 +22,19 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @version 3.6.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name ="优先队列 演示案例", description = "优先队列")
|
||||
@Tag(name = "优先队列 演示案例", description = "优先队列")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/queue/priority")
|
||||
public class PriorityQueueController {
|
||||
|
||||
/**
|
||||
* 添加队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public R<Void> add(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> add(String queueName) {
|
||||
// 用完了一定要销毁 否则会一直存在
|
||||
boolean b = QueueUtils.destroyPriorityQueueObject(queueName);
|
||||
log.info("通道: {} , 删除: {}", queueName, b);
|
||||
@ -56,10 +60,15 @@ public class PriorityQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
* @param name 对象名
|
||||
* @param orderNum 排序号
|
||||
*/
|
||||
@GetMapping("/remove")
|
||||
public R<Void> remove(@Parameter(name = "队列名") String queueName,
|
||||
@Parameter(name = "对象名") String name,
|
||||
@Parameter(name = "排序号") Integer orderNum) {
|
||||
public R<Void> remove(String queueName, String name, Integer orderNum) {
|
||||
PriorityDemo data = new PriorityDemo();
|
||||
data.setName(name);
|
||||
data.setOrderNum(orderNum);
|
||||
@ -71,8 +80,13 @@ public class PriorityQueueController {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取队列数据
|
||||
*
|
||||
* @param queueName 队列名
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
public R<Void> get(@Parameter(name = "队列名") String queueName) {
|
||||
public R<Void> get(String queueName) {
|
||||
PriorityDemo data;
|
||||
do {
|
||||
data = QueueUtils.getPriorityQueueObject(queueName);
|
||||
|
Reference in New Issue
Block a user