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
676c6471
Commit
676c6471
authored
Sep 19, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化提交
parent
83f71736
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
169 additions
and
7 deletions
+169
-7
pom.xml
pom.xml
+6
-0
src/main/java/com/mortals/xhx/common/code/ProductDisEnum.java
...main/java/com/mortals/xhx/common/code/ProductDisEnum.java
+4
-4
src/main/java/com/mortals/xhx/common/code/ProjectDistributeEnum.java
...va/com/mortals/xhx/common/code/ProjectDistributeEnum.java
+66
-0
src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
+46
-0
src/main/java/com/mortals/xhx/module/setup/mode/ProjectSetupEntity.java
...com/mortals/xhx/module/setup/mode/ProjectSetupEntity.java
+5
-0
src/main/java/com/mortals/xhx/module/setup/web/SetupProjectController.java
.../mortals/xhx/module/setup/web/SetupProjectController.java
+31
-3
src/main/resources/bootstrap.yml
src/main/resources/bootstrap.yml
+2
-0
src/main/resources/project/base-platform/base-manager.tar.gz
src/main/resources/project/base-platform/base-manager.tar.gz
+0
-0
src/main/resources/project/portal-platform/portal-manager.tar.gz
...n/resources/project/portal-platform/portal-manager.tar.gz
+0
-0
src/test/java/httpclient/system.http
src/test/java/httpclient/system.http
+9
-0
No files found.
pom.xml
View file @
676c6471
...
@@ -102,6 +102,12 @@
...
@@ -102,6 +102,12 @@
<version>
1.9
</version>
<version>
1.9
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-client
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/mortals/xhx/common/code/ProductDisEnum.java
View file @
676c6471
...
@@ -10,8 +10,8 @@ import java.util.Map;
...
@@ -10,8 +10,8 @@ import java.util.Map;
* @date: 2024/9/14 14:21
* @date: 2024/9/14 14:21
*/
*/
public
enum
ProductDisEnum
{
public
enum
ProductDisEnum
{
基础服务
(
"base-
platform"
,
"基础服务
"
),
基础服务
(
"base-
manager"
,
"base-platform
"
),
门户服务
(
"portal-
platform"
,
"门户服务
"
);
门户服务
(
"portal-
manager"
,
"portal-platform
"
);
private
String
value
;
private
String
value
;
private
String
desc
;
private
String
desc
;
...
@@ -30,7 +30,7 @@ public enum ProductDisEnum {
...
@@ -30,7 +30,7 @@ public enum ProductDisEnum {
public
static
ProductDisEnum
getByValue
(
String
value
)
{
public
static
ProductDisEnum
getByValue
(
String
value
)
{
for
(
ProductDisEnum
productDisEnum
:
ProductDisEnum
.
values
())
{
for
(
ProductDisEnum
productDisEnum
:
ProductDisEnum
.
values
())
{
if
(
productDisEnum
.
getValue
()
==
value
)
{
if
(
productDisEnum
.
getValue
()
.
equals
(
value
)
)
{
return
productDisEnum
;
return
productDisEnum
;
}
}
}
}
...
@@ -49,7 +49,7 @@ public enum ProductDisEnum {
...
@@ -49,7 +49,7 @@ public enum ProductDisEnum {
try
{
try
{
boolean
hasE
=
false
;
boolean
hasE
=
false
;
for
(
String
e
:
eItem
)
{
for
(
String
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
if
(
item
.
getValue
()
.
equals
(
e
)
)
{
hasE
=
true
;
hasE
=
true
;
break
;
break
;
}
}
...
...
src/main/java/com/mortals/xhx/common/code/ProjectDistributeEnum.java
0 → 100644
View file @
676c6471
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 产品资源部署
*
* @author: zxfei
* @date: 2024/9/14 14:21
*/
public
enum
ProjectDistributeEnum
{
基础服务
(
"base-manager"
,
"基础服务"
),
门户服务
(
"portal-platform"
,
"门户服务"
);
private
String
value
;
private
String
desc
;
ProjectDistributeEnum
(
String
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
String
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
ProjectDistributeEnum
getByValue
(
String
value
)
{
for
(
ProjectDistributeEnum
productDisEnum
:
ProjectDistributeEnum
.
values
())
{
if
(
productDisEnum
.
getValue
().
equals
(
value
))
{
return
productDisEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
String
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
ProjectDistributeEnum
item
:
ProjectDistributeEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
String
e
:
eItem
)
{
if
(
item
.
getValue
().
equals
(
e
))
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
View file @
676c6471
...
@@ -64,6 +64,52 @@ public class ZipUtils {
...
@@ -64,6 +64,52 @@ public class ZipUtils {
return
set
;
return
set
;
}
}
/**
* 解压tar.gz压缩包
*
* @param inputStream
* @param unZipPath
* @return
*/
public
static
Set
<
String
>
unGzip
(
InputStream
inputStream
,
String
unZipPath
)
{
Set
<
String
>
set
=
new
HashSet
<>();
try
{
TarArchiveInputStream
fin
=
new
TarArchiveInputStream
(
new
GzipCompressorInputStream
(
inputStream
));
log
.
info
(
"********开始执行gzip"
);
TarArchiveEntry
entry
;
// 将 tar 文件解压到 extractPath 目录下
while
((
entry
=
fin
.
getNextTarEntry
())
!=
null
)
{
if
(
entry
.
isDirectory
())
{
continue
;
}
//目标文件位置
File
curfile
=
new
File
(
unZipPath
+
entry
.
getName
());
File
parent
=
curfile
.
getParentFile
();
log
.
info
(
"***文件保存的路径"
+
curfile
.
getAbsolutePath
());
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
// 将文件写出到解压的目录
IOUtils
.
copy
(
fin
,
new
FileOutputStream
(
curfile
));
set
.
add
(
curfile
.
getAbsolutePath
());
}
}
catch
(
IOException
e
)
{
log
.
error
(
"解压tar.gz文件失败"
,
e
);
}
if
(
localFiles
==
null
)
{
localFiles
=
set
;
}
else
{
localFiles
.
addAll
(
set
);
}
return
set
;
}
// 解压tar包
// 解压tar包
public
Set
<
String
>
unTar
(
String
fileName
,
String
unZipPath
)
{
public
Set
<
String
>
unTar
(
String
fileName
,
String
unZipPath
)
{
Set
<
String
>
set
=
new
HashSet
<>();
Set
<
String
>
set
=
new
HashSet
<>();
...
...
src/main/java/com/mortals/xhx/module/setup/mode/ProjectSetupEntity.java
View file @
676c6471
...
@@ -10,5 +10,10 @@ public class ProjectSetupEntity extends BaseReq {
...
@@ -10,5 +10,10 @@ public class ProjectSetupEntity extends BaseReq {
*/
*/
private
String
resourceFilePath
;
private
String
resourceFilePath
;
/**
* 项目部署值
*/
private
String
projectValue
;
}
}
\ No newline at end of file
src/main/java/com/mortals/xhx/module/setup/web/SetupProjectController.java
View file @
676c6471
...
@@ -6,7 +6,11 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -6,7 +6,11 @@ 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
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.common.code.ProductDisEnum
;
import
com.mortals.xhx.common.code.ProjectDistributeEnum
;
import
com.mortals.xhx.common.utils.EncodeUtil
;
import
com.mortals.xhx.common.utils.EncodeUtil
;
import
com.mortals.xhx.common.utils.ZipUtils
;
import
com.mortals.xhx.module.setup.mode.ProjectSetupEntity
;
import
com.mortals.xhx.module.setup.mode.ResourceSetupEntity
;
import
com.mortals.xhx.module.setup.mode.ResourceSetupEntity
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -19,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -19,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
...
@@ -28,6 +33,7 @@ import static com.mortals.framework.web.BaseController.*;
...
@@ -28,6 +33,7 @@ import static com.mortals.framework.web.BaseController.*;
/**
/**
* 项目部署
* 项目部署
*
* @author: zxfei
* @author: zxfei
* @date: 2024/9/18 13:41
* @date: 2024/9/18 13:41
*/
*/
...
@@ -40,6 +46,10 @@ public class SetupProjectController {
...
@@ -40,6 +46,10 @@ public class SetupProjectController {
@Getter
@Getter
private
String
filePath
;
private
String
filePath
;
@Value
(
"${project.publishPath}"
)
@Getter
private
String
publishPath
;
@Autowired
@Autowired
private
UploadService
uploadService
;
private
UploadService
uploadService
;
...
@@ -61,9 +71,9 @@ public class SetupProjectController {
...
@@ -61,9 +71,9 @@ public class SetupProjectController {
throw
new
AppException
(
"部署只支持zip文件!"
);
throw
new
AppException
(
"部署只支持zip文件!"
);
}
}
if
(!
FileUtil
.
isDirectory
(
filePath
))
{
if
(!
FileUtil
.
isDirectory
(
filePath
))
{
//部署路径是否存在 如果不存在 创建目录,
//部署路径是否存在 如果不存在 创建目录,
FileUtil
.
mkdir
(
filePath
);
FileUtil
.
mkdir
(
filePath
);
}
}
String
fileEncode
=
"UTF-8"
;
String
fileEncode
=
"UTF-8"
;
...
@@ -86,7 +96,25 @@ public class SetupProjectController {
...
@@ -86,7 +96,25 @@ public class SetupProjectController {
}
}
@PostMapping
(
"/distribute"
)
@UnAuth
public
String
distribute
(
@RequestBody
ProjectSetupEntity
projectSetupEntity
)
{
JSONObject
ret
=
new
JSONObject
();
int
code
=
VALUE_RESULT_SUCCESS
;
try
{
String
unZipPath
=
publishPath
;
String
sourcePath
=
"/project/"
+
ProductDisEnum
.
getByValue
(
projectSetupEntity
.
getProjectValue
()).
getDesc
()
+
"/"
+
projectSetupEntity
.
getProjectValue
()
+
".tar.gz"
;
InputStream
inputStream
=
this
.
getClass
().
getResourceAsStream
(
sourcePath
);
ZipUtils
.
unGzip
(
inputStream
,
unZipPath
);
}
catch
(
Exception
e
)
{
code
=
VALUE_RESULT_FAILURE
;
log
.
error
(
"导入资源文件失败"
,
e
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
ret
.
put
(
KEY_RESULT_CODE
,
code
);
ret
.
put
(
KEY_RESULT_MSG
,
"项目资源部署成功"
);
return
ret
.
toJSONString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/resources/bootstrap.yml
View file @
676c6471
...
@@ -26,3 +26,5 @@ spring:
...
@@ -26,3 +26,5 @@ spring:
default-property-inclusion
:
NON_NULL
default-property-inclusion
:
NON_NULL
upload
:
upload
:
path
:
E:/pic
path
:
E:/pic
project
:
publishPath
:
E:\pic\zip\
src/main/resources/project/base-manager.tar.gz
→
src/main/resources/project/base-
platform/base-
manager.tar.gz
View file @
676c6471
File moved
src/main/resources/project/portal-platform/portal-manager.tar.gz
0 → 100644
View file @
676c6471
File added
src/test/java/httpclient/system.http
View file @
676c6471
...
@@ -77,4 +77,13 @@ Content-Type: application/json
...
@@ -77,4 +77,13 @@ Content-Type: application/json
}
}
###测试项目部署
POST http://localhost:8081/project/distribute
Content-Type: application/json
{
"projectValue": "base-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