|
@@ -4,6 +4,9 @@ import cn.hutool.captcha.AbstractCaptcha;
|
|
|
import cn.hutool.captcha.generator.CodeGenerator;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.nacos.api.annotation.NacosInjected;
|
|
|
+import com.alibaba.nacos.api.config.annotation.NacosValue;
|
|
|
+import com.alibaba.nacos.api.naming.NamingService;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.enums.CaptchaType;
|
|
@@ -14,6 +17,10 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.CommandLineRunner;
|
|
|
+import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
@@ -27,11 +34,20 @@ import java.util.concurrent.TimeUnit;
|
|
|
* @author ruoyi
|
|
|
*/
|
|
|
@RestController
|
|
|
-public class CaptchaController {
|
|
|
+public class CaptchaController implements CommandLineRunner {
|
|
|
|
|
|
@Autowired
|
|
|
private CaptchaProperties captchaProperties;
|
|
|
|
|
|
+// @NacosInjected
|
|
|
+// private NamingService namingService;
|
|
|
+
|
|
|
+ @NacosValue(value = "${yjzh.name:ini}",autoRefreshed = true)
|
|
|
+ private String applicationName;
|
|
|
+
|
|
|
+ @NacosValue(value = "${yjzh.port:0}",autoRefreshed = true)
|
|
|
+ private Integer serverPort;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
|
|
@@ -64,6 +80,17 @@ public class CaptchaController {
|
|
|
return AjaxResult.success(ajax);
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ApplicationContext context;
|
|
|
+
|
|
|
+ @GetMapping("/test")
|
|
|
+ public AjaxResult getTest(){
|
|
|
+ Map<String, Object> ajax = new HashMap<>();
|
|
|
+ ajax.put("data", applicationName);
|
|
|
+
|
|
|
+ return AjaxResult.success(ajax);
|
|
|
+
|
|
|
+ }
|
|
|
private String getCodeResult(String capStr) {
|
|
|
int numberLength = captchaProperties.getNumberLength();
|
|
|
int a = Convert.toInt(StringUtils.substring(capStr, 0, numberLength).trim());
|
|
@@ -81,4 +108,16 @@ public class CaptchaController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void run(String... args) throws Exception {
|
|
|
+
|
|
|
+// try{
|
|
|
+// namingService.registerInstance(applicationName+"ss", "127.0.0.1", serverPort.intValue());
|
|
|
+// }catch (Exception ee){
|
|
|
+//
|
|
|
+// }
|
|
|
+// namingService.registerInstance(applicationName+"ss", "127.0.0.1", serverPort.intValue());
|
|
|
+// namingService.registerInstance(applicationName+"1", "127.0.0.1", serverPort.intValue(),"验证码1");
|
|
|
+
|
|
|
+ }
|
|
|
}
|