0.0.1-SNAPSHOT
王兵 5 years ago
parent c5e46e8493
commit 1c71769564

@ -10,7 +10,7 @@
<module name="wsqlite" /> <module name="wsqlite" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="1.8"> <bytecodeTargetLevel>
<module name="admin" target="1.8" /> <module name="admin" target="1.8" />
<module name="nginx-admin" target="1.8" /> <module name="nginx-admin" target="1.8" />
<module name="wsqlite" target="1.8" /> <module name="wsqlite" target="1.8" />

@ -1,21 +1,23 @@
package com.example.action.screen; package com.example.action.screen;
import com.example.frame.base.Screen; import com.example.frame.base.Screen;
import com.example.frame.utils.ProcessUtil;
import com.example.module.admin.ent.NginxCtrl; import com.example.module.admin.ent.NginxCtrl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
public class Mapping extends Screen { public class Mapping extends Screen {
@Autowired @Autowired
private NginxCtrl nginxCtrl; private NginxCtrl nginxCtrl;
@Value("${mapping.default.port}")
private String serverPort;
@Override @Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) { public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
model.addAttribute("run", nginxCtrl.isRunning() ? "true" : "false"); model.addAttribute("run", nginxCtrl.isRunning() ? "true" : "false");
model.addAttribute("serverPort", serverPort);
} }
} }

@ -22,8 +22,8 @@ public class MappingUpdateRequest extends BaseUpdateRequest {
@NotNull(message = "主键不能为NULL") @NotNull(message = "主键不能为NULL")
private Long id; private Long id;
@NotNull(message = "服务Id不能为空") @NotNull(message = "服务端口不能为空")
private Long serviceId; private String servicePort;
@NotNull(message = "映射名称不能为空") @NotNull(message = "映射名称不能为空")
private String name; private String name;
@ -88,11 +88,11 @@ public class MappingUpdateRequest extends BaseUpdateRequest {
this.id = id; this.id = id;
} }
public Long getServiceId() { public String getServicePort() {
return serviceId; return servicePort;
} }
public void setServiceId(Long serviceId) { public void setServicePort(String servicePort) {
this.serviceId = serviceId; this.servicePort = servicePort;
} }
} }

@ -1,51 +0,0 @@
# 生产环境
server.service=80
server.servlet.context-path=/
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:static/
spring.application.name=EXAMPLE-WEB
spring.main.banner-mode=off
spring.devtools.restart.enabled=false
# 编码配置
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
# 根路径、欢迎页
web.welcome.page=/mapping.htm
# 不需要验证授权, 或该请求有自己的验证机制
web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm
# 日志配置
logging.path=/root/
logging.levels=INFO
logging.config=classpath:logback-config.xml
# jackson 相关配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=use_defaults
spring.jackson.mapper.sort-properties-alphabetically=true
spring.jackson.deserialization.fail-on-unknown-properties=false
# freemarker
spring.freemarker.enabled=true
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.settings.template_update_delay=1
spring.freemarker.settings.locale=zh_CN
spring.freemarker.settings.datetime_format=yyyy-MM-dd HH:mm:ss
spring.freemarker.settings.date_format=yyyy-MM-dd
spring.freemarker.settings.number_format=#.##
spring.freemarker.settings.classic_compatible=true
spring.freemarker.settings.whitespace_stripping=true
spring.freemarker.settings.url_escaping_charset=utf-8
# 文件上传配置
spring.servlet.multipart.resolveLazily=false
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB
dbpath=
nginx-path=

@ -1,10 +1,10 @@
# 开发环境 # 开发环境
server.service=8080 server.port=8888
server.servlet.context-path=/ server.servlet.context-path=/
spring.mvc.static-path-pattern=/static/** spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
spring.application.name=EXAMPLE-WEB spring.application.name=nginx-admin
spring.main.banner-mode=CONSOLE spring.main.banner-mode=OFF
spring.devtools.restart.enabled=true spring.devtools.restart.enabled=true
# 编码配置 # 编码配置
spring.http.encoding.force=true spring.http.encoding.force=true
@ -50,4 +50,5 @@ spring.servlet.multipart.max-request-size=100MB
dbpath= dbpath=
nginx-path= nginx-path=
admin.username=admin admin.username=admin
admin.password=admin admin.password=admin
mapping.default.port=8080

@ -31,7 +31,7 @@ http {
keepalive_timeout 65; keepalive_timeout 65;
#gzip on; #gzip on;
<#list services.keySet() as key> <#list services?keys as key>
server { server {
listen ${key}; listen ${key};

@ -35,7 +35,7 @@
</el-card> </el-card>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<span style="float: right;"> <span>
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',{}])">新增 <el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',{}])">新增
</el-button> </el-button>
<el-button size="small" icon="el-icon-refresh" @click="onRefresh"></el-button> <el-button size="small" icon="el-icon-refresh" @click="onRefresh"></el-button>
@ -44,7 +44,11 @@
</el-row> </el-row>
<el-table <el-table
:data="result.filter(data => !vm.search || data.name.toLowerCase().includes(vm.search.toLowerCase())|| data.value.toLowerCase().includes(vm.search.toLowerCase()))" :data="result.filter(
data => !vm.search
|| data.name.toLowerCase().includes(vm.search.toLowerCase())
|| data.context.toLowerCase().includes(vm.search.toLowerCase())
|| data.location.toLowerCase().includes(vm.search.toLowerCase()))"
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
width="150px" width="150px"
@ -97,7 +101,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@click="onAction(['edit',scope.row,item])">编辑 @click="onAction(['edit',scope.row])">编辑
</el-button> </el-button>
<el-button <el-button
size="mini" size="mini"
@ -111,34 +115,33 @@
<el-dialog :title="form.title" :visible.sync="form.dialog" width="550px"> <el-dialog :title="form.title" :visible.sync="form.dialog" width="550px">
<el-form :model="form" :rules="formRules" ref="form" label-width="80px" <el-form :model="form" :rules="formRules" ref="form" label-width="80px"
style="width: 400px;margin: 0 auto"> style="width: 400px;margin: 0 auto">
<el-form-item label="映射名称" required prop="name"> <el-form-item label="映射名称" prop="name">
<el-row> <el-row>
<el-col :span="22"> <el-col :span="22">
<el-input v-model="form.name" clearable size="small" placeholder="映射名称"></el-input> <el-input v-model="form.name" clearable size="small" placeholder="映射名称"></el-input>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="映射端口" required prop="servicePort"> <el-form-item label="端口路径" prop="context">
<el-row> <el-row>
<el-col :span="22"> <el-col :span="8">
<el-input v-model="form.servicePort" type="number" clearable size="small" placeholder="映射端口"></el-input> <el-input v-model="form.servicePort" type="number" clearable size="small"
placeholder="映射端口"></el-input>
</el-col> </el-col>
</el-row> <el-col :span="1">
</el-form-item>
<el-form-item label="映射路径" required prop="context"> </el-col>
<el-row> <el-col :span="13">
<el-col :span="22">
<el-input v-model="form.context" clearable size="small" placeholder="字母数字组合"> <el-input v-model="form.context" clearable size="small" placeholder="字母数字组合">
<template slot="prepend">http://host:{{form.servicePort}}</template>
</el-input> </el-input>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="映射类型" required prop="type"> <el-form-item label="映射类型" prop="type">
<el-radio v-model="form.type" label="HTTP">HTTP</el-radio> <el-radio v-model="form.type" label="HTTP">HTTP</el-radio>
<el-radio v-model="form.type" label="FILE">FILE</el-radio> <el-radio v-model="form.type" label="FILE">FILE</el-radio>
</el-form-item> </el-form-item>
<el-form-item label="映射地址" required prop="location"> <el-form-item label="映射地址" prop="location">
<el-row> <el-row>
<el-col :span="22"> <el-col :span="22">
<el-input v-model="form.location" clearable size="small" <el-input v-model="form.location" clearable size="small"
@ -166,9 +169,9 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="small" @click="form.dialog = false">取 消</el-button> <el-button size="small" @click="form.dialog = false">取 消</el-button>
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button> <el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
<style> <style>
@ -213,6 +216,7 @@
dialog: false, dialog: false,
id: '', id: '',
type: 'HTTP', type: 'HTTP',
servicePort: '',
context: '', context: '',
location: '', location: '',
name: '', name: '',
@ -228,8 +232,8 @@
{pattern: "^[0-9]*$", message: '映射端口只能为数字', trigger: 'blur'}, {pattern: "^[0-9]*$", message: '映射端口只能为数字', trigger: 'blur'},
], ],
context: [ context: [
{required: true, message: '映射路径不能为空', trigger: 'blur'}, {required: true, message: '映射上下文不能为空', trigger: 'blur'},
{pattern: "^/[a-zA-Z][a-zA-Z0-9_-]*$|^/$", message: '上下文须是(/)或(/+字母+字母数字及_', trigger: 'blur'}, {pattern: "^/[a-zA-Z][a-zA-Z0-9_-]*$|^/$", message: '上下文须是(/)或(/+字母+字母数字及_组合', trigger: 'blur'},
], ],
location: [ location: [
{required: true, message: '映射地址不能为空', trigger: 'change'}, {required: true, message: '映射地址不能为空', trigger: 'change'},
@ -271,7 +275,7 @@
switch (action) { switch (action) {
case "create": case "create":
this.form.title = '新增'; this.form.title = '新增';
this.form.servicePoert = "8080"; this.form.servicePort = "${serverPort?default("8080")}";
this.form.port = arg[1].value; this.form.port = arg[1].value;
this.form.id = ''; this.form.id = '';
this.form.name = ''; this.form.name = '';
@ -284,8 +288,7 @@
case "edit": case "edit":
this.form.title = '编辑'; this.form.title = '编辑';
this.form.id = arg[1].id; this.form.id = arg[1].id;
this.form.serviceId = arg[1].serviceId; this.form.servicePort = arg[1].servicePort;
this.form.port = arg[2].value;
this.form.name = arg[1].name; this.form.name = arg[1].name;
this.form.context = arg[1].context; this.form.context = arg[1].context;
this.form.type = arg[1].type; this.form.type = arg[1].type;

Loading…
Cancel
Save

Powered by TurnKey Linux.