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

修改部分功能

上级 e33b846a
......@@ -215,6 +215,7 @@
<module>ruoyi-generator</module>
<module>ruoyi-common</module>
<module>ruoyi-mqtt</module>
<module>topology</module>
</modules>
<packaging>pom</packaging>
......
......@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.Set;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -18,6 +19,7 @@ import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysMenuService;
import org.springframework.web.client.RestTemplate;
/**
* 登录验证
......@@ -49,6 +51,13 @@ public class SysLoginController
public AjaxResult login(@RequestBody LoginBody loginBody)
{
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(),
loginBody.getUuid());
......
......@@ -65,7 +65,8 @@ public class IndexController extends BaseController {
iTopologyService.updateTopologyById(topologyData);
return AjaxResult.success();
}
@PreAuthorize( "@ss.hasAnyPermi('topology:index:list')")
@PreAuthorize("@ss.hasPermi('topology:index:list')")
@GetMapping("/list")
public TableDataInfo list() {
startPage();
......@@ -106,16 +107,29 @@ public class IndexController extends BaseController {
stringRedisTemplate.opsForValue().set( Constants.TOPOLOGY_DATA+id,jsonObject.toJSONString() );
return AjaxResult.success();
}
@PostMapping("/test")
public void test(@RequestBody String data) throws IOException {
System.out.println(data);
@GetMapping("/test")
public void test(@RequestParam(value = "id") String id) throws IOException {
// System.out.println(data);
// JSONObject jsonObject= JSON.parseObject( "{\n" +
// " tag: 'numA', //tag节点\n" +
// " fontColor: 'red', //数据颜色\n" +
// " text: 'test', //文本内容\n" +
// " }" );
// webSocketServer.sendInfo(jsonObject.toJSONString() ,"1" );
iTopologyService.ces();
System.out.println("他请求成功了");
// iTopologyService.ces();
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);
}
}
......@@ -70,4 +70,10 @@ spring:
merge-sql: true
wall:
config:
multi-statement-allow: true
\ No newline at end of file
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 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--安全模块-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.security.oauth.boot</groupId>-->
<!-- <artifactId>spring-security-oauth2-autoconfigure</artifactId>-->
<!-- <version>2.1.2.RELEASE</version>-->
<!-- </dependency>-->
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
......
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.context.annotation.Bean;
import org.springframework.http.HttpMethod;
......@@ -14,15 +17,13 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutFilter;
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配置
*
* @author ruoyi
*/
//@EnableOAuth2Sso
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter
{
......@@ -98,6 +99,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问
.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(
HttpMethod.GET,
"/*.html",
......
......@@ -14,6 +14,7 @@ public interface ITopologyService {
void saveTopologyToId(TopologyData topologyData);
List<TopologyData> getTopology(TopologyData topologyData);
List<TopologyData> getTopologyToSwitchIt(TopologyData topologyData);
TopologyData getTopologyById(Integer id);
......
......@@ -33,6 +33,12 @@ public class TopologyService implements ITopologyService {
return topologyMapper.getTopology(topologyData);
}
@Override
public List<TopologyData> getTopologyToSwitchIt(TopologyData topologyData) {
topologyData.setSwitchIt( "1" );
return topologyMapper.getTopology(topologyData);
}
@Override
public TopologyData getTopologyById(Integer 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论