|
|
|
@ -1,19 +1,26 @@
|
|
|
|
|
package com.dsideal.QingLong.DataShare.Controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.dsideal.QingLong.DataShare.Model.DataShareModel;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.*;
|
|
|
|
|
import com.dsideal.QingLong.Util.CommonUtil;
|
|
|
|
|
import com.dsideal.QingLong.Util.FileSizeUtil;
|
|
|
|
|
import com.dsideal.QingLong.Util.IpUtil;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.core.Controller;
|
|
|
|
|
import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.upload.UploadFile;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DataShareController extends Controller {
|
|
|
|
@ -29,8 +36,8 @@ public class DataShareController extends Controller {
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@IsNumericInterface({"page", "limit"})
|
|
|
|
|
public void listSystem(String keyword,int exclude, int page, int limit) {
|
|
|
|
|
Page<Record> dt = dm.listSystem(keyword,exclude, page, limit);
|
|
|
|
|
public void listSystem(String keyword, int exclude, int page, int limit) {
|
|
|
|
|
Page<Record> dt = dm.listSystem(keyword, exclude, page, limit);
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -56,6 +63,44 @@ public class DataShareController extends Controller {
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:上传系统的EXCEL文档
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
public void saveUploadFile() {
|
|
|
|
|
UploadFile uf = getFile();//得到文件对象
|
|
|
|
|
int system_id = getInt("system_id");
|
|
|
|
|
String fileName = uf.getFileName();
|
|
|
|
|
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).trim();
|
|
|
|
|
if (!suffix.equals("xlsx")) {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "上传文件类型错误!系统只允许上传Excel文档!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//判断文件大小大于20mb则返回错误信息,并终止上传,删除上传文件
|
|
|
|
|
long size = uf.getFile().length();
|
|
|
|
|
if (size > 1024 * 1024 * 20) {
|
|
|
|
|
Kv kv = Kv.by("success", false).set("message", "文件大小大于20MB,请检查是否正确!!");
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String basePath = PathKit.getWebRootPath() + "/upload/";
|
|
|
|
|
if (!FileUtil.exist(basePath)) FileUtil.mkdir(basePath);
|
|
|
|
|
String file_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
|
String filePath = basePath + file_id + "." + suffix;
|
|
|
|
|
uf.getFile().renameTo(new File(filePath));
|
|
|
|
|
String url = PropKit.get("filePrefix") + "/upload/" + file_id + "." + suffix;
|
|
|
|
|
//记录到数据库
|
|
|
|
|
dm.saveUploadFile(system_id, url);
|
|
|
|
|
//返回结果
|
|
|
|
|
Kv kv = Kv.by("success", true);
|
|
|
|
|
kv.set("message", "上传成功!");
|
|
|
|
|
kv.set("url", url);
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:根据系统ID获取系统信息
|
|
|
|
|
*
|
|
|
|
|