栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java > SpringBoot

基于springboot+vue.js实现的前后端分离的blog

SpringBoot 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于springboot+vue.js实现的前后端分离的blog

关于

其实在很早之前我就开发过一个博客系统,不过由于当时自己的技术不够成熟,所以选择的是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;@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}}");
    }    
    private String getUploadToken() {        return this.auth.uploadToken(qiNiuProperties.getBucket(), null, 3600, putPolicy);
    }
}
总结

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



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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/235088.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号