Commit 03a99584 authored by “yiyousong”'s avatar “yiyousong”
parents 4c40ca22 04771f08
#测试环境 #测试环境
NODE_ENV = "test" NODE_ENV = "test"
VUE_APP_API_BASE_URL=http://192.168.0.98:11071/base VUE_APP_API_BASE_URL=http://192.168.0.98:11078/base
\ No newline at end of file \ No newline at end of file
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build --mode production", "build": "vue-cli-service build --mode production",
"test": "vue-cli-service build --mode text", "beta": "vue-cli-service build --mode beta",
"test": "vue-cli-service build --mode test",
"build:prod": "vue-cli-service build --model prod", "build:prod": "vue-cli-service build --model prod",
"lint": "vue-cli-service lint", "lint": "vue-cli-service lint",
"predeploy": "yarn build", "predeploy": "yarn build",
......
<template> <!-- <template>
<admin-layout> <admin-layout>
<contextmenu <contextmenu
:itemList="menuItemList" :itemList="menuItemList"
...@@ -395,4 +395,4 @@ export default { ...@@ -395,4 +395,4 @@ export default {
margin: 0 auto; margin: 0 auto;
} }
} }
</style> </style> -->
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
<format>tar.gz</format> <format>tar.gz</format>
</formats> </formats>
<!-- <includeBaseDirectory>false</includeBaseDirectory>-->
<!-- 需要打包的文件集 --> <!-- 需要打包的文件集 -->
<fileSets> <fileSets>
<fileSet> <fileSet>
......
...@@ -9,19 +9,29 @@ ...@@ -9,19 +9,29 @@
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/bin</directory> <directory>target/bin</directory>
<outputDirectory>bin</outputDirectory> <outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/boot</directory> <directory>${project.parent.basedir}/dist/${project.parent.artifactId}/boot</directory>
<outputDirectory>boot</outputDirectory> <outputDirectory>boot</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/db</directory> <directory>./db</directory>
<includes>
<include>*.sql</include>
</includes>
<outputDirectory>db</outputDirectory> <outputDirectory>db</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
</fileSets> </fileSets>
<files>
<file>
<source>target/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>boot</outputDirectory>
</file>
</files>
</assembly> </assembly>
\ No newline at end of file
This diff is collapsed.
#!/bin/sh
RETVAL=$?
SHELL_NAME="deploy"
BASEDIR=$(dirname $0)
BASEDIR=$( (
cd "$BASEDIR"
pwd
))
LOCK_FILE="/tmp/deploy.lock"
# 时间变量
CDATE=$(date "+%Y-%m-%d")
CTIME=$(date "+%H:%M:%S")
PUBLISH_PATH="@profiles.publish.path@"
PROJECT_NAME="@project.artifactId@"
IP="@profiles.server.ip@"
PORT="@profiles.server.port@"
GATEWAY_PORT="@profiles.server.gatewayport@"
SHELL_LOG="${BASEDIR}/${SHELL_NAME}.log"
SERVICE_PATH="/usr/lib/systemd/system"
JAVA_HOME="/usr/local/java/jdk1.8"
NGINX_CONF_PATH="/etc/nginx/conf.d/"
NGINX_PORT="@profiles.nginx.port@"
NGINX_SERVER_PATH="@profiles.server.path@"
PROJECT_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}"
PROJECT_UI_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}-ui/dist"
PROJECT_FILENAME="${PROJECT_NAME}.tar.gz"
PROJECT_UI_FILENAME="${PROJECT_NAME}-ui.tar.gz"
PROJECT_SERVICE="${SERVICE_PATH}/${PROJECT_NAME}.service"
PROJECT_NGINX_CONF="${NGINX_CONF_PATH}/${PROJECT_NAME}.conf"
#加锁
shell_lock() {
touch ${LOCK_FILE}
}
#删除锁
shell_unlock() {
rm -f ${LOCK_FILE}
}
#写日志
writelog() {
LOGINFO=$1
echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO}" >>${SHELL_LOG}
echo ${LOGINFO}
}
#清理目标
clear_deploy() {
SERVICE=$1
EXECPATH=$2
#清理后台自启服务
rm -rf ${SERVICE}
#清理执行文件目录
rm -rf ${EXECPATH}
#清理nginx服务配置文件
rm -f ${NGINX_CONF_PATH}/${PROJECT_NAME}.conf
mkdir -p ${EXECPATH}
}
#清理ui
clear_ui_deploy() {
EXEC_UI_PATH=$1
rm -rf ${EXEC_UI_PATH}
mkdir -p ${EXEC_UI_PATH}
}
build_service() {
SERVICE=$1
EXECPATH=$2
echo "" >${SERVICE}
echo "[Unit]" >>${SERVICE}
echo "Description=${PROJECT_NAME}" >>${SERVICE}
echo "After=network.target" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Service]" >>${SERVICE}
echo "Environment=\"JAVA_HOME=$JAVA_HOME\"" >>${SERVICE}
echo "Type=forking" >>${SERVICE}
echo "ExecStart=${EXECPATH}/bin/start.sh" >>${SERVICE}
echo "ExecStop=${EXECPATH}/bin/shutdown.sh" >>${SERVICE}
echo "PrivateTmp=true" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Install]" >>${SERVICE}
echo "WantedBy=multi-user.target" >>${SERVICE}
writelog "${PROJECT_NAME}服务创建完成!"
}
build_nginx() {
echo "server{
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable \"MSIE [1-6]\.\";
listen ${NGINX_PORT};
#server_name localhost;
location / {
root ${PROJECT_UI_EXECPATH};
index index.html index.htm;
}
location ${NGINX_SERVER_PATH}/ {
proxy_pass http://${IP}:${GATEWAY_PORT};
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
location /doc/ {
root ${PROJECT_EXECPATH};
index api.html;
}
location /file/fileupload/ {
alias /mortals/app/data/file/fileupload/;
autoindex on;
autoindex_exact_size off;
}
location /file/uploadfile/ {
alias /mortals/app/data/file/uploadfile/;
autoindex on;
autoindex_exact_size off;
}
location /file/preview/ {
alias /mortals/app/data/file/preview/;
autoindex on;
autoindex_exact_size off;
}
}
" >${PROJECT_NGINX_CONF}
}
#启动服务与nginx
start_service_and_nginx() {
writelog "${PROJECT_NAME}服务启动..."
systemctl enable ${PROJECT_NAME}
systemctl daemon-reload
systemctl stop ${PROJECT_NAME} && systemctl start ${PROJECT_NAME}
project_status=$(systemctl status "${PROJECT_NAME}"|grep Active |awk '{print $2}')
nginx -t
nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status:${project_status}"
}
#部署后台服务
project_deploy() {
writelog "${PROJECT_NAME}_deploy"
clear_deploy ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
writelog "${PROJECT_NAME}_clear_finish"
tar -zvxf ./${PROJECT_FILENAME} -C ${PUBLISH_PATH}
build_service ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
build_nginx
start_service_and_nginx
writelog "${PROJECT_NAME}_deploy_finish"
}
#部署前台服务
project_ui_deploy() {
writelog "${PROJECT_NAME}_ui_deploy"
clear_ui_deploy ${PROJECT_UI_EXECPATH}
tar -zvxf ./${PROJECT_UI_FILENAME} -C ${PUBLISH_PATH}
writelog "${PROJECT_NAME}_ui_deploy_finish"
}
#主函数
main() {
echo "后台服务部署"
project_deploy
echo "前端服务部署"
project_ui_deploy
exit ${RETVAL}
}
main $1
...@@ -19,7 +19,7 @@ fi ...@@ -19,7 +19,7 @@ fi
echo "stoping application $PROJECT_NAME......" echo "stoping application $PROJECT_NAME......"
kill -9 ${pid} kill -15 ${pid}
echo "Send shutdown request to Server $PROJECT_NAME OK" echo "Send shutdown request to Server $PROJECT_NAME OK"
......
...@@ -124,13 +124,7 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M ...@@ -124,13 +124,7 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
private void updateOrSave(MatterEntity item, Long siteId, Context context) { private void updateOrSave(MatterEntity item, Long siteId, Context context) {
SiteMatterEntity siteMatterEntity = siteMatterService.selectOne(new SiteMatterQuery().siteId(siteId).matterId(item.getId())); SiteMatterEntity siteMatterEntity = siteMatterService.selectOne(new SiteMatterQuery().siteId(siteId).matterId(item.getId()));
if (!ObjectUtils.isEmpty(siteMatterEntity)) { if (ObjectUtils.isEmpty(siteMatterEntity)) {
BeanUtils.copyProperties(item, siteMatterEntity, new String[]{"id"});
siteMatterEntity.setMatterName(item.getMatterName());
siteMatterEntity.setUpdateTime(new Date());
siteMatterService.update(siteMatterEntity, context);
} else {
siteMatterEntity = new SiteMatterEntity(); siteMatterEntity = new SiteMatterEntity();
SiteEntity siteEntity = siteService.get(siteId); SiteEntity siteEntity = siteService.get(siteId);
siteMatterEntity.setSiteId(siteEntity.getId()); siteMatterEntity.setSiteId(siteEntity.getId());
......
...@@ -3,7 +3,8 @@ spring: ...@@ -3,7 +3,8 @@ spring:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
application: application:
log: log:
level:@profiles.log.level@ level: @profiles.log.level@
path: @profiles.log.path@
...@@ -7,5 +7,9 @@ ...@@ -7,5 +7,9 @@
}, },
"base-test": { "base-test": {
"baseUrl": "http://192.168.0.98:11078/base" "baseUrl": "http://192.168.0.98:11078/base"
} },
"base-test1": {
"baseUrl": "http://192.168.0.98:17211/base"
},
} }
\ No newline at end of file
...@@ -40,6 +40,15 @@ Accept: application/json ...@@ -40,6 +40,15 @@ Accept: application/json
GET {{baseUrl}}/site/matter/delete?id={{SiteMatter_id}} GET {{baseUrl}}/site/matter/delete?id={{SiteMatter_id}}
Accept: application/json Accept: application/json
###站点事项保存
POST {{baseUrl}}/matter/addMatterToSite
Content-Type: application/json
Authorization: {{authToken}}
{
"siteId":35,
"matterIds":"1"
}
...@@ -4,8 +4,8 @@ POST {{baseUrl}}/login/login ...@@ -4,8 +4,8 @@ POST {{baseUrl}}/login/login
Content-Type: application/json Content-Type: application/json
{ {
"loginName":"xiaoyi", "loginName":"admin",
"password":"xiaoyi", "password":"admin",
"securityCode":"8888" "securityCode":"8888"
} }
......
...@@ -54,5 +54,10 @@ GET {{baseUrl}}/workman/delete?id={{Workman_id}} ...@@ -54,5 +54,10 @@ GET {{baseUrl}}/workman/delete?id={{Workman_id}}
Accept: application/json Accept: application/json
###模板导出
POST {{baseUrl}}/workman/downloadTemplate
Content-Type: application/json
Authorization: {{authToken}}
...@@ -92,7 +92,7 @@ SMART_BASE_PLATFORM_EXECPATH="${PUBLISH_PATH}/${SMART_BASE_PLATFORM}" ...@@ -92,7 +92,7 @@ SMART_BASE_PLATFORM_EXECPATH="${PUBLISH_PATH}/${SMART_BASE_PLATFORM}"
SMART_BASE_PLATFORM_UI_EXECPATH="${PUBLISH_PATH}/${SMART_BASE_PLATFORM}-ui" SMART_BASE_PLATFORM_UI_EXECPATH="${PUBLISH_PATH}/${SMART_BASE_PLATFORM}-ui"
# 设备工程变量 # 设备工程变量
DEVICE_PLATFORM="device-platform" DEVICE_PLATFORM="device-manager"
DEVICE_PLATFORM_FILENAME="${DEVICE_PLATFORM}.tar.gz" DEVICE_PLATFORM_FILENAME="${DEVICE_PLATFORM}.tar.gz"
DEVICE_PLATFORM_UI_FILENAME="${DEVICE_PLATFORM}-ui.tar.gz" DEVICE_PLATFORM_UI_FILENAME="${DEVICE_PLATFORM}-ui.tar.gz"
DEVICE_PLATFORM_SERVICE="${SERVICE_PATH}/${DEVICE_PLATFORM}.service" DEVICE_PLATFORM_SERVICE="${SERVICE_PATH}/${DEVICE_PLATFORM}.service"
...@@ -100,7 +100,7 @@ DEVICE_PLATFORM_EXECPATH="${PUBLISH_PATH}/${DEVICE_PLATFORM}" ...@@ -100,7 +100,7 @@ DEVICE_PLATFORM_EXECPATH="${PUBLISH_PATH}/${DEVICE_PLATFORM}"
DEVICE_PLATFORM_UI_EXECPATH="${PUBLISH_PATH}/${DEVICE_PLATFORM}-ui" DEVICE_PLATFORM_UI_EXECPATH="${PUBLISH_PATH}/${DEVICE_PLATFORM}-ui"
# 日志工程变量 # 日志工程变量
LOG_PLATFORM="log-platform" LOG_PLATFORM="log-manager"
LOG_PLATFORM_FILENAME="${LOG_PLATFORM}.tar.gz" LOG_PLATFORM_FILENAME="${LOG_PLATFORM}.tar.gz"
LOG_PLATFORM_UI_FILENAME="${LOG_PLATFORM}-ui.tar.gz" LOG_PLATFORM_UI_FILENAME="${LOG_PLATFORM}-ui.tar.gz"
LOG_PLATFORM_SERVICE="${SERVICE_PATH}/${LOG_PLATFORM}.service" LOG_PLATFORM_SERVICE="${SERVICE_PATH}/${LOG_PLATFORM}.service"
...@@ -305,7 +305,7 @@ setup_nginx() { ...@@ -305,7 +305,7 @@ setup_nginx() {
rm -rf ${NGINX_EXECPATH} rm -rf ${NGINX_EXECPATH}
mkdir -p ${NGINX_EXECPATH} mkdir -p ${NGINX_EXECPATH}
tar -zvxf ${BASEDIR}/soft/${NGINX}/${NGINX_FILENAME} -C ${NGINX_EXECPATH} --strip-components 1 tar -zvx ${BASEDIR}/soft/${NGINX}/${NGINX_FILENAME} -C ${NGINX_EXECPATH} --strip-components 1
cd ${NGINX_EXECPATH} cd ${NGINX_EXECPATH}
./configure --prefix=${NGINX_EXECPATH} --conf-path=${NGINX_CONF} ./configure --prefix=${NGINX_EXECPATH} --conf-path=${NGINX_CONF}
...@@ -410,13 +410,13 @@ start_service_and_nginx() { ...@@ -410,13 +410,13 @@ start_service_and_nginx() {
PROJECT_NAME=$1 PROJECT_NAME=$1
systemctl enable ${PROJECT_NAME} systemctl enable ${PROJECT_NAME}
systemctl daemon-reload systemctl daemon-reload
systemctl start ${PROJECT_NAME} systemctl stop ${PROJECT_NAME} && systemctl start ${PROJECT_NAME}
cd ${NGINX_CONF_PATH} project_status=$(systemctl status "${PROJECT_NAME}" | grep Active | awk '{print $2}')
cp -a ${BASEDIR}/release/conf/${PROJECT_NAME}.conf ${PROJECT_NAME}.conf cp -a ${BASEDIR}/release/conf/${PROJECT_NAME}.conf ${NGINX_CONF_PATH}/${PROJECT_NAME}.conf
nginx -t nginx -t
nginx -s reload nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}') jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
writelog "${PROJECT_NAME}服务启动,PID is ${jcpid}" writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status:${project_status}"
} }
nacos_deploy() { nacos_deploy() {
...@@ -448,7 +448,8 @@ nacos_deploy() { ...@@ -448,7 +448,8 @@ nacos_deploy() {
writelog "NACOS_SERVICE服务启动!" writelog "NACOS_SERVICE服务启动!"
systemctl enable ${NACOS} systemctl enable ${NACOS}
systemctl daemon-reload systemctl daemon-reload
systemctl start ${NACOS} systemctl stop ${NACOS} && systemctl start ${NACOS}
project_status=$(systemctl status "${PROJECT_NAME}" | grep Active | awk '{print $2}')
jcpid=$(ps -ef | grep -v "grep" | grep "${NACOS} " | awk '{print $2}') jcpid=$(ps -ef | grep -v "grep" | grep "${NACOS} " | awk '{print $2}')
writelog "${NACOS}服务启动!pid=${jcpid}" writelog "${NACOS}服务启动!pid=${jcpid}"
} }
...@@ -737,7 +738,7 @@ main() { ...@@ -737,7 +738,7 @@ main() {
echo "Deploy is running" && exit echo "Deploy is running" && exit
fi fi
#获取参数 #获取参数
while getopts h:P:u:p opt; do while getopts h:P:u:p opt; do
case $opt in case $opt in
h) h)
#echo "-mysql-host ---- $OPTARG" #echo "-mysql-host ---- $OPTARG"
......
# 开发环境配置 # 开发环境配置
NODE_ENV = development NODE_ENV = development
VUE_APP_API_BASE_URL=http://192.168.0.98:11072/zwfw VUE_APP_API_BASE_URL=http://192.168.0.98:11078/zwfw
# 生产环境配置 # 生产环境配置
NODE_ENV = production NODE_ENV = production
VUE_APP_API_BASE_URL=http://192.168.0.98:11072/zwfw VUE_APP_API_BASE_URL=http://192.168.0.98:11078/zwfw
# 生产环境配置
NODE_ENV = test
VUE_APP_API_BASE_URL=http://192.168.0.98:11078/zwfw
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"test": "vue-cli-service build --model test",
"build:prod": "vue-cli-service build --model prod" "build:prod": "vue-cli-service build --model prod"
}, },
"dependencies": { "dependencies": {
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
<format>tar.gz</format> <format>tar.gz</format>
</formats> </formats>
<!-- <includeBaseDirectory>false</includeBaseDirectory>-->
<!-- 需要打包的文件集 --> <!-- 需要打包的文件集 -->
<fileSets> <fileSets>
<fileSet> <fileSet>
......
...@@ -9,19 +9,29 @@ ...@@ -9,19 +9,29 @@
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/bin</directory> <directory>target/bin</directory>
<outputDirectory>bin</outputDirectory> <outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/boot</directory> <directory>${project.parent.basedir}/dist/${project.parent.artifactId}/boot</directory>
<outputDirectory>boot</outputDirectory> <outputDirectory>boot</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/db</directory> <directory>./db</directory>
<includes>
<include>*.sql</include>
</includes>
<outputDirectory>db</outputDirectory> <outputDirectory>db</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
</fileSets> </fileSets>
<files>
<file>
<source>target/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>boot</outputDirectory>
</file>
</files>
</assembly> </assembly>
\ No newline at end of file
...@@ -32,17 +32,22 @@ ...@@ -32,17 +32,22 @@
<profiles.nacos.server-addr>192.168.0.218:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.0.218:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.level>INFO</profiles.log.level>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<skipDeploy>true</skipDeploy> <package.environment>test</package.environment>
<skipDeploy>false</skipDeploy>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.active>test</profiles.active> <profiles.active>test</profiles.active>
<profiles.server.ip>192.168.0.98</profiles.server.ip>
<profiles.server.port>17212</profiles.server.port> <profiles.server.port>17212</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type> <profiles.nginx.port>11072</profiles.nginx.port>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers> <profiles.server.gatewayport>11078</profiles.server.gatewayport>
<profiles.server.path>/zwfw</profiles.server.path>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host> <profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
...@@ -51,17 +56,22 @@ ...@@ -51,17 +56,22 @@
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.level>INFO</profiles.log.level>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<skipDeploy>true</skipDeploy> <package.environment>test</package.environment>
<skipDeploy>false</skipDeploy>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>product</id> <id>product</id>
<properties> <properties>
<profiles.active>product</profiles.active> <profiles.active>product</profiles.active>
<profiles.server.ip>192.168.0.251</profiles.server.ip>
<profiles.server.port>17212</profiles.server.port> <profiles.server.port>17212</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type> <profiles.nginx.port>11072</profiles.nginx.port>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers> <profiles.server.gatewayport>11078</profiles.server.gatewayport>
<profiles.server.path>/zwfw</profiles.server.path>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host> <profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>root_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>root_mq</profiles.rabbitmq.username>
...@@ -70,7 +80,9 @@ ...@@ -70,7 +80,9 @@
<profiles.nacos.server-addr>192.168.0.218:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.0.218:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.level>INFO</profiles.log.level>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<package.environment>build</package.environment>
<skipDeploy>false</skipDeploy> <skipDeploy>false</skipDeploy>
</properties> </properties>
</profile> </profile>
...@@ -153,27 +165,9 @@ ...@@ -153,27 +165,9 @@
</resources> </resources>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>true</skipTests> <!--默认关掉单元测试 -->
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/boot</outputDirectory>
<layout>ZIP</layout>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
...@@ -197,10 +191,14 @@ ...@@ -197,10 +191,14 @@
</goals> </goals>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/bin</outputDirectory> <outputDirectory>target/bin
</outputDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/main/bin/</directory> <directory>src/main/bin/</directory>
<excludes>
<exclude>deploy.sh</exclude>
</excludes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
...@@ -208,17 +206,21 @@ ...@@ -208,17 +206,21 @@
</execution> </execution>
<execution> <execution>
<id>copy-db</id> <id>copy-deploy</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy-resources</goal> <goal>copy-resources</goal>
</goals> </goals>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/db</outputDirectory> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/
</outputDirectory>
<resources> <resources>
<resource> <resource>
<directory>db/</directory> <directory>src/main/bin</directory>
<includes>
<include>deploy.sh</include>
</includes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
...@@ -257,12 +259,12 @@ ...@@ -257,12 +259,12 @@
<goal>exec</goal> <goal>exec</goal>
</goals> </goals>
<configuration> <configuration>
<executable>npm</executable> <executable>yarn</executable>
<arguments> <arguments>
<argument>run</argument> <argument>run</argument>
<arguments>build:prod</arguments> <arguments>${package.environment}</arguments>
</arguments> </arguments>
<workingDirectory>${project.parent.basedir}/base-manager-ui/admin</workingDirectory> <workingDirectory>${project.parent.basedir}/portal-manager-ui/admin</workingDirectory>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
...@@ -271,9 +273,7 @@ ...@@ -271,9 +273,7 @@
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
<configuration>
<skipAssembly>${skipDeploy}</skipAssembly>
</configuration>
<executions> <executions>
<execution> <execution>
<id>make-assembly</id> <id>make-assembly</id>
...@@ -282,12 +282,12 @@ ...@@ -282,12 +282,12 @@
<goal>single</goal> <goal>single</goal>
</goals> </goals>
<configuration> <configuration>
<finalName>smart-portal-platform</finalName> <finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptors> <descriptors>
<descriptor>./assembly/assembly.xml</descriptor> <descriptor>./assembly/assembly.xml</descriptor>
</descriptors> </descriptors>
<outputDirectory>${project.parent.basedir}/dist/smart-portal-platform</outputDirectory> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
...@@ -297,12 +297,13 @@ ...@@ -297,12 +297,13 @@
<goal>single</goal> <goal>single</goal>
</goals> </goals>
<configuration> <configuration>
<finalName>smart-portal-platform-ui</finalName> <skipAssembly>${skipDeploy}</skipAssembly>
<finalName>${project.artifactId}-ui</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptors> <descriptors>
<descriptor>./assembly/assembly-ui.xml</descriptor> <descriptor>./assembly/assembly-manager-ui.xml</descriptor>
</descriptors> </descriptors>
<outputDirectory>${project.parent.basedir}/dist/smart-portal-platform</outputDirectory> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
......
#!/bin/sh
RETVAL=$?
SHELL_NAME="deploy"
BASEDIR=$(dirname $0)
BASEDIR=$( (
cd "$BASEDIR"
pwd
))
LOCK_FILE="/tmp/deploy.lock"
# 时间变量
CDATE=$(date "+%Y-%m-%d")
CTIME=$(date "+%H:%M:%S")
PUBLISH_PATH="@profiles.publish.path@"
PROJECT_NAME="@project.artifactId@"
IP="@profiles.server.ip@"
PORT="@profiles.server.port@"
GATEWAY_PORT="@profiles.server.gatewayport@"
SHELL_LOG="${BASEDIR}/${SHELL_NAME}.log"
SERVICE_PATH="/usr/lib/systemd/system"
JAVA_HOME="/usr/local/java/jdk1.8"
NGINX_CONF_PATH="/etc/nginx/conf.d/"
NGINX_PORT="@profiles.nginx.port@"
NGINX_SERVER_PATH="@profiles.server.path@"
PROJECT_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}"
PROJECT_UI_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}-ui/dist"
PROJECT_FILENAME="${PROJECT_NAME}.tar.gz"
PROJECT_UI_FILENAME="${PROJECT_NAME}-ui.tar.gz"
PROJECT_SERVICE="${SERVICE_PATH}/${PROJECT_NAME}.service"
PROJECT_NGINX_CONF="${NGINX_CONF_PATH}/${PROJECT_NAME}.conf"
#加锁
shell_lock() {
touch ${LOCK_FILE}
}
#删除锁
shell_unlock() {
rm -f ${LOCK_FILE}
}
#写日志
writelog() {
LOGINFO=$1
echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO}" >>${SHELL_LOG}
echo ${LOGINFO}
}
#清理目标
clear_deploy() {
SERVICE=$1
EXECPATH=$2
#清理后台自启服务
rm -rf ${SERVICE}
#清理执行文件目录
rm -rf ${EXECPATH}
#清理nginx服务配置文件
rm -f ${NGINX_CONF_PATH}/${PROJECT_NAME}.conf
mkdir -p ${EXECPATH}
}
#清理ui
clear_ui_deploy() {
EXEC_UI_PATH=$1
rm -rf ${EXEC_UI_PATH}
mkdir -p ${EXEC_UI_PATH}
}
build_service() {
SERVICE=$1
EXECPATH=$2
echo "" >${SERVICE}
echo "[Unit]" >>${SERVICE}
echo "Description=${PROJECT_NAME}" >>${SERVICE}
echo "After=network.target" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Service]" >>${SERVICE}
echo "Environment=\"JAVA_HOME=$JAVA_HOME\"" >>${SERVICE}
echo "Type=forking" >>${SERVICE}
echo "ExecStart=${EXECPATH}/bin/start.sh" >>${SERVICE}
echo "ExecStop=${EXECPATH}/bin/shutdown.sh" >>${SERVICE}
echo "PrivateTmp=true" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Install]" >>${SERVICE}
echo "WantedBy=multi-user.target" >>${SERVICE}
writelog "${PROJECT_NAME}服务创建完成!"
}
build_nginx() {
echo "server{
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable \"MSIE [1-6]\.\";
listen ${NGINX_PORT};
#server_name localhost;
location / {
root ${PROJECT_UI_EXECPATH};
index index.html index.htm;
}
location ${NGINX_SERVER_PATH}/ {
proxy_pass http://${IP}:${GATEWAY_PORT};
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
location /doc/ {
root ${PROJECT_EXECPATH};
index api.html;
}
location /file/fileupload/ {
alias /mortals/app/data/file/fileupload/;
autoindex on;
autoindex_exact_size off;
}
location /file/uploadfile/ {
alias /mortals/app/data/file/uploadfile/;
autoindex on;
autoindex_exact_size off;
}
location /file/preview/ {
alias /mortals/app/data/file/preview/;
autoindex on;
autoindex_exact_size off;
}
}
" >${PROJECT_NGINX_CONF}
}
#启动服务与nginx
start_service_and_nginx() {
writelog "${PROJECT_NAME}服务启动..."
systemctl enable ${PROJECT_NAME}
systemctl daemon-reload
systemctl stop ${PROJECT_NAME} && systemctl start ${PROJECT_NAME}
project_status=$(systemctl status "${PROJECT_NAME}"|grep Active |awk '{print $2}')
nginx -t
nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status:${project_status}"
}
#部署后台服务
project_deploy() {
writelog "${PROJECT_NAME}_deploy"
clear_deploy ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
writelog "${PROJECT_NAME}_clear_finish"
tar -zvxf ./${PROJECT_FILENAME} -C ${PUBLISH_PATH}
build_service ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
build_nginx
start_service_and_nginx
writelog "${PROJECT_NAME}_deploy_finish"
}
#部署前台服务
project_ui_deploy() {
writelog "${PROJECT_NAME}_ui_deploy"
clear_ui_deploy ${PROJECT_UI_EXECPATH}
tar -zvxf ./${PROJECT_UI_FILENAME} -C ${PUBLISH_PATH}
writelog "${PROJECT_NAME}_ui_deploy_finish"
}
#主函数
main() {
echo "后台服务部署"
project_deploy
echo "前端服务部署"
project_ui_deploy
exit ${RETVAL}
}
main $1
package com.mortals.xhx.module.user.web; package com.mortals.xhx.module.user.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.framework.annotation.Operlog;
import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.param.service.ParamService; import com.mortals.xhx.module.param.service.ParamService;
import com.mortals.xhx.module.role.model.RoleEntity; import com.mortals.xhx.module.role.model.RoleEntity;
import com.mortals.xhx.module.role.model.RoleQuery; import com.mortals.xhx.module.role.model.RoleQuery;
...@@ -16,40 +16,20 @@ import com.mortals.xhx.module.role.model.RoleUserEntity; ...@@ -16,40 +16,20 @@ import com.mortals.xhx.module.role.model.RoleUserEntity;
import com.mortals.xhx.module.role.model.RoleUserQuery; import com.mortals.xhx.module.role.model.RoleUserQuery;
import com.mortals.xhx.module.role.service.RoleService; import com.mortals.xhx.module.role.service.RoleService;
import com.mortals.xhx.module.role.service.RoleUserService; import com.mortals.xhx.module.role.service.RoleUserService;
import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.model.UserEntityExt; import com.mortals.xhx.module.user.model.UserEntityExt;
import com.mortals.xhx.module.user.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.model.UserQuery;
import com.mortals.xhx.module.user.service.UserService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/** /**
* 用户信息业务 * 用户信息业务
......
spring: spring:
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
application:
log:
level: @profiles.log.level@
path: @profiles.log.path@
...@@ -9,19 +9,21 @@ ...@@ -9,19 +9,21 @@
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/bin</directory> <directory>target/bin</directory>
<outputDirectory>bin</outputDirectory> <outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/boot</directory> <directory>${project.parent.basedir}/dist/${project.parent.artifactId}/boot</directory>
<outputDirectory>boot</outputDirectory> <outputDirectory>boot</outputDirectory>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</fileSet> </fileSet>
<fileSet>
<directory>${project.basedir}/dist/${project.artifactId}/db</directory>
<outputDirectory>db</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
</fileSets> </fileSets>
<files>
<file>
<source>target/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>boot</outputDirectory>
</file>
</files>
</assembly> </assembly>
\ No newline at end of file
...@@ -27,23 +27,24 @@ ...@@ -27,23 +27,24 @@
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers> <profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host> <profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>guest</profiles.rabbitmq.username> <profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>guest</profiles.rabbitmq.password> <profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost> <profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<skipDeploy>true</skipDeploy> <profiles.publish.path>/home/publish</profiles.publish.path>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.active>test</profiles.active> <profiles.active>test</profiles.active>
<profiles.server.ip>192.168.0.98</profiles.server.ip>
<profiles.server.port>17214</profiles.server.port> <profiles.server.port>17214</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type> <profiles.nginx.port>11078</profiles.nginx.port>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host> <profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
...@@ -52,15 +53,19 @@ ...@@ -52,15 +53,19 @@
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.level>INFO</profiles.log.level>
<skipDeploy>true</skipDeploy> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.publish.path>/home/publish</profiles.publish.path>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>product</id> <id>product</id>
<properties> <properties>
<profiles.active>test</profiles.active> <profiles.active>test</profiles.active>
<profiles.server.ip>192.168.0.251</profiles.server.ip>
<profiles.server.port>17214</profiles.server.port> <profiles.server.port>17214</profiles.server.port>
<profiles.nginx.port>11078</profiles.nginx.port>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host> <profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>root_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>root_mq</profiles.rabbitmq.username>
...@@ -69,8 +74,10 @@ ...@@ -69,8 +74,10 @@
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.level>INFO</profiles.log.level>
<skipDeploy>false</skipDeploy> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.publish.path>/home/publish</profiles.publish.path>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>
...@@ -98,15 +105,6 @@ ...@@ -98,15 +105,6 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId> <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency> </dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
...@@ -123,8 +121,6 @@ ...@@ -123,8 +121,6 @@
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -142,31 +138,13 @@ ...@@ -142,31 +138,13 @@
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>true</skipTests> <!--默认关掉单元测试 -->
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/boot</outputDirectory>
<layout>ZIP</layout>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
...@@ -181,10 +159,36 @@ ...@@ -181,10 +159,36 @@
</goals> </goals>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/bin</outputDirectory> <outputDirectory>target/bin
</outputDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/main/bin/</directory> <directory>src/main/bin/</directory>
<excludes>
<exclude>deploy.sh</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-deploy</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>${project.parent.basedir}/dist/${project.artifactId}/
</outputDirectory>
<resources>
<resource>
<directory>src/main/bin</directory>
<includes>
<include>deploy.sh</include>
</includes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
...@@ -195,9 +199,6 @@ ...@@ -195,9 +199,6 @@
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
<configuration>
<skipAssembly>${skipDeploy}</skipAssembly>
</configuration>
<executions> <executions>
<execution> <execution>
<id>make-assembly</id> <id>make-assembly</id>
...@@ -211,7 +212,7 @@ ...@@ -211,7 +212,7 @@
<descriptors> <descriptors>
<descriptor>./assembly/assembly.xml</descriptor> <descriptor>./assembly/assembly.xml</descriptor>
</descriptors> </descriptors>
<outputDirectory>${project.parent.basedir}/dist/smart-gateway</outputDirectory> <outputDirectory>${project.parent.basedir}/dist/${project.artifactId}</outputDirectory>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
......
#!/bin/sh
RETVAL=$?
SHELL_NAME="deploy"
BASEDIR=$(dirname $0)
BASEDIR=$( (
cd "$BASEDIR"
pwd
))
LOCK_FILE="/tmp/deploy.lock"
# 时间变量
CDATE=$(date "+%Y-%m-%d")
CTIME=$(date "+%H:%M:%S")
PUBLISH_PATH="@profiles.publish.path@"
PROJECT_NAME="@project.artifactId@"
IP="@profiles.server.ip@"
PORT="@profiles.server.port@"
SHELL_LOG="${BASEDIR}/${SHELL_NAME}.log"
SERVICE_PATH="/usr/lib/systemd/system"
JAVA_HOME="/usr/local/java/jdk1.8"
NGINX_CONF_PATH="/etc/nginx/conf.d/"
NGINX_PORT="@profiles.nginx.port@"
NGINX_SERVER_PATH="@profiles.server.path@"
PROJECT_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}"
PROJECT_UI_EXECPATH="${PUBLISH_PATH}/${PROJECT_NAME}-ui"
PROJECT_FILENAME="${PROJECT_NAME}.tar.gz"
PROJECT_UI_FILENAME="${PROJECT_NAME}-ui.tar.gz"
PROJECT_SERVICE="${SERVICE_PATH}/${PROJECT_NAME}.service"
PROJECT_NGINX_CONF="${NGINX_CONF_PATH}/${PROJECT_NAME}.conf"
#加锁
shell_lock() {
touch ${LOCK_FILE}
}
#删除锁
shell_unlock() {
rm -f ${LOCK_FILE}
}
#写日志
writelog() {
LOGINFO=$1
echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO}" >>${SHELL_LOG}
echo ${LOGINFO}
}
#清理目标
clear_deploy() {
SERVICE=$1
EXECPATH=$2
#清理后台自启服务
rm -rf ${SERVICE}
#清理执行文件目录
rm -rf ${EXECPATH}
#清理nginx服务配置文件
rm -f ${NGINX_CONF_PATH}/${PROJECT_NAME}.conf
mkdir -p ${EXECPATH}
}
#清理ui
clear_ui_deploy() {
EXEC_UI_PATH=$1
rm -rf ${EXEC_UI_PATH}
mkdir -p ${EXEC_UI_PATH}
}
build_service() {
SERVICE=$1
EXECPATH=$2
echo "" >${SERVICE}
echo "[Unit]" >>${SERVICE}
echo "Description=${PROJECT_NAME}" >>${SERVICE}
echo "After=network.target" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Service]" >>${SERVICE}
echo "Environment=\"JAVA_HOME=$JAVA_HOME\"" >>${SERVICE}
echo "Type=forking" >>${SERVICE}
echo "ExecStart=${EXECPATH}/bin/start.sh" >>${SERVICE}
echo "ExecStop=${EXECPATH}/bin/shutdown.sh" >>${SERVICE}
echo "PrivateTmp=true" >>${SERVICE}
echo "" >>${SERVICE}
echo "[Install]" >>${SERVICE}
echo "WantedBy=multi-user.target" >>${SERVICE}
writelog "${PROJECT_NAME}服务创建完成!"
}
build_nginx() {
echo "server{
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable \"MSIE [1-6]\.\";
listen ${NGINX_PORT};
#server_name localhost;
location / {
proxy_pass http://${IP}:${PORT};
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
location /homeDeviceUrl/ {
alias /home/publish/device-manager-ui/homeDeviceUrl/;
index index.html index.htm;
}
location /file/fileupload/ {
alias /mortals/app/data/file/fileupload/;
autoindex on;
autoindex_exact_size off;
}
location /file/uploadfile/ {
alias /mortals/app/data/file/uploadfile/;
autoindex on;
autoindex_exact_size off;
}
location /file/preview/ {
alias /mortals/app/data/file/preview/;
autoindex on;
autoindex_exact_size off;
}
}
" >${PROJECT_NGINX_CONF}
}
#启动服务与nginx
start_service_and_nginx() {
writelog "${PROJECT_NAME}服务启动..."
systemctl enable ${PROJECT_NAME}
systemctl daemon-reload
systemctl stop ${PROJECT_NAME} && systemctl start ${PROJECT_NAME}
project_status=$(systemctl status "${PROJECT_NAME}"|grep Active |awk '{print $2}')
nginx -t
nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status:${project_status}"
}
#部署后台服务
project_deploy() {
writelog "${PROJECT_NAME}_deploy"
clear_deploy ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
writelog "${PROJECT_NAME}_clear_finish"
tar -zvxf ./${PROJECT_FILENAME} -C ${PUBLISH_PATH}
build_service ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
writelog "${PROJECT_NAME}_deploy_build_nginx"
build_nginx
writelog "${PROJECT_NAME}_deploy_build_nginx_finish"
writelog "${PROJECT_NAME}_deploy_build_service_finish"
start_service_and_nginx
writelog "${PROJECT_NAME}_deploy_finish"
}
#主函数
main() {
echo "后台服务部署"
project_deploy
exit ${RETVAL}
}
main $1
package com.mortals.xhx.base.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author: zxfei
* @date: 2022/2/15 13:16
* @description:
**/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Bean
public CorsFilter corsFilter(){
//初始化配置对象
CorsConfiguration configuration = new CorsConfiguration();
//允许跨域访问的域名
configuration.addAllowedOrigin("*");
// configuration.setAllowCredentials(true); //运行携带cookie
configuration.addAllowedMethod("*"); //代表所有请求方法
configuration.addAllowedHeader("*"); //允许携带任何头信息
//初始化cors配置源对象
UrlBasedCorsConfigurationSource configurationSource=new UrlBasedCorsConfigurationSource();
configurationSource.registerCorsConfiguration("/**",configuration);
//返回CorSfilter实例,参数
return new CorsFilter(configurationSource);
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowCredentials(true)
.allowedOrigins("*")
.allowedMethods(new String[] { "GET", "POST","PUT","DELETE"})
.allowedHeaders("*")
.exposedHeaders("*");
}
}
package com.mortals.xhx.base.framework.config;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author: zxfei
* @date: 2022/6/6 15:05
* @description:添加跨域响应
**/
@Component
public class CrossInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
return true;
}
}
application:
log:
level: @profiles.log.level@
path: @profiles.log.path@
\ No newline at end of file
...@@ -59,8 +59,8 @@ spring: ...@@ -59,8 +59,8 @@ spring:
- Path=/zwfw/** - Path=/zwfw/**
# 设备管理服务 # 设备管理服务
- id: device-manager - id: device-manager
uri: http://192.168.0.98:18222 #uri: http://192.168.0.98:18222
#uri: lb://device-manager uri: lb://device-manager
predicates: predicates:
- Path=/m/** - Path=/m/**
# 日志服务 # 日志服务
...@@ -69,6 +69,12 @@ spring: ...@@ -69,6 +69,12 @@ spring:
uri: lb://log-manager uri: lb://log-manager
predicates: predicates:
- Path=/logservice/** - Path=/logservice/**
# 样表服务服务
- id: sample-form-manager
# uri: http://127.0.0.1:17211
uri: lb://sample-form-manager
predicates:
- Path=/sampleform/**
nacos: nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类 # Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery: discovery:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment