前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于springboot+vue.js实现的前后端分离的blog关于技术栈运行截图主要实现代码总结

基于springboot+vue.js实现的前后端分离的blog关于技术栈运行截图主要实现代码总结

作者头像
yukong
发布2018-08-21 10:15:45
4980
发布2018-08-21 10:15:45
举报
文章被收录于专栏:yukong的小专栏yukong的小专栏

关于

其实在很早之前我就开发过一个博客系统,不过由于当时自己的技术不够成熟,所以选择的是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

主要实现代码

代码语言:javascript
复制
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:
 */
@Service
public 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);
    }
}

总结

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.06.25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 关于
  • 技术栈
  • 运行截图
  • 主要实现代码
  • 总结
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档