Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setup-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
setup-platform
Commits
fd361591
Commit
fd361591
authored
Sep 20, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加实例查询
parent
676c6471
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
21 deletions
+65
-21
src/main/java/com/mortals/xhx/module/setup/web/SetupProjectController.java
.../mortals/xhx/module/setup/web/SetupProjectController.java
+60
-3
src/main/java/com/mortals/xhx/module/setup/web/SetupResourceController.java
...mortals/xhx/module/setup/web/SetupResourceController.java
+3
-17
src/main/resources/bootstrap.yml
src/main/resources/bootstrap.yml
+1
-0
src/test/java/httpclient/system.http
src/test/java/httpclient/system.http
+1
-1
No files found.
src/main/java/com/mortals/xhx/module/setup/web/SetupProjectController.java
View file @
fd361591
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.module.setup.web;
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.module.setup.web;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
...
@@ -43,13 +44,14 @@ import static com.mortals.framework.web.BaseController.*;
...
@@ -43,13 +44,14 @@ import static com.mortals.framework.web.BaseController.*;
public
class
SetupProjectController
{
public
class
SetupProjectController
{
@Value
(
"${upload.path}"
)
@Value
(
"${upload.path}"
)
@Getter
private
String
filePath
;
private
String
filePath
;
@Value
(
"${project.publishPath}"
)
@Value
(
"${project.publishPath}"
)
@Getter
private
String
publishPath
;
private
String
publishPath
;
@Value
(
"${project.nacosUrl}"
)
private
String
nacosUrl
;
@Autowired
@Autowired
private
UploadService
uploadService
;
private
UploadService
uploadService
;
...
@@ -106,13 +108,68 @@ public class SetupProjectController {
...
@@ -106,13 +108,68 @@ public class SetupProjectController {
String
sourcePath
=
"/project/"
+
ProductDisEnum
.
getByValue
(
projectSetupEntity
.
getProjectValue
()).
getDesc
()
+
"/"
+
projectSetupEntity
.
getProjectValue
()
+
".tar.gz"
;
String
sourcePath
=
"/project/"
+
ProductDisEnum
.
getByValue
(
projectSetupEntity
.
getProjectValue
()).
getDesc
()
+
"/"
+
projectSetupEntity
.
getProjectValue
()
+
".tar.gz"
;
InputStream
inputStream
=
this
.
getClass
().
getResourceAsStream
(
sourcePath
);
InputStream
inputStream
=
this
.
getClass
().
getResourceAsStream
(
sourcePath
);
ZipUtils
.
unGzip
(
inputStream
,
unZipPath
);
ZipUtils
.
unGzip
(
inputStream
,
unZipPath
);
ret
.
put
(
KEY_RESULT_MSG
,
"项目资源部署成功"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
code
=
VALUE_RESULT_FAILURE
;
code
=
VALUE_RESULT_FAILURE
;
log
.
error
(
"导入资源文件失败"
,
e
);
log
.
error
(
"导入资源文件失败"
,
e
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
}
ret
.
put
(
KEY_RESULT_CODE
,
code
);
ret
.
put
(
KEY_RESULT_CODE
,
code
);
return
ret
.
toJSONString
();
}
/**
* 服务列表查询
*
* @param projectSetupEntity
* @return
*/
@PostMapping
(
"/list"
)
@UnAuth
public
String
list
(
@RequestBody
ProjectSetupEntity
projectSetupEntity
)
{
JSONObject
ret
=
new
JSONObject
();
int
code
=
VALUE_RESULT_SUCCESS
;
try
{
// curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/catalog/services?pageNo=1&pageSize=100&namespaceId=smart-gov'
String
resp
=
HttpUtil
.
get
(
nacosUrl
+
"/v1/ns/catalog/services?pageNo=1&pageSize=100&namespaceId=smart-gov"
);
ret
.
put
(
KEY_RESULT_DATA
,
resp
);
ret
.
put
(
KEY_RESULT_MSG
,
"项目资源部署成功"
);
ret
.
put
(
KEY_RESULT_MSG
,
"项目资源部署成功"
);
}
catch
(
Exception
e
)
{
code
=
VALUE_RESULT_FAILURE
;
log
.
error
(
"查询服务状态失败"
,
e
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
ret
.
put
(
KEY_RESULT_CODE
,
code
);
return
ret
.
toJSONString
();
}
/**
* 服务实例详细查询
*
* @param projectSetupEntity
* @return
*/
@PostMapping
(
"/instances"
)
@UnAuth
public
String
instances
(
@RequestBody
ProjectSetupEntity
projectSetupEntity
)
{
JSONObject
ret
=
new
JSONObject
();
int
code
=
VALUE_RESULT_SUCCESS
;
try
{
// curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/catalog/instances?serviceName=base-manager&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov'
String
resp
=
HttpUtil
.
get
(
nacosUrl
+
"/v1/ns/catalog/instances?serviceName="
+
projectSetupEntity
.
getProjectValue
()
+
"&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov"
);
ret
.
put
(
KEY_RESULT_DATA
,
resp
);
ret
.
put
(
KEY_RESULT_MSG
,
"服务实例详细查询成功"
);
}
catch
(
Exception
e
)
{
code
=
VALUE_RESULT_FAILURE
;
log
.
error
(
"服务实例详细查询失败"
,
e
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
ret
.
put
(
KEY_RESULT_CODE
,
code
);
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
}
...
...
src/main/java/com/mortals/xhx/module/setup/web/SetupResourceController.java
View file @
fd361591
...
@@ -64,7 +64,7 @@ public class SetupResourceController {
...
@@ -64,7 +64,7 @@ public class SetupResourceController {
throw
new
AppException
(
"部署只支持zip文件!"
);
throw
new
AppException
(
"部署只支持zip文件!"
);
}
}
if
(!
FileUtil
.
isDirectory
(
filePath
))
{
if
(!
FileUtil
.
isDirectory
(
filePath
))
{
//部署路径是否存在 如果不存在 创建目录,
//部署路径是否存在 如果不存在 创建目录,
FileUtil
.
mkdir
(
filePath
);
FileUtil
.
mkdir
(
filePath
);
}
}
...
@@ -88,20 +88,6 @@ public class SetupResourceController {
...
@@ -88,20 +88,6 @@ public class SetupResourceController {
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
}
//检查bank数据库是否存在
private
boolean
databaseExists
(
Connection
conn
,
String
dbName
)
throws
SQLException
{
ResultSet
resultSet
=
conn
.
getMetaData
().
getCatalogs
();
while
(
resultSet
.
next
())
{
if
(
dbName
.
equals
(
resultSet
.
getString
(
1
)))
{
return
true
;
}
}
return
false
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
FileUtil
.
isDirectory
(
"E://pic"
));
System
.
out
.
println
(
FileUtil
.
isDirectory
(
"E://pic"
));
...
...
src/main/resources/bootstrap.yml
View file @
fd361591
...
@@ -28,3 +28,4 @@ upload:
...
@@ -28,3 +28,4 @@ upload:
path
:
E:/pic
path
:
E:/pic
project
:
project
:
publishPath
:
E:\pic\zip\
publishPath
:
E:\pic\zip\
nacosUrl
:
http://127.0.0.1:8848
src/test/java/httpclient/system.http
View file @
fd361591
...
@@ -82,7 +82,7 @@ POST http://localhost:8081/project/distribute
...
@@ -82,7 +82,7 @@ POST http://localhost:8081/project/distribute
Content-Type: application/json
Content-Type: application/json
{
{
"projectValue": "
base
-manager"
"projectValue": "
portal
-manager"
}
}
...
...
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