Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
朱海
/
VVAS-PicGroup
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a7a6b60b
authored
Jul 09, 2025
by
zhuht
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg]增加门店配置集团级配置的适配;
1 parent
02c382e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
12 deletions
src/main/java/com/viontech/keliu/dao/ConfigParamDao.java
src/main/java/com/viontech/keliu/entity/SConfigParam.java
src/main/java/com/viontech/keliu/dao/ConfigParamDao.java
View file @
a7a6b60
package
com
.
viontech
.
keliu
.
dao
;
import
com.viontech.keliu.entity.SConfigParam
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.
namedparam.NamedParameter
JdbcTemplate
;
import
org.springframework.stereotype.Repository
;
import
jakarta.annotation.Resource
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -23,17 +22,46 @@ import java.util.stream.Collectors;
public
class
ConfigParamDao
{
@Resource
private
JdbcTemplate
j
dbcTemplate
;
private
NamedParameterJdbcTemplate
namedParameterJ
dbcTemplate
;
public
String
getConfigParamByMallIdAndConfigKey
(
Long
mallId
,
String
configKey
)
{
String
sql
=
"select mall_id, config_key, config_value from s_config_params where (mall_id = ? or mall_id is null) and config_key = ? order by mall_id asc limit 1;"
;
SConfigParam
configParam
=
null
;
try
{
configParam
=
jdbcTemplate
.
queryForObject
(
sql
,
new
BeanPropertyRowMapper
<>(
SConfigParam
.
class
),
mallId
,
configKey
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取配置异常"
,
e
);
List
<
SConfigParam
>
mallConfigParams
=
getMallConfigParams
(
mallId
,
Collections
.
singletonList
(
configKey
));
if
(
mallConfigParams
.
isEmpty
())
{
return
null
;
}
return
mallConfigParams
.
get
(
0
).
getConfigValue
();
}
public
List
<
SConfigParam
>
getMallConfigParams
(
Long
mallId
,
List
<
String
>
configKeys
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"mallId"
,
mallId
);
params
.
put
(
"configKeys"
,
configKeys
);
String
sql
=
"SELECT * FROM s_config_params WHERE config_key IN (:configKeys) "
+
"AND ((account_id IS NULL AND mall_id IS NULL) "
+
"OR (account_id = (SELECT account_id FROM b_mall WHERE id = :mallId) AND mall_id IS NULL) "
+
"OR (mall_id = :mallId));"
;
// 门店配置,集团配置,系统配置
List
<
SConfigParam
>
sConfigParams
=
namedParameterJdbcTemplate
.
query
(
sql
,
params
,
new
BeanPropertyRowMapper
<>(
SConfigParam
.
class
));
return
new
ArrayList
<>(
sConfigParams
.
stream
().
collect
(
Collectors
.
toMap
(
SConfigParam:
:
getConfigKey
,
config
->
config
,
this
::
mergeByPriority
)).
values
());
}
/**
* @param config 配置
* @return 配置的使用优先级。数字越小,优先级越高。门店级最高
*/
private
int
getLevel
(
SConfigParam
config
)
{
if
(
config
.
getMallId
()
!=
null
)
{
return
1
;
}
if
(
config
.
getAccountId
()
!=
null
)
{
return
2
;
}
return
configParam
==
null
?
null
:
configParam
.
getConfigValue
();
return
3
;
}
private
SConfigParam
mergeByPriority
(
SConfigParam
c1
,
SConfigParam
c2
)
{
return
getLevel
(
c1
)
<=
getLevel
(
c2
)
?
c1
:
c2
;
}
}
\ No newline at end of file
src/main/java/com/viontech/keliu/entity/SConfigParam.java
View file @
a7a6b60
...
...
@@ -12,6 +12,7 @@ import lombok.Data;
@Data
public
class
SConfigParam
{
private
Long
accountId
;
private
Long
mallId
;
private
String
configKey
;
private
String
configValue
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment