This commit is contained in:
zhuangqian 2016-12-01 10:33:23 +08:00
parent 5ba5f09f77
commit a20c9da0bb
13 changed files with 88 additions and 36 deletions

View File

@ -168,7 +168,7 @@ public class Func {
return true; return true;
} }
if (o instanceof String) { if (o instanceof String) {
if (o.toString().trim().equals("")) { if (o.toString().equals("")) {
return true; return true;
} }
} else if (o instanceof List) { } else if (o instanceof List) {

View File

@ -74,15 +74,15 @@ public class BladeFile {
this.file = file; this.file = file;
this.fileName = file.getName(); this.fileName = file.getName();
this.originalFileName = file.getOriginalFilename(); this.originalFileName = file.getOriginalFilename();
this.uploadPath = UploadFileUtils.formatUrl(File.separator + Cst.me().getUploadRealPath() + File.separator + dir + File.separator + DateKit.getDays() + File.separator + this.originalFileName); this.uploadPath = BladeFileKit.formatUrl(File.separator + Cst.me().getUploadRealPath() + File.separator + dir + File.separator + DateKit.getDays() + File.separator + this.originalFileName);
this.uploadVirtualPath = UploadFileUtils.formatUrl(Cst.me().getUploadCtxPath().replace(Cst.me().getContextPath(), "") + File.separator + dir + File.separator + DateKit.getDays() + File.separator + this.originalFileName); this.uploadVirtualPath = BladeFileKit.formatUrl(Cst.me().getUploadCtxPath().replace(Cst.me().getContextPath(), "") + File.separator + dir + File.separator + DateKit.getDays() + File.separator + this.originalFileName);
} }
private BladeFile(MultipartFile file, String dir, String uploadPath, String uploadVirtualPath) { private BladeFile(MultipartFile file, String dir, String uploadPath, String uploadVirtualPath) {
this(file, dir); this(file, dir);
if (null != uploadPath){ if (null != uploadPath){
this.uploadPath = UploadFileUtils.formatUrl(uploadPath); this.uploadPath = BladeFileKit.formatUrl(uploadPath);
this.uploadVirtualPath = UploadFileUtils.formatUrl(uploadVirtualPath); this.uploadVirtualPath = BladeFileKit.formatUrl(uploadVirtualPath);
} }
} }

View File

@ -22,7 +22,7 @@ import com.smallchill.core.toolbox.kit.DateKit;
import com.smallchill.core.toolbox.kit.PathKit; import com.smallchill.core.toolbox.kit.PathKit;
import com.smallchill.core.toolbox.kit.StrKit; import com.smallchill.core.toolbox.kit.StrKit;
public class UploadFileUtils { public class BladeFileKit {
// 定义允许上传的文件扩展名 // 定义允许上传的文件扩展名
private static HashMap<String, String> extMap = new HashMap<String, String>(); private static HashMap<String, String> extMap = new HashMap<String, String>();
@ -49,7 +49,7 @@ public class UploadFileUtils {
} }
/** /**
* 测试文件后缀 只让指定后缀的文件上像jsp,war,sh等危险的后缀禁止 * 测试文件后缀 只让指定后缀的文件上像jsp,war,sh等危险的后缀禁止
* *
* @return * @return
*/ */

View File

@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.Date; import java.util.Date;
import com.smallchill.common.vo.ShiroUser;
import com.smallchill.core.constant.Cst; import com.smallchill.core.constant.Cst;
import com.smallchill.core.plugins.dao.Blade; import com.smallchill.core.plugins.dao.Blade;
import com.smallchill.core.shiro.ShiroKit; import com.smallchill.core.shiro.ShiroKit;
@ -52,13 +53,15 @@ public class DefaultFileProxyFactory implements IFileProxy {
.append(time) .append(time)
.append(getFileExt(f.getName())); .append(getFileExt(f.getName()));
return new String [] {UploadFileUtils.formatUrl(uploadPath.toString()), UploadFileUtils.formatUrl(virtualPath.toString())}; return new String [] {BladeFileKit.formatUrl(uploadPath.toString()), BladeFileKit.formatUrl(virtualPath.toString())};
} }
@Override @Override
public Object getFileId(BladeFile bf) { public Object getFileId(BladeFile bf) {
Attach attach = new Attach(); Attach attach = new Attach();
attach.setCreater(Func.toInt(ShiroKit.getUser().getId(), 0)); ShiroUser user = ShiroKit.getUser();
Object creater = (null == user) ? 0 : user.getId();
attach.setCreater(Func.toInt(creater));
attach.setCreatetime(new Date()); attach.setCreatetime(new Date());
attach.setName(bf.getOriginalFileName()); attach.setName(bf.getOriginalFileName());
attach.setStatus(1); attach.setStatus(1);

View File

@ -59,7 +59,7 @@ public class BeanInjector {
if (value.length > 1) { if (value.length > 1) {
o = CollectionKit.join(value, ","); o = CollectionKit.join(value, ",");
} else { } else {
o = value[0]; o = Func.equals(value[0], "") ? " " : value[0];
} }
} }
map.put(StrKit.removePrefixIgnoreCase(param.getKey(), start).toLowerCase(), o); map.put(StrKit.removePrefixIgnoreCase(param.getKey(), start).toLowerCase(), o);
@ -85,7 +85,7 @@ public class BeanInjector {
if (value.length > 1) { if (value.length > 1) {
o = CollectionKit.join(value, ","); o = CollectionKit.join(value, ",");
} else { } else {
o = value[0]; o = Func.equals(value[0], "") ? " " : value[0];
} }
} }
map.put(param.getKey(), o); map.put(param.getKey(), o);

View File

@ -37,7 +37,7 @@ import com.smallchill.core.toolbox.Paras;
import com.smallchill.core.toolbox.ajax.AjaxResult; import com.smallchill.core.toolbox.ajax.AjaxResult;
import com.smallchill.core.toolbox.file.BladeFile; import com.smallchill.core.toolbox.file.BladeFile;
import com.smallchill.core.toolbox.file.FileRender; import com.smallchill.core.toolbox.file.FileRender;
import com.smallchill.core.toolbox.file.UploadFileUtils; import com.smallchill.core.toolbox.file.BladeFileKit;
import com.smallchill.core.toolbox.kit.PathKit; import com.smallchill.core.toolbox.kit.PathKit;
@Controller @Controller
@ -56,7 +56,7 @@ public class KindEditorController extends BladeController {
String originalFileName = file.getOriginalFilename(); String originalFileName = file.getOriginalFilename();
String dir = getParameter("dir", "image"); String dir = getParameter("dir", "image");
// 测试后缀 // 测试后缀
boolean ok = UploadFileUtils.testExt(dir, originalFileName); boolean ok = BladeFileKit.testExt(dir, originalFileName);
if (!ok) { if (!ok) {
ps.set("error", 1); ps.set("error", 1);
ps.set("message", "上传文件的类型不允许"); ps.set("message", "上传文件的类型不允许");
@ -89,7 +89,7 @@ public class KindEditorController extends BladeController {
} }
String order = getParameter("order", "name"); String order = getParameter("order", "name");
Map<String, Object> result = UploadFileUtils.listFiles(dir, path, order); Map<String, Object> result = BladeFileKit.listFiles(dir, path, order);
return result; return result;
} }

View File

@ -19,7 +19,7 @@ import com.smallchill.core.plugins.dao.Db;
import com.smallchill.core.toolbox.Paras; import com.smallchill.core.toolbox.Paras;
import com.smallchill.core.toolbox.file.BladeFile; import com.smallchill.core.toolbox.file.BladeFile;
import com.smallchill.core.toolbox.file.FileRender; import com.smallchill.core.toolbox.file.FileRender;
import com.smallchill.core.toolbox.file.UploadFileUtils; import com.smallchill.core.toolbox.file.BladeFileKit;
import com.smallchill.core.toolbox.kit.PathKit; import com.smallchill.core.toolbox.kit.PathKit;
@Controller @Controller
@ -38,7 +38,7 @@ public class UploadifyController extends BladeController {
String originalFileName = file.getOriginalFilename(); String originalFileName = file.getOriginalFilename();
String dir = getParameter("dir", "image"); String dir = getParameter("dir", "image");
// 测试后缀 // 测试后缀
boolean ok = UploadFileUtils.testExt(dir, originalFileName); boolean ok = BladeFileKit.testExt(dir, originalFileName);
if (!ok) { if (!ok) {
rd.set("error", 1); rd.set("error", 1);
rd.set("message", "上传文件的类型不允许"); rd.set("message", "上传文件的类型不允许");

View File

@ -26,6 +26,11 @@
<!-- blade通用工具类 --> <!-- blade通用工具类 -->
<script src="${ctxPath}/static/blade/js/blade-toolbox.js" type="text/javascript" ></script> <script src="${ctxPath}/static/blade/js/blade-toolbox.js" type="text/javascript" ></script>
<script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript" ></script> <script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript" ></script>
<script type="text/javascript">
$(function(){
BladeApp.addCtx("${ctxPath}");
});
</script>
</head> </head>
<body class="no-skin"> <body class="no-skin">
<div class="main-container" id="main-container"> <div class="main-container" id="main-container">

View File

@ -5,7 +5,6 @@
${"@"}layout("/common/_container.html"){ ${"@"}layout("/common/_container.html"){
<script type="text/javascript"> <script type="text/javascript">
var ctx = "${"$"}{ctxPath}";
var grid_selector = "#grid-table"; var grid_selector = "#grid-table";
var pager_selector = "#grid-pager"; var pager_selector = "#grid-pager";
@ -15,7 +14,7 @@ ${"@"}layout("/common/_container.html"){
}); });
function initGrid(){ function initGrid(){
var grid_url = ctx + "/${"$"}{code}/list"; var grid_url = "${"$"}{ctxPath}/${"$"}{code}/list";
var _colnames = [@trim(){ var _colnames = [@trim(){
@ for (attr in attrs) { @ for (attr in attrs) {
@if (isEmpty(attr.comment)) { @if (isEmpty(attr.comment)) {

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Blade企业级开发平台-登录页</title> <title>Blade企业级开发平台-登录页</title>

View File

@ -12,13 +12,14 @@
function initGrid(){ function initGrid(){
var grid_url = ctx + "/${code}/list";//查询列表接口 var grid_url = ctx + "/${code}/list";//查询列表接口
var _colnames=[ "序列","通知标题", "公告类型","创建人", "创建时间", "发布时间"]; var _colnames=[ "序列","通知标题", "公告类型", "公告类型", "创建人", "创建时间", "发布时间"];
var _colmodel=[ {name:"F_IT_XL", index:"F_IT_XL", width:80, hidden:true}, var _colmodel=[ {name:"F_IT_XL", index:"F_IT_XL", width:80, hidden:true},
{name:"F_VC_BT",index:"F_VC_BT", width:100}, {name:"F_VC_BT", index:"F_VC_BT", width:250},
{name:"DIC_F_IT_LX",index:"F_IT_LX", width:80}, {name:"F_IT_LX", index:"F_IT_LX", width:80, hidden:true},
{name:"DIC_F_IT_LX", index:"F_IT_LX", width:80, formatter:rowShow},
{name:"DIC_F_IT_CJR", index:"F_IT_CJR", width:80}, {name:"DIC_F_IT_CJR", index:"F_IT_CJR", width:80},
{name:"F_DT_CJSJ",index:"F_DT_CJSJ", width:80}, {name:"F_DT_CJSJ", index:"F_DT_CJSJ", width:135, align:"center"},
{name:"F_DT_FBSJ",index:"F_DT_FBSJ", width:80} {name:"F_DT_FBSJ", index:"F_DT_FBSJ", width:135, align:"center"}
]; ];
@ if (shiro.lacksRole('administrator')) { @ if (shiro.lacksRole('administrator')) {
@ -28,7 +29,7 @@
jQuery(grid_selector).jqGrid({ jQuery(grid_selector).jqGrid({
url:grid_url, url:grid_url,
shrinkToFit:true,//适用于较少字段,响应式 shrinkToFit:false,//适用于较少字段,响应式
colNames:_colnames, colNames:_colnames,
colModel:_colmodel, colModel:_colmodel,
jsonReader:{id : "F_IT_XL"}, jsonReader:{id : "F_IT_XL"},
@ -38,6 +39,40 @@
} }
function rowShow(cellvalue, options, rowObject) {
var lx = rowObject.F_IT_LX;
var sclass = "";
switch (lx) {
case 1:
sclass = "label label-info arrowed-right arrowed-in";
break;
case 2:
sclass = "label label-success arrowed arrowed-right";
break;
case 3:
sclass = "label label-info arrowed arrowed-in-right";
break;
case 4:
sclass = "label label-warning arrowed arrowed-right";
break;
case 5:
sclass = "label label-danger arrowed arrowed-right";
break;
case 6:
sclass = "label label-danger arrowed arrowed-in-right";
break;
case 7:
sclass = "label arrowed arrowed-right";
break;
default:
sclass = "label label-info arrowed-right arrowed-in";
break;
}
var html = "<span class='" + sclass + "'>" + rowObject.DIC_F_IT_LX + "</span>";
return html;
}
</script> </script>

View File

@ -7,7 +7,7 @@ var exwhere;
this.name = btnjson.NAME; this.name = btnjson.NAME;
this.pname = btnjson.PNAME; this.pname = btnjson.PNAME;
this.alias = btnjson.ALIAS; this.alias = btnjson.ALIAS;
this.url = this.isEmpty(ctx) + btnjson.URL; this.url = this.isEmpty(BladeApp.ctxPath) + btnjson.URL;
this.div = this.isEmpty(btnjson.ICON.split('|')[0]); this.div = this.isEmpty(btnjson.ICON.split('|')[0]);
this.li = this.isEmpty(btnjson.ICON.split('|')[1]); this.li = this.isEmpty(btnjson.ICON.split('|')[1]);
this.area=this.isEmpty(btnjson.TIPS); this.area=this.isEmpty(btnjson.TIPS);
@ -144,7 +144,7 @@ var exwhere;
return; return;
} }
var _this = this; var _this = this;
$.post(ctx + "/role/getPowerById", { id: ids }, function (data) { $.post(BladeApp.ctxPath + "/role/getPowerById", { id: ids }, function (data) {
if (data.code === 0) { if (data.code === 0) {
var roleName=rowData.NAME; var roleName=rowData.NAME;
_this.open(_this.url + "?roleId=" + ids + "&roleName=" + roleName); _this.open(_this.url + "?roleId=" + ids + "&roleName=" + roleName);
@ -251,7 +251,7 @@ var exwhere;
if (this.alias == "audit" || this.alias == "recycle") { if (this.alias == "audit" || this.alias == "recycle") {
var code = this.id; var code = this.id;
if (stage.all[code] == undefined) { if (stage.all[code] == undefined) {
$.post(ctx + "/cache/getChildBtn", { code: code }, function (data) { $.post(BladeApp.ctxPath + "/cache/getChildBtn", { code: code }, function (data) {
if (data.code === 0) { if (data.code === 0) {
btnjsons = data.data; btnjsons = data.data;
var _btn_child_stage = new btn_child_stage(); var _btn_child_stage = new btn_child_stage();
@ -268,7 +268,7 @@ var exwhere;
else { else {
stage.all[code].btn.bind(toolbar); stage.all[code].btn.bind(toolbar);
} }
exwhere = this.url.replace(ctx, "");//修复未发布在tomcat根目录下带有项目路径导致不能搜索的问题 exwhere = this.url.replace(BladeApp.ctxPath, "");//修复未发布在tomcat根目录下带有项目路径导致不能搜索的问题
isAutoPage = false;//自动跳转到第一页 isAutoPage = false;//自动跳转到第一页
searchGrid(); searchGrid();
return; return;
@ -482,7 +482,7 @@ var exwhere;
// 根据模块code生成每个工具条上面的 btn // 根据模块code生成每个工具条上面的 btn
function initMenuBtn(obj, code) { function initMenuBtn(obj, code) {
$.post(ctx + "/cache/getBtn", { code: code }, function (data) { $.post(BladeApp.ctxPath + "/cache/getBtn", { code: code }, function (data) {
if (data.code === 0) { if (data.code === 0) {
toolbar = obj; toolbar = obj;
btnjsons = data.data; btnjsons = data.data;

View File

@ -1,5 +1,15 @@
/********************** 公共工具类 ***************/ /****************** 基本信息 ***************/
var BladeApp = {
ctxPath : "",
addCtx: function (ctx) {
if (this.ctxPath == "") {
this.ctxPath = ctx;
}
}
};
/****************** 公共工具类 ***************/
var BladeTool = { var BladeTool = {
isNotEmpty: function(val) { isNotEmpty: function(val) {
return ! this.isEmpty(val); return ! this.isEmpty(val);