|
|
@@ -1,117 +1,87 @@
|
|
|
-//package com.sckw.example.controller;
|
|
|
-//
|
|
|
-//import cn.hutool.core.lang.UUID;
|
|
|
-//import com.alibaba.csp.sentinel.annotation.SentinelResource;
|
|
|
-//import com.alibaba.fastjson2.JSON;
|
|
|
-//import com.sckw.core.model.page.PageResult;
|
|
|
-//import com.sckw.core.web.exceptionHandler.CustomBlockExceptionHandler;
|
|
|
-//import com.sckw.core.web.response.HttpResult;
|
|
|
-//import com.sckw.example.model.SysUser;
|
|
|
-//import com.sckw.example.model.TestSensitive;
|
|
|
-//import com.sckw.example.service.SysUserService;
|
|
|
-//import com.sckw.stream.enums.SmsCodeEnum;
|
|
|
-//import com.sckw.stream.model.SckwMessage;
|
|
|
-//import com.sckw.stream.model.SckwSms;
|
|
|
-//import lombok.AllArgsConstructor;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.redisson.api.RBucket;
|
|
|
-//import org.redisson.api.RedissonClient;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
-//import org.springframework.web.bind.annotation.*;
|
|
|
-//
|
|
|
-//import javax.annotation.Resource;
|
|
|
-//import java.util.Date;
|
|
|
-//import java.util.HashMap;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Map;
|
|
|
-//
|
|
|
-//@Slf4j
|
|
|
-//@AllArgsConstructor
|
|
|
-//@RestController
|
|
|
-//@RequestMapping("/")
|
|
|
-//public class SysUserController {
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// SysUserService sysUserService;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// RedissonClient redissonClient;
|
|
|
-//
|
|
|
-// /*@Autowired
|
|
|
-// RedisService redisService;*/
|
|
|
-//
|
|
|
-// @GetMapping("index")
|
|
|
-// public Object test(){
|
|
|
-// Map result = new HashMap();
|
|
|
-// result.put("user", System.currentTimeMillis());
|
|
|
-// result.put("datatime", System.currentTimeMillis());
|
|
|
-// result.put("database", "redis");
|
|
|
-//
|
|
|
-// RBucket<Object> mytest = redissonClient.getBucket("mytest");
|
|
|
-// mytest.set("value");
|
|
|
-// System.out.println(mytest.get());//value
|
|
|
-// mytest.set("value2");
|
|
|
-// System.out.println(mytest.get());//value2
|
|
|
-// boolean b = mytest.compareAndSet("value2", result); //true
|
|
|
-// System.out.println(mytest.get());//value3
|
|
|
-// Object resultObj = mytest.get();
|
|
|
-//
|
|
|
-// /*result.put("type", "spring boot");
|
|
|
-// redisService.setCacheMap("value2", result);
|
|
|
-// resultObj = redisService.getCacheMap("value2");*/
|
|
|
-//
|
|
|
-// return String.valueOf(resultObj);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //@Override
|
|
|
-// public String getUserInfo(String account) {
|
|
|
-// return account + String.valueOf(new Date());
|
|
|
-// }
|
|
|
-//
|
|
|
-// @PostMapping("findByAccount")
|
|
|
-// public HttpResult findByAccount(HashMap params) {
|
|
|
-// List<SysUser> data = sysUserService.findByAccount(params);
|
|
|
-// return HttpResult.ok(data);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @PostMapping("findPage")
|
|
|
-// public HttpResult findPage(Map<String, Object> params) {
|
|
|
-// PageResult pageResult = sysUserService.findPage(params);
|
|
|
-// return HttpResult.ok(pageResult);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 限流测试示例
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// //value将该方法定义为sentinel的资源,blockHandlerClass指明流控处理的类,blockHandler是流控时调用的方法。
|
|
|
-// //这里需要注意处理异常的方法必须是静态方法添加static, 并需要添加sentinel的异常参数BlockException。
|
|
|
-// @RequestMapping(value = "sentinelFlowDemo", method = RequestMethod.GET)
|
|
|
-// @SentinelResource(value = "sentinelFlowDemo", blockHandlerClass = CustomBlockExceptionHandler.class, blockHandler = "sentinelFlowBlock")
|
|
|
-// public HttpResult sentinelFlowDemo() {
|
|
|
-// return HttpResult.ok("sentinelFlowDemo正常返回");
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 熔断测试示例
|
|
|
-// * @param id
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "sentinelDegradeDemo", method = RequestMethod.GET)
|
|
|
-// @SentinelResource(value = "sentinelDegradeDemo", blockHandlerClass = SysUserController.class, blockHandler = "sentinelDegradeBlock")
|
|
|
-// public HttpResult sentinelDegradeDemo(@RequestParam("id") String id) {
|
|
|
-// if ("2".equals(id)){
|
|
|
-// try {
|
|
|
-// Thread.sleep(5000);
|
|
|
-// } catch (InterruptedException e) {
|
|
|
-// throw new RuntimeException(e);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return HttpResult.ok("sentinelDegradeDemo正常返回");
|
|
|
-// }
|
|
|
-//
|
|
|
+////package com.sckw.example.controller;
|
|
|
+////
|
|
|
+////import cn.hutool.core.lang.UUID;
|
|
|
+////import com.alibaba.csp.sentinel.annotation.SentinelResource;
|
|
|
+////import com.alibaba.fastjson2.JSON;
|
|
|
+////import com.sckw.core.model.page.PageResult;
|
|
|
+////import com.sckw.core.web.exceptionHandler.CustomBlockExceptionHandler;
|
|
|
+////import com.sckw.core.web.response.HttpResult;
|
|
|
+////import com.sckw.example.model.SysUser;
|
|
|
+////import com.sckw.example.model.TestSensitive;
|
|
|
+////import com.sckw.example.service.SysUserService;
|
|
|
+////import com.sckw.stream.enums.SmsCodeEnum;
|
|
|
+////import com.sckw.stream.model.SckwMessage;
|
|
|
+////import com.sckw.stream.model.SckwSms;
|
|
|
+////import lombok.AllArgsConstructor;
|
|
|
+////import lombok.extern.slf4j.Slf4j;
|
|
|
+////import org.redisson.api.RBucket;
|
|
|
+////import org.redisson.api.RedissonClient;
|
|
|
+////import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+////import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
+////import org.springframework.web.bind.annotation.*;
|
|
|
+////
|
|
|
+////import javax.annotation.Resource;
|
|
|
+////import java.util.Date;
|
|
|
+////import java.util.HashMap;
|
|
|
+////import java.util.List;
|
|
|
+////import java.util.Map;
|
|
|
+////
|
|
|
+////@Slf4j
|
|
|
+////@AllArgsConstructor
|
|
|
+////@RestController
|
|
|
+////@RequestMapping("/")
|
|
|
+////public class SysUserController {
|
|
|
+////
|
|
|
+//// @Autowired
|
|
|
+//// SysUserService sysUserService;
|
|
|
+////
|
|
|
+//// @Autowired
|
|
|
+//// RedissonClient redissonClient;
|
|
|
+////
|
|
|
+//// /*@Autowired
|
|
|
+//// RedisService redisService;*/
|
|
|
+////
|
|
|
+//// @GetMapping("index")
|
|
|
+//// public Object test(){
|
|
|
+//// Map result = new HashMap();
|
|
|
+//// result.put("user", System.currentTimeMillis());
|
|
|
+//// result.put("datatime", System.currentTimeMillis());
|
|
|
+//// result.put("database", "redis");
|
|
|
+////
|
|
|
+//// RBucket<Object> mytest = redissonClient.getBucket("mytest");
|
|
|
+//// mytest.set("value");
|
|
|
+//// System.out.println(mytest.get());//value
|
|
|
+//// mytest.set("value2");
|
|
|
+//// System.out.println(mytest.get());//value2
|
|
|
+//// boolean b = mytest.compareAndSet("value2", result); //true
|
|
|
+//// System.out.println(mytest.get());//value3
|
|
|
+//// Object resultObj = mytest.get();
|
|
|
+////
|
|
|
+//// /*result.put("type", "spring boot");
|
|
|
+//// redisService.setCacheMap("value2", result);
|
|
|
+//// resultObj = redisService.getCacheMap("value2");*/
|
|
|
+////
|
|
|
+//// return String.valueOf(resultObj);
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// //@Override
|
|
|
+//// public String getUserInfo(String account) {
|
|
|
+//// return account + String.valueOf(new Date());
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// @PostMapping("findByAccount")
|
|
|
+//// public HttpResult findByAccount(HashMap params) {
|
|
|
+//// List<SysUser> data = sysUserService.findByAccount(params);
|
|
|
+//// return HttpResult.ok(data);
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// @PostMapping("findPage")
|
|
|
+//// public HttpResult findPage(Map<String, Object> params) {
|
|
|
+//// PageResult pageResult = sysUserService.findPage(params);
|
|
|
+//// return HttpResult.ok(pageResult);
|
|
|
+//// }
|
|
|
+////
|
|
|
+////
|
|
|
//// /**
|
|
|
//// * 分布式事务示例
|
|
|
//// * @return
|
|
|
@@ -123,11 +93,9 @@
|
|
|
//// }
|
|
|
//
|
|
|
//
|
|
|
+//import org.springframework.web.bind.annotation.GetMapping;
|
|
|
//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// @GetMapping("/testSensitive")
|
|
|
+//@GetMapping("/testSensitive")
|
|
|
// public HttpResult testSensitive() {
|
|
|
// TestSensitive testSensitive = new TestSensitive();
|
|
|
// testSensitive.setIdCard("210397198608215431");
|