亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

基于springboot+vue.js實現的前后端分離的blog

標簽:
SpringBoot

关于

其实在很早之前我就开发过一个博客系统,不过由于当时自己的技术不够成熟,所以选择的是ssm+velocity开发。前后端没有分离,编辑器选择是百度uedit,后台使用的jQuery easyui,整个界面不是很美观,而且富文本编辑器很难用。所以一直想想给blog 升级。
现在 blog v2.0 beat即将上线。
它是基于 spring + vue实现的。

技术栈

  • springboot  后台基础框架提供rest api接口

  • springsecurity 提供安全权限认证

  • jwt 提供访问token

  • spring-data-jpa 持久层访问

  • redis  提供数据缓存

  • elasticsearch 提供全文检索

  • 七牛云 图片托管至七牛云oss

  • vue.js 前台基础框架

  • iview 后台管理ui

运行截图


image.png


分隔符

image.png

主要实现代码

package com.blog.qiniu.service.impl;import com.blog.qiniu.QiNiuProperties;import com.blog.qiniu.service.QiNiuService;import com.qiniu.common.QiniuException;import com.qiniu.http.Response;import com.qiniu.storage.BucketManager;import com.qiniu.storage.UploadManager;import com.qiniu.util.Auth;import com.qiniu.util.StringMap;import org.springframework.beans.factory.InitializingBean;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.io.File;import java.io.InputStream;/**
 * @author: yukong
 * @date: 2018/6/21 13:50
 * @description:
 */@Servicepublic class QiNiuServiceImpl implements QiNiuService, InitializingBean {    @Autowired
    private UploadManager uploadManager;    @Autowired
    private BucketManager bucketManager;    @Autowired
    private Auth auth;    @Autowired
    private QiNiuProperties qiNiuProperties;    private StringMap putPolicy;    @Override
    public Response uploadFile(File file) throws QiniuException {
        Response response = this.uploadManager.put(file, null, getUploadToken());        int retry = 0;        while (response.needRetry() && retry < 3) {
            response = this.uploadManager.put(file, null, getUploadToken());
            retry++;
        }        return response;
    }    @Override
    public Response uploadFile(InputStream inputStream) throws QiniuException {
        Response response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null);        int retry = 0;        while (response.needRetry() && retry < 3) {
            response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null);
            retry++;
        }        return response;
    }    @Override
    public Response delete(String key) throws QiniuException {
        Response response = bucketManager.delete(qiNiuProperties.getBucket(), key);        int retry = 0;        while (response.needRetry() && retry++ < 3) {
            response = bucketManager.delete(qiNiuProperties.getBucket(), key);
        }        return response;
    }    @Override
    public void afterPropertiesSet() throws Exception {        this.putPolicy = new StringMap();
        putPolicy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"bucket\":\"$(bucket)\",\"width\":$(imageInfo.width), \"height\":${imageInfo.height}}");
    }    /**
     * 获取上传凭证
     *
     * @return
     */
    private String getUploadToken() {        return this.auth.uploadToken(qiNiuProperties.getBucket(), null, 3600, putPolicy);
    }
}

总结

希望大家有兴趣一起完善的可以联系我



作者:余空啊
链接:https://www.jianshu.com/p/8e324dc67d34

點擊查看更多內容
1人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消