Browse Source

新增下载功能

hc.tang 8 years ago
parent
commit
c7be6d14cd
51 changed files with 771 additions and 2187 deletions
  1. 14 0
      .gitignore
  2. 1 0
      .tomcatplugin
  3. 0 2
      add-sql-2015-5-26.sql
  4. 24 22
      autoCode.sql
  5. 12 65
      pom.xml
  6. 3 2
      readme.MD
  7. 0 36
      src/main/java/org/durcframework/autocode/common/SearchEasyUI.java
  8. 26 0
      src/main/java/org/durcframework/autocode/controller/BackUserController.java
  9. 27 2
      src/main/java/org/durcframework/autocode/controller/GeneratorController.java
  10. 2 2
      src/main/java/org/durcframework/autocode/entity/DatasourceConfigSch.java
  11. 0 1
      src/main/java/org/durcframework/autocode/entity/GeneratorParam.java
  12. 9 0
      src/main/java/org/durcframework/autocode/entity/TemplateConfig.java
  13. 2 2
      src/main/java/org/durcframework/autocode/entity/TemplateConfigSch.java
  14. 10 1
      src/main/java/org/durcframework/autocode/generator/SQLContext.java
  15. 60 51
      src/main/java/org/durcframework/autocode/service/GeneratorService.java
  16. 20 0
      src/main/java/org/durcframework/autocode/util/DateUtil.java
  17. 14 0
      src/main/java/org/durcframework/autocode/util/FieldUtil.java
  18. 283 0
      src/main/java/org/durcframework/autocode/util/FileUtil.java
  19. 5 1
      src/main/resources/mybatis/mapper/mapperTemplateConfig.xml
  20. 1 0
      src/main/webapp/.#webclasspath
  21. 6 4
      src/main/webapp/decorator/main.jsp
  22. BIN
      src/main/webapp/download/admin1443595614030.zip
  23. BIN
      src/main/webapp/download/admin1443595931960.zip
  24. 0 58
      src/main/webapp/js/Action.js
  25. 0 195
      src/main/webapp/js/Crud.js
  26. 0 44
      src/main/webapp/js/EventUtil.js
  27. 0 53
      src/main/webapp/js/FunUtil.js
  28. 0 34
      src/main/webapp/js/HtmlUtil.js
  29. 0 43
      src/main/webapp/js/MaskUtil.js
  30. 0 56
      src/main/webapp/js/MsgUtil.js
  31. 0 56
      src/main/webapp/js/VelocityContext.js
  32. 0 504
      src/main/webapp/js/common.js
  33. 0 1
      src/main/webapp/js/common.min.js
  34. BIN
      src/main/webapp/js/jquery.zclip/ZeroClipboard.swf
  35. 0 495
      src/main/webapp/js/jquery.zclip/jquery.zclip.js
  36. 0 1
      src/main/webapp/js/jquery.zclip/jquery.zclip.min.js
  37. 0 5
      src/main/webapp/login/common/footer.jsp
  38. 0 28
      src/main/webapp/login/common/header.jsp
  39. 0 63
      src/main/webapp/login/common/menu.jsp
  40. 0 103
      src/main/webapp/login/main.jsp
  41. 0 132
      src/main/webapp/login/welcome.jsp
  42. 1 11
      src/main/webapp/resources/js/libs/Action.js
  43. 2 0
      src/main/webapp/resources/js/util/HtmlUtil.js
  44. 0 56
      src/main/webapp/sys/VelocityContext.js
  45. 118 0
      src/main/webapp/sys/VelocityHelper.js
  46. 61 27
      src/main/webapp/sys/generator.js
  47. 28 13
      src/main/webapp/sys/generator.jsp
  48. 1 1
      src/main/webapp/sys/home.jsp
  49. 40 11
      src/main/webapp/sys/template.jsp
  50. 0 6
      src/main/webapp/sys/updatePswd.jsp
  51. 1 0
      src/main/webapp/taglib.jsp

+ 14 - 0
.gitignore

@@ -1,2 +1,16 @@
 /target
+
+
 /work
+
+release.properties
+
+
+.classpath
+
+.project
+
+/.settings
+
+.tomcatplugin
+

+ 1 - 0
.tomcatplugin

@@ -31,6 +31,7 @@
         <webClassPathEntry>M2_REPO/net/oschina/durcframework/durcframework-core/1.0.16/durcframework-core-1.0.16.jar</webClassPathEntry>
         <webClassPathEntry>M2_REPO/net/sf/jxls/jxls-core/1.0-RC-2/jxls-core-1.0-RC-2.jar</webClassPathEntry>
         <webClassPathEntry>M2_REPO/net/sourceforge/jtds/jtds/1.2.2/jtds-1.2.2.jar</webClassPathEntry>
+        <webClassPathEntry>M2_REPO/org/apache/ant/ant/1.8.2/ant-1.8.2.jar</webClassPathEntry>
         <webClassPathEntry>M2_REPO/org/apache/commons/commons-jexl/2.0.1/commons-jexl-2.0.1.jar</webClassPathEntry>
         <webClassPathEntry>M2_REPO/org/apache/poi/poi-ooxml/3.6/poi-ooxml-3.6.jar</webClassPathEntry>
         <webClassPathEntry>M2_REPO/org/apache/poi/poi/3.6/poi-3.6.jar</webClassPathEntry>

File diff suppressed because it is too large
+ 0 - 2
add-sql-2015-5-26.sql


File diff suppressed because it is too large
+ 24 - 22
autoCode.sql


+ 12 - 65
pom.xml

@@ -54,6 +54,17 @@
 			<artifactId>jtds</artifactId>
 			<version>1.2.2</version>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.ant</groupId>
+			<artifactId>ant</artifactId>
+			<version>1.8.2</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.apache.ant</groupId>
+					<artifactId>ant-launcher</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 	</dependencies>
 
 	<build>
@@ -89,71 +100,7 @@
 					<encoding>UTF-8</encoding>
 				</configuration>
 			</plugin>
-
-			<plugin>
-				<!-- YUI Compressor Maven压缩插件 -->
-				<groupId>net.alchim31.maven</groupId>
-				<artifactId>yuicompressor-maven-plugin</artifactId>
-				<version>1.3.0</version>
-				<configuration>
-					<!-- 读取js,css文件采用UTF-8编码 -->
-					<encoding>UTF-8</encoding>
-					<!-- 不显示js可能的错误 -->
-					<jswarn>false</jswarn>
-					<!-- 若存在已压缩的文件,会先对比源文件是否有改动。有改动便压缩,无改动就不压缩 -->
-					<force>false</force>
-					<!-- 在指定的列号后插入新行 -->
-					<linebreakpos>-1</linebreakpos>
-					<!-- 压缩之前先执行聚合文件操作 -->
-					<preProcessAggregates>true</preProcessAggregates>
-					<!-- 压缩后保存文件后缀 -->
-					<suffix>.min</suffix>
-					<!-- 源目录,即需压缩的根目录 -->
-					<sourceDirectory>src/main/webapp</sourceDirectory>
-					<!-- 压缩js和css文件 -->
-					<includes>
-						<!-- 只压缩src/main/webapp/js/common.js -->
-						<include>js/common.js</include>
-					</includes>
-					<!-- 以下目录和文件不会被压缩 -->
-					<excludes>
-						<exclude>easyui/locale/*.js</exclude>
-						<exclude>easyui/themes/*.css</exclude>
-					</excludes>
-					<!-- 压缩后输出文件目录 -->
-					<outputDirectory>src/main/webapp</outputDirectory>
-					<!-- 聚合文件 -->
-					<aggregations>
-						<aggregation>
-							<!-- 合并每一个文件后插入一新行 -->
-							<insertNewLine>true</insertNewLine>
-							<!-- 需合并文件的根文件夹 -->
-							<inputDir>src/main/webapp/js</inputDir>
-							<!-- 最终合并的输出文件 -->
-							<output>src/main/webapp/js/common.js</output>
-							<!-- 把以下js文件合并成一个js文件,是按顺序合并的 -->
-							
-							<!-- 
-							运行命令mvn yuicompressor:compress
-							会把下面几个js文件压缩到src/main/webapp/js/common.js中
-							并生成一个common.min.js
-							不会影响到其它js,css
-							 -->
-							<includes>
-								<include>Action.js</include>
-								<include>Crud.js</include>
-								<include>EventUtil.js</include>
-								<include>FunUtil.js</include>
-								<include>HtmlUtil.js</include>
-								<include>MaskUtil.js</include>
-								<include>MsgUtil.js</include>
-								<include>VelocityContext.js</include>
-							</includes>
-						</aggregation>
-					</aggregations>
-				</configuration>
-			</plugin>
-
+			
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-war-plugin</artifactId>

+ 3 - 2
readme.MD

@@ -2,6 +2,7 @@
 ===================
 > **更新列表:**
 
+> - 2015-9-30,新增下载功能,代码生成后可以下载zip包,代码可直接导入项目中使用.[界面预览](https://git.oschina.net/durcframework/autoCode/wikis/autoCode%E6%96%B0%E7%89%88%E9%A2%84%E8%A7%88)
 > - 2015-9-25,前端改造,使用FDUI
 > - 2015-5-15,新建了一个QQ群:328180219欢迎加群探讨
 > - 升级为依赖[durcframework-core](https://git.oschina.net/durcframework/durcframework-core)框架
@@ -11,7 +12,7 @@
 -------------------
 > **autoCode介绍**
 
-> - autoCode是一个代码生成工具。基于velocity模板引擎,采用SpringMVC + mybatis + jquery easyUI + mysql
+> - autoCode是一个代码生成工具。基于velocity模板引擎,采用SpringMVC + mybatis + FDUI + mysql
 
 > **其特点主要有**
 
@@ -26,7 +27,7 @@
 > 2. 导入数据库(MYSQL),SQL文件在项目根目录下,名为autoCode.sql,运行里面的内容即可
 > 3. 修改数据库连接参数,配置文件在src/main/resources/config.properties
 > 4. 启动项目,运行Maven命令:mvn jetty:run
-> 5. 浏览器输入http://localhost:8088/autoCode/login.jsp
+> 5. 浏览器输入http://localhost:8088/autoCode
 
 登录用户名密码均为admin
 端口默认用了8088,如需修改,前往pom.xml,找到maven-jetty-plugin插件的port参数.

+ 0 - 36
src/main/java/org/durcframework/autocode/common/SearchEasyUI.java

@@ -1,36 +0,0 @@
-package org.durcframework.autocode.common;
-
-import org.durcframework.core.SearchEntity;
-
-/**
- * 专门为easyUI提供的查询类
- * 后面的查询类都要继承这个类
- * 2013年12月13日
- *
- */
-public class SearchEasyUI extends SearchEntity {
-
-	// 当前第几页
-	private int page = 1;
-	// 每页记录数
-	private int rows = 10;
-
-	public int getPage() {
-		return page;
-	}
-
-	public void setPage(int page) {
-		this.setPageIndex(page);
-		this.page = page;
-	}
-
-	public int getRows() {
-		return rows;
-	}
-
-	public void setRows(int rows) {
-		this.setPageSize(rows);
-		this.rows = rows;
-	}
-
-}

+ 26 - 0
src/main/java/org/durcframework/autocode/controller/BackUserController.java

@@ -1,5 +1,6 @@
 package org.durcframework.autocode.controller;
 
+import org.durcframework.autocode.common.AutoCodeContext;
 import org.durcframework.autocode.entity.BackUser;
 import org.durcframework.autocode.entity.BackUserSch;
 import org.durcframework.autocode.service.BackUserService;
@@ -37,5 +38,30 @@ public class BackUserController extends
 	MessageResult delDataSource(BackUser enity) {
 		return this.delete(enity);
 	}
+	
+	 @RequestMapping("/updateUserPassword.do")
+	    public @ResponseBody
+		Object updateUserPassword(
+	    		String oldPswd
+	    		,String newPswd
+	    		,String newPswd2
+	    		){
+	    	
+	    	if(!newPswd.equals(newPswd2)){
+	    		return error("两次输入的新密码不一样");
+	    	}
+	    	
+	    	BackUser user = AutoCodeContext.getInstance().getUser();
+	    	
+	    	if(!oldPswd.equals(user.getPassword())){
+	    		return error("原密码输入有误");
+	    	}
+	    	
+	    	user.setPassword(newPswd);
+	    	
+	    	this.update(user);
+	    	
+	    	return success();
+	    }
 
 }

+ 27 - 2
src/main/java/org/durcframework/autocode/controller/GeneratorController.java

@@ -1,7 +1,11 @@
 package org.durcframework.autocode.controller;
 
+import java.io.IOException;
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.durcframework.autocode.entity.CodeFile;
 import org.durcframework.autocode.entity.DataSourceConfig;
 import org.durcframework.autocode.entity.GeneratorParam;
@@ -27,13 +31,34 @@ public class GeneratorController {
 
 	@RequestMapping("/generatFile.do")
 	public @ResponseBody
-	Object generatFile(GeneratorParam generatorParam) {
+	Object generatFile(GeneratorParam generatorParam,HttpServletRequest request) {
+		
+		request.getSession().setAttribute("generatorParam", generatorParam);
+		
 		DataSourceConfig dataSourceConfig = 
 				dataSourceConfigService.get(generatorParam.getDcId());
 
 		List<CodeFile> resultList = 
 				generatorService.generate(generatorParam,dataSourceConfig);
-
+		
 		return resultList;
 	}
+	
+	@RequestMapping("/downloadZip.do")
+	public void downloadZip(HttpServletRequest request,HttpServletResponse response) {
+		GeneratorParam generatorParam = (GeneratorParam)request.getSession().getAttribute("generatorParam");
+		String webRootPath = request.getSession().getServletContext().getRealPath("/");
+		
+		DataSourceConfig dataSourceConfig = 
+				dataSourceConfigService.get(generatorParam.getDcId());
+
+		String zipPath = generatorService.generateZip(generatorParam, dataSourceConfig, webRootPath);
+		
+		try {
+			String downloadUrl = request.getContextPath() + zipPath.substring(webRootPath.length()).replace("\\", "/");
+			response.sendRedirect(downloadUrl);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
 }

+ 2 - 2
src/main/java/org/durcframework/autocode/entity/DatasourceConfigSch.java

@@ -1,9 +1,9 @@
 package org.durcframework.autocode.entity;
 
-import org.durcframework.autocode.common.SearchEasyUI;
+import org.durcframework.core.SearchEntity;
 import org.durcframework.core.expression.annotation.ValueField;
 
-public class DatasourceConfigSch extends SearchEasyUI{
+public class DatasourceConfigSch extends SearchEntity{
 
     private Integer dcIdSch;
     private String nameSch;

+ 0 - 1
src/main/java/org/durcframework/autocode/entity/GeneratorParam.java

@@ -8,7 +8,6 @@ public class GeneratorParam {
 	private List<Integer> tcIds;
 	private String packageName;
 	
-
 	public int getDcId() {
 		return dcId;
 	}

+ 9 - 0
src/main/java/org/durcframework/autocode/entity/TemplateConfig.java

@@ -5,6 +5,7 @@ public class TemplateConfig {
     private int tcId;
     private String name;
     private String savePath;
+    private String fileName;
     private String content;
     private String backUser;
     private String suffix;
@@ -57,4 +58,12 @@ public class TemplateConfig {
         this.backUser = backUser;
     }
 
+	public String getFileName() {
+		return fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
 }

+ 2 - 2
src/main/java/org/durcframework/autocode/entity/TemplateConfigSch.java

@@ -1,10 +1,10 @@
 package org.durcframework.autocode.entity;
 
-import org.durcframework.autocode.common.SearchEasyUI;
+import org.durcframework.core.SearchEntity;
 import org.durcframework.core.expression.annotation.LikeDoubleField;
 import org.durcframework.core.expression.annotation.ValueField;
 
-public class TemplateConfigSch extends SearchEasyUI{
+public class TemplateConfigSch extends SearchEntity{
 
     private Integer tcIdSch;
     private String nameSch;

+ 10 - 1
src/main/java/org/durcframework/autocode/generator/SQLContext.java

@@ -19,10 +19,19 @@ public class SQLContext {
 	}
 	
 	public String getJavaBeanName(){
+		String tableName = getJavaBeanNameLF();
+		return FieldUtil.upperFirstLetter(tableName);
+	}
+	
+	/**
+	 * 返回Java类名且首字母小写
+	 * @return
+	 */
+	public String getJavaBeanNameLF(){
 		String tableName = tableDefinition.getTableName();
 		tableName = FieldUtil.underlineFilter(tableName);
 		tableName = FieldUtil.dotFilter(tableName);
-		return FieldUtil.upperFirstLetter(tableName);
+		return FieldUtil.lowerFirstLetter(tableName);
 	}
 	
 	public String getPkName(){

+ 60 - 51
src/main/java/org/durcframework/autocode/service/GeneratorService.java

@@ -1,14 +1,11 @@
 package org.durcframework.autocode.service;
 
 import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.regex.Matcher;
 
 import org.apache.velocity.VelocityContext;
+import org.durcframework.autocode.common.AutoCodeContext;
 import org.durcframework.autocode.entity.CodeFile;
 import org.durcframework.autocode.entity.DataSourceConfig;
 import org.durcframework.autocode.entity.GeneratorParam;
@@ -16,6 +13,7 @@ import org.durcframework.autocode.entity.TemplateConfig;
 import org.durcframework.autocode.generator.SQLContext;
 import org.durcframework.autocode.generator.SQLService;
 import org.durcframework.autocode.generator.SQLServiceFactory;
+import org.durcframework.autocode.util.FileUtil;
 import org.durcframework.autocode.util.VelocityUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,6 +23,8 @@ import org.springframework.util.StringUtils;
 public class GeneratorService {
     @Autowired
     private TemplateConfigService templateConfigService;
+    
+    private static final String DOWNLOAD_FOLDER_NAME = "download";
 
     /**
      * 生成代码内容,map的
@@ -40,70 +40,76 @@ public class GeneratorService {
         List<SQLContext> contextList = service.getColumnSelector(dataSourceConfig).buildSQLContextList(generatorParam.getTableNames());
 
         List<CodeFile> codeFileList = new ArrayList<CodeFile>();
-
+        
         for (SQLContext sqlContext : contextList) {
             setPackageName(sqlContext, generatorParam.getPackageName());
 
-            String tableName = sqlContext.getTableDefinition().getTableName();
+            String packageName = sqlContext.getJavaBeanNameLF();
 
             for (int tcId : generatorParam.getTcIds()) {
 
                 TemplateConfig template = templateConfigService.get(tcId);
-
+                
+                String fileName = doGenerator(sqlContext,template.getFileName());
                 String content = doGenerator(sqlContext, template.getContent());
 
-                CodeFile codeFile = new CodeFile(tableName, template.getName(), content);
-                /*
-                 * 代码生成文件
-                 * 文件存放路径为:包名+文件名称+文件名称+文件后缀类型
-                 * 1.包名不为空,则利用用户自定义包名
-                 * 2.包名为空,则生成AutoCodeSource目录
-                */
-//                String CodeDirPath = "";
-//                if (generatorParam.getPackageName().length() > 0) {
-//                    CodeDirPath = (generatorParam.getPackageName() + "/" + generatorParam.getPackageName().replaceAll("\\.", Matcher.quoteReplacement("/")) + "/" + template.getSavePath() + "/");
-//                } else {
-//                    CodeDirPath = ("AutoCodeSource" + "/" + template.getSavePath() + "/");
-//                }
-//
-//                File directory = new File(".");
-//                try {
-//                    createDir(directory.getCanonicalPath() + "/" + CodeDirPath);
-//                    File f = new File(directory.getCanonicalPath() + "/" + CodeDirPath + sqlContext.getJavaBeanName() + "." + template.getSuffix());
-//                    writeFile(f, content);
-//                } catch (IOException e) {
-//                    e.printStackTrace();
-//                }
+                CodeFile codeFile = new CodeFile(packageName, fileName, content);
+                
                 codeFileList.add(codeFile);
             }
         }
 
         return codeFileList;
     }
-
-    private void writeFile(File f, String content) throws IOException {
-        if (f.exists() == false) {
-            f.createNewFile();
+    
+    /**
+     * 生成zip
+     * @param generatorParam
+     * @param dataSourceConfig
+     * @param webRootPath
+     * @return
+     */
+    public String generateZip(GeneratorParam generatorParam, DataSourceConfig dataSourceConfig,String webRootPath) {
+        SQLService service = SQLServiceFactory.build(dataSourceConfig);
+        List<SQLContext> contextList = service.getColumnSelector(dataSourceConfig).buildSQLContextList(generatorParam.getTableNames());
+        String projectFolder = this.buildProjectFolder(webRootPath);
+        
+        for (SQLContext sqlContext : contextList) {
+            setPackageName(sqlContext, generatorParam.getPackageName());
+            for (int tcId : generatorParam.getTcIds()) {
+                TemplateConfig template = templateConfigService.get(tcId);
+                String content = doGenerator(sqlContext, template.getContent());
+                String fileName = doGenerator(sqlContext,template.getFileName());
+                String savePath = doGenerator(sqlContext,template.getSavePath());
+                
+                if(StringUtils.isEmpty(fileName)) {
+                	fileName = template.getName();
+                }
+                
+                FileUtil.createFolder(projectFolder +File.separator + savePath);
+                
+                FileUtil.write(content, 
+                		projectFolder + File.separator + 
+                		savePath + File.separator + 
+                		fileName);
+            }
         }
-        Writer w = new FileWriter(f);
-        w.write(content);
-        w.flush();
-        w.close();
+        
+        try {
+			FileUtil.zip(projectFolder, projectFolder + ".zip");
+		} catch (Exception e) {
+			e.printStackTrace();
+		}finally{
+			FileUtil.deleteDir(new File(projectFolder));
+		}
+
+        return projectFolder + ".zip";
     }
-
-    public static boolean createDir(String destDirName) {
-        File dir = new File(destDirName);
-        if (dir.exists()) {
-            return false;
-        }
-        if (!destDirName.endsWith(File.separator)) {
-            destDirName = destDirName + File.separator;
-        }
-        if (dir.mkdirs()) {
-            return true;
-        } else {
-            return false;
-        }
+    
+    private String buildProjectFolder(String webRootPath) {
+    	return webRootPath + File.separator + 
+    			DOWNLOAD_FOLDER_NAME + File.separator + 
+    			AutoCodeContext.getInstance().getUser().getUsername() + System.currentTimeMillis();
     }
 
     private void setPackageName(SQLContext sqlContext, String packageName) {
@@ -113,6 +119,9 @@ public class GeneratorService {
     }
 
     private String doGenerator(SQLContext sqlContext, String template) {
+    	if(template == null) {
+    		return "";
+    	}
         VelocityContext context = new VelocityContext();
 
         context.put("context", sqlContext);

+ 20 - 0
src/main/java/org/durcframework/autocode/util/DateUtil.java

@@ -0,0 +1,20 @@
+package org.durcframework.autocode.util;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DateUtil {
+	private static DateFormat YMDHMS_FORMAT = new SimpleDateFormat(
+			"yyyy-MM-dd HH:mm:ss.sss");
+	private static DateFormat YMD_FORMAT = new SimpleDateFormat(
+			"yyyy-MM-dd");
+
+	public static String ymdhmsFormat(Date date) {
+		return YMDHMS_FORMAT.format(date);
+	}
+	public static String ymdFormat(Date date) {
+		return YMD_FORMAT.format(date);
+	}
+
+}

+ 14 - 0
src/main/java/org/durcframework/autocode/util/FieldUtil.java

@@ -47,6 +47,20 @@ public class FieldUtil {
 		}
 		return str;
 	}
+	
+	/**
+	 * 将第一个字母转换成小写
+	 * 
+	 * @param str
+	 * @return
+	 */
+	public static String lowerFirstLetter(String str) {
+		if (StringUtils.hasText(str)) {
+			String firstLower = str.substring(0, 1).toLowerCase();
+			str = firstLower + str.substring(1, str.length());
+		}
+		return str;
+	}
 
 	
 	public static void main(String[] args) {

+ 283 - 0
src/main/java/org/durcframework/autocode/util/FileUtil.java

@@ -0,0 +1,283 @@
+package org.durcframework.autocode.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.tools.zip.ZipOutputStream;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+public class FileUtil {
+
+	public static final String NEXT_LINE = "\r\n";
+	
+	private static final String ZIP_COMMENT = "本文件由代码生成工具autoCode生成.\r\n项目地址:https://git.oschina.net/durcframework/autoCode";
+
+	/**
+	 * 读文件
+	 * 
+	 * @param fileName
+	 * @return
+	 */
+	public static String readFromClassPath(String fileName) {
+		Resource resource = new ClassPathResource(fileName);
+		StringBuilder sb = new StringBuilder();
+		BufferedReader read = null;
+		try {
+			read = new BufferedReader(new FileReader(resource.getFile()));
+			char[] buf = new char[(int) resource.contentLength()];
+			read.read(buf);
+			sb.append(buf);
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				read.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return sb.toString();
+	}
+
+	public static String read(String fileName) {
+		StringBuilder sb = new StringBuilder();
+		BufferedReader read = null;
+		try {
+			File file = new File(fileName);
+			read = new BufferedReader(new FileReader(file));
+			char[] buf = new char[(int) file.length()];
+			read.read(buf);
+			sb.append(buf);
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				read.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * 写文件
+	 */
+	public static void write(String txt, String fileName) {
+		BufferedWriter writer = null;
+		try {
+			writer = new BufferedWriter(new FileWriter(fileName));
+			writer.write(txt);
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				writer.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * copy file or folder
+	 * 
+	 * @param srcFile
+	 * @param desFile
+	 * @throws IOException
+	 */
+	public static void copy(File srcFile, File desFile) {
+		if (!srcFile.exists()) {
+			return;
+		}
+		if (!desFile.exists()) {
+			desFile.mkdirs();
+		}
+		if (srcFile.isFile()) {
+			doCopy(srcFile, desFile);
+		} else {
+			String objFolder = desFile.getPath() + File.separator
+					+ srcFile.getName();
+			File _objFolderFile = new File(objFolder);
+			_objFolderFile.mkdirs();
+			for (File sf : srcFile.listFiles()) {
+				copy(sf, new File(objFolder));
+			}
+		}
+	}
+
+	private static void doCopy(File srcFile, File desFile) {
+		InputStream ins = null;
+		FileOutputStream outs = null;
+		try {
+			File objFile = new File(desFile.getPath() + File.separator
+					+ srcFile.getName());
+			ins = new FileInputStream(srcFile);
+			outs = new FileOutputStream(objFile);
+			byte[] buffer = new byte[ins.available()];
+			int length;
+			while ((length = ins.read(buffer)) != -1) {
+				outs.write(buffer, 0, length);
+			}
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				ins.close();
+				outs.flush();
+				outs.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+
+		}
+
+	}
+
+	/**
+	 * 创建文件夹
+	 * 
+	 * @param folderName
+	 */
+	public static void createFolder(String folderName) {
+		File file = new File(folderName);
+		if (file.exists()) {
+			return;
+		}
+		file.mkdirs();
+	}
+	
+	/**
+     * 删除空目录
+     * @param dir 将要删除的目录路径
+     */
+	public static void doDeleteEmptyDir(String dir) {
+        (new File(dir)).delete();
+    }
+
+    /**
+     * 递归删除目录下的所有文件及子目录下所有文件
+     * @param dir 将要删除的文件目录
+     * @return boolean Returns "true" if all deletions were successful.
+     *                 If a deletion fails, the method stops attempting to
+     *                 delete and returns "false".
+     */
+	public static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            //递归删除目录中的子目录下
+            for (int i=0; i<children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+        // 目录此时为空,可以删除
+        return dir.delete();
+    }
+
+	public static void createFolders(List<String> folders) {
+		for (String folder : folders) {
+			createFolder(folder);
+		}
+	}
+
+	/**
+	 * 重命名
+	 * 
+	 * @param srcFileName
+	 * @param desFileName
+	 */
+	public static void renameFile(String srcFileName, String desFileName) {
+		File desFile = new File(desFileName);
+		if (desFile.exists()) {
+			return;
+		}
+		File srcFile = new File(srcFileName);
+		srcFile.renameTo(desFile);
+	}
+
+	/**
+	 * 把"."操作符转化成"/"
+	 * 
+	 * @param path
+	 * @return
+	 */
+	public static String replacePointToSep(String path) {
+		return path.replaceAll("\\.", "/");
+	}
+
+	/**
+	 * zip("D:/ccc", "D:/ccc.zip");
+	 * @param inputFileName 目标文件夹
+	 * @param desZipFile 生成zip
+	 * @throws Exception
+	 */
+	public static void zip(String inputFileName, String desZipFile)
+			throws Exception {
+		zip(desZipFile, new File(inputFileName));
+	}
+
+	private static void zip(String zipFileName, File inputFile)
+			throws Exception {
+		ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
+				zipFileName));
+		out.setComment(String.format(ZIP_COMMENT, inputFile.getName(),
+				DateUtil.ymdFormat(new Date())));
+		out.setEncoding("GBK");
+		zip(out, inputFile, "");
+		out.close();
+	}
+
+	private static void zip(ZipOutputStream out, File f, String base)
+			throws Exception {
+		if (f.isDirectory()) {
+			File[] fl = f.listFiles();
+			// 如果不加最外层文件夹作为zip名
+			base = (base.length() == 0 ? f.getName() : base);
+			out.putNextEntry(new org.apache.tools.zip.ZipEntry(base + "/"));
+			base = base.length() == 0 ? "" : base + "/";
+			for (File file : fl) {
+				zip(out, file, base + file.getName());
+			}
+		} else {
+			out.putNextEntry(new org.apache.tools.zip.ZipEntry(base));
+			FileInputStream in = new FileInputStream(f);
+			byte[] buf = new byte[in.available()];
+			in.read(buf);
+			out.write(buf);
+			in.close();
+		}
+	}
+
+	public static void main(String[] args) {
+		 String s = read("S:/Users/thc/Desktop/1.txt");
+		String[] arr = s.split(",");
+		for (String str : arr) {
+			System.out.println("INSERT INTO table VALUE('" + str + "')");
+		}
+//		try {
+//			zip("D:/ccc", "D:/ccc.zip");
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//		}
+	}
+}

+ 5 - 1
src/main/resources/mybatis/mapper/mapperTemplateConfig.xml

@@ -6,6 +6,7 @@
 		<result column="tc_id" property="tcId" jdbcType="INTEGER" />
 		<result column="name" property="name" jdbcType="VARCHAR" />
 		<result column="save_path" property="savePath" jdbcType="VARCHAR" />
+		<result column="file_name" property="fileName" jdbcType="VARCHAR" />
 		<result column="content" property="content" jdbcType="VARCHAR" />
 		<result column="back_user" property="backUser" jdbcType="VARCHAR" />
 	</resultMap>
@@ -16,7 +17,7 @@
 		FROM `template_config` t
 		<include refid="expressionBlock.where" />
 		<if test="sortname == null">
-			ORDER BY tc_id desc
+			ORDER BY `name`
 		</if>
 		<if test="sortname != null">
 			ORDER BY ${order}
@@ -38,12 +39,14 @@
             (
              `name`,
              `save_path`,
+             `file_name`,
              `content`,
              `back_user`,
              `suffix`)
 		VALUES (
         #{name,jdbcType=VARCHAR},
         #{savePath,jdbcType=VARCHAR},
+        #{fileName,jdbcType=VARCHAR},
         #{content,jdbcType=VARCHAR},
         #{backUser,jdbcType=VARCHAR},
         #{suffix,jdbcType=VARCHAR}
@@ -55,6 +58,7 @@
 		SET 
 		  `name` = #{name,jdbcType=VARCHAR},
 		  `save_path` =  #{savePath,jdbcType=VARCHAR},
+		  `file_name` =  #{fileName,jdbcType=VARCHAR},
 		  `content` = #{content,jdbcType=VARCHAR},
 		  `back_user` = #{backUser,jdbcType=VARCHAR},
 		  `suffix` = #{suffix,jdbcType=VARCHAR}

+ 1 - 0
src/main/webapp/.#webclasspath

@@ -46,3 +46,4 @@ D:\dev\maven3\repository\org\apache\velocity\velocity\1.7\velocity-1.7.jar
 D:\dev\maven3\repository\org\sitemesh\sitemesh\3.0.0\sitemesh-3.0.0.jar
 D:\dev\maven3\repository\junit\junit\4.8\junit-4.8.jar
 D:\dev\maven3\repository\net\sourceforge\jtds\jtds\1.2.2\jtds-1.2.2.jar
+D:\dev\maven3\repository\org\apache\ant\ant\1.8.2\ant-1.8.2.jar

+ 6 - 4
src/main/webapp/decorator/main.jsp

@@ -9,16 +9,16 @@
 	<link rel="stylesheet" type="text/css" href="${resources}css/common.css"/>
 	<link rel="stylesheet" type="text/css" href="${resources}css/main.css"/>
 	<!-- fdui css -->
-	<link href="${resources}fdui/theme/aristo/theme.css" rel="stylesheet" type="text/css" />
-	<link href="${resources}fdui/primeui-1.1-min.css" rel="stylesheet" type="text/css" />
+	<link href="${fdui}styles/theme/aristo/theme.css" rel="stylesheet" type="text/css" />
+	<link href="${fdui}styles/primeui-1.1-min.css" rel="stylesheet" type="text/css" />
 	<script type="text/javascript">var ctx = '${ctx}';</script>
 	<!-- fdui js -->
 	<c:choose>
 		<c:when test="${debugModel}">
-			<script type="text/javascript" src="${resources}fdui/fdui.all.js"></script>
+			<script type="text/javascript" src="${fdui}js/fdui.all.js"></script>
 		</c:when>
 		<c:otherwise>
-		    <script type="text/javascript" src="${resources}fdui/fdui.all.min.js"></script>
+		    <script type="text/javascript" src="${fdui}js/fdui.all.min.js"></script>
 		</c:otherwise>
 	</c:choose>
 	<script type="text/javascript" src="${resources}js/libs/jquery.min.js"></script>
@@ -28,6 +28,7 @@
 	<script type="text/javascript" src="${resources}js/util/MaskUtil.js"></script>
 	<script type="text/javascript" src="${resources}js/util/HtmlUtil.js"></script>
 	<script type="text/javascript" src="${resources}js/util/FunUtil.js"></script>
+	<script type="text/javascript" src="${ctx}sys/VelocityHelper.js"></script>
 	
 	<style type="text/css">
 		.sub-body{margin: 10px;}
@@ -45,6 +46,7 @@
         </div>
         <div class="top-info-wrap">
             <ul class="top-info-list clearfix">
+                <li><a href="#" onclick="VelocityHelper.show(); return false;">Velocity参数</a></li>
                 <li><a href="${ctx}sys/updatePswd.jsp">修改密码</a></li>
                 <li><a href="javascript:void(0)" onclick="logout();">退出</a></li>
             </ul>

BIN
src/main/webapp/download/admin1443595614030.zip


BIN
src/main/webapp/download/admin1443595931960.zip


+ 0 - 58
src/main/webapp/js/Action.js

@@ -1,58 +0,0 @@
-var Action = {
-	ajsxSucc:function(e,succFun){
-		if(succFun){
-			succFun(e);
-		}
-	},
-	/**
-	 * 异步请求
-	 */
-	jsonAsyncActByData:function(url,data,succFun){
-		$.ajax({
-			type: "POST",
-			url: url,
-			async:true,
-			traditional:true,
-			dataType: "json",
-			data:data,
-			success: function(e){
-				Action.ajsxSucc(e,succFun);
-			},
-			error:function(hxr,type,error){
-				Action._showError('后台出错,请查看日志');
-			}
-		});
-	},
-	/**
-	 * 同步请求
-	 */
-	jsonSyncActByData:function(url,data,succFun){
-		$.ajax({
-			type: "POST",
-			url: url,
-			async:false,
-			traditional:true,
-			dataType: "json",
-			data:data,
-			success: function(e){
-				Action.ajsxSucc(e,succFun);
-			},
-			error:function(hxr,type,error){
-				Action._showError('后台出错,请查看日志');
-			}
-		});
-	}
-	,_showError:function(msg,title){
-		title = title || "提示";
-		var $ = parent.$ || $;
-		$.messager.show({
-			title: title,
-			msg: msg,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-}

+ 0 - 195
src/main/webapp/js/Crud.js

@@ -1,195 +0,0 @@
-/**
- * var crud = Crud.create({
- *  pk:'id' // 主键名
-	,addUrl:ctx + 'addDataSource.do' // 添加请求
-	,updateUrl:ctx + 'updateDataSource.do' // 修改请求
-	,delUrl:ctx + 'delDataSource.do' // 删除请求
-	,dlgId:'dlg' // 对话框id
-	,formId:'fm' // 表单id
-	,girdId:'dg' // 表格id
-})
- */
-var Crud = (function(){
-	
-	var CrudClass = function(param){
-		this.addUrl = param.addUrl;
-		this.listUrl = param.listUrl;
-		this.updateUrl = param.updateUrl;
-		this.delUrl = param.delUrl;
-		this.pk = param.pk;
-		this.encryptConfig = param.encryptConfig;
-		
-		this.$dlg = $('#'+param.dlgId);
-		this.$form = $('#'+param.formId);
-		this.$grid = $('#'+param.gridId);
-		
-		this.submitUrl;
-	}
-	
-	CrudClass.prototype = {
-		add:function(title){
-			title = title || '添加'
-			this.$dlg.dialog('open').dialog('setTitle',title);
-			this.$form.form('reset');
-			this.submitUrl = this.addUrl;
-			
-			if(this._hasPkInput()){
-				this.getPkInput().prop('disabled',false);
-			}
-		}
-		,update:function(row,title){
-			title = title || '修改'
-			if (row){
-				this.$dlg.dialog('open').dialog('setTitle',title);
-				this.$form.form('clear').form('load',row);
-				
-				this.submitUrl = this.updateUrl + ['?',this.pk,'=',row[this.pk]].join('');
-				
-				// 如果表单中有主键控件,则不能被修改
-				if(this._hasPkInput()){
-					this.getPkInput().prop('disabled',true);
-				}
-			}
-		}
-		,_hasPkInput:function(){
-			return this.getPkInput().length > 0;
-		}
-		,getPkInput:function(){
-			if(!this.pkInput){
-				this.pkInput = this.getByName(this.pk);
-			}
-			return this.pkInput;
-		}
-		,getByName:function(name){
-			return this.$form.find('[name='+name+']');
-		}
-		,del:function(row,msg){
-			msg = msg || '确定要删除该数据吗?';
-			var self = this;
-			if (row){
-				$.messager.confirm('Confirm',msg,function(r){
-					if (r){
-						$.post(self.delUrl,row,function(result){
-							if (result.success){
-								self.$grid.datagrid('reload');	// reload the user data
-							} else {
-								showMsg(result.errorMsg);
-							}
-						},'json');
-					}
-				});
-			}
-		}
-		,save:function(){
-			var self = this;
-			this.$form.form('submit',{
-				url: this.submitUrl,
-				onSubmit: function(){
-					self._doEncrypt();
-					return $(this).form('validate');
-				},
-				success: function(resultTxt){
-					var result = $.parseJSON(resultTxt);
-					if (result.success){
-						self.$dlg.dialog('close');		// close the dialog
-						self.$grid.datagrid('reload');	// reload the user data
-					} else {
-						var errorMsg = result.errorMsg;
-						errorMsg = errorMsg || buildValidateError(result);
-						showMsg(errorMsg);
-					}
-				}
-			});
-		}
-		,_doEncrypt:function(){
-			if(this.encryptConfig){
-				var encrypt = this.encryptConfig.encrypt;
-				var fields = this.encryptConfig.fields||[];
-				
-				for(var i=0,len=fields.length; i<len; i++) {
-					var $input = this.getByName(fields[i]);
-					var md5 = faultylabs.MD5($.trim($input.val()))
-					$input.val(md5);
-				}
-			}
-		}
-		,createOperColumn:function(buttons){
-			return {field:'_operate',title:'操作',align:'center',formatter:this.createOperFormatter(buttons)};
-		}
-		,createEditColumn:function(appendButton){
-			appendButton = $.isArray(appendButton) ? appendButton : [];
-			var that = this;
-			var buttons = [
-				{text:'修改',onclick:function(row){
-					that.update(row);
-				}}
-				,{text:'删除',onclick:function(row){
-					that.del(row);
-				}}
-			].concat(appendButton);
-			
-			return this.createOperColumn(buttons);
-		}
-		,createOperFormatter:function(buttons){
-			buttons = $.isArray(buttons) ? buttons : [];
-			
-			return function(val,row,index){
-				var html = [];
-				for(var i=0,len=buttons.length; i<len; i++) {
-					var button = buttons[i];
-					html.push('<a href="javascript:void(0)" onclick="'+FunUtil.createFun(button,'onclick',row,val,index)+'">'+button.text+'</a>')
-				}
-				return html.join(' | ');
-			}
-		}
-		/**
-		 * 创建datagrid,options为追加的datagird属性
-		 * crud.datagrid([    
-			    {field:'name',title:'名称'}  
-			    ,{field:'driverClass',title:'驱动'}  
-			    ,{field:'driverClass',title:'驱动'}
-			    ,{field:'jdbcUrl',title:'连接'}
-			    
-			],{toolbar:"#toolbar"});
-		 */
-		,buildGrid:function(columns,options){
-			// 默认参数
-			var settings = {    
-			    url:this.listUrl,columns:[columns],toolbar:'#toolbar'
-			    ,pagination:true,fitColumns:true,singleSelect:true,striped:true
-			};
-			// 合并参数
-			$.extend(settings, options);
-			
-			this.$grid.datagrid(settings);
-		}
-		,closeDlg:function(){
-			this.$dlg.dialog('close');
-		}
-	}
-	
-	function showMsg(errorMsg){
-		var $ = parent.$ || $;
-		$.messager.show({
-			title: '提示',
-			msg: errorMsg,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-	
-	function buildValidateError(result){
-		var validateErrors = result.validateErrors;
-		return validateErrors.join('<br>')
-	}
-	
-	return {
-		create:function(param){
-			return new CrudClass(param);
-		}
-	};
-	
-})();

+ 0 - 44
src/main/webapp/js/EventUtil.js

@@ -1,44 +0,0 @@
-var EventUtil = {
-	/**
-	 * 格式化事件对象
-	 */
-	getEvent : function(){
-		if(window.event){
-			return this.formatEvent(window.event);
-		}else {
-			return this.getEvent.caller.arguments[0];
-		}
-	}
-	/**
-	 * 格式化事件对象,做到IE与DOM的统一
-	 * @param oEvent:事件对象
-	 */
-	,formatEvent : function(oEvent){
-		if($.browser.msie){
-			oEvent.charCode = (oEvent.type == "keypress")?oEvent.charCode:0;
-			oEvent.eventPhase = 2;
-			oEvent.isChar = (oEvent.charCode > 0);
-			oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
-			oEvent.pageY = oEvent.clientY + document.body.scrollTop;
-			// 阻止某个事件的默认行为
-			oEvent.preventDefault = function(){
-				this.returnValue = false;
-			}
-			
-			if(oEvent.type == "mouseout"){
-				oEvent.relateTarget = oEvent.toElement;
-			} else if(oEvent.type == "mouseover"){
-				oEvent.relateTarget = oEvent.fromElement;
-			}
-			
-			// 阻止冒泡
-			oEvent.stopPropagation = function(){
-				this.cancelBubble = true;
-			}
-			
-			oEvent.target = oEvent.srcElement;
-			oEvent.timestamp = (new Date()).getTime();
-		}
-		return oEvent;
-	}
-}

+ 0 - 53
src/main/webapp/js/FunUtil.js

@@ -1,53 +0,0 @@
-/*
-&nbsp;使用方法:
-&nbsp;FunUtil.createFun(scope,'some_mothod_name',obj1);
-&nbsp;FunUtil.createFun(scope,'some_mothod_name',obj1,obj2);
-&nbsp;...
-*/
-var FunUtil = (function(){
-	
-	var index = 0; 
-	var handlerStore = []; // 存放方法句柄
-
-	return {		
-		// scope:作用域
-		// methodName:方法名,字符串格式
-		// ...:参数可放多个
-		createFun:function(scope,methodName){
-			var currentIndex = index++; // 创建索引
-			
-			var argu = []; // 用来存放多个参数
-			// 构建参数
-			for(var i=2,len=arguments.length;i<len;i++){
-				argu.push(arguments[i]);	
-			}
-
-			// 把函数句柄存在数组里
-			handlerStore[currentIndex] = (function(scope,methodName,argu){
-				// 生成函数调用句柄
-				return function(){
-					scope[methodName].apply(scope,argu);
-				}
-
-			}(scope,methodName,argu));			
-			
-			return 'FunUtil._runFun(event,'+currentIndex+');';
-		}
-		// 执行方法
-		// index:索引.根据这个索引找到执行函数
-		,_runFun:function(e,index){
-			var handler = handlerStore[index];
-			handler();// 该函数已经传入了参数
-			
-			// 阻止默认行为并取消冒泡
-			if(typeof e.preventDefault === 'function') {
-				e.preventDefault();
-				e.stopPropagation();
-			}else {
-				e.returnValue = false;
-				e.cancelBubble = true;
-			}
-		}
-	};
-	
-})();

+ 0 - 34
src/main/webapp/js/HtmlUtil.js

@@ -1,34 +0,0 @@
-var HtmlUtil = (function(){
-	
-	var parseHtmlMap = {
-		"<":"&lt;"
-		,">":"&gt;"
-		,"\r\n":"<br>"
-		," ":"&nbsp;"
-		,"\t":"&nbsp;&nbsp;&nbsp;&nbsp;"
-	}
-	
-	var parseTextMap = {
-		"\&nbsp;":' '
-		,"\<br ?\/?\>":'\r\n'
-		,"\&lt;":"<"
-		,"\&gt;":">"
-	}
-	
-	function parse(content,map){
-		for(var key in map){
-			content = content.replace(new RegExp(key, "g"),map[key]);
-		}
-		return content;
-	}
-	
-	return {
-		parseToHtml:function(text){
-			return parse(text,parseHtmlMap);
-		}
-		,parseToText:function(html){
-			return parse(html,parseTextMap);
-		}
-	}
-	
-}());

+ 0 - 43
src/main/webapp/js/MaskUtil.js

@@ -1,43 +0,0 @@
-/**
- * 使用方法:
- * 开启:MaskUtil.mask();
- * 关闭:MaskUtil.unmask();
- * 
- * MaskUtil.mask('其它提示文字...');
- */
-var MaskUtil = (function(){
-	
-	var $mask,$maskMsg;
-	
-	var defMsg = '正在处理,请稍候...';
-	
-	function init(){
-		if(!$mask){
-			$mask = $("<div class=\"datagrid-mask mymask\"></div>").appendTo("body");
-		}
-		if(!$maskMsg){
-			$maskMsg = $("<div class=\"datagrid-mask-msg mymask\">"+defMsg+"</div>")
-				.appendTo("body").css({'font-size':'12px'});
-		}
-		
-		$mask.css({width:"100%",height:$(document).height()});
-		
-		$maskMsg.css({
-			left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2
-		}); 
-				
-	}
-	
-	return {
-		mask:function(msg){
-			init();
-			$mask.show();
-			$maskMsg.html(msg||defMsg).show();
-		}
-		,unmask:function(){
-			$mask.hide();
-			$maskMsg.hide();
-		}
-	}
-	
-}());

+ 0 - 56
src/main/webapp/js/MsgUtil.js

@@ -1,56 +0,0 @@
-
-var MsgUtil = {
-	topMsg:function(msg,title){
-		title = title || "提示";
-		this.getJQ().messager.show({
-			title: title,
-			msg: msg,
-			showSpeed:300,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-	,alert:function(msg,title,type){
-		title = title || "提示";
-		type = type || 'info'
-		
-		if(msg && msg.length > 1000){
-			this.getJQ().messager.show({
-				title: title,
-				msg: '<div style="height:300px;overflow-y: auto; overflow-x:hidden;">'+msg+'</div>',
-				width:600,
-				height:350,
-				showType:null,
-				timeout:0,
-				style:{
-					right:'',
-					bottom:''
-				}
-			});
-		}else{
-			$.messager.alert(title,msg,type);
-		}
-		
-	}
-	,error:function(msg,title){
-		title = title || "错误";
-		this.alert(msg,title,'error')
-	}
-	,confirm:function(msg,callback,title){
-		title = title || "确认";
-		this.getJQ().messager.confirm(title,msg,function(r){    
-		    if (r){    
-		        callback();
-		    } 
-		});
-	}
-	,getJQ:function(){
-		return parent.$ || $;
-	}
-}  
-
-	
-

+ 0 - 56
src/main/webapp/js/VelocityContext.js

@@ -1,56 +0,0 @@
-/**
- * VelocityContext.createGrid('id');
- */
-var VelocityContext = (function(){
-	
-	var data = null;
-	
-	function getData(){
-		if(!data){
-			data = [
-			{"name":"${context.packageName}","value":"包名","group":"${context}"}
-			,{"name":"${context.javaBeanName}","value":"Java类名","group":"${context}"}
-			,{"name":"${context.pkName}","value":"表主键名","group":"${context}"}
-			,{"name":"${context.javaPkName}","value":"表主键对应的java字段名","group":"${context}"}
-			,{"name":"${context.javaPkType}","value":"主键的java类型","group":"${context}"}
-			,{"name":"${context.mybatisPkType}","value":"主键对应的mybatis类型","group":"${context}"}
-			
-			,{"name":"${table.tableName}","value":"数据库表名","group":"${table}"}
-			
-			
-			,{"name":"${pkColumn}","value":"主键对象<br>即${columns}中的一个元素","group":"${pkColumn}"}
-			
-			,{"name":"${column.columnName}","value":"表中字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.type}","value":"字段的数据库类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldName}","value":"java字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldNameUF}","value":"java字段名<br>并且第一个字母大写","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaType}","value":"字段的java类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaTypeBox}","value":"字段的java装箱类型<br>如Integer,Long","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentity}","value":"是否自增,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isPk}","value":"是否主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentityPk}","value":"是否自增主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.mybatisJdbcType}","value":"返回mybatis定义的jdbcType,<br>如VARCHAR,INTEGER等","group":"#foreach($column in $columns)...#end"}
-			]
-		}
-		return data;	
-	}
-	
-	return {
-		/**
-		 * 创建Velocity参数列表
-		 */
-		createGrid:function(id){
-			var $pgVelocity = $('<table></table>');
-			$('#'+id).html($pgVelocity);
-			$pgVelocity.propertygrid({    
-			    showGroup: true,    
-			    fitColumns:true,
-			    border:false,
-			    scrollbarSize: 0    
-			}).propertygrid('loadData',getData());
-			
-			return $pgVelocity;
-		}
-	}
-	
-}());

+ 0 - 504
src/main/webapp/js/common.js

@@ -1,504 +0,0 @@
-var Action = {
-	ajsxSucc:function(e,succFun){
-		if(succFun){
-			succFun(e);
-		}
-	},
-	/**
-	 * 异步请求
-	 */
-	jsonAsyncActByData:function(url,data,succFun){
-		$.ajax({
-			type: "POST",
-			url: url,
-			async:true,
-			traditional:true,
-			dataType: "json",
-			data:data,
-			success: function(e){
-				Action.ajsxSucc(e,succFun);
-			},
-			error:function(hxr,type,error){
-				Action._showError('后台出错,请查看日志');
-			}
-		});
-	},
-	/**
-	 * 同步请求
-	 */
-	jsonSyncActByData:function(url,data,succFun){
-		$.ajax({
-			type: "POST",
-			url: url,
-			async:false,
-			traditional:true,
-			dataType: "json",
-			data:data,
-			success: function(e){
-				Action.ajsxSucc(e,succFun);
-			},
-			error:function(hxr,type,error){
-				Action._showError('后台出错,请查看日志');
-			}
-		});
-	}
-	,_showError:function(msg,title){
-		title = title || "提示";
-		var $ = parent.$ || $;
-		$.messager.show({
-			title: title,
-			msg: msg,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-}
-
-/**
- * var crud = Crud.create({
- *  pk:'id' // 主键名
-	,addUrl:ctx + 'addDataSource.do' // 添加请求
-	,updateUrl:ctx + 'updateDataSource.do' // 修改请求
-	,delUrl:ctx + 'delDataSource.do' // 删除请求
-	,dlgId:'dlg' // 对话框id
-	,formId:'fm' // 表单id
-	,girdId:'dg' // 表格id
-})
- */
-var Crud = (function(){
-	
-	var CrudClass = function(param){
-		this.addUrl = param.addUrl;
-		this.listUrl = param.listUrl;
-		this.updateUrl = param.updateUrl;
-		this.delUrl = param.delUrl;
-		this.pk = param.pk;
-		
-		this.$dlg = $('#'+param.dlgId);
-		this.$form = $('#'+param.formId);
-		this.$grid = $('#'+param.gridId);
-		
-		this.submitUrl;
-	}
-	
-	CrudClass.prototype = {
-		add:function(title){
-			title = title || '添加'
-			this.$dlg.dialog('open').dialog('setTitle',title);
-			this.$form.form('reset');
-			this.submitUrl = this.addUrl;
-			
-			if(this._hasPkInput()){
-				this.getPkInput().prop('disabled',false);
-			}
-		}
-		,update:function(row,title){
-			title = title || '修改'
-			if (row){
-				this.$dlg.dialog('open').dialog('setTitle',title);
-				this.$form.form('clear').form('load',row);
-				
-				this.submitUrl = this.updateUrl + ['?',this.pk,'=',row[this.pk]].join('');
-				
-				// 如果表单中有主键控件,则不能被修改
-				if(this._hasPkInput()){
-					this.getPkInput().prop('disabled',true);
-				}
-			}
-		}
-		,_hasPkInput:function(){
-			return this.getPkInput().length > 0;
-		}
-		,getPkInput:function(){
-			return this.$form.find('[name='+this.pk+']');
-		}
		,del:function(row,msg){
-			msg = msg || '确定要删除该数据吗?';
-			var self = this;
-			if (row){
-				$.messager.confirm('Confirm',msg,function(r){
-					if (r){
-						$.post(self.delUrl,row,function(result){
-							if (result.success){
-								self.$grid.datagrid('reload');	// reload the user data
-							} else {
-								showMsg(result.errorMsg);
-							}
-						},'json');
-					}
-				});
-			}
-		}
-		,save:function(){
-			var self = this;
-			this.$form.form('submit',{
-				url: this.submitUrl,
-				onSubmit: function(){
-					return $(this).form('validate');
-				},
-				success: function(resultTxt){
-					var result = $.parseJSON(resultTxt);
-					if (result.success){
-						self.$dlg.dialog('close');		// close the dialog
-						self.$grid.datagrid('reload');	// reload the user data
-					} else {
-						var errorMsg = result.errorMsg;
-						errorMsg = errorMsg || buildValidateError(result);
-						showMsg(errorMsg);
-					}
-				}
-			});
-		}
-		
-		,createOperColumn:function(){
-			return {field:'_operate',title:'操作',align:'center',formatter:this.createOperFormatter()};
-		}
-		
-		,createOperFormatter:function(){
-			var that = this;
-			return function(val,row,index){
-				return '<a href="javascript:void(0)" onclick="'+FunUtil.createFun(that,'update',row)+'">修改</a>'+
-				' | <a href="javascript:void(0)" onclick="'+FunUtil.createFun(that,'del',row)+'">删除</a>';
-			}
-		}
-		/**
-		 * 创建datagrid,options为追加的datagird属性
-		 * crud.datagrid([    
-			    {field:'name',title:'名称'}  
-			    ,{field:'driverClass',title:'驱动'}  
-			    ,{field:'driverClass',title:'驱动'}
-			    ,{field:'jdbcUrl',title:'连接'}
-			    
-			],{toolbar:"#toolbar"});
-		 */
-		,buildGrid:function(columns,options){
-			// 默认参数
-			var settings = {    
-			    url:this.listUrl,columns:[columns],toolbar:'#toolbar'
-			    ,pagination:true,fitColumns:true,singleSelect:true,striped:true
-			};
-			// 合并参数
-			$.extend(settings, options);
-			
-			this.$grid.datagrid(settings);
-		}
-		,closeDlg:function(){
-			this.$dlg.dialog('close');
-		}
-	}
-	
-	function showMsg(errorMsg){
-		var $ = parent.$ || $;
-		$.messager.show({
-			title: '提示',
-			msg: errorMsg,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-	
-	function buildValidateError(result){
-		var validateErrors = result.validateErrors;
-		return validateErrors.join('<br>')
-	}
-	
-	return {
-		create:function(param){
-			return new CrudClass(param);
-		}
-	};
-	
-})();
-var EventUtil = {
-	/**
-	 * 格式化事件对象
-	 */
-	getEvent : function(){
-		if(window.event){
-			return this.formatEvent(window.event);
-		}else {
-			return this.getEvent.caller.arguments[0];
-		}
-	}
-	/**
-	 * 格式化事件对象,做到IE与DOM的统一
-	 * @param oEvent:事件对象
-	 */
-	,formatEvent : function(oEvent){
-		if($.browser.msie){
-			oEvent.charCode = (oEvent.type == "keypress")?oEvent.charCode:0;
-			oEvent.eventPhase = 2;
-			oEvent.isChar = (oEvent.charCode > 0);
-			oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
-			oEvent.pageY = oEvent.clientY + document.body.scrollTop;
-			// 阻止某个事件的默认行为
-			oEvent.preventDefault = function(){
-				this.returnValue = false;
-			}
-			
-			if(oEvent.type == "mouseout"){
-				oEvent.relateTarget = oEvent.toElement;
-			} else if(oEvent.type == "mouseover"){
-				oEvent.relateTarget = oEvent.fromElement;
-			}
-			
-			// 阻止冒泡
-			oEvent.stopPropagation = function(){
-				this.cancelBubble = true;
-			}
-			
-			oEvent.target = oEvent.srcElement;
-			oEvent.timestamp = (new Date()).getTime();
-		}
-		return oEvent;
-	}
-}
-/*
-&nbsp;使用方法:
-&nbsp;FunUtil.createFun(scope,'some_mothod_name',obj1);
-&nbsp;FunUtil.createFun(scope,'some_mothod_name',obj1,obj2);
-&nbsp;...
-*/
-var FunUtil = (function(){
-	
-	var index = 0; 
-	var handlerStore = []; // 存放方法句柄
-
-	return {		
-		// scope:作用域
-		// methodName:方法名,字符串格式
-		// ...:参数可放多个
-		createFun:function(scope,methodName){
-			var currentIndex = index++; // 创建索引
-			
-			var argu = []; // 用来存放多个参数
-			// 构建参数
-			for(var i=2,len=arguments.length;i<len;i++){
-				argu.push(arguments[i]);	
-			}
-
-			// 把函数句柄存在数组里
-			handlerStore[currentIndex] = (function(scope,methodName,argu){
-				// 生成函数调用句柄
-				return function(){
-					scope[methodName].apply(scope,argu);
-				}
-
-			}(scope,methodName,argu));			
-			
-			return 'FunUtil._runFun(event,'+currentIndex+');';
-		}
-		// 执行方法
-		// index:索引.根据这个索引找到执行函数
-		,_runFun:function(e,index){
-			var handler = handlerStore[index];
-			handler();// 该函数已经传入了参数
-			
-			// 阻止默认行为并取消冒泡
-			if(typeof e.preventDefault === 'function') {
-				e.preventDefault();
-				e.stopPropagation();
-			}else {
-				e.returnValue = false;
-				e.cancelBubble = true;
-			}
-		}
-	};
-	
-})();
-
-var HtmlUtil = (function(){
-	
-	var parseHtmlMap = {
-		"<":"&lt;"
-		,">":"&gt;"
-		,"\r\n":"<br>"
-		," ":"&nbsp;"
-		,"\t":"&nbsp;&nbsp;&nbsp;&nbsp;"
-	}
-	
-	var parseTextMap = {
-		"\&nbsp;":' '
-		,"\<br ?\/?\>":'\r\n'
-		,"\&lt;":"<"
-		,"\&gt;":">"
-	}
-	
-	function parse(content,map){
-		for(var key in map){
-			content = content.replace(new RegExp(key, "g"),map[key]);
-		}
-		return content;
-	}
-	
-	return {
-		parseToHtml:function(text){
-			return parse(text,parseHtmlMap);
-		}
-		,parseToText:function(html){
-			return parse(html,parseTextMap);
-		}
-	}
-	
-}());
-/**
- * 使用方法:
- * 开启:MaskUtil.mask();
- * 关闭:MaskUtil.unmask();
- * 
- * MaskUtil.mask('其它提示文字...');
- */
-var MaskUtil = (function(){
-	
-	var $mask,$maskMsg;
-	
-	var defMsg = '正在处理,请稍待。。。';
-	
-	function init(){
-		if(!$mask){
-			$mask = $("<div class=\"datagrid-mask mymask\"></div>").appendTo("body");
-		}
-		if(!$maskMsg){
-			$maskMsg = $("<div class=\"datagrid-mask-msg mymask\">"+defMsg+"</div>")
-				.appendTo("body").css({'font-size':'12px'});
-		}
-		
-		$mask.css({width:"100%",height:$(document).height()});
-		
-		$maskMsg.css({
-			left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2
-		}); 
-				
-	}
-	
-	return {
-		mask:function(msg){
-			init();
-			$mask.show();
-			$maskMsg.html(msg||defMsg).show();
-		}
-		,unmask:function(){
-			$mask.hide();
-			$maskMsg.hide();
-		}
-	}
-	
-}());
-
-var MsgUtil = {
-	topMsg:function(msg,title){
-		title = title || "提示";
-		this.getJQ().messager.show({
-			title: title,
-			msg: msg,
-			showSpeed:300,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
-	}
-	,alert:function(msg,title,type){
-		title = title || "提示";
-		type = type || 'info'
-		
-		if(msg && msg.length > 1000){
-			this.getJQ().messager.show({
-				title: title,
-				msg: '<div style="height:300px;overflow-y: auto; overflow-x:hidden;">'+msg+'</div>',
-				width:600,
-				height:350,
-				showType:null,
-				timeout:0,
-				style:{
-					right:'',
-					bottom:''
-				}
-			});
-		}else{
-			$.messager.alert(title,msg,type);
-		}
-		
-	}
-	,error:function(msg,title){
-		title = title || "错误";
-		this.alert(msg,title,'error')
-	}
-	,confirm:function(msg,callback,title){
-		title = title || "确认";
-		this.getJQ().messager.confirm(title,msg,function(r){    
-		    if (r){    
-		        callback();
-		    } 
-		});
-	}
-	,getJQ:function(){
-		return parent.$ || $;
-	}
-}  
-
-	
-
-
-/**
- * VelocityContext.createGrid('id');
- */
-var VelocityContext = (function(){
-	
-	var data = null;
-	
-	function getData(){
-		if(!data){
-			data = [
-			{"name":"${context.packageName}","value":"包名","group":"${context}"}
-			,{"name":"${context.javaBeanName}","value":"Java类名","group":"${context}"}
-			,{"name":"${context.pkName}","value":"表主键名","group":"${context}"}
-			,{"name":"${context.javaPkName}","value":"表主键对应的java字段名","group":"${context}"}
-			,{"name":"${context.javaPkType}","value":"主键的java类型","group":"${context}"}
-			,{"name":"${context.mybatisPkType}","value":"主键对应的mybatis类型","group":"${context}"}
-			
-			,{"name":"${table.tableName}","value":"数据库表名","group":"${table}"}
-			
-			
-			,{"name":"${pkColumn}","value":"主键对象<br>即${columns}中的一个元素","group":"${pkColumn}"}
-			
-			,{"name":"${column.columnName}","value":"表中字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.type}","value":"字段的数据库类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldName}","value":"java字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldNameUF}","value":"java字段名<br>并且第一个字母大写","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaType}","value":"字段的java类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaTypeBox}","value":"字段的java装箱类型<br>如Integer,Long","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentity}","value":"是否自增,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isPk}","value":"是否主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentityPk}","value":"是否自增主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.mybatisJdbcType}","value":"返回mybatis定义的jdbcType,<br>如VARCHAR,INTEGER等","group":"#foreach($column in $columns)...#end"}
-			]
-		}
-		return data;	
-	}
-	
-	return {
-		/**
-		 * 创建Velocity参数列表
-		 */
-		createGrid:function(id){
-			var $pgVelocity = $('<table></table>');
-			$('#'+id).html($pgVelocity);
-			$pgVelocity.propertygrid({    
-			    showGroup: true,    
-			    fitColumns:true,
-			    border:false,
-			    scrollbarSize: 0    
-			}).propertygrid('loadData',getData());
-			
-			return $pgVelocity;
-		}
-	}
-	
-}());

File diff suppressed because it is too large
+ 0 - 1
src/main/webapp/js/common.min.js


BIN
src/main/webapp/js/jquery.zclip/ZeroClipboard.swf


File diff suppressed because it is too large
+ 0 - 495
src/main/webapp/js/jquery.zclip/jquery.zclip.js


File diff suppressed because it is too large
+ 0 - 1
src/main/webapp/js/jquery.zclip/jquery.zclip.min.js


+ 0 - 5
src/main/webapp/login/common/footer.jsp

@@ -1,5 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-	pageEncoding="UTF-8"%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<div style="text-align: center;">
-</div>

+ 0 - 28
src/main/webapp/login/common/header.jsp

@@ -1,28 +0,0 @@
-<%@page import="org.durcframework.autocode.common.AutoCodeContext"%>
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-	pageEncoding="UTF-8"%>
-<span style="float: right; padding-right: 10px;">
-欢迎,<%=AutoCodeContext.getInstance().getUser().getUsername()%> | <a href="javascript:void(0)" onclick="logout(); return false;">安全退出</a>
-</span>
-<script type="text/javascript">
-function logout(){
-	$.ajax({
-		type: "POST",
-	    url: ctx + 'logout.do',
-	  	dataType:'json',
-	    success: function(result){
-			if (result.success){
-				var win = window.parent || window;
-				win.location.reload();
-			} 
-		},
-		error:function(){
-			window.location.reload();
-		}
-	});
-}
-</script>
-<span style="padding-left: 5px; font-size: 16px;">
-<!-- 		<img src="images/blocks.gif" width="20" height="20" align="absmiddle" /> -->
-代码生成系统
-</span>

+ 0 - 63
src/main/webapp/login/common/menu.jsp

@@ -1,63 +0,0 @@
-<%@page import="org.durcframework.autocode.common.AutoCodeContext"%>
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-    pageEncoding="UTF-8"%>
-<div id="menu"></div>
-
-<script type="text/javascript">
-(function(){
-	var treeData = [
-	    {
-		    text : "生成代码",
-		    attributes : {
-	            url : "generator/generator.jsp"
-	        }
-		}
-	    ,{
-		    text : "配置数据源",
-		    attributes : {
-	            url : "config/dataSource.jsp"
-	        }
-		}
-	    ,{
-		    text : "配置模板",
-		    attributes : {
-	            url : "config/template.jsp"
-	        }
-		}
-	    <%if(AutoCodeContext.getInstance().isAdmin()){%>
-	    ,{
-		    text : "用户管理",
-		    attributes : {
-	            url : "config/backUser.jsp"
-	        }
-		}
-	    <%}%>
-	    
-	];
-	$("#menu").tree({
-	    data : treeData,
-	    lines : true,
-	    onClick : function (node) {
-	        if (node.attributes) {
-	        	openTab(node.text, node.attributes.url);
-	        }
-	    }
-	});
-
-	//在右边center区域打开菜单,新增tab
-	function openTab(text, url) {
-	    if ($("#mainTab").tabs('exists', text)) {
-	        $('#mainTab').tabs('select', text);
-	    } else {
-	        $('#mainTab').tabs('add', {
-	            title : text,
-	            closable : true,
-	           // href : ctx + url
-	            content : '<iframe src="'+ ctx + url+'" scrolling="yes" frameborder="0" style="width:100%;height:100%;"></iframe>'
-	        });
-	    }
-	}
-
-})();
-
-</script>

+ 0 - 103
src/main/webapp/login/main.jsp

@@ -1,103 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-    pageEncoding="UTF-8"%>
-<%@ include file="../taglib.jsp" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>代码生成系统</title>
-<jsp:include page="../easyui_lib.jsp"></jsp:include>	
-</head>
-<body>
-<body id="mainLayout" class="easyui-layout">
-	<div data-options="region:'north',border:false" style="height:30px;padding:5px;">
-		<jsp:include page="common/header.jsp"></jsp:include>
-	</div>
-	<div data-options="region:'west',split:true,title:'菜单'" style="width:150px;padding:10px;">
-		<jsp:include page="common/menu.jsp"></jsp:include>
-	</div>
-	<div data-options="region:'east',split:false,collapsed:true,title:'Velocity参数列表'" style="width:360px;">
-		<div id="vcPg"></div>
-	</div>
-	<div data-options="region:'center'">
-		<div id="mainTab" class="easyui-tabs" data-options="fit:true,border:false">
-			<div title="首页" style="padding:10px">
-				<jsp:include page="welcome.jsp"></jsp:include>
-			</div>
-		</div>
-	</div>
-<!-- 	<div data-options="region:'south',border:false" style="height:25px;"> -->
-<%-- 		<jsp:include page="common/footer.jsp"></jsp:include> --%>
-<!-- 	</div> -->
-	
-	<div id="tabsMenu" class="easyui-menu" style="width:120px;">
-	  <div name="Refresh">刷新</div>  
-	  <div name="Other">关闭其他</div>  
-	  <div name="All">关闭所有</div>
-	</div>  
-	
-
-<script type="text/javascript">
-$(function(){
-	VelocityContext.createGrid('vcPg');
-})
-//绑定tabs的右键菜单
-$("#mainTab").tabs({
-    onContextMenu : function (e, title) {
-        e.preventDefault();
-        $('#tabsMenu').menu('show', {
-            left : e.pageX,
-            top : e.pageY
-        }).data("tabTitle", title);
-    }
-});
-
-	//实例化menu的onClick事件
-$("#tabsMenu").menu({
-    onClick : function (item) {
-        closeTab(this, item.name);
-    }
-});
-
-	//几个关闭事件的实现
-function closeTab(menu, type) {
-    var curTabTitle = $(menu).data("tabTitle");
-    var tabs = $("#mainTab");
-    
-    if (type === "close") {
-        tabs.tabs("close", curTabTitle);
-        return;
-    }
-    if (type === "Refresh") {
-    	var currTab =  tabs.tabs('getSelected'); //获得当前tab
-        var url = $(currTab.panel('options').content).attr('src');
-    	if(url){
-   		  tabs.tabs('update', {
-   	        	tab : currTab,
-   				options : {
-   	            	content : '<iframe src="'+ url+'" scrolling="yes" frameborder="0" style="width:100%;height:100%;"></iframe>'
-   	            }
-   			});
-    	}
-		return;
-    }
-    
-    var allTabs = tabs.tabs("tabs");
-    var closeTabsTitle = [];
-    
-    $.each(allTabs, function () {
-        var opt = $(this).panel("options");
-        if (opt.closable && opt.title != curTabTitle && type === "Other") {
-            closeTabsTitle.push(opt.title);
-        } else if (opt.closable && type === "All") {
-            closeTabsTitle.push(opt.title);
-        } 
-    });
-    
-    for (var i = 0; i < closeTabsTitle.length; i++) {
-        tabs.tabs("close", closeTabsTitle[i]);
-    }
-}
-</script>
-</body>
-</html>

+ 0 - 132
src/main/webapp/login/welcome.jsp

@@ -1,132 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-    pageEncoding="UTF-8"%>
-<%@ include file="../taglib.jsp" %>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>首页</title>
-</head>
-<body>
-<p style="font-size:14px">欢迎使用代码生成系统</p>
-如果您首次使用本系统,请按以下步骤操作:
-<ol>
-	<li>配置数据源。模板的生成需要依赖数据库表</li>
-	<li>配置模板。基于Velocity模板引擎,<a href="javascript:void(0)" onclick="showVelocity(); return false;">点此查看</a>Velocity参数列表</li>
-	<li>生成代码。只需三步即可生成代码文件</li>
-</ol>
-
-<strong>示例:</strong><br>
-=======表结构=======<br>
-<img src="../table.png">
-<div class="easyui-tabs" style="width:800px;height:400px;">
-<div title="模板内容" style="padding:5px">
-<pre>
-package &#36;{context.packageName}.entity;
-
-import org.durcframework.entity.BaseEntity;
-
-public class &#36;{context.javaBeanName} extends BaseEntity {
-## 此处用foreach循环构建java类中的属性
-#foreach(&#36;column in &#36;columns) 
-    private &#36;{column.javaType} &#36;{column.javaFieldName};
-#end
-
-## 此处用foreach循环构建属性的get/set方法
-#foreach(&#36;{column} in &#36;{columns}) 
-    public void set&#36;{column.javaFieldNameUF}(&#36;{column.javaType} &#36;{column.javaFieldName}){
-        this.&#36;{column.javaFieldName} = &#36;{column.javaFieldName};
-    }
-
-    public &#36;{column.javaType} get&#36;{column.javaFieldNameUF}(){
-        return this.&#36;{column.javaFieldName};
-    }
-
-#end
-}
-</pre>
-	</div>
-	<div title="生成后的代码" style="padding:5px">
-<pre>
-package datasourceconfig.entity;
-
-import org.durcframework.entity.BaseEntity;
-
-publc class DatasourceConfig extends BaseEntity {
-    private int dcId;
-    private String name;
-    private String driverClass;
-    private String jdbcUrl;
-    private String username;
-    private String password;
-    private String backUser;
-
-    public void setDcId(int dcId){
-        this.dcId = dcId;
-    }
-
-    public int getDcId(){
-        return this.dcId;
-    }
-
-    public void setName(String name){
-        this.name = name;
-    }
-
-    public String getName(){
-        return this.name;
-    }
-
-    public void setDriverClass(String driverClass){
-        this.driverClass = driverClass;
-    }
-
-    public String getDriverClass(){
-        return this.driverClass;
-    }
-
-    public void setJdbcUrl(String jdbcUrl){
-        this.jdbcUrl = jdbcUrl;
-    }
-
-    public String getJdbcUrl(){
-        return this.jdbcUrl;
-    }
-
-    public void setUsername(String username){
-        this.username = username;
-    }
-
-    public String getUsername(){
-        return this.username;
-    }
-
-    public void setPassword(String password){
-        this.password = password;
-    }
-
-    public String getPassword(){
-        return this.password;
-    }
-
-    public void setBackUser(String backUser){
-        this.backUser = backUser;
-    }
-
-    public String getBackUser(){
-        return this.backUser;
-    }
-
-}
-</pre>
-	</div>
-</div>
-
-<script type="text/javascript" src="${ctx}js/VelocityContext.js"></script>
-<script type="text/javascript">
-function showVelocity(){
-	$('#mainLayout').layout('expand','east');
-}
-</script>
-</body>
-</html>

+ 1 - 11
src/main/webapp/resources/js/libs/Action.js

@@ -85,16 +85,6 @@ var Action = {
 		}
 	}
 	,_showError:function(msg,title){
-		title = title || "提示";
-		var $ = parent.$ || $;
-		$.messager.show({
-			title: title,
-			msg: msg,
-			style:{
-				right:'',
-				top:document.body.scrollTop+document.documentElement.scrollTop,
-				bottom:''
-			}
-		});
+		FDWindow.alert(msg);
 	}
 }

+ 2 - 0
src/main/webapp/resources/js/util/HtmlUtil.js

@@ -4,6 +4,8 @@ var HtmlUtil = (function(){
 		"<":"&lt;"
 		,">":"&gt;"
 		,"\r\n":"<br>"
+		,"\r":"<br>"
+		,"\n":"<br>"
 		," ":"&nbsp;"
 		,"\t":"&nbsp;&nbsp;&nbsp;&nbsp;"
 	}

+ 0 - 56
src/main/webapp/sys/VelocityContext.js

@@ -1,56 +0,0 @@
-/**
- * VelocityContext.createGrid('id');
- */
-var VelocityContext = (function(){
-	
-	var data = null;
-	
-	function getData(){
-		if(!data){
-			data = [
-			{"name":"${context.packageName}","value":"包名","group":"${context}"}
-			,{"name":"${context.javaBeanName}","value":"Java类名","group":"${context}"}
-			,{"name":"${context.pkName}","value":"表主键名","group":"${context}"}
-			,{"name":"${context.javaPkName}","value":"表主键对应的java字段名","group":"${context}"}
-			,{"name":"${context.javaPkType}","value":"主键的java类型","group":"${context}"}
-			,{"name":"${context.mybatisPkType}","value":"主键对应的mybatis类型","group":"${context}"}
-			
-			,{"name":"${table.tableName}","value":"数据库表名","group":"${table}"}
-			
-			
-			,{"name":"${pkColumn}","value":"主键对象<br>即${columns}中的一个元素","group":"${pkColumn}"}
-			
-			,{"name":"${column.columnName}","value":"表中字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.type}","value":"字段的数据库类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldName}","value":"java字段名","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaFieldNameUF}","value":"java字段名<br>并且第一个字母大写","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaType}","value":"字段的java类型","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.javaTypeBox}","value":"字段的java装箱类型<br>如Integer,Long","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentity}","value":"是否自增,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isPk}","value":"是否主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.isIdentityPk}","value":"是否自增主键,返回boolean","group":"#foreach($column in $columns)...#end"}
-			,{"name":"${column.mybatisJdbcType}","value":"返回mybatis定义的jdbcType,<br>如VARCHAR,INTEGER等","group":"#foreach($column in $columns)...#end"}
-			]
-		}
-		return data;	
-	}
-	
-	return {
-		/**
-		 * 创建Velocity参数列表
-		 */
-		createGrid:function(id){
-			var $pgVelocity = $('<table></table>');
-			$('#'+id).html($pgVelocity);
-			$pgVelocity.propertygrid({    
-			    showGroup: true,    
-			    fitColumns:true,
-			    border:false,
-			    scrollbarSize: 0    
-			}).propertygrid('loadData',getData());
-			
-			return $pgVelocity;
-		}
-	}
-	
-}());

+ 118 - 0
src/main/webapp/sys/VelocityHelper.js

@@ -0,0 +1,118 @@
+/**
+ * VelocityHelper.show()
+ */
+var VelocityHelper = (function(){
+	
+	var treeData = null;
+	
+	var treeDomId = '_treeDomId';
+	var winDomId = '_veloctyHelper';
+	
+	var tree,win;
+	
+	function getData(){		
+		if(!treeData) {
+			treeData = [
+				{text:'${pkColumn} : 主键对象,即${columns}中的一个元素'}
+				,{
+			     	text:'${context}'
+			     	,children:[
+			     		{text:'${context.packageName} : 包名'}
+			     		,{text:'${context.javaBeanName} : Java类名'}
+			     		,{text:'${context.javaBeanNameLF} : Java类名且首字母小写'}
+			     		,{text:'${context.pkName} : 表主键名'}
+			     		,{text:'${context.javaPkName} : 表主键对应的java字段名'}
+			     		,{text:'${context.javaPkType} : 主键的java类型'}
+			     		,{text:'${context.mybatisPkType} : 主键对应的mybatis类型'}
+			     	]
+			     }
+			     ,{text:'${table}'
+			     	,children:[
+			     		{text:'${table.tableName} : 数据库表名'}
+			     	]
+			     }
+			     ,{text:'#foreach($column in $columns)...#end'
+			     	,children:[
+			     		{text:'${$column.columnName} : 表中字段名'}
+			     		,{text:'${$column.type} : 字段的数据库类型'}
+			     		,{text:'${$column.javaFieldName} : java字段名'}
+			     		,{text:'${$column.javaFieldNameUF} : java字段名首字母大写'}
+			     		,{text:'${$column.javaType} : 字段的java类型'}
+			     		,{text:'${$column.javaTypeBox} : 字段的java装箱类型,如Integer,Long'}
+			     		,{text:'${$column.isIdentity} : 是否自增,返回boolean'}
+			     		,{text:'${$column.isPk} : 是否自增主键,返回boolean'}
+			     		,{text:'${$column.isIdentityPk} : 是否自增主键,返回boolean'}
+			     		,{text:'${$column.mybatisJdbcType} : 返回mybatis定义的jdbcType'}
+			     	]
+			     }
+			];
+		}
+		return treeData;
+	}
+	
+	return {
+		/**
+		 * 创建Velocity参数列表
+		 */
+		createGrid:function(id){
+			var $pgVelocity = $('<table></table>');
+			$('#'+id).html($pgVelocity);
+			$pgVelocity.propertygrid({    
+			    showGroup: true,    
+			    fitColumns:true,
+			    border:false,
+			    scrollbarSize: 0    
+			}).propertygrid('loadData',getData());
+			
+			return $pgVelocity;
+		}
+		,create:function() {
+			
+			init();
+			
+			tree = new FDTree({
+				domId:treeDomId
+				,clickToggle:true
+				,data:getData()
+			});
+			tree.expandAll();
+			
+			
+			win = new FDWindow({
+				contentId:winDomId
+				,title:'Velocity参数'
+				,modal:false
+				,width:'400px'
+			});
+			
+		}
+		,show:function() {
+			if(!win) {
+				this.create();
+			}
+			win.show();
+			win.moveTo(getClientWidth()-430,0);
+		}
+	}
+	
+	function init() {
+		var treeDiv = document.createElement(FDTag.DIV);
+		treeDiv.id = treeDomId;
+		
+		var winDiv = document.createElement(FDTag.DIV);
+		winDiv.id = winDomId;
+		winDiv.style.display = 'none';
+		
+		winDiv.appendChild(treeDiv);
+		
+		document.body.appendChild(winDiv);
+	}
+	
+	function getClientHeight() {
+		return document.documentElement.clientHeight || document.body.clientHeight;
+	}
+	function getClientWidth() {
+		return document.documentElement.clientWidth || document.body.clientWidth;
+	}
+	
+}());

+ 61 - 27
src/main/webapp/sys/generator.js

@@ -6,29 +6,43 @@ var viewWin;
 var finishWin;
 var finishTree;
 var schPanelTemplate
+var step1Panel;
+var step2Panel;
 
 var listUrlDS = ctx + 'listDataSource.do'; // 查询
 var listUrlTable = ctx + 'listTable.do'; // 查询
 var listUrlTemplate = ctx + 'listUserTepmlate.do'; // 查询
 
-//请求参数
-var GeneratorParam = {
-	dcId:0
-	,tableNames:[]
-	,tcIds:[]
-	,packageName:''
-}
+step1Panel = new FDFormPanel({
+	domId:'step1Panel'
+	,controls:[
+		new FDHidden({domId:'txt-dcId',name:'dcId',defaultValue:0}) 
+	]
+});
+
+step2Panel = new FDFormPanel({
+	domId:'step2Panel'
+	,controls:[
+		new FDTextBox({domId:'txt-packageName',name:'packageName',nativeAttr:{placeholder:'com.aa.bb'},width:'300px'}) 
+//		,new FDTextBox({domId:'txt-boFolderName',name:'boFolderName',defaultValue:'bo'}) 
+//		,new FDTextBox({domId:'txt-daoFolderName',name:'daoFolderName',defaultValue:'dao'}) 
+//		,new FDTextBox({domId:'txt-pojoFolderName',name:'pojoFolderName',defaultValue:'pojo'}) 
+//		,new FDTextBox({domId:'txt-webFolderName',name:'webFolderName',defaultValue:'web'}) 
+	]
+});
+
 
 gridDS = new FDGrid({
 	domId:'gridDS'
 	,url:listUrlDS
+	,width:'800px'
 	,columns:[
- 		{text:'名称',name:'name',style:{width:'200px'}}
+ 		{text:'操作',name:'name',style:{width:'50px'},render:function(row){
+ 			return '<a href="#" onclick="'+FunUtil.createFun(window,'selectDataSource',row)+'">选择</a>';
+ 		}}
+ 		,{text:'名称',name:'name',style:{width:'200px'}}
  		,{text:'链接',name:'jdbcUrl'}
  	]
-	,actionButtons:[
-   		{text:'选择',onclick:selectDataSource}
-   	]
 });
 
 gridTable = new FDGrid({
@@ -49,11 +63,12 @@ gridTemplate = new FDGrid({
 	domId:'gridTemplate'
 	,selectOption:{multiSelect:true}
 	,url:listUrlTemplate
-	,width:'600px'
 	,loadSearch:false
-	,columns:[
+		,columns:[
 		{text:'模版名',name:'name'}
-		,{text:'内容',name:'content',style:{'textAlign':'center'},render:formatContent}
+		,{text:'文件名',name:'fileName'}
+		,{text:'保存路径',name:'savePath',style:{width:'120px','textAlign':'center'}}
+		,{text:'内容',name:'content',style:{width:'50px','textAlign':'center'},render:formatContent}
 	]
 });
 
@@ -129,7 +144,7 @@ function selectDataSource(row){
 	testConnection(row,function(row){
 		MaskUtil.unmask();
 		
-		GeneratorParam.dcId = row.dcId;
+		step1Panel.getControl('dcId').setValue(row.dcId);
 		
 		showStep2(function(){		
 			gridTable.search({dcId:row.dcId})
@@ -155,7 +170,8 @@ function formatContent(row){
 
 //展示内容
 this.showContent = function(row){
-	$('#viewCode').html(HtmlUtil.parseToHtml(row.content));
+	$('#viewCode').val(row.content);
+	viewWin.setTitle(row.name);
 	viewWin.show();
 }
 
@@ -197,12 +213,6 @@ function goStep3(){
 		return false;
 	}
 	
-	GeneratorParam.packageName = packageName;
-	GeneratorParam.tableNames = [];
-	
-	for(var i=0,len=rows.length;i<len;i++){
-		GeneratorParam.tableNames.push(rows[i].tableName);
-	}
 	showStep3(listTemplate);
 }
 
@@ -230,10 +240,6 @@ function finish(){
 	var rows = gridTemplate.getChecked();
 	
 	if(rows && rows.length > 0){
-		GeneratorParam.tcIds = [];
-		for(var i=0,len=rows.length;i<len;i++){
-			GeneratorParam.tcIds.push(rows[i].tcId);
-		}
 		generate();
 	}else{
 		FDWindow.alert('请选择模板');
@@ -243,7 +249,10 @@ function finish(){
 //生成代码
 function generate(){
 	MaskUtil.mask('代码生成中,请稍后...');
-	Action.jsonAsyncActByData(ctx + 'generatFile.do',GeneratorParam,function(rows){
+	
+	var data = getPostData();
+	
+	Action.jsonAsyncActByData(ctx + 'generatFile.do',data,function(rows){
 		MaskUtil.unmask();
 		if(rows){
 			showGeneratCode(rows);
@@ -253,6 +262,31 @@ function generate(){
 	});
 }
 
+function getPostData() {
+	var data1 = step1Panel.getData();
+	var data2 = step2Panel.getData();
+	var data = $.extend({},data1,data2);
+	var tcIds = [];
+	var tableNames = [];
+	
+	var templateRows = gridTemplate.getChecked();
+	
+	for(var i=0,len=templateRows.length;i<len;i++){
+		tcIds.push(templateRows[i].tcId);
+	}
+	
+	data.tcIds = tcIds;
+	
+	var tableRows = gridTable.getChecked();
+	for(var i=0,len=tableRows.length;i<len;i++){
+		tableNames.push(tableRows[i].tableName);
+	}
+	
+	data.tableNames = tableNames;
+	
+	return data;
+}
+
 //显示结果
 function showGeneratCode(rows){
 	var treeData = buildTreeData(rows);

+ 28 - 13
src/main/webapp/sys/generator.jsp

@@ -9,7 +9,6 @@
 <style type="text/css">
 	.step{margin-bottom: 20px;padding:5px;border-bottom: 1px solid #ccc;}
 	.codeArea{height:400px;overflow:auto;width:100%;font-size:13px;border: dotted #ccc 1px;padding: 3px;font-family: 宋体,Consolas,sans-serif ;}
-	.code-right{margin-left: 20px;}
 </style>
 </head>
 <body>
@@ -17,16 +16,31 @@
 	
 	<div id="step1">
 		<div id="gridDS"></div>
+		<div id="step1Panel">
+			<div id="txt-dcId"></div>
+		</div>
 	</div>
 	
-	<div id="step2" style="display: none;width: 600px;">
-		<fieldset style="border: 1px solid #ccc;font-size: 12px;">
-		    <legend>输入包名</legend>
-		    package: <input id="packageName" type="text" style="width:260px; "/> (不填则表名作为包名)
-		</fieldset>
-		<br>
-		<div id="gridTable"></div>
-		<br>
+	<div id="step2" style="display: none;">
+		<table width="100%">
+			<tr>
+				<td valign="top" width="200"><div id="gridTable"></div></td>
+				<td valign="top">
+					<div id="step2Panel">
+						<fieldset style="border: 1px solid #ccc;font-size: 12px;">
+						    <legend>配置项</legend>
+						    <table>
+						    	<tr><td>package: </td><td id="txt-packageName"></td></tr>
+<!-- 							    <tr><td>bo文件夹名:</td><td id="txt-boFolderName"></td></tr> -->
+<!-- 							    <tr><td>dao文件夹名:</td><td id="txt-daoFolderName"></td></tr> -->
+<!-- 							    <tr><td>pojo文件夹名:</td><td id="txt-pojoFolderName"></td></tr> -->
+<!-- 							    <tr><td>web文件夹名:</td><td id="txt-webFolderName"></td></tr> -->
+						    </table>
+						</fieldset>
+					</div>
+				</td>
+			</tr>
+		</table>
 		<button onclick="showStep1();">上一步</button>
 		<button onclick="goStep3();">下一步</button>
 	</div>
@@ -55,12 +69,13 @@
 	</div>
 	
 
-	<div id="viewWin" style="height: 400px;overflow: auto;">   
-   		<div id="viewCode"></div>
-	</div> 
+	<div id="viewWin" style="height: 430px;overflow: auto;">   
+   		<textarea readonly="readonly" id="viewCode" style="height: 400px;width: 950px;"></textarea>
+	</div>
 	
 	<div id="finishWin" style="padding:5px;display: none;">   
-					<a id="copyCode" href="javascript:void(0)" style="display: none;">复制代码</a>
+		<a id="dlBtn" target="_blank" href="${ctx}downloadZip.do">下载ZIP</a>
+		<a id="copyCode" href="javascript:void(0)" style="display: none;">复制代码</a>
 		<table width="100%">
 			<tr>
 				<td valign="top" width="200"><div id="tree"></div></td>

+ 1 - 1
src/main/webapp/sys/home.jsp

@@ -12,7 +12,7 @@
 如果您首次使用本系统,请按以下步骤操作:
 <ol>
 	<li>1. 配置数据源。模板的生成需要依赖数据库表</li>
-	<li>2. 配置模板。基于Velocity模板引擎,<a href="javascript:void(0)" onclick="showVelocity(); return false;">点此查看</a>Velocity参数列表</li>
+	<li>2. 配置模板。基于Velocity模板引擎,<a href="javascript:void(0)" onclick="VelocityHelper.show(); return false;">点此查看</a>Velocity参数列表</li>
 	<li>3. 生成代码。只需三步即可生成代码文件</li>
 </ol>
 

+ 40 - 11
src/main/webapp/sys/template.jsp

@@ -36,19 +36,26 @@
    			<caption id="formMsg"></caption>
         	<tbody>
                 <tr>
-                    <th width="100"><i class="require-red">*</i>模板名:</th>
-                    <td id="txt-name"></td>
+                    <th width="80"><i class="require-red">*</i>模板名:</th>
+                    <td id="txt-name" width="100"></td>
+                    <td colspan="3"><a href="#" class="link" onclick="VelocityHelper.show(); return false;">查看Velocity参数</a></td>
+                </tr>
+                <tr>
+                	<th><i class="require-red">*</i>文件名:</th>
+                    <td id="txt-fileName" colspan="2"></td>
+                    <th width="80"><i class="require-red">*</i>保存路径:</th>
+                    <td id="txt-savePath"></td>
                 </tr>
                 <tr>
                     <th><i class="require-red">*</i>内容:</th>
-                    <td id="txt-content"></td>
+                    <td id="txt-content" colspan="4"></td>
                 </tr>
          	</tbody>
          </table>
    </div>
    
-	<div id="viewWin" style="height: 400px;overflow: auto;">   
-   		<div id="viewCode"></div>
+	<div id="viewWin" style="height: 430px;overflow: auto;">   
+   		<textarea readonly="readonly" id="viewCode" style="height: 400px;width: 950px;"></textarea>
 	</div> 
 
 <script type="text/javascript">
@@ -65,7 +72,9 @@ var listUrl = ctx + 'listTemplate.do'; // 查询
 var addUrl = ctx + 'addTemplate.do'; // 添加
 var updateUrl = ctx + 'updateTemplate.do'; // 修改
 var delUrl = ctx + 'delTemplate.do'; // 删除
-	
+
+var suffixArr = ['java','js','jsp','html','xml','txt'];
+
 schPanel = new FDFormPanel({
 	controls:[
 		new FDTextBox({domId:'txt-nameSch',name:'nameSch'})
@@ -84,10 +93,11 @@ $('#addNew').click(function(){
 grid = new FDGrid({
 	domId:'grid'
 	,url:listUrl
-	,width:'800px'
 	,columns:[
 		{text:'模版名',name:'name'}
-		,{text:'内容',name:'content',style:{'textAlign':'center'},render:formatContent}
+		,{text:'文件名',name:'fileName'}
+		,{text:'保存路径',name:'savePath',style:{'textAlign':'center'}}
+		,{text:'内容',name:'content',style:{width:'50px','textAlign':'center'},render:formatContent}
 	]
 	,actionButtons:[
 		{text:'修改',onclick:update}
@@ -101,13 +111,14 @@ function formatContent(row){
 
 //展示内容
 this.showContent = function(row){
-	$('#viewCode').html(HtmlUtil.parseToHtml(row.content));
+	$('#viewCode').val(row.content);
+	viewWin.setTitle(row.name);
 	viewWin.show();
 }
 
 crudWin = new FDWindow({
 	contentId:'crudWin'
-	,height:'450px'
+	,height:'460px'
 	,width:'960px'
 	,modal:false
 	,buttons:[
@@ -144,12 +155,22 @@ formPanel = new FDFormPanel({
 	}
 	,controls:[
 	    new FDHidden({name:'tcId',defaultValue:0})
-		,new FDTextBox({domId:'txt-name',name:'name',msgId:'formMsg',width:200
+		,new FDTextBox({domId:'txt-name',name:'name',msgId:'formMsg'
 			,validates:[
 		     {rule:{notNull:true},successClass:'green',errorClass:'require-red',errorMsg:'模版名不能为空'}
 		     ,{rule:{maxLength:20},successClass:'green',errorClass:'require-red',errorMsg:'模版名长度不能大于20'}
 		     ]
 		})
+	    ,new FDTextBox({domId:'txt-fileName',name:'fileName',msgId:'formMsg',width:300
+	    	,validates:[
+	    		{rule:{notNull:true},successClass:'green',errorClass:'require-red',errorMsg:'文件名不能为空'}
+	    	]
+	    })
+	    ,new FDTextBox({domId:'txt-savePath',name:'savePath',msgId:'formMsg',width:300
+	    	,validates:[
+	    		{rule:{notNull:true},successClass:'green',errorClass:'require-red',errorMsg:'保存路径不能为空'}
+	    	]
+	    })
 		,new FDTextArea({domId:'txt-content',name:'content',msgId:'formMsg',width:800,height:360
 			,validates:[
 		     {rule:{notNull:true},successClass:'green',errorClass:'require-red',errorMsg:'模板内容不能为空'}
@@ -158,6 +179,14 @@ formPanel = new FDFormPanel({
 	]
 });
 
+function getSuffixItems() {
+	var items = [];
+	for(var i=0,len=suffixArr.length;i<len;i++){
+		items.push({text:suffixArr[i],value:suffixArr[i]})
+	}
+	return items;
+}
+
 function add() {
 	formPanel.add();
 }

+ 0 - 6
src/main/webapp/sys/updatePswd.jsp

@@ -6,7 +6,6 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>修改密码</title>
-<script type="text/javascript" src="${ctx}resources/js/libs/MD5.js"></script>
 </head>
 <body>
 <div class="result-wrap">
@@ -67,14 +66,9 @@ function compareSamePswd(val) {
 }
 
 $('#updatePswdBtn').click(function(){
-	//alert()
 	if(panel.validate()) {
 		var data = panel.getData();
 		
-		data.oldPswd = faultylabs.MD5(data.oldPswd);
-		data.newPswd = faultylabs.MD5(data.newPswd);
-		data.newPswd2 = faultylabs.MD5(data.newPswd2);
-		
 		Action.post(ctx + 'updateUserPassword.do',data,function(e){
 			if(e.success) {
 				FDWindow.alert('密码修改成功,请重新登录',function(){

+ 1 - 0
src/main/webapp/taglib.jsp

@@ -2,6 +2,7 @@
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <c:set var="ctx" value='<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/" %>'/>
 <c:set var="resources" value="${ctx}resources/"/>
+<c:set var="fdui" value="http://localhost/fdui/build/"/>
 <c:set var="easyui" value="${assets}easyui/"/>
 <c:set var="debugModel" value='<%=PropertiesManager.getInstance().get("debugModel") %>'/>