Skip to content

Commit

Permalink
✨ 新增文件资源库管理,可删除、批量删除和上传图片等操作
Browse files Browse the repository at this point in the history
👽 将发布文章选择封面图片时的素材库由原来的查询文章封面列表改为现在的文件库表,可以选择库中所有的图片记录
  • Loading branch information
zhangyd-c committed Feb 18, 2019
1 parent a36eaa0 commit 05b64ea
Show file tree
Hide file tree
Showing 26 changed files with 463 additions and 204 deletions.
2 changes: 1 addition & 1 deletion blog-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.1.0.Beta</version>
<version>2.2.0</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.zyd.blog.business.consts.CommonConst;
import com.zyd.blog.business.enums.ResponseStatus;
import com.zyd.blog.file.exception.OssApiException;
import com.zyd.blog.framework.exception.*;
import com.zyd.blog.file.exception.GlobalFileException;
import com.zyd.blog.framework.exception.ZhydException;
import com.zyd.blog.framework.object.ResponseVO;
import com.zyd.blog.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -60,7 +60,7 @@ public ResponseVO maxUploadSizeExceededExceptionHandle(Throwable e) {
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ResponseVO handle(Throwable e) {
if (e instanceof ZhydException || e instanceof OssApiException) {
if (e instanceof ZhydException || e instanceof GlobalFileException) {
return ResultUtil.error(e.getMessage());
}
if (e instanceof UndeclaredThrowableException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ public Object uploadFileForMd(@RequestParam("file") MultipartFile file) {
return resultMap;
}

/**
* 发布文章选择图片时获取素材库
*
* @return
*/
@RequiresPermissions("article:publish")
@PostMapping("/material")
public ResponseVO material() {
return ResultUtil.success("", articleService.listMaterial());
}

/**
* 发送消息通知
*
Expand All @@ -90,6 +79,6 @@ public ResponseVO material() {
@BussinessLog("通过websocket向前台用户发送通知")
public ResponseVO notice(String msg) throws UnsupportedEncodingException {
WebSocketUtil.sendNotificationMsg(msg, websocketServer.getOnlineUsers());
return ResultUtil.success("消息发送成功", articleService.listMaterial());
return ResultUtil.success("消息发送成功");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.annotation.BussinessLog;
import com.zyd.blog.business.entity.File;
import com.zyd.blog.business.enums.FileUploadType;
import com.zyd.blog.business.service.BizFileService;
import com.zyd.blog.business.vo.FileConditionVO;
import com.zyd.blog.file.FileUploader;
import com.zyd.blog.framework.object.ResponseVO;
import com.zyd.blog.plugin.file.GlobalFileUploader;
import com.zyd.blog.util.ResultUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -54,9 +50,11 @@ public ResponseVO remove(Long[] ids) {
@RequiresPermissions("files")
@PostMapping(value = "/add")
@BussinessLog("添加文件")
public ResponseVO add(MultipartFile file) {
FileUploader uploader = new GlobalFileUploader();
uploader.upload(file, FileUploadType.COMMON.getPath(), true);
return ResultUtil.success("成功上传一张图片");
public ResponseVO add(MultipartFile[] file) {
if (null == file || file.length == 0) {
return ResultUtil.error("请至少选择一张图片!");
}
int res = fileService.upload(file);
return ResultUtil.success("成功上传" + res + "张图片");
}
}
114 changes: 90 additions & 24 deletions blog-admin/src/main/resources/static/assets/css/zhyd.core.css
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,9 @@ a.star {
padding: 3px 0;
border: 1px solid #EFEFEF
}
.editor-statusbar .lines:before {
content: ''!important;
}

.input-group {
margin-bottom: 10px
Expand Down Expand Up @@ -3501,7 +3504,16 @@ ul.project_files li a i {
margin-bottom: 5px
}

.caption img {
.caption p span {
display: inline-block;
width: 88%;
white-space: nowrap;
word-wrap: normal;
text-overflow: ellipsis;
overflow: hidden;
}

.caption p img {
float: right;
width: 20px;
}
Expand Down Expand Up @@ -3566,10 +3578,11 @@ ul.project_files li a i {

.view p {
font-family: Georgia, serif;
font-size: 12px;
font-size: 15px;
color: #fff;
padding: 10px 20px 20px;
text-align: center
text-align: center;
line-height: 7;
}

.view a.info {
Expand Down Expand Up @@ -3642,20 +3655,24 @@ ul.project_files li a i {
-webkit-box-shadow:0 0 15px #b5b5b5;
box-shadow:0 0 15px #b5b5b5;
}
.thumbnail.selected .selected-mask, .thumbnail:hover .selected-mask {
.thumbnail.selected .selected-mask, .thumbnail:hover .selected-mask, .material-item.selected .selected-mask {
opacity: 1;
}
.thumbnail .selected-mask {
.thumbnail .selected-mask, .material-item .selected-mask {
display: block;
position: absolute;
top: 0;
left: 0;
opacity: 0;
}
.thumbnail .selected-mask.mask-xs, .material-item .selected-mask.mask-xs {
width: 95px;
height: 95px;
}
.thumbnail .selected-mask [class^="icheckbox"] {
float: left!important;
}
.thumbnail .selected-mask .inner {
.thumbnail .selected-mask .inner, .material-item .selected-mask .inner {
width: 100%;
height: 100%;
-moz-opacity: .6;
Expand All @@ -3664,7 +3681,7 @@ ul.project_files li a i {
background-color: #000;
filter: alpha(opacity=60);
}
.thumbnail .selected-mask .icon {
.thumbnail .selected-mask .icon, .material-item .selected-mask .icon {
position: absolute;
top: 0;
left: 0;
Expand Down Expand Up @@ -4888,43 +4905,92 @@ ul, menu, dir {
background-color: #f5f5f5;
}



.chooseImgModal .material-status, #chooseImgModal .material-status {
line-height: 3;
color: #333
}

.chooseImgModal .material-box::-webkit-scrollbar {
margin-right: 2px;
width: 5px;
}

.chooseImgModal .material-box::-webkit-scrollbar-thumb {
width: 5px;
border: 0 solid #000;
background: #cbcbcb;
}

.chooseImgModal .material-box::-webkit-scrollbar-track-piece {
border-left: 0 solid #d2d2d2;
background-color: #f5f5f5;
}

.material-box {
min-height: 250px;
height: 250px;
max-height: 325px;
min-height: 215px;
/*height: 250px;*/
overflow-y: scroll;
}

.material-box ul li {
.material-box ul li.material-item {
border: 1px solid #ddd;
-webkit-transition: border .2s ease-in-out;
-o-transition: border .2s ease-in-out;
transition: border .2s ease-in-out;
/*-webkit-transition: border .2s ease-in-out;*/
/*-o-transition: border .2s ease-in-out;*/
/*transition: border .2s ease-in-out;*/
float: left;
width: 120px;
height: 120px;
margin: 5px;
width: 96px;
height: 96px;
margin: 7px;
}

.material-box ul li:hover {
.material-box ul li.material-item:hover {
-moz-box-shadow: 2px 2px 5px #cbd0d6;
-webkit-box-shadow: 2px 2px 5px #cbd0d6;
box-shadow: 2px 2px 5px #cbd0d6;
}

.material-box ul li.active {
.material-box ul li.material-item.active {
-moz-box-shadow: 2px 2px 5px #cbd0d6;
-webkit-box-shadow: 2px 2px 5px #cbd0d6;
box-shadow: 2px 2px 5px #cbd0d6;
}

.material-box ul li img {
transition: all .2s linear;
width: 100px;
max-height: 100px;
.material-box ul li.material-item img {
/*transition: all .2s linear;*/
width: 100%;
max-height: 95px;
}

.material-box ul li.material-item:hover img {
/*transform: scale(1.1);*/
}

.material-box ul li:hover img {
transform: scale(1.1);
.material-box ul li.material-page {
width: 100%;
height: 38px;
border: 0 solid #ddd;
text-align: right;
padding-right: 15px;
padding-top: 5px;
float: right;
}

.material-box ul li.material-page .material-page-body {
width: 100%;
height: 100%;
}

.material-box ul li.material-page .material-page-body a, .material-box ul li.material-page .material-page-body input {
display: inline-block
}

.material-box ul li.material-page .material-page-body input {
width: 50px;
position: relative;
top: -2px;
}

.preview img {
Expand Down
Loading

0 comments on commit 05b64ea

Please sign in to comment.