Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-shiro
Overview
Overview
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
常超
xzxt-shiro
Commits
ac719fa0
Commit
ac719fa0
authored
Aug 22, 2018
by
liuyongshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改redis的读取单位代码的方式
parent
917cc01d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
4 deletions
+53
-4
src/main/java/com/xzxtshiro/util/PropertiesUtils.java
+40
-0
src/main/java/com/xzxtshiro/util/RedisUtil.java
+13
-4
No files found.
src/main/java/com/xzxtshiro/util/PropertiesUtils.java
0 → 100644
View file @
ac719fa0
package
com
.
xzxtshiro
.
util
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.Set
;
/**
* Created by Administrator on 2018/5/24.
*/
public
class
PropertiesUtils
{
private
Properties
properties
=
new
Properties
();
/*
* 锟斤拷锟斤拷XXX.properties锟侥硷拷锟斤拷息
*/
public
PropertiesUtils
(
String
file
)
{
try
{
InputStream
in
=
PropertiesUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
file
);
this
.
properties
.
load
(
in
);
in
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
Set
getKeys
()
{
return
this
.
properties
.
keySet
();
}
public
String
getValue
(
String
itemName
)
{
String
str
=
""
;
try
{
str
=
new
String
(
this
.
properties
.
getProperty
(
itemName
).
getBytes
(
"ISO8859_1"
),
"GBK"
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"PropertiesUtil: getValue "
+
e
.
getMessage
());
}
return
str
;
}
}
src/main/java/com/xzxtshiro/util/RedisUtil.java
View file @
ac719fa0
...
...
@@ -2,9 +2,7 @@ package com.xzxtshiro.util;
import
com.alibaba.fastjson.JSONObject
;
import
com.xzxtshiro.pojo.SysDictitem
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -23,13 +21,22 @@ public class RedisUtil {
XzxtRestResult
xzxtRestResult
=
new
XzxtRestResult
();
param
.
put
(
"key"
,
key
);
//调用redisrest的服务
String
json
=
HttpClientUtil
.
doPost
(
"http://127.0.0.1:9043/xzxt-rest/ReadRedisRest"
,
param
);
String
url
=
getRedisParam
();
String
json
=
HttpClientUtil
.
doPost
(
url
+
"/xzxt-rest/ReadRedisRest"
,
param
);
xzxtRestResult
=
JSONObject
.
parseObject
(
json
,
XzxtRestResult
.
class
);
if
(!
StringUtils
.
isBlank
(
xzxtRestResult
.
getData
().
toString
()))
{
xzxtRestResult
=
xzxtRestResult
.
format
(
xzxtRestResult
.
getData
().
toString
());
}
return
xzxtRestResult
;
}
public
static
String
getRedisParam
(){
PropertiesUtils
propertiesUtil
=
new
PropertiesUtils
(
"resource/db.properties"
);
String
host
=
propertiesUtil
.
getValue
(
"redis.host"
);
String
port
=
propertiesUtil
.
getValue
(
"redis.port"
);
return
host
+
":"
+
port
;
}
//更新edis服务
/**
* redis存储服务
...
...
@@ -40,10 +47,12 @@ public class RedisUtil {
//查询参数
Map
<
String
,
String
>
param
=
new
HashMap
<>();
XzxtRestResult
xzxtRestResult
=
new
XzxtRestResult
();
String
url
=
getRedisParam
();
param
.
put
(
"ssdw"
,
ssdw
);
param
.
put
(
"type"
,
type
);
//调用redisrest的服务
String
json
=
HttpClientUtil
.
doPost
(
"http://127.0.0.1:9043
/xzxt-rest/UpdateRedisRest"
,
param
);
String
json
=
HttpClientUtil
.
doPost
(
url
+
"
/xzxt-rest/UpdateRedisRest"
,
param
);
if
(!
StringUtils
.
isBlank
(
json
))
{
xzxtRestResult
=
XzxtRestResult
.
format
(
json
);
}
...
...
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