Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-tool
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
tool
amos-tool
Commits
ce676dd9
Commit
ce676dd9
authored
Jul 27, 2023
by
Code-KingTT
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
parents
90bb8068
245a5681
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
49 deletions
+22
-49
ApiInfoResource.java
...com/yeejoin/amos/api/tool/controller/ApiInfoResource.java
+1
-1
DataBaseLinkResource.java
...eejoin/amos/api/tool/controller/DataBaseLinkResource.java
+2
-2
DataBaseLinkService.java
...ejoin/amos/api/tool/face/service/DataBaseLinkService.java
+15
-6
DataBaseUtils.java
...n/java/com/yeejoin/amos/api/tool/utils/DataBaseUtils.java
+2
-38
application.properties
src/main/resources/application.properties
+2
-2
No files found.
src/main/java/com/yeejoin/amos/api/tool/controller/ApiInfoResource.java
View file @
ce676dd9
...
...
@@ -35,7 +35,7 @@ public class ApiInfoResource {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增"
,
notes
=
"新增"
)
public
ResponseModel
<
ApiInfoModel
>
save
(
@RequestBody
ApiInfoModel
apiInfoModel
)
throws
Exception
{
public
ResponseModel
<
ApiInfoModel
>
save
(
@RequestBody
ApiInfoModel
apiInfoModel
)
{
apiInfoModel
=
apiInfoService
.
createWithModel
(
apiInfoModel
);
return
ResponseHelper
.
buildResponse
(
apiInfoModel
);
}
...
...
src/main/java/com/yeejoin/amos/api/tool/controller/DataBaseLinkResource.java
View file @
ce676dd9
...
...
@@ -125,8 +125,8 @@ public class DataBaseLinkResource {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/agency/list"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"机构列表查询"
,
notes
=
"列表查询"
)
public
ResponseModel
<
List
<
AgencyModel
>>
queryForList
(
HttpServletRequest
request
)
throws
SQLException
,
IOException
{
return
ResponseHelper
.
buildResponse
(
dataBaseLinkService
.
queryForAgencyList
(
request
));
public
ResponseModel
<
List
<
AgencyModel
>>
queryForList
()
throws
SQLException
,
IOException
{
return
ResponseHelper
.
buildResponse
(
dataBaseLinkService
.
queryForAgencyList
());
}
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/DataBaseLinkService.java
View file @
ce676dd9
...
...
@@ -8,6 +8,8 @@ import com.yeejoin.amos.api.tool.face.orm.dao.DataBaseLinkMapper;
import
com.yeejoin.amos.api.tool.face.orm.entity.DataBaseLink
;
import
com.yeejoin.amos.api.tool.utils.AESUtils
;
import
com.yeejoin.amos.api.tool.utils.DataBaseUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
...
...
@@ -15,6 +17,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
...
...
@@ -32,8 +35,10 @@ import java.util.Map;
@Service
public
class
DataBaseLinkService
extends
BaseService
<
DataBaseLinkModel
,
DataBaseLink
,
DataBaseLinkMapper
>
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
DataBaseLinkService
.
class
);
@Autowired
DataBaseLinkMapper
dataBaseLinkMapper
;
private
DataSource
dataSource
;
/**
* 新增
*/
...
...
@@ -89,14 +94,18 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
/**
* 机构列表查询
*/
public
List
<
AgencyModel
>
queryForAgencyList
(
HttpServletRequest
request
)
throws
SQLException
,
IOException
{
// URL url = new URL(request.getRequestURL().toString());
DataBaseLink
dataBaseLink
=
getOne
(
new
QueryWrapper
<
DataBaseLink
>().
eq
(
"IP"
,
DataBaseUtils
.
getIp
()));
public
List
<
AgencyModel
>
queryForAgencyList
()
throws
SQLException
,
IOException
{
Connection
con
=
dataSource
.
getConnection
();
URL
url
=
new
URL
(
con
.
getMetaData
().
getURL
().
replace
(
"jdbc:mysql"
,
"http"
));
con
.
close
();
log
.
info
(
url
);
DataBaseLink
dataBaseLink
=
getOne
(
new
QueryWrapper
<
DataBaseLink
>().
eq
(
"IP"
,
url
.
getHost
()));
DataBaseLinkModel
dataBaseLinkModel
=
new
DataBaseLinkModel
();
Bean
.
toModel
(
dataBaseLink
,
dataBaseLinkModel
);
Connection
connection
=
this
.
connectNewDatabase
(
dataBaseLinkModel
);
List
<
Map
<
String
,
Object
>>
maps
=
DataBaseUtils
.
getMaps
(
"SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;"
,
connection
);
List
<
Map
<
String
,
Object
>>
maps
=
DataBaseUtils
.
getMaps
(
"SELECT AGENCY_NAME, AGENCY_CODE, AGENCY_DESC FROM privilege_agency;"
,
connection
);
connection
.
close
();
List
<
AgencyModel
>
records
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
map
:
maps
)
{
...
...
src/main/java/com/yeejoin/amos/api/tool/utils/DataBaseUtils.java
View file @
ce676dd9
...
...
@@ -2,16 +2,15 @@ package com.yeejoin.amos.api.tool.utils;
import
com.alibaba.fastjson.JSON
;
import
com.yeejoin.amos.api.tool.face.orm.entity.TableColumn
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java
.io.*
;
import
java
x.sql.DataSource
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.sql.*
;
import
java.util.*
;
...
...
@@ -151,40 +150,5 @@ public class DataBaseUtils {
return
sql
;
}
public
static
String
getIp
()
throws
IOException
{
// InetAddress inetAddress = null;
// boolean isFind = false; // 返回标识
// Enumeration<NetworkInterface> networkInterfaceLists = null;
// try {
// // 获取网络接口
// networkInterfaceLists = (Enumeration<NetworkInterface>) NetworkInterface.getNetworkInterfaces();
// } catch (SocketException e) {
// e.printStackTrace();
// }
// while (networkInterfaceLists.hasMoreElements()) {
// NetworkInterface networkInterface = (NetworkInterface) networkInterfaceLists.nextElement();
// Enumeration<InetAddress> ips = networkInterface.getInetAddresses();
// // 遍历所有ip,获取本地地址中不是回环地址的ipv4地址
// while (ips.hasMoreElements()) {
// inetAddress = (InetAddress) ips.nextElement();
// if (inetAddress instanceof Inet4Address && inetAddress.isSiteLocalAddress()
// && !inetAddress.isLoopbackAddress()) {
// isFind = true;
// break;
// }
// }
// if (isFind) {
// break;
// }
// }
// return inetAddress == null ? "" : inetAddress.getHostAddress();
//获取jar包同级目录
String
filePath
=
System
.
getProperty
(
"user.dir"
)
+
"/config/application-dev.properties"
;
InputStream
in
=
new
BufferedInputStream
(
Files
.
newInputStream
(
Paths
.
get
(
filePath
)));
Properties
properties
=
new
Properties
();
properties
.
load
(
in
);
//获取配置文件数据
return
properties
.
getProperty
(
"eureka.instance.hostname"
);
}
}
src/main/resources/application.properties
View file @
ce676dd9
spring.application.name
=
AMOS-ATL
server.servlet.context-path
=
/atl
#server.servlet.context-path=/jcs
#server.port=30201
server.port
=
20000
server.port
=
30002
#
server.port=20000
spring.profiles.active
=
dev
management.health.elasticsearch.enabled
=
false
...
...
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