Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
刘栋
/
infynova-udi
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b3c5e98a
authored
May 17, 2024
by
刘栋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UDI-用户数据隔离
parent
605580c6
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
328 additions
and
29 deletions
pom.xml
saas-udi-service/pom.xml
saas-udi-service/src/main/java/com/infynova/udi/UdiApplication.java
saas-udi-service/src/main/java/com/infynova/udi/config/JsonSerializerManage.java
saas-udi-service/src/main/java/com/infynova/udi/config/LongToStringSerializer.java
saas-udi-service/src/main/java/com/infynova/udi/config/mybatis/CustomTenantHandler.java
saas-udi-service/src/main/java/com/infynova/udi/config/mybatis/MybatisInterceptor.java
saas-udi-service/src/main/java/com/infynova/udi/config/MybatisPlusConfig.java → saas-udi-service/src/main/java/com/infynova/udi/config/mybatis/MybatisPlusConfig.java
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiController.java
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiHelperController.java
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiMatchDataController.java
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiMatchTaskController.java
saas-udi-service/src/main/java/com/infynova/udi/dto/UdiMatchDetailListQry.java
saas-udi-service/src/main/java/com/infynova/udi/dto/UdiMatchTaskListQry.java
saas-udi-service/src/main/java/com/infynova/udi/entity/MatchData.java
saas-udi-service/src/main/java/com/infynova/udi/entity/MatchTemp.java
saas-udi-service/src/main/java/com/infynova/udi/entity/Task.java
saas-udi-service/src/main/java/com/infynova/udi/entity/TaskRecord.java
saas-udi-service/src/main/java/com/infynova/udi/filter/IdentityFilter.java
saas-udi-service/src/main/java/com/infynova/udi/mapper/MatchDataMapper.java
saas-udi-service/src/main/java/com/infynova/udi/service/impl/MatchDataServiceImpl.java
saas-udi-service/src/main/resources/mapper/MatchDataMapper.xml
saas-udi-service/src/main/resources/mapper/TaskMapper.xml
pom.xml
View file @
b3c5e98a
...
...
@@ -24,7 +24,7 @@
<alibaba.version>
2021.1
</alibaba.version>
<lombok.version>
1.18.20
</lombok.version>
<fastjson.version>
1.2.57
</fastjson.version>
<mybatisplus.version>
3.
4.0
</mybatisplus.version>
<mybatisplus.version>
3.
5.6
</mybatisplus.version>
<mybatisplus.dynamic.datasource.version>
3.4.1
</mybatisplus.dynamic.datasource.version>
<spring.version>
5.3.7
</spring.version>
<redis.version>
2.4.2
</redis.version>
...
...
saas-udi-service/pom.xml
View file @
b3c5e98a
...
...
@@ -180,7 +180,23 @@
<artifactId>
hutool-all
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
transmittable-thread-local
</artifactId>
<version>
2.11.4
</version>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
0.9.1
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.10.4
</version>
</dependency>
<dependency>
<groupId>
com.infynova
</groupId>
...
...
saas-udi-service/src/main/java/com/infynova/udi/UdiApplication.java
View file @
b3c5e98a
...
...
@@ -21,7 +21,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableDiscoveryClient
@MapperScan
(
UdiConstant
.
MAPPER_PACKAGE_NAME
)
@EnableMethodCache
(
basePackages
=
{
UdiConstant
.
UDI_PACKAGE_NAME
})
@SpringBootApplication
(
scanBasePackages
=
{
"com.infynova.udi"
})
@SpringBootApplication
(
scanBasePackages
=
{
"com.infynova.udi"
,
"com.infynova.common"
})
public
class
UdiApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UdiApplication
.
class
,
args
);
...
...
saas-udi-service/src/main/java/com/infynova/udi/config/JsonSerializerManage.java
View file @
b3c5e98a
...
...
@@ -24,7 +24,8 @@ import java.time.format.DateTimeFormatter;
* @date 2020/9/15
* @return
*/
@Configuration
@Deprecated
//@Configuration
public
class
JsonSerializerManage
{
@Bean
...
...
saas-udi-service/src/main/java/com/infynova/udi/config/LongToStringSerializer.java
View file @
b3c5e98a
...
...
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import
java.io.IOException
;
@Deprecated
public
class
LongToStringSerializer
extends
StdSerializer
<
Long
>
{
protected
LongToStringSerializer
(
Class
<
Long
>
t
)
{
super
(
t
);
...
...
saas-udi-service/src/main/java/com/infynova/udi/config/mybatis/CustomTenantHandler.java
0 → 100644
View file @
b3c5e98a
package
com
.
infynova
.
udi
.
config
.
mybatis
;
/**
* @author liudong
* 2024/5/17 19:25
* @version 1.0
*/
import
com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler
;
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
net.sf.jsqlparser.expression.Expression
;
import
net.sf.jsqlparser.expression.LongValue
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.mapping.SqlCommandType
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Component
public
class
CustomTenantHandler
implements
TenantLineHandler
{
@Override
public
Expression
getTenantId
()
{
// 假设有一个租户上下文,能够从中获取当前用户的租户
Long
identityId
=
SpringContextUtils
.
getIdentityId
();
// 返回租户ID的表达式
return
new
LongValue
(
identityId
);
}
@Override
public
String
getTenantIdColumn
()
{
return
"create_by"
;
}
@Override
public
boolean
ignoreTable
(
String
tableName
)
{
// 根据需要返回是否忽略该表
if
(
StringUtils
.
equals
(
"product"
,
tableName
)){
return
true
;
}
return
false
;
}
}
saas-udi-service/src/main/java/com/infynova/udi/config/mybatis/MybatisInterceptor.java
0 → 100644
View file @
b3c5e98a
/*
* Copyright [2021] [SaasPlatform ]
*
* 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
.
infynova
.
udi
.
config
.
mybatis
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
com.infynova.common.core.context.HeaderCode
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
@Slf4j
@Component
public
class
MybatisInterceptor
implements
MetaObjectHandler
{
/**
* 如果请求的实体有参数则默认不会替换值
*
* @param metaObject
*/
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
log
.
info
(
"start insert fill ...."
);
if
(
metaObject
.
hasGetter
(
"createTime"
))
{
this
.
strictInsertFill
(
metaObject
,
"createTime"
,
LocalDateTime:
:
now
,
LocalDateTime
.
class
);
}
if
(
metaObject
.
hasGetter
(
"createBy"
)
&&
metaObject
.
getValue
(
"createBy"
)
==
null
)
{
this
.
strictInsertFill
(
metaObject
,
"createBy"
,
Long
.
class
,
SpringContextUtils
.
getIdentityId
());
}
if
(
metaObject
.
hasGetter
(
"operatorId"
)
&&
metaObject
.
getValue
(
"operatorId"
)
==
null
)
{
this
.
strictInsertFill
(
metaObject
,
"operatorId"
,
Long
.
class
,
SpringContextUtils
.
getIdentityId
());
}
if
(
metaObject
.
hasGetter
(
"updateTime"
))
{
this
.
strictInsertFill
(
metaObject
,
"updateTime"
,
LocalDateTime:
:
now
,
LocalDateTime
.
class
);
}
if
(
metaObject
.
hasGetter
(
"updateBy"
))
{
this
.
strictInsertFill
(
metaObject
,
"updateBy"
,
Long
.
class
,
SpringContextUtils
.
getIdentityId
());
}
if
(
metaObject
.
hasGetter
(
"tenantId"
)
&&
metaObject
.
getValue
(
"tenantId"
)
==
null
)
{
// udi使用创建人id作为数据隔离用途
this
.
strictInsertFill
(
metaObject
,
"tenantId"
,
Long
.
class
,
SpringContextUtils
.
getIdentityId
());
}
}
/**
* 如果请求的实体有参数则默认不会替换值
*
* @param metaObject
*/
@Override
public
void
updateFill
(
MetaObject
metaObject
)
{
log
.
info
(
"start update fill ...."
);
if
(
metaObject
.
hasGetter
(
"updateTime"
))
{
this
.
strictUpdateFill
(
metaObject
,
"updateTime"
,
LocalDateTime:
:
now
,
LocalDateTime
.
class
);
}
if
(
metaObject
.
hasGetter
(
"updateBy"
))
{
this
.
strictUpdateFill
(
metaObject
,
"updateBy"
,
Long
.
class
,
SpringContextUtils
.
getIdentityId
());
}
if
(
metaObject
.
hasGetter
(
"updateName"
)
&&
metaObject
.
getValue
(
"updateName"
)
==
null
)
{
this
.
strictInsertFill
(
metaObject
,
"updateName"
,
String
.
class
,
SpringContextUtils
.
get
(
HeaderCode
.
USER_NAME
));
}
}
}
saas-udi-service/src/main/java/com/infynova/udi/config/MybatisPlusConfig.java
→
saas-udi-service/src/main/java/com/infynova/udi/config/
mybatis/
MybatisPlusConfig.java
View file @
b3c5e98a
package
com
.
infynova
.
udi
.
config
;
package
com
.
infynova
.
udi
.
config
.
mybatis
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.core.injector.AbstractMethod
;
import
com.baomidou.mybatisplus.core.injector.DefaultSqlInjector
;
import
com.baomidou.mybatisplus.core.injector.ISqlInjector
;
import
com.baomidou.mybatisplus.core.metadata.TableInfo
;
import
com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById
;
import
com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
...
...
@@ -22,12 +26,18 @@ import java.util.List;
@Configuration
public
class
MybatisPlusConfig
{
@Resource
private
CustomTenantHandler
customTenantHandler
;
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
// 分页插件
interceptor
.
addInnerInterceptor
(
new
PaginationInnerInterceptor
(
DbType
.
MYSQL
));
interceptor
.
addInnerInterceptor
(
new
OptimisticLockerInnerInterceptor
());
TenantLineInnerInterceptor
tenantInterceptor
=
new
TenantLineInnerInterceptor
();
tenantInterceptor
.
setTenantLineHandler
(
customTenantHandler
);
interceptor
.
addInnerInterceptor
(
tenantInterceptor
);
return
interceptor
;
}
...
...
@@ -35,8 +45,8 @@ public class MybatisPlusConfig {
public
ISqlInjector
sqlInjector
()
{
return
new
DefaultSqlInjector
()
{
@Override
public
List
<
AbstractMethod
>
getMethodList
(
Class
<?>
mapperClass
)
{
List
<
AbstractMethod
>
methodList
=
super
.
getMethodList
(
mapperClass
);
public
List
<
AbstractMethod
>
getMethodList
(
org
.
apache
.
ibatis
.
session
.
Configuration
configuration
,
Class
<?>
mapperClass
,
TableInfo
tableInfo
)
{
List
<
AbstractMethod
>
methodList
=
super
.
getMethodList
(
configuration
,
mapperClass
,
tableInfo
);
methodList
.
add
(
new
InsertBatchSomeColumn
());
methodList
.
add
(
new
AlwaysUpdateSomeColumnById
());
return
methodList
;
...
...
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiController.java
View file @
b3c5e98a
...
...
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infynova.common.core.api.ResponseData
;
import
com.infynova.common.core.context.HeaderCode
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
com.infynova.udi.dto.UdiListQry
;
import
com.infynova.udi.service.helper.UdiEasyExcelHelper
;
import
com.infynova.udi.service.UdiService
;
...
...
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiHelperController.java
View file @
b3c5e98a
...
...
@@ -29,25 +29,6 @@ public class UdiHelperController {
@Resource
private
MatchHelper
matchHelper
;
@ApiOperationSupport
(
order
=
10000
)
@ApiOperation
(
value
=
"测试对码匹配"
,
notes
=
"测试对码匹配"
,
hidden
=
true
)
@GetMapping
(
"tranMatchRate"
)
public
ResponseData
<?>
tranMatchRate
()
{
log
.
info
(
"tranMatchRate"
);
matchHelper
.
tranMatchRate
();
return
ResponseData
.
ok
();
}
// @ApiOperationSupport(order = 10000)
// @ApiOperation(value = "测试分词器", notes = "测试分词器", hidden = true)
// @GetMapping("splitWord")
// public ResponseData<String> splitWord(@RequestParam(name = "word") String word) throws Exception {
// log.info("splitWord:");
// List<String> splitWord = IKAnalyzerSupport.iKSegmenterToList(word);
// String result = splitWord.stream().map(String::valueOf).distinct().collect(Collectors.joining("|")) ;
// return ResponseData.ok(result);
// }
@Resource
private
TaskUploadHelper
taskUploadHelper
;
...
...
@@ -55,7 +36,7 @@ public class UdiHelperController {
private
TaskHelper
taskHelper
;
@ApiOperationSupport
(
order
=
10000
)
@ApiOperation
(
value
=
"测试
转换数据"
,
notes
=
"测试
转换数据"
,
hidden
=
true
)
@ApiOperation
(
value
=
"测试
任务转换数据"
,
notes
=
"测试任务
转换数据"
,
hidden
=
true
)
@PostMapping
(
"testTranData"
)
public
ResponseData
<?>
testTranData
(
@RequestBody
@Valid
IdQry
idQry
)
{
log
.
info
(
"testTranData:"
+
JSON
.
toJSONString
(
idQry
));
...
...
@@ -79,4 +60,15 @@ public class UdiHelperController {
log
.
info
(
"getTaskNo:"
);
return
ResponseData
.
ok
(
taskHelper
.
getTaskNo
());
}
@ApiOperationSupport
(
order
=
20000
)
@ApiOperation
(
value
=
"测试对码匹配"
,
notes
=
"测试对码匹配"
,
hidden
=
true
)
@GetMapping
(
"tranMatchRate"
)
public
ResponseData
<?>
tranMatchRate
()
{
log
.
info
(
"tranMatchRate"
);
matchHelper
.
tranMatchRate
();
return
ResponseData
.
ok
();
}
}
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiMatchDataController.java
View file @
b3c5e98a
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infynova.common.core.api.ResponseData
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
com.infynova.udi.dto.*
;
import
com.infynova.udi.entity.MatchData
;
import
com.infynova.udi.entity.MatchTemp
;
...
...
@@ -43,6 +44,7 @@ public class UdiMatchDataController {
@PostMapping
(
"list"
)
public
ResponseData
<
Page
<
UdiMatchDataVo
>>
list
(
@RequestBody
@Valid
UdiMatchDetailListQry
udiMatchDetailListQry
){
log
.
info
(
"list:"
+
JSON
.
toJSONString
(
udiMatchDetailListQry
));
udiMatchDetailListQry
.
setCreateBy
(
SpringContextUtils
.
getIdentityId
());
return
ResponseData
.
ok
(
matchDataService
.
queryMatchDataPage
(
udiMatchDetailListQry
));
}
...
...
@@ -51,6 +53,7 @@ public class UdiMatchDataController {
@PostMapping
(
"export"
)
public
void
export
(
@RequestBody
@Valid
UdiMatchDetailListQry
udiMatchDetailListQry
)
throws
IOException
{
log
.
info
(
"export:"
+
JSON
.
toJSONString
(
udiMatchDetailListQry
));
udiMatchDetailListQry
.
setCreateBy
(
SpringContextUtils
.
getIdentityId
());
udiMatchDetailListQry
.
setPageSize
(-
1
);
Page
<
UdiMatchDataVo
>
page
=
matchDataService
.
queryMatchDataPage
(
udiMatchDetailListQry
);
List
<
UdiMatchDataExportVo
>
exportList
=
new
ArrayList
<>();
...
...
saas-udi-service/src/main/java/com/infynova/udi/controller/UdiMatchTaskController.java
View file @
b3c5e98a
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infynova.common.core.api.ResponseData
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
com.infynova.udi.dto.*
;
import
com.infynova.udi.service.helper.UdiEasyExcelHelper
;
import
com.infynova.udi.service.TaskImportService
;
...
...
@@ -82,6 +83,7 @@ public class UdiMatchTaskController {
@PostMapping
(
"list"
)
public
ResponseData
<
Page
<
UdiMatchListVo
>>
list
(
@RequestBody
@Valid
UdiMatchTaskListQry
udiMatchTaskListQry
){
log
.
info
(
"list:"
+
JSON
.
toJSONString
(
udiMatchTaskListQry
));
udiMatchTaskListQry
.
setCreateBy
(
SpringContextUtils
.
getIdentityId
());
return
ResponseData
.
ok
(
taskService
.
queryTaskPage
(
udiMatchTaskListQry
));
}
...
...
saas-udi-service/src/main/java/com/infynova/udi/dto/UdiMatchDetailListQry.java
View file @
b3c5e98a
...
...
@@ -72,4 +72,7 @@ public class UdiMatchDetailListQry extends PageVo {
*/
@ApiModelProperty
(
value
=
"处理状态:0-待处理、10-处理中、44-无需处理、100-已处理"
)
private
List
<
Integer
>
updateStatusList
;
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
,
hidden
=
true
)
private
Long
createBy
;
}
saas-udi-service/src/main/java/com/infynova/udi/dto/UdiMatchTaskListQry.java
View file @
b3c5e98a
...
...
@@ -32,4 +32,7 @@ public class UdiMatchTaskListQry extends PageVo {
@ApiModelProperty
(
value
=
"上传时间结束"
)
private
LocalDate
uploadTimeEnd
;
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
,
hidden
=
true
)
private
Long
createBy
;
}
saas-udi-service/src/main/java/com/infynova/udi/entity/MatchData.java
View file @
b3c5e98a
...
...
@@ -154,7 +154,13 @@ public class MatchData {
@ApiModelProperty
(
value
=
"灭菌方式"
)
private
String
sterilizationMethod
;
/** 租户=创建人数据隔离 */
@TableField
(
fill
=
FieldFill
.
INSERT
)
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
)
private
Long
tenantId
;
/** 创建人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建人id"
)
private
Long
createBy
;
...
...
@@ -163,10 +169,12 @@ public class MatchData {
private
String
createName
;
/** 创建时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
LocalDateTime
createTime
;
/** 修改人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"修改人id"
)
private
Long
updateBy
;
...
...
@@ -175,6 +183,7 @@ public class MatchData {
private
String
updateName
;
/** 修改时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
LocalDateTime
updateTime
;
...
...
saas-udi-service/src/main/java/com/infynova/udi/entity/MatchTemp.java
View file @
b3c5e98a
package
com
.
infynova
.
udi
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -133,7 +135,13 @@ public class MatchTemp {
@ApiModelProperty
(
value
=
"灭菌方式"
)
private
String
sterilizationMethod
;
/** 租户=创建人数据隔离 */
@TableField
(
fill
=
FieldFill
.
INSERT
)
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
)
private
Long
tenantId
;
/** 创建人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建人id"
)
private
Long
createBy
;
...
...
@@ -142,10 +150,12 @@ public class MatchTemp {
private
String
createName
;
/** 创建时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
LocalDateTime
createTime
;
/** 修改人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"修改人id"
)
private
Long
updateBy
;
...
...
@@ -154,6 +164,7 @@ public class MatchTemp {
private
String
updateName
;
/** 修改时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
LocalDateTime
updateTime
;
...
...
saas-udi-service/src/main/java/com/infynova/udi/entity/Task.java
View file @
b3c5e98a
...
...
@@ -85,6 +85,7 @@ public class Task {
private
String
matchTimeDesc
;
/** 操作人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"操作人id"
)
private
Long
operatorId
;
...
...
@@ -92,7 +93,13 @@ public class Task {
@ApiModelProperty
(
value
=
"操作人"
)
private
String
operator
;
/** 租户=创建人数据隔离 */
@TableField
(
fill
=
FieldFill
.
INSERT
)
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
)
private
Long
tenantId
;
/** 创建人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建人id"
)
private
Long
createBy
;
...
...
@@ -101,10 +108,12 @@ public class Task {
private
Long
creator
;
/** 创建时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
LocalDateTime
createTime
;
/** 修改时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
LocalDateTime
updateTime
;
...
...
saas-udi-service/src/main/java/com/infynova/udi/entity/TaskRecord.java
View file @
b3c5e98a
package
com
.
infynova
.
udi
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.infynova.udi.enums.task.TaskRecordEnum
;
import
com.infynova.udi.enums.task.TaskRecordTypeEnum
;
...
...
@@ -37,7 +39,13 @@ public class TaskRecord {
@ApiModelProperty
(
value
=
"记录标识:0-普通、1-上传、2-对码"
)
private
Integer
recordType
;
/** 租户=创建人数据隔离 */
@TableField
(
fill
=
FieldFill
.
INSERT
)
@ApiModelProperty
(
value
=
"租户=创建人数据隔离"
)
private
Long
tenantId
;
/** 创建人id */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建人id"
)
private
Long
createBy
;
...
...
@@ -46,6 +54,7 @@ public class TaskRecord {
private
Long
creator
;
/** 创建时间 */
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
LocalDateTime
createTime
;
}
...
...
saas-udi-service/src/main/java/com/infynova/udi/filter/IdentityFilter.java
0 → 100644
View file @
b3c5e98a
package
com
.
infynova
.
udi
.
filter
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.infynova.common.core.constant.AuthRedisKeyConstant
;
import
com.infynova.common.core.context.HeaderCode
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
com.infynova.common.core.exception.SaasException
;
import
com.infynova.common.core.exception.SaasNotTokenException
;
import
com.infynova.common.core.jwt.AuthUtil
;
import
com.infynova.common.core.jwt.model.JwtUserInfo
;
import
com.infynova.udi.exception.CommonExceptionCode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.Ordered
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* @author liudong
* 2024/5/16 18:13
* @version 1.0
*/
@Slf4j
@WebFilter
(
urlPatterns
=
"/*"
,
filterName
=
"IdentityFilter"
)
@Component
public
class
IdentityFilter
implements
Filter
{
private
final
static
String
LOG_PREFIX
=
"身份验证"
;
@Resource
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Resource
private
AuthUtil
authUtil
;
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
log
.
info
(
LOG_PREFIX
+
"初始化~"
);
Filter
.
super
.
init
(
filterConfig
);
}
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
HttpServletRequest
httpRequest
=
(
HttpServletRequest
)
request
;
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
// 进行身份验证逻辑,例如检查用户是否已登录,或者检查请求中的认证信息等
// 如果验证成功,则调用chain.doFilter(request, response)来继续执行请求,否则可以返回未经授权的错误信息
// 客户端
// 获取请求头的值
String
clientCode
=
httpRequest
.
getHeader
(
HeaderCode
.
CLIENT_CODE
);
// token
String
token
=
httpRequest
.
getHeader
(
HeaderCode
.
TOKEN
);
//log.info("请求路径:{}", httpRequest.getPathInfo());
//log.info("请求客户端:{}", clientCode);
if
(
StrUtil
.
isBlank
(
token
))
{
throw
new
SaasException
(
CommonExceptionCode
.
SYSTEM_401
);
}
JwtUserInfo
authInfo
=
authUtil
.
getAuthInfo
(
token
);
Optional
.
ofNullable
(
authInfo
).
orElseThrow
(()
->
new
SaasNotTokenException
(
CommonExceptionCode
.
SYSTEM_401
));
String
identityId
=
String
.
valueOf
(
authInfo
.
getIdentityId
());
Long
identityInvalid
=
(
Long
)
redisTemplate
.
opsForValue
().
get
(
AuthRedisKeyConstant
.
USER_INVALID_JWT
+
identityId
);
if
(
ObjectUtil
.
isNotNull
(
identityInvalid
))
{
log
.
error
(
"TOKEN失效-用户禁用 {}"
,
token
);
throw
new
SaasNotTokenException
(
CommonExceptionCode
.
SYSTEM_401
);
}
SpringContextUtils
.
set
(
HeaderCode
.
IDENTITY_ID
,
identityId
);
SpringContextUtils
.
set
(
HeaderCode
.
USER_NAME
,
authInfo
.
getUserName
());
SpringContextUtils
.
set
(
HeaderCode
.
ACCOUNT_ID
,
String
.
valueOf
(
authInfo
.
getAccountId
()));
SpringContextUtils
.
set
(
HeaderCode
.
DEPT_ID
,
String
.
valueOf
(
authInfo
.
getDeptId
()));
SpringContextUtils
.
set
(
HeaderCode
.
DEPT_CODE
,
authInfo
.
getDeptCode
());
SpringContextUtils
.
set
(
HeaderCode
.
USER_TYPE
,
String
.
valueOf
(
authInfo
.
getUserType
()));
SpringContextUtils
.
set
(
HeaderCode
.
DATA_SCOPE
,
String
.
valueOf
(
authInfo
.
getDeptCode
()));
SpringContextUtils
.
set
(
HeaderCode
.
TENANT_ID
,
String
.
valueOf
(
authInfo
.
getTenantId
()));
chain
.
doFilter
(
request
,
response
);
}
@Override
public
void
destroy
()
{
log
.
info
(
LOG_PREFIX
+
"销毁~"
);
Filter
.
super
.
destroy
();
}
}
saas-udi-service/src/main/java/com/infynova/udi/mapper/MatchDataMapper.java
View file @
b3c5e98a
...
...
@@ -25,5 +25,5 @@ public interface MatchDataMapper extends SuperMapper<MatchData> {
Set
<
Long
>
queryMatchWaitingTask
();
List
<
TaskMatchStatisticVo
>
queryTaskMatchStatistic
(
@Param
(
"taskIds"
)
Collection
<
Long
>
taskIds
);
List
<
TaskMatchStatisticVo
>
queryTaskMatchStatistic
(
@Param
(
"taskIds"
)
Collection
<
Long
>
taskIds
,
@Param
(
"createBy"
)
Long
createBy
);
}
saas-udi-service/src/main/java/com/infynova/udi/service/impl/MatchDataServiceImpl.java
View file @
b3c5e98a
...
...
@@ -3,6 +3,7 @@ package com.infynova.udi.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.infynova.common.core.context.SpringContextUtils
;
import
com.infynova.udi.dto.UdiAllMatchQry
;
import
com.infynova.udi.dto.UdiBatchMatchQry
;
import
com.infynova.udi.dto.UdiMatchConfirmationDto
;
...
...
@@ -80,7 +81,7 @@ public class MatchDataServiceImpl extends BaseService implements MatchDataServic
*/
@Override
public
List
<
TaskMatchStatisticVo
>
queryTaskMatchStatistic
(
List
<
Long
>
taskIds
)
{
return
matchDataMapper
.
queryTaskMatchStatistic
(
taskIds
);
return
matchDataMapper
.
queryTaskMatchStatistic
(
taskIds
,
SpringContextUtils
.
getIdentityId
()
);
}
/**
...
...
saas-udi-service/src/main/resources/mapper/MatchDataMapper.xml
View file @
b3c5e98a
...
...
@@ -10,6 +10,7 @@
match_data as md
left join task as t on t.id = md.task_id
<where>
AND md.create_by = #{query.createBy}
<if
test=
" query.taskId != null"
>
AND md.task_id = #{query.taskId}
</if>
...
...
@@ -62,6 +63,7 @@
SUM(IF(match_status = 99, 1, 0)) AS never
from match_data
<where>
AND create_by = #{createBy}
<if
test=
" taskIds != null and taskIds.size > 0"
>
AND task_id IN
<foreach
collection=
"taskIds"
item=
"taskId"
open=
"("
close=
")"
separator=
","
>
#{taskId}
</foreach>
</if>
...
...
saas-udi-service/src/main/resources/mapper/TaskMapper.xml
View file @
b3c5e98a
...
...
@@ -8,6 +8,7 @@
from
task as t
<where>
AND t.create_by = #{query.createBy}
<if
test=
" query.taskStatusList != null and query.taskStatusList.size() > 0"
>
AND t.task_status IN
<foreach
collection=
"query.taskStatusList"
item=
"taskStatus"
open=
"("
close=
")"
separator=
","
>
#{taskStatus}
</foreach>
</if>
...
...
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