Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
1aa5d1eb
Commit
1aa5d1eb
authored
Mar 31, 2020
by
季圣华
Browse files
优化架构的代码逻辑
parent
f954061d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/service/InterfaceContainer.java
View file @
1aa5d1eb
...
@@ -13,48 +13,19 @@ import java.util.Map;
...
@@ -13,48 +13,19 @@ import java.util.Map;
*/
*/
@Service
@Service
public
class
InterfaceContainer
{
public
class
InterfaceContainer
{
private
final
Map
<
String
,
Integer
>
nameTypeMap
;
private
final
Map
<
String
,
ICommonQuery
>
configComponentMap
=
new
HashMap
<>();
private
final
Map
<
Integer
,
ICommonQuery
>
configComponentMap
;
public
InterfaceContainer
()
{
nameTypeMap
=
new
HashMap
<>();
configComponentMap
=
new
HashMap
<>();
}
@Autowired
(
required
=
false
)
@Autowired
(
required
=
false
)
private
void
init
(
ICommonQuery
[]
configComponents
)
{
private
synchronized
void
init
(
ICommonQuery
[]
configComponents
)
{
for
(
ICommonQuery
configComponent
:
configComponents
)
{
for
(
ICommonQuery
configComponent
:
configComponents
)
{
ResourceInfo
info
=
AnnotationUtils
.
getAnnotation
(
configComponent
,
ResourceInfo
.
class
);
ResourceInfo
info
=
AnnotationUtils
.
getAnnotation
(
configComponent
,
ResourceInfo
.
class
);
if
(
info
!=
null
)
{
if
(
info
!=
null
)
{
initResourceInfo
(
info
);
configComponentMap
.
put
(
info
.
value
(),
configComponent
);
configComponentMap
.
put
(
info
.
type
(),
configComponent
);
}
}
}
}
}
}
public
int
getResourceType
(
String
apiName
)
{
if
(!
nameTypeMap
.
containsKey
(
apiName
))
{
throw
new
RuntimeException
(
"资源:"
+
apiName
+
"的组件不存在"
);
}
return
nameTypeMap
.
get
(
apiName
);
}
public
ICommonQuery
getCommonQuery
(
String
apiName
)
{
public
ICommonQuery
getCommonQuery
(
String
apiName
)
{
return
get
Com
m
on
Query
(
this
.
getResourceType
(
apiName
)
)
;
return
config
Com
p
on
entMap
.
get
(
apiName
);
}
}
private
ICommonQuery
getCommonQuery
(
int
resourceType
)
{
Assert
.
isTrue
(
configComponentMap
.
containsKey
(
resourceType
));
return
configComponentMap
.
get
(
resourceType
);
}
private
synchronized
void
initResourceInfo
(
ResourceInfo
info
)
{
if
(
nameTypeMap
.
containsKey
(
info
.
value
()))
{
Assert
.
isTrue
(
nameTypeMap
.
get
(
info
.
value
()).
equals
(
info
.
type
()));
}
else
{
nameTypeMap
.
put
(
info
.
value
(),
info
.
type
());
}
}
}
}
Write
Preview
Supports
Markdown
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