Pre Merge pull request !428 from David Wei/update/r_method

This commit is contained in:
David Wei 2023-10-07 07:20:59 +00:00 committed by Gitee
commit 284162c7cf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 31 additions and 35 deletions

View File

@ -99,7 +99,7 @@ public class AuthController {
} }
AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties); AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties);
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
return R.ok("操作成功", authorizeUrl); return R.ok(authorizeUrl);
} }
/** /**
@ -140,7 +140,7 @@ public class AuthController {
@PostMapping("/logout") @PostMapping("/logout")
public R<Void> logout() { public R<Void> logout() {
loginService.logout(); loginService.logout();
return R.ok("退出成功"); return R.ok(null, "退出成功");
} }
/** /**

View File

@ -43,11 +43,7 @@ public class R<T> implements Serializable {
return restResult(data, SUCCESS, "操作成功"); return restResult(data, SUCCESS, "操作成功");
} }
public static <T> R<T> ok(String msg) { public static <T> R<T> ok(T data, String msg) {
return restResult(null, SUCCESS, msg);
}
public static <T> R<T> ok(String msg, T data) {
return restResult(data, SUCCESS, msg); return restResult(data, SUCCESS, msg);
} }

View File

@ -42,7 +42,7 @@ public class RedisCacheController {
@Cacheable(cacheNames = "demo:cache#60s#10m#20", key = "#key", condition = "#key != null") @Cacheable(cacheNames = "demo:cache#60s#10m#20", key = "#key", condition = "#key != null")
@GetMapping("/test1") @GetMapping("/test1")
public R<String> test1(String key, String value) { public R<String> test1(String key, String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -56,7 +56,7 @@ public class RedisCacheController {
@CachePut(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null") @CachePut(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null")
@GetMapping("/test2") @GetMapping("/test2")
public R<String> test2(String key, String value) { public R<String> test2(String key, String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -70,7 +70,7 @@ public class RedisCacheController {
@CacheEvict(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null") @CacheEvict(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null")
@GetMapping("/test3") @GetMapping("/test3")
public R<String> test3(String key, String value) { public R<String> test3(String key, String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**

View File

@ -40,7 +40,7 @@ public class RedisLockController {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("end :" + key + ",time:" + LocalTime.now().toString()); System.out.println("end :" + key + ",time:" + LocalTime.now().toString());
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -65,7 +65,7 @@ public class RedisLockController {
lockTemplate.releaseLock(lockInfo); lockTemplate.releaseLock(lockInfo);
} }
//结束 //结束
return R.ok("操作成功", value); return R.ok(value);
} }
} }

View File

@ -28,7 +28,7 @@ public class RedisPubSubController {
RedisUtils.publish(key, value, consumer -> { RedisUtils.publish(key, value, consumer -> {
System.out.println("发布通道 => " + key + ", 发送值 => " + value); System.out.println("发布通道 => " + key + ", 发送值 => " + value);
}); });
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -41,7 +41,7 @@ public class RedisPubSubController {
RedisUtils.subscribe(key, String.class, msg -> { RedisUtils.subscribe(key, String.class, msg -> {
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg); System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
}); });
return R.ok("操作成功"); return R.ok();
} }
} }

View File

@ -26,7 +26,7 @@ public class RedisRateLimiterController {
@RateLimiter(count = 2, time = 10) @RateLimiter(count = 2, time = 10)
@GetMapping("/test") @GetMapping("/test")
public R<String> test(String value) { public R<String> test(String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -36,7 +36,7 @@ public class RedisRateLimiterController {
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP) @RateLimiter(count = 2, time = 10, limitType = LimitType.IP)
@GetMapping("/testip") @GetMapping("/testip")
public R<String> testip(String value) { public R<String> testip(String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -46,7 +46,7 @@ public class RedisRateLimiterController {
@RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER) @RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER)
@GetMapping("/testcluster") @GetMapping("/testcluster")
public R<String> testcluster(String value) { public R<String> testcluster(String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
/** /**
@ -58,7 +58,7 @@ public class RedisRateLimiterController {
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP, key = "#value") @RateLimiter(count = 2, time = 10, limitType = LimitType.IP, key = "#value")
@GetMapping("/testObj") @GetMapping("/testObj")
public R<String> testObj(String value) { public R<String> testObj(String value) {
return R.ok("操作成功", value); return R.ok(value);
} }
} }

View File

@ -25,7 +25,7 @@ public class Swagger3DemoController {
*/ */
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<String> upload(@RequestPart("file") MultipartFile file) { public R<String> upload(@RequestPart("file") MultipartFile file) {
return R.ok("操作成功", file.getOriginalFilename()); return R.ok(file.getOriginalFilename());
} }
} }

View File

@ -73,7 +73,7 @@ public class TestDemoController extends BaseController {
@Log(title = "测试单表", businessType = BusinessType.IMPORT) @Log(title = "测试单表", businessType = BusinessType.IMPORT)
@SaCheckPermission("demo:demo:import") @SaCheckPermission("demo:demo:import")
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { public R<String> importData(@RequestPart("file") MultipartFile file) throws Exception {
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
List<TestDemo> list = MapstructUtils.convert(excelResult.getList(), TestDemo.class); List<TestDemo> list = MapstructUtils.convert(excelResult.getList(), TestDemo.class);
testDemoService.saveBatch(list); testDemoService.saveBatch(list);

View File

@ -32,7 +32,7 @@ public class TestI18nController {
* @param code 国际化code * @param code 国际化code
*/ */
@GetMapping() @GetMapping()
public R<Void> get(String code) { public R<String> get(String code) {
return R.ok(MessageUtils.message(code)); return R.ok(MessageUtils.message(code));
} }
@ -43,7 +43,7 @@ public class TestI18nController {
* 测试使用 not.null * 测试使用 not.null
*/ */
@GetMapping("/test1") @GetMapping("/test1")
public R<Void> test1(@NotBlank(message = "{not.null}") String str) { public R<String> test1(@NotBlank(message = "{not.null}") String str) {
return R.ok(str); return R.ok(str);
} }

View File

@ -28,6 +28,6 @@ public class WeSocketController {
@GetMapping("/send") @GetMapping("/send")
public R<Void> send(WebSocketMessageDto dto) throws InterruptedException { public R<Void> send(WebSocketMessageDto dto) throws InterruptedException {
WebSocketUtils.publishMessage(dto); WebSocketUtils.publishMessage(dto);
return R.ok("操作成功"); return R.ok();
} }
} }

View File

@ -55,7 +55,7 @@ public class BoundedQueueController {
log.info("通道: {} , 发送数据: {}", queueName, data); log.info("通道: {} , 发送数据: {}", queueName, data);
} }
} }
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -71,7 +71,7 @@ public class BoundedQueueController {
} else { } else {
return R.fail("操作失败"); return R.fail("操作失败");
} }
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -86,7 +86,7 @@ public class BoundedQueueController {
data = QueueUtils.getBoundedQueueObject(queueName); data = QueueUtils.getBoundedQueueObject(queueName);
log.info("通道: {} , 获取数据: {}", queueName, data); log.info("通道: {} , 获取数据: {}", queueName, data);
} while (data != null); } while (data != null);
return R.ok("操作成功"); return R.ok();
} }
} }

View File

@ -41,7 +41,7 @@ public class DelayedQueueController {
// 观察接收时间 // 观察接收时间
log.info("通道: {}, 收到数据: {}", queueName, orderNum); log.info("通道: {}, 收到数据: {}", queueName, orderNum);
}); });
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -56,7 +56,7 @@ public class DelayedQueueController {
QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS); QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS);
// 观察发送时间 // 观察发送时间
log.info("通道: {} , 发送数据: {}", queueName, orderNum); log.info("通道: {} , 发送数据: {}", queueName, orderNum);
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -72,7 +72,7 @@ public class DelayedQueueController {
} else { } else {
return R.fail("操作失败"); return R.fail("操作失败");
} }
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -84,7 +84,7 @@ public class DelayedQueueController {
public R<Void> destroy(String queueName) { public R<Void> destroy(String queueName) {
// 用完了一定要销毁 否则会一直存在 // 用完了一定要销毁 否则会一直存在
QueueUtils.destroyDelayedQueue(queueName); QueueUtils.destroyDelayedQueue(queueName);
return R.ok("操作成功"); return R.ok();
} }
} }

View File

@ -48,7 +48,7 @@ public class PriorityQueueController {
log.info("通道: {} , 发送数据: {}, 发送失败", queueName, data); log.info("通道: {} , 发送数据: {}, 发送失败", queueName, data);
} }
} }
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -68,7 +68,7 @@ public class PriorityQueueController {
} else { } else {
return R.fail("操作失败"); return R.fail("操作失败");
} }
return R.ok("操作成功"); return R.ok();
} }
/** /**
@ -83,7 +83,7 @@ public class PriorityQueueController {
data = QueueUtils.getPriorityQueueObject(queueName); data = QueueUtils.getPriorityQueueObject(queueName);
log.info("通道: {} , 获取数据: {}", queueName, data); log.info("通道: {} , 获取数据: {}", queueName, data);
} while (data != null); } while (data != null);
return R.ok("操作成功"); return R.ok();
} }
} }

View File

@ -68,7 +68,7 @@ public class SysConfigController extends BaseController {
* @param configKey 参数Key * @param configKey 参数Key
*/ */
@GetMapping(value = "/configKey/{configKey}") @GetMapping(value = "/configKey/{configKey}")
public R<Void> getConfigKey(@PathVariable String configKey) { public R<String> getConfigKey(@PathVariable String configKey) {
return R.ok(configService.selectConfigByKey(configKey)); return R.ok(configService.selectConfigByKey(configKey));
} }

View File

@ -85,7 +85,7 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.IMPORT) @Log(title = "用户管理", businessType = BusinessType.IMPORT)
@SaCheckPermission("system:user:import") @SaCheckPermission("system:user:import")
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { public R<String> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport)); ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
return R.ok(result.getAnalysis()); return R.ok(result.getAnalysis());
} }