1、BUG修复

master
wangbing 5 years ago
parent a2c0d1f58a
commit 4dd9c20bce

@ -504,6 +504,12 @@ public class JavaFxApplication extends Application {
currentTable.setGetAll(newValue); currentTable.setGetAll(newValue);
} }
}); });
detailTableController.getHtml().selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
currentTable.setHtml(newValue);
}
});
} }
ManagerFactory.getReflashManager(this).start(); ManagerFactory.getReflashManager(this).start();

@ -729,6 +729,26 @@ public class SpringBootCallable implements Callable {
Tool.outputResource(option + "/resources/templates/403.ftl", new File(templates.getAbsolutePath(), "403.ftl")); Tool.outputResource(option + "/resources/templates/403.ftl", new File(templates.getAbsolutePath(), "403.ftl"));
Tool.outputResource(option + "/resources/templates/404.ftl", new File(templates.getAbsolutePath(), "404.ftl")); Tool.outputResource(option + "/resources/templates/404.ftl", new File(templates.getAbsolutePath(), "404.ftl"));
Tool.outputResource(option + "/resources/templates/500.ftl", new File(templates.getAbsolutePath(), "500.ftl")); Tool.outputResource(option + "/resources/templates/500.ftl", new File(templates.getAbsolutePath(), "500.ftl"));
for (Module mo : project.getModules()) {
if (mo.isHasSysFields()) {//标准模型才好生成简单的htm
for (Table table : mo.getTables()) {
if (table.getHtml()) {
File module = new File(screen.getAbsolutePath(), mo.getModuleName());
module.mkdirs();
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", project.getProjectBasePackage());
ctx.put("tool", Tool.class);
ctx.put("author", project.getProjectAuthor());
ctx.put("date", new Date());
ctx.put("table", table);
ctx.put("fields", table.getFields());
freeMarkerManager.outputTemp(new File(module.getAbsolutePath(), table.getFName() + ".ftl"), option + "/resources/templates/screen/module/mgr.ftl", ctx);
}
}
}
}
} }
} }

@ -101,9 +101,7 @@ public class GlobalController implements ErrorController {
@RequestMapping(value = ERROR_PATH) @RequestMapping(value = ERROR_PATH)
public String error(HttpServletRequest request, HttpServletResponse response) { public String error(HttpServletRequest request, HttpServletResponse response) {
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); switch (response.getStatus()) {
switch (statusCode) {
case 404: case 404:
return "404"; return "404";
case 403: case 403:

@ -6,6 +6,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@ -17,6 +18,8 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Configuration @Configuration
@EnableGlobalMethodSecurity(securedEnabled = true) @EnableGlobalMethodSecurity(securedEnabled = true)
@ -29,6 +32,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${r"${spring.mvc.static-path-pattern}"}") @Value("${r"${spring.mvc.static-path-pattern}"}")
private String[] staticPath; private String[] staticPath;
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().mvcMatchers(staticPath);
}
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
@ -80,6 +88,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
token1.putResource(".*"); token1.putResource(".*");
LocalData.setToken(token1); LocalData.setToken(token1);
} }
// Action
String servletPath = request.getServletPath();
Pattern compile = Pattern.compile("^/(.+)\\.htm");
Matcher matcher = compile.matcher(servletPath);
if (matcher.find()) {
LocalData.setAction(matcher.group(1));
}
filterChain.doFilter(servletRequest, servletResponse); filterChain.doFilter(servletRequest, servletResponse);
} }
} }
@ -89,7 +106,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new Object() { return new Object() {
public boolean hasPermission(HttpServletRequest request, Authentication authentication) { public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
// 授权 // 授权
Token token_ = LocalData.getToken(); Token token_ = LocalData.getToken();
if (token_.hasResource(request.getServletPath())) { if (token_.hasResource(request.getServletPath())) {

@ -29,8 +29,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Configuration @Configuration
public class WebMvcConfig implements WebMvcConfigurer { public class WebMvcConfig implements WebMvcConfigurer {
@ -41,42 +39,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
private String[] staticPath; private String[] staticPath;
/** /**
* *
* *
* @param registry * @param registry
*/ */
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
// .htm拦截器
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// Action
String servletPath = request.getServletPath();
Pattern compile = Pattern.compile("^/(.+)\\.htm");
Matcher matcher = compile.matcher(servletPath);
if (matcher.find()) {
LocalData.setAction(matcher.group(1));
}return super.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
super.postHandle(request, response, handler, modelAndView);
//当请求为@ResponseBodymodelAndView为null,不处理
if (modelAndView == null) {
return;
}
//获取当前用户信息
Token token = LocalData.getToken();
modelAndView.addObject("token", token);
}
}).addPathPatterns("/**/*.htm");
// 全局异常收集拦截器 // 全局异常收集拦截器
registry.addInterceptor(new HandlerInterceptorAdapter() { registry.addInterceptor(new HandlerInterceptorAdapter() {
@ -94,7 +62,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
/** /**
* Jackson * Jackson
* * <p>
* 1LonglongStringjavascriptNumber * 1LonglongStringjavascriptNumber
* *
* @param converters * @param converters

@ -28,7 +28,6 @@ public class BaseEntity implements Serializable {
/** /**
* *
*/ */
@JsonIgnore
private Date createTime; private Date createTime;
/** /**

@ -0,0 +1,247 @@
<div id="app" v-cloak>
<el-card class="box-card">
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
<#list fields as item>
<#if item.isQuery>
<el-form-item label="${item.fieldComment}" prop="${item.getFName()}">
<el-input v-model="vm.${item.getFName()}" clearable size="small" placeholder=""></el-input>
</el-form-item>
</#if>
</#list>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="box-card">
<el-row>
<el-col :span="12">
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增
</el-button>
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
<el-dialog :title="form.title" :visible.sync="form.dialog">
<el-form :model="form" :rules="formRules" ref="form" label-width="90px"
style="width: 290px;">
<#list fields as item>
<#if item.isQuery && !item.isSystem>
<el-form-item label="${item.fieldComment}" prop="${item.getFName()}">
<el-input v-model="form.${item.getFName()}" clearable size="small" placeholder=""></el-input>
</el-form-item>
</#if>
</#list>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="form.dialog = false">取 消</el-button>
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
</span>
</el-dialog>
</el-col>
<el-col :span="12">
<el-button-group style="float: right;">
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
</el-button-group>
</el-col>
</el-row>
<el-table
@selection-change="onSelectionChange"
empty-text="无数据"
:data="result"
size="small"
style="width: 100%">
<el-table-column
align="center"
type="selection"
width="40">
</el-table-column>
<#list fields as item>
<#if item.isQuery && !item.isSystem>
<el-table-column
align="center"
prop="${item.getFName()}"
label="${item.fieldComment}">
</el-table-column>
</#if>
</#list>
<el-table-column
align="center"
prop="createTime"
label="创建时间">
</el-table-column>
<el-table-column
align="center"
fixed="right"
width="120"
label="操作">
<template slot-scope="scope">
<el-dropdown size="mini" split-button type="primary" @click="onAction(['edit',scope.row])"
@command="onAction">
<i class="el-icon-edit"></i>编辑
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="vm.totalCount > vm.pageSize"
@current-change="onPage"
:current-page="vm.pageNumber"
:page-size="vm.pageSize"
layout="total, prev, pager, next, jumper"
:total="vm.totalCount">
</el-pagination>
</el-card>
</div>
<style>
#app {
padding: 10px;
}
.box-card {
margin: 10px;
}
</style>
<script>
var app = new Vue({
el: "#app",
data: {
vm: {//条件及分页参数
<#list fields as item>
<#if item.isQuery>
${item.getFName()}: "",
</#if>
</#list>
pageNumber: 1,
pageSize: 10,
totalCount: 0
},
form: {//待提交表单
title: "",
dialog: false,
id: '',
<#list fields as item>
<#if !item.isSystem>
${item.getFName()}: "",
</#if>
</#list>
rowVersion: ""
},
formRules: {
code: [
{required: true, message: '部门代码不能为空', trigger: 'blur'},
{min: 1, max: 100, message: '长度在 1 到 50 个字符', trigger: 'blur'}
],
},
select: [],
result: [],
},
methods: {
onSearch: function () {
this.vm.pageNumber = 1;
this.onFind();
},
onReset: function (form) {
this.$refs[form].resetFields();
nav.w('重置成功');
},
onFind: function () {
ajax.${table.getFName()}Find(this.vm).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.result = response.result;
this.totalCount = Number(response.totalCount);
}
}.bind(this))
},
onPage: function (pageNumber) {
this.vm.pageNumber = pageNumber;
this.onFind();
},
onSelectionChange: function (select) {
this.select = select;
},
onAction: function (arg) {
const action = arg[0];
const item = arg[1];
switch (action) {
case "create":
this.form.title = "${table.tableComment}新增";
this.form.dialog = true;
this.form.id = "";
<#list fields as item>
<#if !item.isSystem>
this.form.${item.getFName()} = "";
</#if>
</#list>
break;
case "save":
if (this.form.id) {
ajax.${table.getFName()}Update(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
} else {
ajax.${table.getFName()}Create(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
}
break;
case "edit":
this.form.title = "${table.tableComment}编辑";
this.form.dialog = true;
this.form.id = item.id;
<#list fields as item>
<#if !item.isSystem>
this.form.${item.getFName()} = item.${item.getFName()};
</#if>
</#list>
this.form.rowVersion = item.rowVersion;
break;
case "delete":
this.$confirm('将删除该项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
ajax.${table.getFName()}Delete({id: item.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
nav.s("删除成功")
this.onFind();
}
}.bind(this))
}.bind(this)).catch(function (action) {
});
break;
}
},
},
created: function () {
},
mounted: function () {
this.onFind();
},
watch: {}
})
</script>
Loading…
Cancel
Save

Powered by TurnKey Linux.