基于javaweb和mysql的springboot在线嘿嘿网盘系统设计和实现(java+springboot+ssm+mysql+maven+thymeleaf+html)
·
基于javaweb和mysql的springboot在线嘿嘿网盘系统设计和实现(java+springboot+ssm+mysql+maven+thymeleaf+html)
私信源码获取及调试交流
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot在线嘿嘿网盘系统设计和实现(java+springboot+ssm+mysql+maven+thymeleaf+html)
一、项目简述
功能:用户的邮箱注册、验证码验证以及用户登录。 不需要注册账号,也可以上传满足条件的临时文件,但是 只4小时内有效。 文件的管理,上传、下载、重命名、删除、查看统计数 据、分类管理等。 文件夹的管理,创建、删除、重命名。 文件的分享,支持通过链博口二维码的分享方式等等。
二、项目运行
环境配置: Jdk1.8 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等
}else {
user.setUserName(removeNonBmpUnicode(userInfoBean.getNickname()));
user.setImagePath(userInfoBean.getAvatar().getAvatarURL100());
userService.update(user);
}
logger.info("QQ用户登录成功!"+user);
session.setAttribute("loginUser", user);
return "redirect:/index";
} else {
logger.error("很抱歉,我们没能正确获取到您的信息,原因是: " + userInfoBean.getMsg());
}
}
} catch (QQConnectException e) {
} finally {
logger.error("登录成功!");
}
return "登录失败!请查看日志信息...";
}
/**
* @Description 处理掉QQ网名中的特殊表情
* 返回处理之后的网名
**/
public String removeNonBmpUnicode(String str) {
if (str == null) {
return null;
}
str = str.replaceAll("[^\\u0000-\\uFFFF]", "");
if ("".equals(str)) {
str = "($ _ $)";
}
return str;
}
/**
* @Description 退出登录,清空session
**/
@GetMapping("/logout")
public String logout() {
logger.info("用户退出登录!");
session.invalidate();
return "redirect:/";
}
}
User user = userService.getUserByOpenId("123456");
logger.info("使用免登陆方式登录成功!"+user);
session.setAttribute("loginUser", user);
return "redirect:/index";
}
/**
* 用于注册流程,用户名,密码,邮箱等校验工作由前端来完成
*
* @param map 用于存储提示信息
*/
@PostMapping("/register")
public String register(User user, String code, Map<String, Object> map) {
String uCode = (String) session.getAttribute(user.getEmail() + "_code");
if (!code.equals(uCode)) {
map.put("errorMsg", "验证码错误");
return "index";
}
// 用户名去空格
user.setUserName(user.getUserName().trim());
user.setImagePath("https://p.qpic.cn/qqconnect/0/app_101851241_1582451550/100?max-age=2592000&t=0");
user.setRegisterTime(new Date());
user.setRole(1);
if (userService.insert(user)) {
FileStore store = FileStore.builder().userId(user.getUserId()).currentSize(0).build();
fileStoreService.addFileStore(store);
user.setFileStoreId(store.getFileStoreId());
userService.update(user);
logger.info("注册用户成功!当前注册用户" + user);
logger.info("注册仓库成功!当前注册仓库" + store);
} else {
map.put("errorMsg", "服务器发生错误,注册失败");
return "index";
}
session.removeAttribute(user.getEmail() + "_code");
session.setAttribute("loginUser", user);
return "redirect:/index";
}
/**
* 用户登录
* @param map 存储提示信息
location.add(nowFolder);
} else {
//当前为具体目录
folders = fileFolderService.getFileFolderByParentFolderId(fId);
nowFolder = fileFolderService.getFileFolderByFileFolderId(fId);
//遍历查询当前目录
FileFolder temp = nowFolder;
while (temp.getParentFolderId() != 0) {
temp = fileFolderService.getFileFolderByFileFolderId(temp.getParentFolderId());
location.add(temp);
}
}
Collections.reverse(location);
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
map.put("folders", folders);
map.put("nowFolder", nowFolder);
map.put("location", location);
logger.info("网盘页面域中的数据:" + map);
return "u-admin/upload";
}
/**
* @Description 前往所有文档页面
**/
@GetMapping("/doc-files")
public String toDocFilePage( Map<String, Object> map) {
List<MyFile> files = myFileService.getFilesByType(loginUser.getFileStoreId(),1);
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
map.put("files", files);
map.put("permission", fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission());
return "u-admin/doc-files";
}
/**
* @Description 前往所有图像页面
**/
@GetMapping("/image-files")
public String toImageFilePage( Map<String, Object> map) {
List<MyFile> files = myFileService.getFilesByType(loginUser.getFileStoreId(),2);
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
map.put("files", files);
map.put("permission", fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission());
return "u-admin/image-files";
}
def generate_cheatsheet(data):
print "Generate Cheatsheet"
cheatsheet_file_path = os.path.join(ROOT_PATH, 'cheatsheet.html')
template_path = os.path.join(BUILDER_PATH, 'cheatsheet', 'template.html')
icon_row_path = os.path.join(BUILDER_PATH, 'cheatsheet', 'icon-row.html')
f = open(template_path, 'r')
template_html = f.read()
f.close()
f = open(icon_row_path, 'r')
icon_row_template = f.read()
f.close()
content = []
for ionicon in data['icons']:
css_code = ionicon['code'].replace('0x', '\\')
escaped_html_code = ionicon['code'].replace('0x', '&#x') + ';'
html_code = ionicon['code'].replace('0x', '&#x') + ';'
item_row = icon_row_template
item_row = item_row.replace('{{name}}', ionicon['name'])
item_row = item_row.replace('{{prefix}}', data['prefix'])
item_row = item_row.replace('{{css_code}}', css_code)
item_row = item_row.replace('{{escaped_html_code}}', escaped_html_code)
item_row = item_row.replace('{{html_code}}', html_code)
content.append(item_row)
template_html = template_html.replace("{{font_name}}", data["name"])
template_html = template_html.replace("{{font_version}}", data["version"])
template_html = template_html.replace("{{icon_count}}", str(len(data["icons"])) )
template_html = template_html.replace("{{content}}", '\n'.join(content) )
f = open(cheatsheet_file_path, 'w')
f.write(template_html)
f.close()
def generate_component_json(data):
print "Generate component.json"
d = {
"name": data['name'],
"repo": "driftyco/ionicons",
version = EOT.EOT_VERSION
flags = 0
charset = EOT.EOT_DEFAULT_CHARSET
magicNumber = EOT.EOT_MAGIC_NUMBER
# read values from OS/2 table
os2Dir = tableDir[OpenType.TABLE_OS2]
os2offset = os2Dir['offset']
os2size = struct.calcsize(OpenType.OS2_UNPACK)
if os2size > os2Dir['length']:
raise FontError, 'OS/2 table invalid length'
os2fields = struct.unpack(OpenType.OS2_UNPACK, fontdata[os2offset : os2offset + os2size])
panose = []
urange = []
codepage = []
weight, fsType = os2fields[:2]
panose[:10] = os2fields[2:12]
urange[:4] = os2fields[12:16]
fsSelection = os2fields[16]
codepage[:2] = os2fields[17:19]
italic = fsSelection & OpenType.OS2_FSSELECTION_ITALIC
# read in values from head table
headDir = tableDir[OpenType.TABLE_HEAD]
headoffset = headDir['offset']
headsize = struct.calcsize(OpenType.HEAD_UNPACK)
if headsize > headDir['length']:
raise FontError, 'head table invalid length'
headfields = struct.unpack(OpenType.HEAD_UNPACK, fontdata[headoffset : headoffset + headsize])
checkSumAdjustment = headfields[0]
# make name headers
nameheaders = make_eot_name_headers(fontdata, tableDir[OpenType.TABLE_NAME])
rootstring = make_root_string()
# calculate the total eot size
eotSize = struct.calcsize(EOT.EOT_HEADER_PACK) + len(nameheaders) + len(rootstring) + fontDataSize
fixed = struct.pack(EOT.EOT_HEADER_PACK,
*([eotSize, fontDataSize, version, flags] + panose + [charset, italic] +
[weight, fsType, magicNumber] + urange + codepage + [checkSumAdjustment]))
return ''.join((fixed, nameheaders, rootstring))
def write_eot_font(eot, header, data):
# SHORT yStrikeoutSize
# SHORT yStrikeoutPosition
# SHORT sFamilyClass
# BYTE panose[10]
# ULONG ulUnicodeRange1 // Bits 0-31
# ULONG ulUnicodeRange2 // Bits 32-63
# ULONG ulUnicodeRange3 // Bits 64-95
# ULONG ulUnicodeRange4 // Bits 96-127
# CHAR achVendID[4]
# USHORT fsSelection
# USHORT usFirstCharIndex
# USHORT usLastCharIndex
# SHORT sTypoAscender
# SHORT sTypoDescender
# SHORT sTypoLineGap
# USHORT usWinAscent
# USHORT usWinDescent
# ULONG ulCodePageRange1 // Bits 0-31
# ULONG ulCodePageRange2 // Bits 32-63
# SHORT sxHeight
# SHORT sCapHeight
# USHORT usDefaultChar
# USHORT usBreakChar
# USHORT usMaxContext
#
#
# The Naming Table is organized as follows:
#
# [name table header]
# [name records]
# [string data]
#
# Name Table Header
#
# USHORT format // Format selector (=0).
# USHORT count // Number of name records.
# USHORT stringOffset // Offset to start of string storage (from start of table).
#
# Name Record
#
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
statistics.setFileStore(fileStoreService.getFileStoreById(loginUser.getFileStoreId()));
map.put("statistics", statistics);
return "u-admin/index";
}
/**
* @Description 前往帮助页面
**/
@GetMapping("/help")
public String helpPage(Map<String, Object> map) {
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
return "u-admin/help";
}
}
/**
* @ClassName: AdminController
* @Description: 管理员控制器
**/
@Controller
public class AdminController extends BaseController {
private Logger logger = LogUtils.getInstance(AdminController.class);
/**
* @Description 前往用户管理页面
* @Param [map]
* @return java.lang.String
**/
@GetMapping("/manages-users")
# OpenType file structure
# http://www.microsoft.com/typography/otspec/otff.htm
#
# Types:
#
# BYTE 8-bit unsigned integer.
# CHAR 8-bit signed integer.
# USHORT 16-bit unsigned integer.
# SHORT 16-bit signed integer.
# ULONG 32-bit unsigned integer.
# Fixed 32-bit signed fixed-point number (16.16)
# LONGDATETIME Date represented in number of seconds since 12:00 midnight, January 1, 1904. The value is represented as a signed 64-bit integer.
#
# SFNT Header
#
# Fixed sfnt version // 0x00010000 for version 1.0.
# USHORT numTables // Number of tables.
# USHORT searchRange // (Maximum power of 2 <= numTables) x 16.
# USHORT entrySelector // Log2(maximum power of 2 <= numTables).
# USHORT rangeShift // NumTables x 16-searchRange.
#
# Table Directory
#
# ULONG tag // 4-byte identifier.
# ULONG checkSum // CheckSum for this table.
# ULONG offset // Offset from beginning of TrueType font file.
# ULONG length // Length of this table.
#
# OS/2 Table (Version 4)
#
# USHORT version // 0x0004
# SHORT xAvgCharWidth
# USHORT usWeightClass
# USHORT usWidthClass
# USHORT fsType
# SHORT ySubscriptXSize
# SHORT ySubscriptYSize
# SHORT ySubscriptXOffset
# SHORT ySubscriptYOffset
# SHORT ySuperscriptXSize
# SHORT ySuperscriptYSize
# SHORT ySuperscriptXOffset
# SHORT ySuperscriptYOffset
# SHORT yStrikeoutSize
# SHORT yStrikeoutPosition
# SHORT sFamilyClass
List<MyFile> files = myFileService.getRootFilesByFileStoreId(fileStore.getFileStoreId());
//删除该用户仓库根目录下的所有文件
for (MyFile f:files) {
String remotePath = f.getMyFilePath();
String fileName = f.getMyFileName()+f.getPostfix();
//从FTP文件服务器上删除文件
boolean b = FtpUtil.deleteFile("/"+remotePath, fileName);
if (b){
//删除成功,返回空间
fileStoreService.subSize(f.getFileStoreId(),Integer.valueOf(f.getSize()));
//删除文件表对应的数据
myFileService.deleteByFileId(f.getMyFileId());
}
logger.info("删除文件成功!"+f);
}
if (FtpUtil.deleteFolder("/" + uId)){
logger.info("清空FTP上该用户的文件成功");
}else {
logger.error("清空FTP上该用户的文件失败");
}
userService.deleteById(uId);
fileStoreService.deleteById(fileStore.getFileStoreId());
return "redirect:/manages-users?cur="+cur;
}
/**
* @Description 迭代删除文件夹里面的所有文件和子文件夹
**/
public void deleteFolderF(FileFolder folder){
//获得当前文件夹下的所有子文件夹
List<FileFolder> folders = fileFolderService.getFileFolderByParentFolderId(folder.getFileFolderId());
//删除当前文件夹的所有的文件
List<MyFile> files = myFileService.getFilesByParentFolderId(folder.getFileFolderId());
if (files.size()!=0){
for (int i = 0; i < files.size(); i++) {
Integer fileId = files.get(i).getMyFileId();
boolean b = FtpUtil.deleteFile("/"+files.get(i).getMyFilePath(), files.get(i).getMyFileName() + files.get(i).getPostfix());
if (b){
myFileService.deleteByFileId(fileId);
fileStoreService.subSize(folder.getFileStoreId(),Integer.valueOf(files.get(i).getSize()));
}
}
}
if (folders.size()!=0){
for (int i = 0; i < folders.size(); i++) {
deleteFolderF(folders.get(i));
}
}
fileFolderService.deleteFileFolderById(folder.getFileFolderId());
return "u-admin/files";
}
/**
* @Description 前往文件上传页面
**/
@GetMapping("/upload")
public String toUploadPage(Integer fId, String fName, Map<String, Object> map) {
//包含的子文件夹
List<FileFolder> folders = null;
//当前文件夹信息
FileFolder nowFolder = null;
//当前文件夹的相对路径
List<FileFolder> location = new ArrayList<>();
if (fId == null || fId <= 0) {
//代表当前为根目录
fId = 0;
folders = fileFolderService.getRootFoldersByFileStoreId(loginUser.getFileStoreId());
nowFolder = FileFolder.builder().fileFolderId(fId).build();
location.add(nowFolder);
} else {
//当前为具体目录
folders = fileFolderService.getFileFolderByParentFolderId(fId);
nowFolder = fileFolderService.getFileFolderByFileFolderId(fId);
//遍历查询当前目录
FileFolder temp = nowFolder;
while (temp.getParentFolderId() != 0) {
temp = fileFolderService.getFileFolderByFileFolderId(temp.getParentFolderId());
location.add(temp);
}
}
Collections.reverse(location);
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
map.put("folders", folders);
map.put("nowFolder", nowFolder);
map.put("location", location);
logger.info("网盘页面域中的数据:" + map);
return "u-admin/upload";
}
folder.setFileStoreId(loginUser.getFileStoreId());
folder.setTime(new Date());
//获得当前目录下的所有文件夹,检查当前文件夹是否已经存在
List<FileFolder> fileFolders = null;
if (folder.getParentFolderId() == 0){
//向用户根目录添加文件夹
fileFolders = fileFolderService.getRootFoldersByFileStoreId(loginUser.getFileStoreId());
}else{
//向用户的其他目录添加文件夹
fileFolders = fileFolderService.getFileFolderByParentFolderId(folder.getParentFolderId());
}
for (int i = 0; i < fileFolders.size(); i++) {
FileFolder fileFolder = fileFolders.get(i);
if (fileFolder.getFileFolderName().equals(folder.getFileFolderName())){
logger.info("添加文件夹失败!文件夹已存在...");
return "redirect:/files?error=1&fId="+folder.getParentFolderId();
}
}
//向数据库写入数据
Integer integer = fileFolderService.addFileFolder(folder);
logger.info("添加文件夹成功!"+folder);
return "redirect:/files?fId="+folder.getParentFolderId();
}
/**
* @Description 重命名文件夹
**/
@PostMapping("/updateFolder")
public String updateFolder(FileFolder folder,Map<String, Object> map) {
//获得文件夹的数据库信息
FileFolder fileFolder = fileFolderService.getFileFolderByFileFolderId(folder.getFileFolderId());
fileFolder.setFileFolderName(folder.getFileFolderName());
//获得当前目录下的所有文件夹,用于检查文件夹是否已经存在
List<FileFolder> fileFolders = fileFolderService.getFileFolderByParentFolderId(fileFolder.getParentFolderId());
for (int i = 0; i < fileFolders.size(); i++) {
FileFolder folder1 = fileFolders.get(i);
if (folder1.getFileFolderName().equals(folder.getFileFolderName()) && folder1.getFileFolderId() != folder.getFileFolderId()){
logger.info("重命名文件夹失败!文件夹已存在...");
return "redirect:/files?error=2&fId="+fileFolder.getParentFolderId();
}
}
//向数据库写入数据
Integer integer = fileFolderService.updateFileFolderById(fileFolder);
logger.info("重命名文件夹成功!"+folder);
class EOT:
EOT_VERSION = 0x00020001
EOT_MAGIC_NUMBER = 0x504c
EOT_DEFAULT_CHARSET = 0x01
EOT_FAMILY_NAME_INDEX = 0 # order of names in variable portion of EOT header
EOT_STYLE_NAME_INDEX = 1
EOT_VERSION_NAME_INDEX = 2
EOT_FULL_NAME_INDEX = 3
EOT_NUM_NAMES = 4
EOT_HEADER_PACK = '<4L10B2BL2H7L18x'
class OpenType:
SFNT_CFF = multichar('OTTO') # Postscript CFF SFNT version
SFNT_TRUE = 0x10000 # Standard TrueType version
SFNT_APPLE = multichar('true') # Apple TrueType version
SFNT_UNPACK = '>I4H'
TABLE_DIR_UNPACK = '>4I'
TABLE_HEAD = multichar('head') # TrueType table tags
TABLE_NAME = multichar('name')
TABLE_OS2 = multichar('OS/2')
TABLE_GLYF = multichar('glyf')
TABLE_CFF = multichar('CFF ')
OS2_FSSELECTION_ITALIC = 0x1
OS2_UNPACK = '>4xH2xH22x10B4L4xH14x2L'
HEAD_UNPACK = '>8xL'
NAME_RECORD_UNPACK = '>6H'
NAME_ID_FAMILY = 1
NAME_ID_STYLE = 2
NAME_ID_UNIQUE = 3
NAME_ID_FULL = 4
NAME_ID_VERSION = 5
NAME_ID_POSTSCRIPT = 6
PLATFORM_ID_UNICODE = 0 # Mac OS uses this typically
PLATFORM_ID_MICROSOFT = 3
ENCODING_ID_MICROSOFT_UNICODEBMP = 1 # with Microsoft platformID BMP-only Unicode encoding
LANG_ID_MICROSOFT_EN_US = 0x0409 # with Microsoft platformID EN US lang code
def eotname(ttf):
i = ttf.rfind('.')
if i != -1:
ttf = ttf[:i]
}
}
fileFolderService.deleteFileFolderById(folder.getFileFolderId());
}
}
/**
* @ClassName: BaseController
* @Description: 控制器的基类,所有控制器必须继承此类
**/
public class BaseController {
@Autowired
protected UserService userService;
@Autowired
protected MyFileService myFileService;
@Autowired
protected FileFolderService fileFolderService;
@Autowired
protected FileStoreService fileStoreService;
@Autowired
protected TempFileService tempFileService;
protected HttpServletRequest request;
protected HttpServletResponse response;
protected HttpSession session;
protected User loginUser;
@Autowired
protected JavaMailSenderImpl mailSender;
protected MailUtils mailUtils;
/**
* 在每个子类方法调用之前先调用
* 设置request,response,session这三个对象
*
* @param request
boolean b = FtpUtil.reNameFile(myFile.getMyFilePath() + "/" + oldName+myFile.getPostfix(), myFile.getMyFilePath() + "/" + newName+myFile.getPostfix());
if (b){
Integer integer = myFileService.updateFile(
MyFile.builder().myFileId(myFile.getMyFileId()).myFileName(newName).build());
if (integer == 1){
logger.info("修改文件名成功!原文件名:"+oldName+" 新文件名:"+newName);
}else{
logger.error("修改文件名失败!原文件名:"+oldName+" 新文件名:"+newName);
}
}
}
}
return "redirect:/files?fId="+myFile.getParentFolderId();
}
/**
* @Description 获得二维码
**/
@GetMapping("getQrCode")
@ResponseBody
public Map<String,Object> getQrCode(@RequestParam Integer id,@RequestParam String url){
Map<String,Object> map = new HashMap<>();
map.put("imgPath","https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2654852821,3851565636&fm=26&gp=0.jpg");
if (id != null){
MyFile file = myFileService.getFileByFileId(id);
if (file != null){
try {
String path = request.getSession().getServletContext().getRealPath("/user_img/");
url = url+"/file/share?t="+ UUID.randomUUID().toString().substring(0,10) +"&f="+file.getMyFileId()+"&p="+file.getUploadTime().getTime()+""+file.getSize()+"&flag=1";
File targetFile = new File(path, "");
if (!targetFile.exists()) {
targetFile.mkdirs();
}
File f = new File(path, id + ".jpg");
if (!f.exists()){
//文件不存在,开始生成二维码并保存文件
OutputStream os = new FileOutputStream(f);
QRCodeUtil.encode(url, "/static/img/logo.png", os, true);
os.close();
}
map.put("imgPath","user_img/"+id+".jpg");
map.put("url",url);
} catch (Exception e) {
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
map.put("files", files);
map.put("permission", fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission());
return "u-admin/other-files";
}
/**
* @Description 登录之后的用户主页
**/
@GetMapping("/index")
public String index(Map<String, Object> map) {
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
statistics.setFileStore(fileStoreService.getFileStoreById(loginUser.getFileStoreId()));
map.put("statistics", statistics);
return "u-admin/index";
}
/**
* @Description 前往帮助页面
**/
@GetMapping("/help")
public String helpPage(Map<String, Object> map) {
//获得统计信息
FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId());
map.put("statistics", statistics);
return "u-admin/help";
}
}
/**
* @ClassName: AdminController
composer_file_path = os.path.join(ROOT_PATH, 'composer.json')
f = open(composer_file_path, 'w')
f.write(txt)
f.close()
def generate_bower_json(data):
print "Generate bower.json"
d = {
"name": data['name'],
"version": data['version'],
"homepage": "https://github.com/driftyco/ionicons",
"authors": [
"Ben Sperry <ben@drifty.com>",
"Adam Bradley <adam@drifty.com>",
"Max Lynch <max@drifty.com>"
],
"description": "Ionicons - free and beautiful icons from the creators of Ionic Framework",
"main": [
"css/%s.css" % (data['name'].lower()),
"fonts/*"
],
"keywords": [ "fonts", "icon font", "icons", "ionic", "web font"],
"license": "MIT",
"ignore": [
"**/.*",
"builder",
"node_modules",
"bower_components",
"test",
"tests"
]
}
txt = json.dumps(d, indent=4, separators=(',', ': '))
bower_file_path = os.path.join(ROOT_PATH, 'bower.json')
f = open(bower_file_path, 'w')
f.write(txt)
f.close()
def get_build_data():
build_data_path = os.path.join(BUILDER_PATH, 'build_data.json')
f = open(build_data_path, 'r')
data = json.loads(f.read())
f.close()
return data
cmd = "sass %s %s --style compact" % (scss_file_path, css_file_path)
call(cmd, shell=True)
print "Generate Minified CSS From SCSS"
cmd = "sass %s %s --style compressed" % (scss_file_path, css_min_file_path)
call(cmd, shell=True)
def generate_cheatsheet(data):
print "Generate Cheatsheet"
cheatsheet_file_path = os.path.join(ROOT_PATH, 'cheatsheet.html')
template_path = os.path.join(BUILDER_PATH, 'cheatsheet', 'template.html')
icon_row_path = os.path.join(BUILDER_PATH, 'cheatsheet', 'icon-row.html')
f = open(template_path, 'r')
template_html = f.read()
f.close()
f = open(icon_row_path, 'r')
icon_row_template = f.read()
f.close()
content = []
for ionicon in data['icons']:
css_code = ionicon['code'].replace('0x', '\\')
escaped_html_code = ionicon['code'].replace('0x', '&#x') + ';'
html_code = ionicon['code'].replace('0x', '&#x') + ';'
item_row = icon_row_template
item_row = item_row.replace('{{name}}', ionicon['name'])
item_row = item_row.replace('{{prefix}}', data['prefix'])
item_row = item_row.replace('{{css_code}}', css_code)
item_row = item_row.replace('{{escaped_html_code}}', escaped_html_code)
item_row = item_row.replace('{{html_code}}', html_code)
content.append(item_row)
template_html = template_html.replace("{{font_name}}", data["name"])
os.close();
}
//异步删除临时文件
tempFileService.deleteById(tempFile.getFileId());
session.setAttribute("imgPath","user_img/"+id+".jpg");
session.setAttribute("url",url);
session.setAttribute("msg","上传成功,扫码/访问链接 即可下载!");
return "redirect:/temp-file";
} catch (Exception e) {
e.printStackTrace();
}
}else {
logger.info("临时文件数据库写入失败!"+name);
session.setAttribute("url","error");
session.setAttribute("msg", "服务器出错了,临时文件上传失败!");
}
}else{
//上传失败
logger.info("临时文件上传失败!"+name);
session.setAttribute("url","error");
session.setAttribute("msg", "服务器出错了,上传失败!");
}
} catch (IOException e) {
e.printStackTrace();
}
return "redirect:/temp-file";
}
/**
* @Description 网盘的文件上传
**/
@PostMapping("/uploadFile")
@ResponseBody
public Map<String, Object> uploadFile(@RequestParam("file") MultipartFile files) {
Map<String, Object> map = new HashMap<>();
if (fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission() != 0){
logger.error("用户没有上传文件的权限!上传失败...");
map.put("code", 499);
return map;
}
FileStore store = fileStoreService.getFileStoreByUserId(loginUser.getUserId());
Integer folderId = Integer.valueOf(request.getHeader("id"));
String name = files.getOriginalFilename().replaceAll(" ","");
//获取当前目录下的所有文件,用来判断是否已经存在
List<MyFile> myFiles = null;
if (folderId == 0){
//当前目录为根目录
myFiles = myFileService.getRootFilesByFileStoreId(loginUser.getFileStoreId());
}else {
//当前目录为其他目录
myFiles = myFileService.getFilesByParentFolderId(folderId);





更多推荐
所有评论(0)