update 优化响应信息主体,避免 string 类型的 data 数据返回到 msg 字段中

This commit is contained in:
David Wei 2023-10-04 20:12:04 +08:00
parent b24e6348c3
commit 1bc238d428
12 changed files with 27 additions and 31 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

@ -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));
} }