Преглед на файлове

新建风控模块用于解析风控策略
增加feign组件用于微服务间通信

marxjaw преди 5 месеца
родител
ревизия
28fe4e15cb

+ 1 - 0
pom.xml

@@ -13,6 +13,7 @@
         <module>yt-gateway</module>
         <module>yt-oauth</module>
         <module>yt-agent</module>
+        <module>yt-risk</module>
     </modules>
 
     <properties>

+ 34 - 0
yt-agent/agent-feign/pom.xml

@@ -0,0 +1,34 @@
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ytpm</groupId>
+        <artifactId>yt-agent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>agent-feign</artifactId>
+    <packaging>jar</packaging>
+
+    <name>agent-feign</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <configuration>
+                    <skip>
+                        true
+                    </skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 12 - 0
yt-agent/agent-feign/src/main/java/com/ytpm/feign/AgentFeign.java

@@ -0,0 +1,12 @@
+package com.ytpm.feign;
+
+import com.ytpm.agent.view.AgentUserInfo;
+import com.ytpm.general.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@FeignClient(name = "agent-service")
+public interface AgentFeign {
+    @GetMapping("/ytUser/curUser")
+    Result<AgentUserInfo> getLoginInfo();
+}

+ 5 - 0
yt-agent/agent-service/pom.xml

@@ -32,5 +32,10 @@
             <artifactId>guava</artifactId>
             <version>31.0-jre</version>
         </dependency>
+        <dependency>
+            <groupId>com.ytpm</groupId>
+            <artifactId>agent-feign</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>

+ 2 - 1
yt-agent/agent-service/src/main/java/com/ytpm/AgentApplication.java

@@ -4,13 +4,14 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 @SpringBootApplication
 @EnableDiscoveryClient
 @MapperScan(basePackages = "com.ytpm.dao")
-//@EnableFeignClients(basePackages = {"com.source.cloud.feign"})
+@EnableFeignClients(basePackages = {"com.ytpm.feign"})
 public class AgentApplication
 {
     public static void main( String[] args )

+ 0 - 1
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/YtAppUserServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ytpm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.app.model.YtAppUserLoginRecord;

+ 1 - 0
yt-agent/pom.xml

@@ -15,6 +15,7 @@
     <url>http://maven.apache.org</url>
     <modules>
         <module>agent-service</module>
+        <module>agent-feign</module>
     </modules>
 
     <properties>

+ 112 - 0
yt-risk/pom.xml

@@ -0,0 +1,112 @@
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ytpm</groupId>
+        <artifactId>yt_platform</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>yt-risk</artifactId>
+    <packaging>pom</packaging>
+
+    <name>yt-risk</name>
+    <url>http://maven.apache.org</url>
+    <modules>
+        <module>risk-manage</module>
+        <module>risk-feign</module>
+    </modules>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>jsr305</artifactId>
+                    <groupId>com.google.code.findbugs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j2</artifactId>
+        </dependency>
+
+        <!--Spring Cloud Alibaba-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+
+        <!--database-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>jsqlparser</artifactId>
+                    <groupId>com.github.jsqlparser</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>com.ytpm</groupId>
+            <artifactId>yt-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>jsqlparser</artifactId>
+                    <groupId>com.github.jsqlparser</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>jsr305</artifactId>
+                    <groupId>com.google.code.findbugs</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 37 - 0
yt-risk/risk-feign/pom.xml

@@ -0,0 +1,37 @@
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ytpm</groupId>
+        <artifactId>yt-risk</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>risk-feign</artifactId>
+    <packaging>jar</packaging>
+
+    <name>risk-feign</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <configuration>
+                    <skip>
+                        true
+                    </skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 8 - 0
yt-risk/risk-feign/src/main/java/com/ytpm/feign/RiskFeign.java

@@ -0,0 +1,8 @@
+package com.ytpm.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+
+@FeignClient(name = "risk-manage")
+public interface RiskFeign {
+
+}

+ 40 - 0
yt-risk/risk-manage/pom.xml

@@ -0,0 +1,40 @@
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.ytpm</groupId>
+        <artifactId>yt-risk</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>risk-manage</artifactId>
+    <packaging>jar</packaging>
+
+    <name>risk-manage</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-oauth2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>31.0-jre</version>
+        </dependency>
+        <dependency>
+            <groupId>com.ytpm</groupId>
+            <artifactId>risk-feign</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>

+ 19 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/RiskManageApplication.java

@@ -0,0 +1,19 @@
+package com.ytpm;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@SpringBootApplication
+@EnableDiscoveryClient
+@MapperScan(basePackages = "com.ytpm.dao")
+public class RiskManageApplication
+{
+    public static void main( String[] args )
+    {
+        SpringApplication.run(RiskManageApplication.class, args);
+    }
+}

+ 100 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/config/CustomUserAuthenticationConverter.java

@@ -0,0 +1,100 @@
+package com.ytpm.config;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ytpm.agent.view.AgentUserInfo;
+import com.ytpm.constant.StrConstant;
+import com.ytpm.dao.AgentUserMapper;
+import com.ytpm.util.RedisService;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.*;
+
+/**
+ * 自定义Security上下文信息
+ */
+@Data
+@Component
+@Slf4j
+public class CustomUserAuthenticationConverter implements UserAuthenticationConverter {
+    private Collection<? extends GrantedAuthority> defaultAuthorities =
+            new ArrayList<>(AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_ADMIN"));
+    private UserDetailsService userDetailsService;
+
+    @Autowired
+    private RedisService redisService;
+    @Autowired
+    private AgentUserMapper userMapper;
+
+    @Override
+    public Map<String, ?> convertUserAuthentication(Authentication authentication) {
+        Map<String, Object> response = new LinkedHashMap();
+        response.put("username", authentication.getName());
+        if (authentication.getAuthorities() != null && !authentication.getAuthorities().isEmpty()) {
+            response.put("authorities", AuthorityUtils.authorityListToSet(authentication.getAuthorities()));
+        }
+        return response;
+    }
+
+    @Override
+    public Authentication extractAuthentication(Map<String, ?> map) {
+        if (map.containsKey("user_name")) {
+            String userName = (String) map.get("user_name");
+            Object principal;
+            Collection<? extends GrantedAuthority> authorities = this.getAuthorities(map);
+            AgentUserInfo user = userMapper.getCurrentUserInfo(userName);
+            if(Objects.isNull(user)){
+                log.error("当前用户不存在,应该退出登录");
+                return null;
+            }
+            String key = StrConstant.USER_INFO_PRE + userName ;
+            if (redisService.hasKey(key)) {
+                String str = redisService.getStr(key);
+                AgentUserInfo jwtUser = JSONObject.parseObject(str, AgentUserInfo.class);
+                principal = jwtUser;
+                authorities = jwtUser.getAuthorities();
+            } else {
+                AgentUserInfo jwtUser = new AgentUserInfo();
+                BeanUtil.copyProperties(user,jwtUser);
+                authorities = jwtUser.getAuthorities();
+                principal = jwtUser;
+                redisService.setStr(key, JSON.toJSONString(user));
+            }
+            return new UsernamePasswordAuthenticationToken(principal, "N/A", authorities);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 用户资源授权的方法重写  暂时未使用
+     *
+     * @param map
+     * @return
+     */
+    private Collection<? extends GrantedAuthority> getAuthorities(Map<String, ?> map) {
+        if (!map.containsKey("authorities")) {
+            return this.defaultAuthorities;
+        } else {
+            Object authorities = map.get("authorities");
+            if (authorities instanceof String) {
+                return AuthorityUtils.commaSeparatedStringToAuthorityList((String) authorities);
+            } else if (authorities instanceof Collection) {
+                return AuthorityUtils.commaSeparatedStringToAuthorityList(StringUtils.collectionToCommaDelimitedString((Collection) authorities));
+            } else {
+                throw new IllegalArgumentException("Authorities must be either a String or a Collection");
+            }
+        }
+    }
+}

+ 72 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/config/ResourceServerConfig.java

@@ -0,0 +1,72 @@
+package com.ytpm.config;
+
+import com.ytpm.config.handle.AuthExceptionEntryPoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
+
+
+@Configuration
+@EnableResourceServer
+public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
+    @Value("${security.oauth2.client.client-id}")
+    private String clientId;
+
+    @Value("${security.oauth2.client.client-secret}")
+    private String secret;
+
+    @Value("${security.oauth2.authorization.check-token-access}")
+    private String checkTokenEndpointUrl;
+
+    @Autowired
+    private RedisConnectionFactory redisConnectionFactory;
+
+    @Autowired
+    private AuthExceptionEntryPoint authExceptionEntryPoint;
+
+    @Autowired
+    private CustomUserAuthenticationConverter userAuthenticationConverter;
+
+    @Bean
+    public TokenStore redisTokenStore() {
+        return new RedisTokenStore(redisConnectionFactory);
+    }
+
+    @Bean
+    public RemoteTokenServices tokenService() {
+        RemoteTokenServices tokenService = new RemoteTokenServices();
+        tokenService.setClientId(clientId);
+        tokenService.setClientSecret(secret);
+        tokenService.setCheckTokenEndpointUrl(checkTokenEndpointUrl);
+        DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();
+        defaultAccessTokenConverter.setUserTokenConverter(userAuthenticationConverter);
+        tokenService.setAccessTokenConverter(defaultAccessTokenConverter);
+        return tokenService;
+    }
+
+    @Override
+    public void configure(ResourceServerSecurityConfigurer resources) {
+        resources.authenticationEntryPoint(authExceptionEntryPoint);
+        resources.resourceId("agent-service");
+    }
+
+    @Override
+    public void configure(HttpSecurity http) throws Exception {
+        http.headers().frameOptions().disable()
+                .and()
+                .authorizeRequests().antMatchers("/api/public/**","/doc.html","/api/v2/**","/v2/api-docs", "/configuration/ui", "/swagger-resources", "/configuration/security",
+                        "/swagger-ui.html", "/webjars/**","/swagger-resources/configuration/ui","/swagger-ui.html").permitAll()
+                .anyRequest().authenticated();
+    }
+
+}

+ 33 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/config/feign/FeignConfiguration.java

@@ -0,0 +1,33 @@
+package com.ytpm.config.feign;
+
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Enumeration;
+
+@Configuration
+public class FeignConfiguration implements RequestInterceptor {
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
+                .getRequestAttributes();
+        if (attributes == null) {
+            return;
+        }
+        HttpServletRequest request = attributes.getRequest();
+
+        Enumeration<String> headerNames = request.getHeaderNames();
+        if (headerNames != null) {
+            while (headerNames.hasMoreElements()) {
+                String name = headerNames.nextElement();
+                String values = request.getHeader(name);
+                requestTemplate.header(name, values);
+            }
+        }
+    }
+}

+ 40 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/config/handle/AuthExceptionEntryPoint.java

@@ -0,0 +1,40 @@
+package com.ytpm.config.handle;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ytpm.general.RepMessage;
+import com.ytpm.general.StatusCode;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 客户端未授权的访问处理逻辑
+ */
+@Component
+@Slf4j
+public class AuthExceptionEntryPoint implements AuthenticationEntryPoint {
+    @Override
+    public void commence(HttpServletRequest request, HttpServletResponse response,
+                         AuthenticationException authException) {
+        Throwable cause = authException.getCause();
+        response.setHeader("Content-Type", "application/json;charset=UTF-8");
+        try {
+            JSONObject body = new JSONObject();
+            body.put("code", StatusCode.MANAGE_NOT_LOGIN);
+            body.put("message", RepMessage.TOKEN_EXPIRE);
+            if (!(cause instanceof InvalidTokenException)) {
+                body.put("code", StatusCode.MANAGE_NOT_LOGIN);
+                body.put("message", RepMessage.TOKEN_INVALID);
+            }
+            response.getWriter().write(body.toJSONString());
+        } catch (IOException e) {
+            log.error("token认证失败={}", e);
+        }
+    }
+}

+ 40 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/config/swagger/SwaggerConfig.java

@@ -0,0 +1,40 @@
+package com.ytpm.config.swagger;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    private static final String VERSION = "1.0.0";
+
+    @Bean
+    public Docket createApi(){
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.ytpm.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("")
+                .contact(new Contact("易推网络","http://www.sourcetreasure.com/index.html","marxjaw6466@163.com"))
+                .description("代理商管理系统")
+                .termsOfServiceUrl("https://juejin.cn/user/4310510864972254")
+                .license("The Apache License, Version 2.0")
+                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
+                .version(VERSION)
+                .build();
+    }
+}

+ 14 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/dao/AgentUserMapper.java

@@ -0,0 +1,14 @@
+package com.ytpm.dao;
+
+import com.ytpm.agent.view.AgentUserInfo;
+import org.apache.ibatis.annotations.Param;
+import org.mapstruct.Mapper;
+
+@Mapper
+public interface AgentUserMapper {
+    /**
+     * 获取当前登录用户信息
+     * @param loginName 用户名
+     */
+    AgentUserInfo getCurrentUserInfo(@Param("loginName")String loginName);
+}

+ 35 - 0
yt-risk/risk-manage/src/main/resources/bootstrap.yml

@@ -0,0 +1,35 @@
+spring:
+  profiles:
+    active: local
+---
+spring:
+  profiles: local
+  main:
+    allow-bean-definition-overriding: true
+  application:
+    name: risk-manage
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        namespace: 52439154-ea03-4121-9759-44d0cacc4765
+      config:
+        server-addr: 127.0.0.1:8848
+        file-extension: yml
+        namespace: 52439154-ea03-4121-9759-44d0cacc4765
+---
+spring:
+  profiles: dev
+  main:
+    allow-bean-definition-overriding: true
+  application:
+    name: risk-manage
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 121.37.82.232:8848
+        namespace: 776851c5-aa23-4606-b2b2-941487de707f
+      config:
+        server-addr: 121.37.82.232:8848
+        file-extension: yml
+        namespace: 776851c5-aa23-4606-b2b2-941487de707f

+ 12 - 0
yt-risk/risk-manage/src/main/resources/mapper/AgentUserMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ytpm.dao.AgentUserMapper">
+
+    <select id="getCurrentUserInfo" resultType="com.ytpm.agent.view.AgentUserInfo">
+        select
+            user_id, nick_name, head_image, login_name, encrypt_pwd, salt, phone, last_login_time, last_login_ip, phone_brand, phone_model, account_status, channel_id, user_type, login_days, total_income, app_id, registry_time, transfer_amount
+        from yt_platform_user
+        where account_status = 1
+        and login_name = #{loginName}
+    </select>
+</mapper>