提交 a7db4af2 authored 作者: jianglw's avatar jianglw

修改部分功能

上级 e33b846a
...@@ -215,6 +215,7 @@ ...@@ -215,6 +215,7 @@
<module>ruoyi-generator</module> <module>ruoyi-generator</module>
<module>ruoyi-common</module> <module>ruoyi-common</module>
<module>ruoyi-mqtt</module> <module>ruoyi-mqtt</module>
<module>topology</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>
......
...@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system; ...@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.client.support.BasicAuthenticationInterceptor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -18,6 +19,7 @@ import com.ruoyi.framework.web.service.SysLoginService; ...@@ -18,6 +19,7 @@ import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService; import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysMenuService;
import org.springframework.web.client.RestTemplate;
/** /**
* 登录验证 * 登录验证
...@@ -49,6 +51,13 @@ public class SysLoginController ...@@ -49,6 +51,13 @@ public class SysLoginController
public AjaxResult login(@RequestBody LoginBody loginBody) public AjaxResult login(@RequestBody LoginBody loginBody)
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
RestTemplate restTemplate=new RestTemplate();
StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append( "http://192.168.2.223:3000/oauth/token" +
"?username=admin&password=123456&scope=server&grant_type=password" );
restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor( "pig","pig" ) );
String o=restTemplate.getForObject( stringBuilder.toString(),String.class );
System.out.println(o);
// 生成令牌 // 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid()); loginBody.getUuid());
......
...@@ -65,7 +65,8 @@ public class IndexController extends BaseController { ...@@ -65,7 +65,8 @@ public class IndexController extends BaseController {
iTopologyService.updateTopologyById(topologyData); iTopologyService.updateTopologyById(topologyData);
return AjaxResult.success(); return AjaxResult.success();
} }
@PreAuthorize( "@ss.hasAnyPermi('topology:index:list')")
@PreAuthorize("@ss.hasPermi('topology:index:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list() { public TableDataInfo list() {
startPage(); startPage();
...@@ -106,16 +107,29 @@ public class IndexController extends BaseController { ...@@ -106,16 +107,29 @@ public class IndexController extends BaseController {
stringRedisTemplate.opsForValue().set( Constants.TOPOLOGY_DATA+id,jsonObject.toJSONString() ); stringRedisTemplate.opsForValue().set( Constants.TOPOLOGY_DATA+id,jsonObject.toJSONString() );
return AjaxResult.success(); return AjaxResult.success();
} }
@PostMapping("/test")
public void test(@RequestBody String data) throws IOException { @GetMapping("/test")
System.out.println(data); public void test(@RequestParam(value = "id") String id) throws IOException {
// System.out.println(data);
// JSONObject jsonObject= JSON.parseObject( "{\n" + // JSONObject jsonObject= JSON.parseObject( "{\n" +
// " tag: 'numA', //tag节点\n" + // " tag: 'numA', //tag节点\n" +
// " fontColor: 'red', //数据颜色\n" + // " fontColor: 'red', //数据颜色\n" +
// " text: 'test', //文本内容\n" + // " text: 'test', //文本内容\n" +
// " }" ); // " }" );
// webSocketServer.sendInfo(jsonObject.toJSONString() ,"1" ); // webSocketServer.sendInfo(jsonObject.toJSONString() ,"1" );
iTopologyService.ces(); // iTopologyService.ces();
System.out.println("他请求成功了"); System.out.println("他请求成功了"+id);
}
//-------------------公共接口可匿名访问------------------
@GetMapping("/listAll")
public TableDataInfo listAll() {
startPage();
TopologyData topologyData = new TopologyData();
List<TopologyData> list = iTopologyService.getTopologyToSwitchIt( topologyData );
for(TopologyData t:list){
t.setData( stringRedisTemplate.opsForValue().get( Constants.TOPOLOGY_DATA+t.getId() ) );
}
return getDataTable(list);
} }
} }
...@@ -71,3 +71,9 @@ spring: ...@@ -71,3 +71,9 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
security:
oauth2:
client:
client-id: pig
client-secret: pig
scope: server
\ No newline at end of file
...@@ -34,7 +34,12 @@ ...@@ -34,7 +34,12 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<!--安全模块-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.security.oauth.boot</groupId>-->
<!-- <artifactId>spring-security-oauth2-autoconfigure</artifactId>-->
<!-- <version>2.1.2.RELEASE</version>-->
<!-- </dependency>-->
<!-- pagehelper 分页插件 --> <!-- pagehelper 分页插件 -->
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
......
package com.ruoyi.framework.config; package com.ruoyi.framework.config;
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
...@@ -14,15 +17,13 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; ...@@ -14,15 +17,13 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.web.filter.CorsFilter; import org.springframework.web.filter.CorsFilter;
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
/** /**
* spring security配置 * spring security配置
* *
* @author ruoyi * @author ruoyi
*/ */
//@EnableOAuth2Sso
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter public class SecurityConfig extends WebSecurityConfigurerAdapter
{ {
...@@ -98,6 +99,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -98,6 +99,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.authorizeRequests() .authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问 // 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage").anonymous() .antMatchers("/login", "/captchaImage").anonymous()
.antMatchers( "/topology/listAll" ).anonymous()
.antMatchers( "/topology/listAll" ).permitAll()
.antMatchers( "/topology/getTopology/**" ).anonymous()
.antMatchers( "/topology/getTopology/**" ).permitAll()
.antMatchers( "/params/**" ).anonymous()
.antMatchers( "/params/**" ).permitAll()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",
......
...@@ -14,6 +14,7 @@ public interface ITopologyService { ...@@ -14,6 +14,7 @@ public interface ITopologyService {
void saveTopologyToId(TopologyData topologyData); void saveTopologyToId(TopologyData topologyData);
List<TopologyData> getTopology(TopologyData topologyData); List<TopologyData> getTopology(TopologyData topologyData);
List<TopologyData> getTopologyToSwitchIt(TopologyData topologyData);
TopologyData getTopologyById(Integer id); TopologyData getTopologyById(Integer id);
......
...@@ -33,6 +33,12 @@ public class TopologyService implements ITopologyService { ...@@ -33,6 +33,12 @@ public class TopologyService implements ITopologyService {
return topologyMapper.getTopology(topologyData); return topologyMapper.getTopology(topologyData);
} }
@Override
public List<TopologyData> getTopologyToSwitchIt(TopologyData topologyData) {
topologyData.setSwitchIt( "1" );
return topologyMapper.getTopology(topologyData);
}
@Override @Override
public TopologyData getTopologyById(Integer id) { public TopologyData getTopologyById(Integer id) {
return topologyMapper.getTopologyById(id); return topologyMapper.getTopologyById(id);
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.3.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>topology</artifactId>
<description>
topologyWeb服务入口
</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-quartz</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
package com.ruoyi.topology;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TopologyApplication {
public static void main(String[] args) {
SpringApplication.run( TopologyApplication.class, args );
}
}
package com.ruoyi.topology;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class TopologyApplicationTests {
@Test
void contextLoads() {
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论