Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
7181c6e9
Commit
7181c6e9
authored
May 23, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
df5c37f7
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
216 additions
and
2 deletions
+216
-2
pom.xml
pom.xml
+4
-0
pom.xml
yifu-common/pom.xml
+1
-0
pom.xml
yifu-common/yifu-common-core/pom.xml
+1
-0
CommonConstants.java
...ud.plus.v1/yifu/common/core/constant/CommonConstants.java
+5
-0
UpmsDaprSiderConstants.java
....v1/yifu/common/core/constant/UpmsDaprSiderConstants.java
+19
-0
pom.xml
yifu-common/yifu-common-dapr/pom.xml
+27
-0
DaprUpmsProperties.java
...d/plus/v1/yifu/common/dapr/config/DaprUpmsProperties.java
+55
-0
HttpDaprUtil.java
...ifu/cloud/plus/v1/yifu/common/dapr/util/HttpDaprUtil.java
+61
-0
daprConfig.properties
...yifu-common-dapr/src/main/resources/daprConfig.properties
+6
-0
pom.xml
yifu-common/yifu-common-mybatis/pom.xml
+5
-0
BaseEntity.java
...fu.cloud.plus.v1/yifu/common/mybatis/base/BaseEntity.java
+3
-0
pom.xml
yifu-common/yifu-common-security/pom.xml
+6
-0
YifuResourceServerConfigurerAdapter.java
...curity/component/YifuResourceServerConfigurerAdapter.java
+4
-1
YifuUserDetailsServiceImpl.java
...u/common/security/service/YifuUserDetailsServiceImpl.java
+9
-1
UserController.java
...u.cloud.plus.v1/yifu/admin/controller/UserController.java
+10
-0
UpmsDaprSiderConstants.xml
...-biz/src/main/resources/mapper/UpmsDaprSiderConstants.xml
+0
-0
No files found.
pom.xml
View file @
7181c6e9
...
@@ -233,6 +233,10 @@
...
@@ -233,6 +233,10 @@
<profiles>
<profiles>
<profile>
<profile>
<id>
dev
</id>
<id>
dev
</id>
<activation>
<!-- 默认环境 -->
<activeByDefault>
true
</activeByDefault>
</activation>
<properties>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>
dev
</profiles.active>
<profiles.active>
dev
</profiles.active>
...
...
yifu-common/pom.xml
View file @
7181c6e9
...
@@ -41,5 +41,6 @@
...
@@ -41,5 +41,6 @@
<module>
yifu-common-feign
</module>
<module>
yifu-common-feign
</module>
<module>
yifu-common-swagger
</module>
<module>
yifu-common-swagger
</module>
<module>
yifu-common-test
</module>
<module>
yifu-common-test
</module>
<module>
yifu-common-dapr
</module>
</modules>
</modules>
</project>
</project>
yifu-common/yifu-common-core/pom.xml
View file @
7181c6e9
...
@@ -62,5 +62,6 @@
...
@@ -62,5 +62,6 @@
<artifactId>
spring-webmvc
</artifactId>
<artifactId>
spring-webmvc
</artifactId>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
View file @
7181c6e9
...
@@ -72,6 +72,11 @@ public interface CommonConstants {
...
@@ -72,6 +72,11 @@ public interface CommonConstants {
*/
*/
Integer
SUCCESS
=
0
;
Integer
SUCCESS
=
0
;
/**
* 成功标记 200
*/
int
SUCCESS_CODE
=
200
;
/**
/**
* 失败标记
* 失败标记
*/
*/
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/UpmsDaprSiderConstants.java
0 → 100644
View file @
7181c6e9
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
constant
;
/**
* @author fxj
* @Date 2022-05-19
*/
public
interface
UpmsDaprSiderConstants
{
// -app-id register-sider -app-port 8848 -dapr-http-port 3005 -dapr-grpc-port 52000 -metrics-port 9098
String
APP_ID
=
"yifu_upms_sider"
;
String
APP_PORT
=
"4000"
;
String
HTTP_PORT
=
"3005"
;
String
GRPC_PORT
=
"52000"
;
String
METRICS_PORT
=
"9094"
;
}
yifu-common/yifu-common-dapr/pom.xml
0 → 100644
View file @
7181c6e9
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
yifu-common
</artifactId>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<version>
1.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<description>
dapr引入
</description>
<artifactId>
yifu-common-dapr
</artifactId>
<dependencies>
<dependency>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<artifactId>
yifu-upms-api
</artifactId>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
yifu-common/yifu-common-dapr/src/main/java/com/yifu/cloud/plus/v1/yifu/common/dapr/config/DaprUpmsProperties.java
0 → 100644
View file @
7181c6e9
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
dapr
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
/*
*
*
* @author fxj
* @date 2022-05-23 14:28
**/
@Data
@Component
@PropertySource
(
"classpath:daprConfig.properties"
)
@ConfigurationProperties
(
value
=
"dapr.upms"
,
ignoreInvalidFields
=
false
)
public
class
DaprUpmsProperties
{
/*
* @author fxj
* @date 14:34
* @Description dapr sidercar url 如:http://localhost:3005/v1.0/invoke/
**/
String
appUrl
;
/*
* @author fxj
* @date 14:35
* @decription app_id 如:"yifu_upms_sider"
**/
String
appId
;
String
appPort
;
String
httpPort
;
String
grpcPort
;
String
metricsPort
;
}
yifu-common/yifu-common-dapr/src/main/java/com/yifu/cloud/plus/v1/yifu/common/dapr/util/HttpDaprUtil.java
0 → 100644
View file @
7181c6e9
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
dapr
.
util
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.client.RestTemplate
;
/**
* @author fxj
* @date 2022年05月23日 9:47
*/
@Log4j2
public
class
HttpDaprUtil
{
private
static
RestTemplate
restTemplate
;
private
static
HttpHeaders
headers
;
private
static
StringBuffer
stringBuffer
;
/**
* @author fxj
* @date 2022-05-23 17:56
* @param appUrl
* @param appId
* @param method
* @param param
* @param cs
* @return com.yifu.cloud.plus.v1.yifu.common.core.util.R<T>
* @description get请求获取指定对象信息
**/
public
static
<
T
>
R
<
T
>
invokeMothod
(
String
appUrl
,
String
appId
,
String
method
,
String
param
,
Class
cs
)
throws
Exception
{
// 实例化 RestTemplate
if
(
null
==
restTemplate
)
{
restTemplate
=
new
RestTemplate
();
}
// 初始化请求URL
initUrl
(
appUrl
,
appId
,
method
,
param
);
ResponseEntity
<
T
>
res
;
try
{
res
=
restTemplate
.
getForEntity
(
stringBuffer
.
toString
(),
cs
);
}
catch
(
Exception
e
)
{
return
R
.
failed
(
"获取信息失败:"
+
e
.
getMessage
());
}
if
(
null
!=
res
&&
CommonConstants
.
SUCCESS_CODE
==
res
.
getStatusCodeValue
())
{
return
R
.
ok
(
res
.
getBody
());
}
else
{
return
R
.
failed
(
"获取信息失败!"
);
}
}
private
static
void
initUrl
(
String
appUrl
,
String
appId
,
String
method
,
String
param
)
{
stringBuffer
=
new
StringBuffer
();
stringBuffer
.
append
(
appUrl
);
stringBuffer
.
append
(
appId
);
stringBuffer
.
append
(
"/method"
);
stringBuffer
.
append
(
method
);
stringBuffer
.
append
(
param
);
}
}
yifu-common/yifu-common-dapr/src/main/resources/daprConfig.properties
0 → 100644
View file @
7181c6e9
dapr.upms.appUrl
=
http://localhost:3005/v1.0/invoke/
dapr.upms.appId
=
yifu_upms_sider
dapr.upms.appPort
=
4000
dapr.upms.httpPort
=
3005
dapr.upms.grpcPort
=
52000
dapr.upms.metricsPort
=
9094
yifu-common/yifu-common-mybatis/pom.xml
View file @
7181c6e9
...
@@ -68,5 +68,10 @@
...
@@ -68,5 +68,10 @@
<artifactId>
spring-security-core
</artifactId>
<artifactId>
spring-security-core
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-annotations
</artifactId>
<version>
2.13.2
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
yifu-common/yifu-common-mybatis/src/main/java/com/yifu.cloud.plus.v1/yifu/common/mybatis/base/BaseEntity.java
View file @
7181c6e9
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.mybatis.base;
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.mybatis.base;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
...
@@ -29,6 +30,7 @@ public class BaseEntity implements Serializable {
...
@@ -29,6 +30,7 @@ public class BaseEntity implements Serializable {
/**
/**
* 创建时间
* 创建时间
*/
*/
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@Schema
(
description
=
"创建时间"
)
@Schema
(
description
=
"创建时间"
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
LocalDateTime
createTime
;
private
LocalDateTime
createTime
;
...
@@ -43,6 +45,7 @@ public class BaseEntity implements Serializable {
...
@@ -43,6 +45,7 @@ public class BaseEntity implements Serializable {
/**
/**
* 更新时间
* 更新时间
*/
*/
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@Schema
(
description
=
"更新时间"
)
@Schema
(
description
=
"更新时间"
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
LocalDateTime
updateTime
;
private
LocalDateTime
updateTime
;
...
...
yifu-common/yifu-common-security/pom.xml
View file @
7181c6e9
...
@@ -56,5 +56,11 @@
...
@@ -56,5 +56,11 @@
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<artifactId>
yifu-common-dapr
</artifactId>
<version>
1.0.0
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
yifu-common/yifu-common-security/src/main/java/com/yifu.cloud.plus.v1/yifu/common/security/component/YifuResourceServerConfigurerAdapter.java
View file @
7181c6e9
...
@@ -63,7 +63,10 @@ public class YifuResourceServerConfigurerAdapter extends ResourceServerConfigure
...
@@ -63,7 +63,10 @@ public class YifuResourceServerConfigurerAdapter extends ResourceServerConfigure
ExpressionUrlAuthorizationConfigurer
<
HttpSecurity
>.
ExpressionInterceptUrlRegistry
registry
=
httpSecurity
ExpressionUrlAuthorizationConfigurer
<
HttpSecurity
>.
ExpressionInterceptUrlRegistry
registry
=
httpSecurity
.
authorizeRequests
();
.
authorizeRequests
();
permitAllUrl
.
getUrls
().
forEach
(
url
->
registry
.
antMatchers
(
url
).
permitAll
());
permitAllUrl
.
getUrls
().
forEach
(
url
->
registry
.
antMatchers
(
url
).
permitAll
());
registry
.
anyRequest
().
authenticated
().
and
().
csrf
().
disable
();
// “/user/getInfoByUsername" URL 访问放行
registry
.
and
()
.
authorizeRequests
().
antMatchers
(
"/user/getInfoByUsername"
).
permitAll
()
.
anyRequest
().
authenticated
().
and
().
csrf
().
disable
();
}
}
@Override
@Override
...
...
yifu-common/yifu-common-security/src/main/java/com/yifu.cloud.plus.v1/yifu/common/security/service/YifuUserDetailsServiceImpl.java
View file @
7181c6e9
...
@@ -21,9 +21,13 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteUserService;
...
@@ -21,9 +21,13 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteUserService;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
...
@@ -36,6 +40,7 @@ import org.springframework.security.core.userdetails.UserDetails;
...
@@ -36,6 +40,7 @@ import org.springframework.security.core.userdetails.UserDetails;
*/
*/
@Slf4j
@Slf4j
@Primary
@Primary
@EnableConfigurationProperties
(
DaprUpmsProperties
.
class
)
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
YifuUserDetailsServiceImpl
implements
YifuUserDetailsService
{
public
class
YifuUserDetailsServiceImpl
implements
YifuUserDetailsService
{
...
@@ -43,6 +48,8 @@ public class YifuUserDetailsServiceImpl implements YifuUserDetailsService {
...
@@ -43,6 +48,8 @@ public class YifuUserDetailsServiceImpl implements YifuUserDetailsService {
private
final
CacheManager
cacheManager
;
private
final
CacheManager
cacheManager
;
private
final
DaprUpmsProperties
daprUpmsProperties
;
/**
/**
* 用户名密码登录
* 用户名密码登录
* @param username 用户名
* @param username 用户名
...
@@ -56,7 +63,8 @@ public class YifuUserDetailsServiceImpl implements YifuUserDetailsService {
...
@@ -56,7 +63,8 @@ public class YifuUserDetailsServiceImpl implements YifuUserDetailsService {
return
(
YifuUser
)
cache
.
get
(
username
).
get
();
return
(
YifuUser
)
cache
.
get
(
username
).
get
();
}
}
R
<
UserInfo
>
result
=
remoteUserService
.
info
(
username
,
SecurityConstants
.
FROM_IN
);
R
<
UserInfo
>
result
;
// = remoteUserService.info(username, SecurityConstants.FROM_IN);
result
=
HttpDaprUtil
.
invokeMothod
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
(),
"/user/getInfoByUsername"
,
"?username="
+
username
,
UserInfo
.
class
);
UserDetails
userDetails
=
getUserDetails
(
result
);
UserDetails
userDetails
=
getUserDetails
(
result
);
if
(
cache
!=
null
)
{
if
(
cache
!=
null
)
{
cache
.
put
(
username
,
userDetails
);
cache
.
put
(
username
,
userDetails
);
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/UserController.java
View file @
7181c6e9
...
@@ -93,6 +93,16 @@ public class UserController {
...
@@ -93,6 +93,16 @@ public class UserController {
return
R
.
ok
(
userService
.
getUserInfo
(
user
));
return
R
.
ok
(
userService
.
getUserInfo
(
user
));
}
}
@GetMapping
(
"/getInfoByUsername"
)
public
UserInfo
infoAPI
(
@RequestParam
(
required
=
true
,
name
=
"username"
)
String
username
)
{
SysUser
user
=
userService
.
getOne
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getUsername
,
username
));
return
userService
.
getUserInfo
(
user
);
/*if (user == null) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
}
return R.ok(userService.getUserInfo(user));*/
}
/**
/**
* 根据部门id,查询对应的用户 id 集合
* 根据部门id,查询对应的用户 id 集合
* @param deptIds 部门id 集合
* @param deptIds 部门id 集合
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/
SysDeptMapper
.xml
→
yifu-upms/yifu-upms-biz/src/main/resources/mapper/
UpmsDaprSiderConstants
.xml
View file @
7181c6e9
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment