Skip to content

Commit ce69033

Browse files
committed
refactor/微服务改造
1 parent 42eaecc commit ce69033

File tree

1,855 files changed

+120161
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,855 files changed

+120161
-87
lines changed

pmhub-api/pmhub-api-system/pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
8+
<artifactId>pmhub-api</artifactId>
9+
<version>0.0.1</version>
10+
</parent>
11+
12+
<artifactId>pmhub-api-system</artifactId>
13+
<description>
14+
pmhub-api-system系统接口模块feign
15+
</description>
16+
17+
<properties>
18+
<maven.compiler.source>8</maven.compiler.source>
19+
<maven.compiler.target>8</maven.compiler.target>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
26+
<artifactId>pmhub-base-core</artifactId>
27+
</dependency>
28+
</dependencies>
29+
30+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.laigeoffer.pmhub.api.system;
2+
3+
import com.laigeoffer.pmhub.api.system.factory.UserFeginFallbackFactory;
4+
import com.laigeoffer.pmhub.base.core.constant.ServiceNameConstants;
5+
import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
6+
import org.springframework.cloud.openfeign.FeignClient;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
10+
/**
11+
* @author canghe
12+
* @description 用户服务
13+
* @create 2024-04-24-22:38
14+
*/
15+
@FeignClient(contextId = "userFeignService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = UserFeginFallbackFactory.class)
16+
public interface UserFeignService {
17+
18+
/**
19+
* 根据用户编号获取详细信息
20+
*/
21+
@GetMapping(value = {"/", "/{userId}"})
22+
AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) ;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.laigeoffer.pmhub.api.system.factory;
2+
3+
import com.laigeoffer.pmhub.api.system.UserFeignService;
4+
import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.cloud.openfeign.FallbackFactory;
8+
import org.springframework.stereotype.Component;
9+
10+
/**
11+
* 用户服务降级处理
12+
*
13+
* @author ruoyi
14+
*/
15+
@Component
16+
public class UserFeginFallbackFactory implements FallbackFactory<UserFeignService>
17+
{
18+
private static final Logger log = LoggerFactory.getLogger(UserFeginFallbackFactory.class);
19+
20+
@Override
21+
public UserFeignService create(Throwable throwable)
22+
{
23+
log.error("用户服务调用失败:{}", throwable.getMessage());
24+
return new UserFeignService()
25+
{
26+
@Override
27+
public AjaxResult getInfo(Long userId)
28+
{
29+
return AjaxResult.error("获取用户失败:" + throwable.getMessage());
30+
}
31+
32+
};
33+
}
34+
}

pmhub-api/pom.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
8+
<artifactId>pmhub</artifactId>
9+
<version>0.0.1</version>
10+
</parent>
11+
12+
<artifactId>pmhub-api</artifactId>
13+
<packaging>pom</packaging>
14+
15+
<properties>
16+
<maven.compiler.source>8</maven.compiler.source>
17+
<maven.compiler.target>8</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<modules>
22+
<module>pmhub-api-system</module>
23+
</modules>
24+
25+
</project>

pmhub-auth/pom.xml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
8+
<artifactId>pmhub</artifactId>
9+
<version>0.0.1</version>
10+
</parent>
11+
12+
<artifactId>pmhub-auth</artifactId>
13+
14+
<description>
15+
pmhub-auth认证授权中心
16+
</description>
17+
18+
<properties>
19+
<maven.compiler.source>8</maven.compiler.source>
20+
<maven.compiler.target>8</maven.compiler.target>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
</properties>
23+
24+
<dependencies>
25+
26+
<!-- SpringCloud Alibaba Nacos -->
27+
<dependency>
28+
<groupId>com.alibaba.cloud</groupId>
29+
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
30+
</dependency>
31+
32+
<!-- SpringCloud Alibaba Nacos Config -->
33+
<dependency>
34+
<groupId>com.alibaba.cloud</groupId>
35+
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
36+
</dependency>
37+
38+
<!-- SpringCloud Alibaba Sentinel -->
39+
<dependency>
40+
<groupId>com.alibaba.cloud</groupId>
41+
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
42+
</dependency>
43+
44+
<!-- SpringBoot Web -->
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-web</artifactId>
48+
</dependency>
49+
50+
<!-- SpringBoot Actuator -->
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-starter-actuator</artifactId>
54+
</dependency>
55+
56+
<!-- PmHub Base Core-->
57+
<dependency>
58+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
59+
<artifactId>pmhub-base-core</artifactId>
60+
</dependency>
61+
62+
<!-- PmHub Base Core-->
63+
<dependency>
64+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
65+
<artifactId>pmhub-base-security</artifactId>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
70+
<artifactId>pmhub-base-framework</artifactId>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>com.laigeoffer.pmhub-cloud</groupId>
75+
<artifactId>pmhub-api-system</artifactId>
76+
</dependency>
77+
78+
79+
80+
</dependencies>
81+
82+
83+
84+
<build>
85+
<finalName>${project.artifactId}</finalName>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.springframework.boot</groupId>
89+
<artifactId>spring-boot-maven-plugin</artifactId>
90+
<executions>
91+
<execution>
92+
<goals>
93+
<goal>repackage</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
</plugins>
99+
</build>
100+
101+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.laigeoffer.pmhub.auth;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
6+
7+
/**
8+
* @author canghe
9+
* @description 认证授权中心
10+
* @create 2024-04-23-15:00
11+
*/
12+
//@EnableRyFeignClients todo
13+
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
14+
public class PmHubAuthApplication {
15+
public static void main(String[] args) {
16+
SpringApplication.run(PmHubAuthApplication.class, args);
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.laigeoffer.pmhub.auth.controller;
2+
3+
import com.laigeoffer.pmhub.api.system.UserFeignService;
4+
import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
5+
import com.laigeoffer.pmhub.base.core.utils.JsonUtils;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
import javax.annotation.Resource;
12+
13+
14+
/**
15+
* 登录验证
16+
*
17+
* @author canghe
18+
*/
19+
@RestController
20+
@Slf4j
21+
public class LoginController {
22+
23+
24+
// @Autowired
25+
// private SysLoginService loginService;
26+
27+
@Resource
28+
private UserFeignService userFeignService;
29+
30+
// @Autowired
31+
// private ISysMenuService menuService;
32+
//
33+
//
34+
// @Autowired
35+
// private SysPermissionService permissionService;
36+
37+
38+
39+
40+
41+
42+
// /**
43+
// * 登录方法
44+
// *
45+
// * @param loginBody 登录信息
46+
// * @return 结果
47+
// */
48+
// @PostMapping("/login")
49+
// public AjaxResult login(@RequestBody LoginBody loginBody) {
50+
// AjaxResult ajax = success();
51+
// // 生成令牌
52+
// String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
53+
// loginBody.getUuid());
54+
// ajax.put(Constants.TOKEN, token);
55+
// return ajax;
56+
// }
57+
//
58+
/**
59+
* 获取用户信息
60+
*
61+
* @return 用户信息
62+
*/
63+
@GetMapping("getInfo/{userid}")
64+
public AjaxResult getInfo(@PathVariable long userid) {
65+
// SysUser user = SecurityUtils.getLoginUser().getUser();
66+
AjaxResult userInfo = userFeignService.getInfo(userid);
67+
log.info(JsonUtils.toJsonString(userInfo));
68+
return userInfo;
69+
}
70+
//
71+
// /**
72+
// * 获取路由信息
73+
// *
74+
// * @return 路由信息
75+
// */
76+
// @GetMapping("getRouters")
77+
// public AjaxResult getRouters() {
78+
// Long userId = SecurityUtils.getUserId();
79+
// List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
80+
// return success(menuService.buildMenus(menus));
81+
// }
82+
83+
84+
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//package com.laigeoffer.pmhub.auth.controller;
2+
//
3+
//import com.laigeoffer.pmhub.auth.service.SysRegisterService;
4+
//import com.laigeoffer.pmhub.base.core.core.controller.BaseController;
5+
//import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
6+
//import com.laigeoffer.pmhub.base.core.core.domain.model.RegisterBody;
7+
//import com.laigeoffer.pmhub.base.core.utils.StringUtils;
8+
//import org.springframework.beans.factory.annotation.Autowired;
9+
//import org.springframework.web.bind.annotation.PostMapping;
10+
//import org.springframework.web.bind.annotation.RequestBody;
11+
//import org.springframework.web.bind.annotation.RestController;
12+
//
13+
///**
14+
// * 注册验证
15+
// *
16+
// * @author canghe
17+
// */
18+
//@RestController
19+
//public class SysRegisterController extends BaseController {
20+
// @Autowired
21+
// private SysRegisterService registerService;
22+
//
23+
//// @Autowired
24+
//// private ISysConfigService configService;
25+
//
26+
// @PostMapping("/register")
27+
// public AjaxResult register(@RequestBody RegisterBody user) {
28+
//// if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
29+
//// return error("当前系统没有开启注册功能!");
30+
//// }
31+
// String msg = registerService.register(user);
32+
// return StringUtils.isEmpty(msg) ? success() : error(msg);
33+
// }
34+
//}

0 commit comments

Comments
 (0)