Merge remote-tracking branch 'origin/master'

master
wangbing 5 years ago
commit 40eefdada9

@ -2,17 +2,14 @@ package xyz.wbsite.dbtool.javafx.manger.callable;
import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import xyz.wbsite.dbtool.javafx.po.AbstractDBmapper;
import xyz.wbsite.dbtool.javafx.po.AndroidOption;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.tool.ZipUtil;
import xyz.wbsite.dbtool.web.framework.utils.ZipUtil;
import javax.validation.constraints.NotNull;
import java.io.File;
import java.util.HashMap;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
public class AndroidCallable implements Callable {

@ -4,7 +4,7 @@ import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.po.SBMDBOption;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.tool.ZipUtil;
import xyz.wbsite.dbtool.web.framework.utils.ZipUtil;
import javax.validation.constraints.NotNull;
import java.io.File;

@ -4,7 +4,7 @@ import xyz.wbsite.dbtool.javafx.manger.FreeMarkerManager;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.po.VueOption;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.tool.ZipUtil;
import xyz.wbsite.dbtool.web.framework.utils.ZipUtil;
import javax.validation.constraints.NotNull;
import java.io.File;

@ -0,0 +1,897 @@
package xyz.wbsite.dbtool.web.framework.utils;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class FileUtil {
/**
*
*/
private FileUtil() {
}
/**
* 访
*
* <b></b>
*
* @param file 访
* @since 1.0
*/
public static void touch(File file) {
long currentTime = System.currentTimeMillis();
if (!file.exists()) {
System.err.println("file not found:" + file.getName());
System.err.println("Create a new file:" + file.getName());
try {
if (file.createNewFile()) {
System.out.println("Succeeded!");
} else {
System.err.println("Create file failed!");
}
} catch (IOException e) {
System.err.println("Create file failed!");
e.printStackTrace();
}
}
boolean result = file.setLastModified(currentTime);
if (!result) {
System.err.println("touch failed: " + file.getName());
}
}
/**
* 访
*
* <b></b>
*
* @param fileName 访
* @since 1.0
*/
public static void touch(String fileName) {
File file = new File(fileName);
touch(file);
}
/**
* 访
*
* <b></b>
*
* @param files 访
* @since 1.0
*/
public static void touch(File[] files) {
for (int i = 0; i < files.length; i++) {
touch(files[i]);
}
}
/**
* 访
*
* <b></b>
*
* @param fileNames 访
* @since 1.0
*/
public static void touch(String[] fileNames) {
File[] files = new File[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
files[i] = new File(fileNames[i]);
}
touch(files);
}
/**
*
*
* @param fileName
* @return truefalse
* @since 1.0
*/
public static boolean isFileExist(String fileName) {
return new File(fileName).isFile();
}
/**
*
*
* <b>false</b>
*
* @param file
* @return truefalse
* @since 1.0
*/
public static boolean makeDirectory(File file) {
File parent = file.getParentFile();
if (parent != null) {
return parent.mkdirs();
}
return false;
}
/**
*
*
* <b>false</b>
*
* @param fileName
* @return truefalse
* @since 1.0
*/
public static boolean makeDirectory(String fileName) {
File file = new File(fileName);
return makeDirectory(file);
}
/**
*
* false
*
*
* @param directory
* @return truefalse.
* @since 1.0
*/
public static boolean emptyDirectory(File directory) {
boolean result = true;
File[] entries = directory.listFiles();
for (int i = 0; i < entries.length; i++) {
if (!entries[i].delete()) {
result = false;
}
}
return result;
}
/**
*
* false
*
*
* @param directoryName
* @return truefalse
* @since 1.0
*/
public static boolean emptyDirectory(String directoryName) {
File dir = new File(directoryName);
return emptyDirectory(dir);
}
/**
*
*
* @param dirName
* @return truefalse
* @since 1.0
*/
public static boolean deleteDirectory(String dirName) {
return deleteDirectory(new File(dirName));
}
/**
*
*
* @param dir
* @return truefalse
* @since 1.0
*/
public static boolean deleteDirectory(File dir) {
if ((dir == null) || !dir.isDirectory()) {
throw new IllegalArgumentException("Argument " + dir +
" is not a directory. ");
}
File[] entries = dir.listFiles();
int sz = entries.length;
for (int i = 0; i < sz; i++) {
if (entries[i].isDirectory()) {
if (!deleteDirectory(entries[i])) {
return false;
}
} else {
if (!entries[i].delete()) {
return false;
}
}
}
if (!dir.delete()) {
return false;
}
return true;
}
/**
*
*
* @param file
* @param filter
* @return
* @since 1.0
*/
public static File[] listAll(File file,
javax.swing.filechooser.FileFilter filter) {
ArrayList list = new ArrayList();
File[] files;
if (!file.exists() || file.isFile()) {
return null;
}
list(list, file, filter);
files = new File[list.size()];
list.toArray(files);
return files;
}
/**
*
*
* @param list
* @param filter
* @param file
*/
private static void list(ArrayList list, File file,
javax.swing.filechooser.FileFilter filter) {
if (filter.accept(file)) {
list.add(file);
if (file.isFile()) {
return;
}
}
if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
list(list, files[i], filter);
}
}
}
/**
* URL
*
* @param file
* @return URL
* @throws MalformedURLException
* @since 1.0
* @deprecated FiletoURLURL
* 使File.toURL
*/
public static URL getURL(File file) throws MalformedURLException {
String fileURL = "file:/" + file.getAbsolutePath();
URL url = new URL(fileURL);
return url;
}
/**
*
*
* @param filePath
* @return
* @since 1.0
*/
public static String getFileName(String filePath) {
File file = new File(filePath);
return file.getName();
}
/**
*
*
* @param fileName
* @return
* @since 1.0
*/
public static String getFilePath(String fileName) {
File file = new File(fileName);
return file.getAbsolutePath();
}
/**
* DOS/WindowsUNIX/Linux
* "\"全部换为"/"便
* "/""\"DOS/Windows
*
* @param filePath
* @return
* @since 1.0
*/
public static String toUNIXpath(String filePath) {
return filePath.replace('\\', '/');
}
/**
* UNIX
*
* @param fileName
* @return UNIX
* @see #toUNIXpath(String filePath) toUNIXpath
* @since 1.0
*/
public static String getUNIXfilePath(String fileName) {
File file = new File(fileName);
return toUNIXpath(file.getAbsolutePath());
}
/**
*
* .
*
* @param fileName
* @return
* @since 1.0
*/
public static String getTypePart(String fileName) {
int point = fileName.lastIndexOf('.');
int length = fileName.length();
if (point == -1 || point == length - 1) {
return "";
} else {
return fileName.substring(point + 1, length);
}
}
/**
*
* .
*
* @param file
* @return
* @since 1.0
*/
public static String getFileType(File file) {
return getTypePart(file.getName());
}
/**
*
*
*
* @param fileName
* @return
* @since 1.0
*/
public static String getNamePart(String fileName) {
int point = getPathLsatIndex(fileName);
int length = fileName.length();
if (point == -1) {
return fileName;
} else if (point == length - 1) {
int secondPoint = getPathLsatIndex(fileName, point - 1);
if (secondPoint == -1) {
if (length == 1) {
return fileName;
} else {
return fileName.substring(0, point);
}
} else {
return fileName.substring(secondPoint + 1, point);
}
} else {
return fileName.substring(point + 1);
}
}
/**
*
*
* ""
* "/path/"""
*
* @param fileName
* @return ""
* @since 1.0
*/
public static String getPathPart(String fileName) {
int point = getPathLsatIndex(fileName);
int length = fileName.length();
if (point == -1) {
return "";
} else if (point == length - 1) {
int secondPoint = getPathLsatIndex(fileName, point - 1);
if (secondPoint == -1) {
return "";
} else {
return fileName.substring(0, secondPoint);
}
} else {
return fileName.substring(0, point);
}
}
/**
*
* DOSUNIX
*
* @param fileName
* @return -1
* @since 1.0
*/
public static int getPathIndex(String fileName) {
int point = fileName.indexOf('/');
if (point == -1) {
point = fileName.indexOf('\\');
}
return point;
}
/**
*
* DOSUNIX
*
* @param fileName
* @param fromIndex
* @return -1
* @since 1.0
*/
public static int getPathIndex(String fileName, int fromIndex) {
int point = fileName.indexOf('/', fromIndex);
if (point == -1) {
point = fileName.indexOf('\\', fromIndex);
}
return point;
}
/**
*
* DOSUNIX
*
* @param fileName
* @return -1
* @since 1.0
*/
public static int getPathLsatIndex(String fileName) {
int point = fileName.lastIndexOf('/');
if (point == -1) {
point = fileName.lastIndexOf('\\');
}
return point;
}
/**
*
* DOSUNIX
*
* @param fileName
* @param fromIndex
* @return -1
* @since 1.0
*/
public static int getPathLsatIndex(String fileName, int fromIndex) {
int point = fileName.lastIndexOf('/', fromIndex);
if (point == -1) {
point = fileName.lastIndexOf('\\', fromIndex);
}
return point;
}
/**
*
*
* @param filename
* @return
* @since 1.0
*/
public static String trimType(String filename) {
int index = filename.lastIndexOf(".");
if (index != -1) {
return filename.substring(0, index);
} else {
return filename;
}
}
/**
*
*
*
* @param pathName
* @param fileName
* @return
* @since 1.0
*/
public static String getSubpath(String pathName, String fileName) {
int index = fileName.indexOf(pathName);
if (index != -1) {
return fileName.substring(index + pathName.length() + 1);
} else {
return fileName;
}
}
/**
*
*
*
* @param path
* @return
* @since 1.0
*/
public static final boolean pathValidate(String path) {
//String path="d:/web/www/sub";
//System.out.println(path);
//path = getUNIXfilePath(path);
//path = ereg_replace("^\\/+", "", path);
//path = ereg_replace("\\/+$", "", path);
String[] arraypath = path.split("/");
String tmppath = "";
for (int i = 0; i < arraypath.length; i++) {
tmppath += "/" + arraypath[i];
File d = new File(tmppath.substring(1));
if (!d.exists()) { //检查Sub目录是否存在
System.out.println(tmppath.substring(1));
if (!d.mkdir()) {
return false;
}
}
}
return true;
}
/**
*
*
*
* @param path
* @return
* @since 1.0
*/
public static final String getFileContent(String path) throws IOException {
String filecontent = "";
try {
File f = new File(path);
if (f.exists()) {
FileReader fr = new FileReader(path);
BufferedReader br = new BufferedReader(fr); //建立BufferedReader对象并实例化为br
String line = br.readLine(); //从文件读取一行字符串
//判断读取到的字符串是否不为空
while (line != null) {
filecontent += line + "\n";
line = br.readLine(); //从文件中继续读取一行数据
}
br.close(); //关闭BufferedReader对象
fr.close(); //关闭文件
}
} catch (IOException e) {
throw e;
}
return filecontent;
}
/**
*
*
* @param path
* @param modulecontent
* @return
* @since 1.0
*/
public static final boolean genModuleTpl(String path, String modulecontent) throws IOException {
path = getUNIXfilePath(path);
String[] patharray = path.split("\\/");
String modulepath = "";
for (int i = 0; i < patharray.length - 1; i++) {
modulepath += "/" + patharray[i];
}
File d = new File(modulepath.substring(1));
if (!d.exists()) {
if (!pathValidate(modulepath.substring(1))) {
return false;
}
}
try {
FileWriter fw = new FileWriter(path); //建立FileWriter对象并实例化fw
//将字符串写入文件
fw.write(modulecontent);
fw.close();
} catch (IOException e) {
throw e;
}
return true;
}
/**
*
*
* @param pic_path
* @return
* @since 1.0
*/
public static final String getPicExtendName(String pic_path) {
pic_path = getUNIXfilePath(pic_path);
String pic_extend = "";
if (isFileExist(pic_path + ".gif")) {
pic_extend = ".gif";
}
if (isFileExist(pic_path + ".jpeg")) {
pic_extend = ".jpeg";
}
if (isFileExist(pic_path + ".jpg")) {
pic_extend = ".jpg";
}
if (isFileExist(pic_path + ".png")) {
pic_extend = ".png";
}
return pic_extend; //返回图片扩展名
}
/**
*
*
* @param in
* @param out
* @return
* @throws Exception
*/
public static final boolean CopyFile(File in, File out) throws Exception {
try {
FileInputStream fis = new FileInputStream(in);
FileOutputStream fos = new FileOutputStream(out);
byte[] buf = new byte[1024];
int i = 0;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
return true;
} catch (IOException ie) {
ie.printStackTrace();
return false;
}
}
/**
*
*
* @param infile
* @param outfile
* @return
* @throws Exception
*/
public static final boolean CopyFile(String infile, String outfile) throws Exception {
try {
File in = new File(infile);
File out = new File(outfile);
return CopyFile(in, out);
} catch (IOException ie) {
ie.printStackTrace();
return false;
}
}
/**
* contentpath
*
* @param content
* @param path
* @return
*/
public static boolean SaveFileAs(String content, String path) {
FileWriter fw = null;
try {
fw = new FileWriter(new File(path), false);
if (content != null) {
fw.write(content);
}
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
if (fw != null) {
try {
fw.flush();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return true;
}
/**
*
*/
public static byte[] readFileByBytes(String fileName) throws IOException {
FileInputStream in = new FileInputStream(fileName);
byte[] bytes = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1) {
out.write(temp, 0, size);
}
in.close();
bytes = out.toByteArray();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (in != null) {
in.close();
}
}
return bytes;
}
/**
*
*/
public static void readFileByChars(String fileName) {
File file = new File(fileName);
Reader reader = null;
try {
System.out.println("以字符为单位读取文件内容,一次读一个字节:");
// 一次读一个字符
reader = new InputStreamReader(new FileInputStream(file));
int tempchar;
while ((tempchar = reader.read()) != -1) {
// 对于windows下\r\n这两个字符在一起时表示一个换行。
// 但如果这两个字符分开显示时,会换两次行。
// 因此,屏蔽掉\r或者屏蔽\n。否则将会多出很多空行。
if (((char) tempchar) != '\r') {
System.out.print((char) tempchar);
}
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
System.out.println("以字符为单位读取文件内容,一次读多个字节:");
// 一次读多个字符
char[] tempchars = new char[30];
int charread = 0;
reader = new InputStreamReader(new FileInputStream(fileName));
// 读入多个字符到字符数组中charread为一次读取字符数
while ((charread = reader.read(tempchars)) != -1) {
// 同样屏蔽掉\r不显示
if ((charread == tempchars.length)
&& (tempchars[tempchars.length - 1] != '\r')) {
System.out.print(tempchars);
} else {
for (int i = 0; i < charread; i++) {
if (tempchars[i] == '\r') {
continue;
} else {
System.out.print(tempchars[i]);
}
}
}
}
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/**
*
*/
public static List<String> readFileByLines(String fileName) {
List<String> returnString = new ArrayList<String>();
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读入一行直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
returnString.add(tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return returnString;
}
/**
*
*/
public static void readFileByRandomAccess(String fileName) {
RandomAccessFile randomFile = null;
try {
System.out.println("随机读取一段文件内容:");
// 打开一个随机访问文件流,按只读方式
randomFile = new RandomAccessFile(fileName, "r");
// 文件长度,字节数
long fileLength = randomFile.length();
// 读文件的起始位置
int beginIndex = (fileLength > 4) ? 4 : 0;
// 将读文件的开始位置移到beginIndex位置。
randomFile.seek(beginIndex);
byte[] bytes = new byte[10];
int byteread = 0;
// 一次读10个字节如果文件内容不足10个字节则读剩下的字节。
// 将一次读取的字节数赋给byteread
while ((byteread = randomFile.read(bytes)) != -1) {
System.out.write(bytes, 0, byteread);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (randomFile != null) {
try {
randomFile.close();
} catch (IOException e1) {
}
}
}
}
/**
*
*
* @param fileName
* @return
*/
public static String readFileAll(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
return new String(filecontent, encoding);
} catch (UnsupportedEncodingException e) {
System.err.println("The OS does not support " + encoding);
e.printStackTrace();
return "";
}
}
/**
*
*/
private static void showAvailableBytes(InputStream in) {
try {
System.out.println("当前字节输入流中的字节数为:" + in.available());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.dbtool.javafx.tool;
package xyz.wbsite.dbtool.web.framework.utils;
import java.io.*;
import java.util.Enumeration;

@ -61,7 +61,7 @@ spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.settings.template_update_delay=1
spring.freemarker.settings.locale=zh_CN
spring.freemarker.settings.datetime_format=yyyy-MM-dd
spring.freemarker.settings.datetime_format=yyyy-MM-dd HH:mm:ss
spring.freemarker.settings.date_format=yyyy-MM-dd
spring.freemarker.settings.number_format=#.##
spring.freemarker.settings.classic_compatible=true

@ -61,7 +61,7 @@ spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.settings.template_update_delay=1
spring.freemarker.settings.locale=zh_CN
spring.freemarker.settings.datetime_format=yyyy-MM-dd
spring.freemarker.settings.datetime_format=yyyy-MM-dd HH:mm:ss
spring.freemarker.settings.date_format=yyyy-MM-dd
spring.freemarker.settings.number_format=#.##
spring.freemarker.settings.classic_compatible=true

@ -4,8 +4,8 @@
<div class="login-title">系统登录</div>
<el-form :model="form" :rules="rules" ref="form" class="form">
<el-form-item prop="name">
<el-input placeholder="用户名" v-model="form.name">
<el-form-item prop="username">
<el-input placeholder="用户名" v-model="form.username">
<template slot="prepend"><i class="icon iconfont el-icon-user"></i></template>
</el-input>
</el-form-item>
@ -95,11 +95,11 @@
el: "#app",
data: {
form: {
name: '',
username: '',
password: ''
},
rules: {
name: [
username: [
{required: true, message: '请输入用户名', trigger: 'blur'}
],
password: [
@ -117,6 +117,7 @@
if (valid) {
this.isLogin = true;
setTimeout(function(){
this.isLogin = false;
nav.i("登录成功!", function () {
location.href = "/index.htm"
});

Loading…
Cancel
Save

Powered by TurnKey Linux.