Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
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
15所TongWeb
aserver
Commits
60798c9e
Commit
60798c9e
authored
Dec 02, 2020
by
李德才
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除SN码存入redis中的操作,由各子系统校验成功后存入
parent
573f90f3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
17 deletions
+39
-17
SnController.java
...ain/java/com/archser/aserver/controller/SnController.java
+1
-5
SnService.java
src/main/java/com/archser/aserver/service/SnService.java
+4
-8
PropertyUtil.java
src/main/java/com/archser/aserver/util/PropertyUtil.java
+32
-2
SN.properties
src/main/webapp/SN.properties
+2
-2
No files found.
src/main/java/com/archser/aserver/controller/SnController.java
View file @
60798c9e
...
@@ -21,11 +21,7 @@ public class SnController extends Controller {
...
@@ -21,11 +21,7 @@ public class SnController extends Controller {
public
void
getPropertiesValue
()
{
public
void
getPropertiesValue
()
{
String
cupCode
=
getPara
(
"cupCode"
);
String
cupCode
=
getPara
(
"cupCode"
);
try
{
try
{
String
snCode
=
snService
.
getPropertiesValue
(
cupCode
);
renderJson
(
Ret
.
ok
(
"snCode"
,
snService
.
getPropertiesValue
(
cupCode
)));
if
(
StrKit
.
isBlank
(
snCode
))
{
snService
.
setProperty
(
cupCode
,
""
);
}
renderJson
(
Ret
.
ok
(
"snCode"
,
snCode
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
renderJson
(
Ret
.
fail
());
renderJson
(
Ret
.
fail
());
...
...
src/main/java/com/archser/aserver/service/SnService.java
View file @
60798c9e
...
@@ -25,19 +25,15 @@ public class SnService {
...
@@ -25,19 +25,15 @@ public class SnService {
/**
/**
* 从 Properties 文件中获取指定对应的值
* 从 Properties 文件中获取指定对应的值
*
*
* @param c
up
Code
* @param c
pu
Code
* @return
* @return
*/
*/
public
String
getPropertiesValue
(
String
c
up
Code
)
{
public
String
getPropertiesValue
(
String
c
pu
Code
)
{
Object
redisSnCode
=
Redis
.
use
().
get
(
PREFIX
+
c
up
Code
);
Object
redisSnCode
=
Redis
.
use
().
get
(
PREFIX
+
c
pu
Code
);
if
(
redisSnCode
!=
null
)
{
if
(
redisSnCode
!=
null
)
{
return
redisSnCode
.
toString
();
return
redisSnCode
.
toString
();
}
}
String
fileSnCode
=
PropertyUtil
.
getProperty
(
cupCode
,
FILE_PATH
);
return
PropKit
.
use
(
new
File
(
FILE_PATH
)).
get
(
cpuCode
);
if
(
StrKit
.
notBlank
(
fileSnCode
))
{
saveSnToRedis
(
PREFIX
+
cupCode
,
fileSnCode
);
}
return
fileSnCode
;
}
}
...
...
src/main/java/com/archser/aserver/util/PropertyUtil.java
View file @
60798c9e
package
com
.
archser
.
aserver
.
util
;
package
com
.
archser
.
aserver
.
util
;
import
java.io.BufferedReader
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -17,6 +21,30 @@ import java.util.Properties;
...
@@ -17,6 +21,30 @@ import java.util.Properties;
public
class
PropertyUtil
{
public
class
PropertyUtil
{
public
static
Properties
loadResource
(
String
propFile
)
throws
IOException
{
Properties
properties
=
new
Properties
();
InputStreamReader
reader
=
new
InputStreamReader
(
PropertyUtil
.
class
.
getResourceAsStream
(
propFile
));
properties
.
load
(
reader
);
return
properties
;
}
public
static
String
get
(
String
filePath
,
String
key
)
{
Properties
prop
=
null
;
try
{
prop
=
loadResource
(
filePath
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
title
=
null
;
try
{
assert
prop
!=
null
;
title
=
new
String
(
prop
.
getOrDefault
(
key
,
null
).
toString
().
getBytes
(),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
ignored
)
{
}
return
title
;
}
/**
/**
* 读取配置文件中的值
* 读取配置文件中的值
*
*
...
@@ -29,8 +57,9 @@ public class PropertyUtil {
...
@@ -29,8 +57,9 @@ public class PropertyUtil {
InputStream
input
=
null
;
InputStream
input
=
null
;
try
{
try
{
input
=
new
FileInputStream
(
filePath
);
input
=
new
FileInputStream
(
filePath
);
props
.
load
(
input
);
BufferedReader
bf
=
new
BufferedReader
(
new
InputStreamReader
(
input
));
value
=
props
.
getProperty
(
key
);
props
.
load
(
bf
);
value
=
new
String
(
props
.
getProperty
(
key
).
getBytes
(
StandardCharsets
.
ISO_8859_1
),
StandardCharsets
.
UTF_8
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
...
@@ -46,6 +75,7 @@ public class PropertyUtil {
...
@@ -46,6 +75,7 @@ public class PropertyUtil {
/**
/**
* 向配置文件中写值
* 向配置文件中写值
*
* @param key
* @param key
* @param value
* @param value
* @param filePath
* @param filePath
...
...
src/main/webapp/SN.properties
View file @
60798c9e
#Tue Dec 01 16:30:09 CST 2020
cfc84f0ff5395302517acc5ded7e7101f415cb953d535833296b292fa0f9c5ae
=
huayiwendang,04c5c8a0db17ff09e046e64099dbe532fc2c79e0f8898a4351234d96049055964448a10b4d1459e598532c33069a1b1293d2d6aeb66ca28448a622a364fdeec28e781180b7cbf8738b654860ac18dd2592d055ee3d1a1104b747c7f43070ae0e1102287bd0a6f84113a629e4eb9a4f5f7c4628c691416ab536201bccfd8f5d3fe44e7bb737760dd21edff98347200a0d258b5097fc252b3c41401f2bb26683f2aa56e220c85fb83ae653e1a26a11adf14564383578e7d202d9c83f7130b4c912e8295f8c9fa93deb20dbbe18e1fcc2cbd7e281d5acfe5b01ad61477542c335012b8753a27a52f164990743194b1314885a
AAAAAAAAAAAAAAA
=
cdcdscdscsdcdc
\ No newline at end of file
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