From 00af391ce67fefafc77b8cb4c80946549f991ac3 Mon Sep 17 00:00:00 2001 From: caojianbin <1910336823> Date: Mon, 25 Mar 2024 17:09:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=9B=BD=E9=99=85=E5=8C=96,?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=A8=A1=E5=9D=97=E5=BC=80=E5=8F=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/feign/SysUserFeignClient.java | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../security/annotation/EnableRyFeignClients.java | 24 ++++++++++++++++++++++ .../src/main/resources/META-INF/spring.factories | 6 ++++++ .../src/main/resources/application-dev.yml | 12 +++++------ .../system/security/EcellSecurityApplication.java | 23 +++++++++++++++++++++ .../security/service/impl/SysMenuServiceImpl.java | 2 ++ .../src/main/resources/application-dev.yml | 4 ++-- .../src/main/resources/bootstrap.yml | 6 +++--- 9 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/java/com/ecell/internationalize/common/security/annotation/EnableRyFeignClients.java create mode 100644 ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/resources/META-INF/spring.factories create mode 100644 ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/EcellSecurityApplication.java diff --git a/ecell-internationalize/ecell-internationalize-auth/src/main/java/com/ecell/internationalize/auth/feign/SysUserFeignClient.java b/ecell-internationalize/ecell-internationalize-auth/src/main/java/com/ecell/internationalize/auth/feign/SysUserFeignClient.java index e32e893..e3cd253 100644 --- a/ecell-internationalize/ecell-internationalize-auth/src/main/java/com/ecell/internationalize/auth/feign/SysUserFeignClient.java +++ b/ecell-internationalize/ecell-internationalize-auth/src/main/java/com/ecell/internationalize/auth/feign/SysUserFeignClient.java @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; /** * @author borui */ -@FeignClient(value = "yisai-system-security",fallback = SysUserFeignServiceFallBack.class,contextId ="yisai-system-security003") +@FeignClient(value = "ecell-internationalize-security",fallback = SysUserFeignServiceFallBack.class,contextId ="ecell-internationalize-security003") public interface SysUserFeignClient { /** * 通过用户名查询用户信息 diff --git a/ecell-internationalize/ecell-internationalize-auth/src/main/resources/application-dev.yml b/ecell-internationalize/ecell-internationalize-auth/src/main/resources/application-dev.yml index eca5750..08a0fe3 100644 --- a/ecell-internationalize/ecell-internationalize-auth/src/main/resources/application-dev.yml +++ b/ecell-internationalize/ecell-internationalize-auth/src/main/resources/application-dev.yml @@ -16,7 +16,7 @@ mybatis: #配置SQL映射文件路径 mapper-locations: classpath:mapper/*.xml # 搜索指定包别名 - typeAliasesPackage: com.yisai.auth + typeAliasesPackage: com.ecell.internationalize.auth #驼峰命名 configuration: map-underscore-to-camel-case: true diff --git a/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/java/com/ecell/internationalize/common/security/annotation/EnableRyFeignClients.java b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/java/com/ecell/internationalize/common/security/annotation/EnableRyFeignClients.java new file mode 100644 index 0000000..5c2d535 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/java/com/ecell/internationalize/common/security/annotation/EnableRyFeignClients.java @@ -0,0 +1,24 @@ +package com.ecell.internationalize.common.security.annotation; + +import org.springframework.cloud.openfeign.EnableFeignClients; + +import java.lang.annotation.*; + +/** + * @author borui + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@EnableFeignClients +public @interface EnableRyFeignClients { + String[] value() default {}; + + String[] basePackages() default {"com.ecell.internationalize"}; + + Class[] basePackageClasses() default {}; + + Class[] defaultConfiguration() default {}; + + Class[] clients() default {}; +} diff --git a/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/resources/META-INF/spring.factories b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..d262be1 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-common/ecell-internationalize-security/src/main/resources/META-INF/spring.factories @@ -0,0 +1,6 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.ecell.internationalize.common.security.config.WebMvcConfig,\ + com.ecell.internationalize.common.security.service.TokenService,\ + com.ecell.internationalize.common.security.aspect.PreAuthorizeAspect,\ + com.ecell.internationalize.common.security.aspect.InnerAuthAspect,\ + com.ecell.internationalize.common.security.handler.GlobalExceptionHandler diff --git a/ecell-internationalize/ecell-internationalize-gateway/src/main/resources/application-dev.yml b/ecell-internationalize/ecell-internationalize-gateway/src/main/resources/application-dev.yml index 3ffd078..b2a469d 100644 --- a/ecell-internationalize/ecell-internationalize-gateway/src/main/resources/application-dev.yml +++ b/ecell-internationalize/ecell-internationalize-gateway/src/main/resources/application-dev.yml @@ -15,7 +15,7 @@ spring: - id: ecell-internationalize-auth uri: lb://ecell-internationalize-auth predicates: - - Path=/auth/** + - Path=/ecell-internationalize-auth/** filters: # 验证码处理 - CacheRequestFilter @@ -30,10 +30,10 @@ spring: - StripPrefix=1 #易赛授权服务 - - id: yisai-system-security - uri: lb://yisai-system-security + - id: ecell-internationalize-security + uri: lb://ecell-internationalize-security predicates: - - Path=/yisai_security/** + - Path=/ecell-internationalize-security/** filters: - StripPrefix=1 #易赛APP服务 @@ -59,8 +59,8 @@ security: # 不校验白名单 ignore: whites: - - /auth/logout - - /auth/login + - /ecell-internationalize-auth/auth/logout + - /ecell-internationalize-auth/auth/login - /auth/register - /*/v2/api-docs - /csrf diff --git a/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/EcellSecurityApplication.java b/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/EcellSecurityApplication.java new file mode 100644 index 0000000..17ca535 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/EcellSecurityApplication.java @@ -0,0 +1,23 @@ +package com.ecell.internationalize.system.security; + +import com.ecell.internationalize.common.security.annotation.EnableCustomConfig; +import com.ecell.internationalize.common.security.annotation.EnableRyFeignClients; +import com.ecell.internationalize.common.swagger.annotation.EnableCustomSwagger2; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author borui + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@MapperScan("com.**.mapper") +@SpringBootApplication(scanBasePackages = {"com.ecell.internationalize"}) +public class EcellSecurityApplication { + public static void main(String[] args) { + SpringApplication.run(EcellSecurityApplication.class, args); + System.out.println("系统用户服务启动成功"); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/service/impl/SysMenuServiceImpl.java b/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/service/impl/SysMenuServiceImpl.java index 8d2b7cf..6e7079b 100644 --- a/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/service/impl/SysMenuServiceImpl.java +++ b/ecell-internationalize/ecell-internationalize-system-security/src/main/java/com/ecell/internationalize/system/security/service/impl/SysMenuServiceImpl.java @@ -10,12 +10,14 @@ import com.ecell.internationalize.system.security.mapper.SysMenuMapper; import com.ecell.internationalize.system.security.service.SysMenuService; import com.ecell.internationalize.system.security.util.TreeUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import java.util.*; /** * @author borui */ +@Service public class SysMenuServiceImpl extends ServiceImpl implements SysMenuService { @Autowired private SysMenuMapper sysMenuMapper; diff --git a/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/application-dev.yml b/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/application-dev.yml index 22baaaf..cff67f7 100644 --- a/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/application-dev.yml +++ b/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ spring: encoding: UTF-8 datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.0.108:3306/ys-business?serverTimeZone=UTC + url: jdbc:mysql://192.168.0.113:3306/ys-business?serverTimeZone=UTC username: root password: 123456 #数据源的其他配置 @@ -35,7 +35,7 @@ mybatis: #配置SQL映射文件路径 mapper-locations: classpath:mapper/*.xml # 搜索指定包别名 - typeAliasesPackage: com.yisai.system.security + typeAliasesPackage: com.ecell.internationalize.system.security #驼峰命名 configuration: map-underscore-to-camel-case: true diff --git a/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/bootstrap.yml b/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/bootstrap.yml index 8f1c23a..e07959d 100644 --- a/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/bootstrap.yml +++ b/ecell-internationalize/ecell-internationalize-system-security/src/main/resources/bootstrap.yml @@ -6,7 +6,7 @@ server: spring: application: # 应用名称 - name: yisai-system-security + name: ecell-internationalize-security profiles: # 环境配置 active: dev @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: ecell-nacos:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: ecell-nacos:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置