Springboot+Vue实现网页内容生成图片功能
Java引导者
共 6421字,需浏览 13分钟
· 2020-09-10
点击上方 web项目开发,选择 设为星标
优质文章,及时送达
案例功能效果图
文章详情页面
把文章详情生成图片页面
环境介绍
前端:vue
后端:springboot
jdk:1.8及以上
数据库:mysql
完整源码获取方式
源码获取方式
扫码关注回复【分享图片】获取完整源码
如果你在运行这个代码的过程中有遇到问题,请加小编微信xxf960513,我拉你进对应微信学习群!!帮助你快速掌握这个功能代码!
核心代码介绍
AtricleCtrle.java
public class ArticleCtrler
{
private ArticleService articleService;
public Object addarticle( Article vo)
{
try
{
articleService.insert(vo);
return Result.success(null);
}
catch (Exception e)
{
e.printStackTrace();
}
return Result.error(CodeMsg.SERVER_ERROR);
}
public Object loadPage( Article_Condit vo)
{
try
{
PageInfo
loadPage = articleService.loadPage(vo); return Result.success(loadPage);
}
catch (Exception e)
{
e.printStackTrace();
}
return Result.error(CodeMsg.SERVER_ERROR);
}
}
ArticleService.interface
public class ArticleServiceImpl implements ArticleService
{
private ArticleDao articleDao;
public void insert(Article vo)
{
vo.setCreatedatetime(new Timestamp(new Date().getTime()));
vo.setCreateuserid("system");
articleDao.save(vo);
}
public PageInfo
loadPage(Article_Condit vo) {
PageHelper.startPage(vo.getPageIndex()==null?0:vo.getPageIndex(), vo.getPageSize()==null?0:vo.getPageSize());
List
findByCondit = articleDao.findByCondit(vo); return new PageInfo
(findByCondit); }
}
ArticleDao.java
public interface ArticleDao
{
void save(Article vo);
List
findByCondit(Article_Condit vo) ;}
main.js
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
import $ from 'jquery'
axios.defaults.baseURL = 'http://127.0.0.1:8080';
Vue.prototype.HOST='/email'
Vue.config.productionTip = false
Vue.prototype.$axios = axios
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '
' })
index.vue
<template>
<div class="wrap">
<div class="top">
<h1>文章列表h1>
<el-button type="primary" @click="goToEdit">添加文章el-button>
div>
<div class="card-wrap">
<div v-for="(item, index) in art" :key="index" class="box-card" @click="goToDetail(item)">
<el-card>
<div class="title">{{ item.title }}div>
<div class="des">{{ item.description }}div>
<div class="time">{{ item.createdatetime }}div>
el-card>
div>
div>
div>
template>
<script>
import axios from 'axios'
export default {
components: {},
props: {},
data() {
return {
art: []
}
},
computed: {},
watch: {},
created() {},
mounted() {
axios
.post('http://139.159.147.237:8080/yxyz/article/loadPage')
.then((res) => {
console.log(res.data, 'res')
if (res.data && res.data.data && res.data.data.list) {
console.log(res.data.data.list, this, 'res')
const list = res.data.data.list
this.art = list
}
})
.catch(function(error) {
console.log(error)
})
},
methods: {
goToEdit() {
this.$router.push('/about')
},
goToDetail(item) {
console.log(123)
this.$router.push({
name: 'detail',
params: {
item: item
}
})
}
}
}
script>
<style scoped lang="scss">
.wrap {
margin-top: 50px;
}
.top {
display: flex;
justify-content: center;
align-items: center;
position: relative;
button {
position: absolute;
right: 0;
}
}
.card-wrap {
display: flex;
flex-wrap: wrap;
}
.box-card {
margin-bottom: 20px;
margin-right: 20px;
width: 30%;
.title {
font-weight: bold;
font-size: 16px;
text-align: left;
margin-bottom: 10px;
}
.des {
font-size: 14px;
text-align: left;
margin-bottom: 10px;
}
.time {
font-size: 14px;
text-align: left;
}
}
style>
detail.vue
<template>
<div class="">
<h2>文章详情h2>
<el-card>
<div class="title">{{ detail.title }}div>
<div class="des">{{ detail.description }}div>
<div class="con" v-html="detail.content" />
<div class="time">{{ detail.createdatetime }}div>
el-card>
div>
template>
<script>
export default {
components: {},
props: {},
data() {
return {
detail: {}
}
},
computed: {},
watch: {},
created() {
console.log(this.$route)
const item = this.$route.params.item
this.detail = item
},
mounted() {},
methods: {}
}
script>
<style scoped lang="scss">
.title {
font-weight: bold;
font-size: 16px;
text-align: left;
margin-bottom: 10px;
}
.des {
font-size: 14px;
text-align: left;
margin-bottom: 10px;
}
.con {
font-size: 14px;
text-align: left;
margin-bottom: 10px;
}
.time {
font-size: 14px;
text-align: left;
}
style>
application.yml
spring:
profiles:
active: dev
application-dev.yml
server:
port: 8080
servlet:
/yxyz :
spring:
datasource:
name: yxyz
url: jdbc:mysql://localhost/test?serverTimezone=GMT%2b8&characterEncoding=UTF8
username: root
password: 123
# 使用druid数据源
type: com.alibaba.druid.pool.DruidDataSource
com.mysql.cj.jdbc.Driver :
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
## 该配置节点为独立的节点
mybatis:
classpath:mapping/*Mapper.xml #注意:一定要对应mapper映射xml文件的所在路径 :
com.yxyz.vo # 注意:对应实体类的路径 :
#打印sql最终填充的参数值
org.apache.ibatis.logging.stdout.StdOutImpl :
t_article.sql
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_article
-- ----------------------------
DROP TABLE IF EXISTS `t_article`;
CREATE TABLE `t_article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`description` varchar(512) NOT NULL,
`content` text NOT NULL,
`articletype` varchar(16) DEFAULT NULL,
`createdatetime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
`createuserid` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8;
--完--
推荐案例
温暖提示
请长按识别二维码
想学习更多的java功能案例请关注
Java项目开发
如果你觉得这个案例以及我们的分享思路不错,对你有帮助,请分享给身边更多需要学习的朋友。别忘了《留言+点在看》给作者一个鼓励哦!
评论
用 Shader 实现旗帜飘扬动画效果
我觉得对于刚入门 3D 编程的朋友来说,如果能够完成代码创建模型数据->创建材质->编写Shader动画这一系列,想必会有满满的成就感。今天就用 Cocos Creator 的 utils.MeshUtils.createMesh 接口,带大家感受一下这个流程。这个流程不仅可以用于新手学
COCOS
2
OpenUI:输入一段文字就能生成网!页!!
今天给大家介绍一个开源的 AI 网页生成工具:OpenUI!!!前言 在软件开发领域,用户界面(UI)的设计和构建确实是一个至关重要的环节。传统的 UI 开发需要设计师和开发人员紧密合作,通过反复的设计、修改和测试来达到理想的效果,这个过程往往耗时且成本较高。随着 AI 技术的发展,现在有越来越多的
前端技术江湖
0
知乎高问:程序员有必要知道为什么做某个功能吗?
将Python客栈设为“星标⭐”第一时间收到最新资讯前言知乎上有一个提问:程序员有必要知道为什么做某个功能吗?↓↓↓今天,我们就这个话题一起来做个讨论。不知道程序员的你,在接到产品经理提的一个需求后,是习惯马上动手开始撸代码呢?还是会先暂停一下,认真思考一会如下一些问题,比如这个需求产生的背景是什么
Python客栈
0
SpringBoot+Minio实现上传凭证、分片上传、秒传和断点续传
关注我们,设为星标,每天7:40不见不散,架构路上与您共享回复架构师获取资源大家好,我是你们的朋友架构君,一个会写代码吟诗的架构师。Spring Boot整合Minio后,前端的文件上传有两种方式:1、文件上传到后端,由后端保存到Minio这种方式好处是完全由后端集中管理,可以很好的做到、身份验证、
Java架构师社区
0
超越原生,散点图实现华夫饼图
之前我们介绍过了如何使用新卡片图实现华夫饼图。参考:超越原生,PowerBI 华夫饼图实现但是利用卡片图实现的华夫饼图有一些缺点,形状之间的大小跟间距不太好把握,而且有时形状大一点的话显示就会不正常,需要做出二次调整。今天给大家介绍一种原生视觉对象生成华夫饼图的更佳方案,既简单又美观。上图是利用散点
PowerBI战友联盟
2
Spring Boot + flowable 快速实现工作流
关注我们,设为星标,每天7:40不见不散,架构路上与您共享回复架构师获取资源大家好,我是你们的朋友架构君,一个会写代码吟诗的架构师。来源:blog.csdn.net/zhan107876/article/details/120815560总览一、flowable-ui部署运行二、绘制流程图绘图细节:
Java架构师社区
0
实现订单30分钟自动取消的策略
原文:juejin.cn/post/7285167401821798400简介在电商和其他涉及到在线支付的应用中,通常需要实现一个功能:如果用户在生成订单后的一定时间内未完成支付,系统将自动取消该订单。本文将详细介绍基于Spring Boot框架实现订单30分钟内未支付自动取消的几种方案,并提供实例
JAVA乐园
0
AI大模型之路 第三篇:从零实现词嵌入模型,加深理解!
你好,我是郭震今天我们研究「AI大模型第三篇」:词维度预测,很多读者听过词嵌入,这篇文章解答下面问题:词嵌入是什么意思?怎么做到的?原理是什么?从零实现一个专属你数据集的词嵌入我们完整从零走一遍,根基的东西要理解透,这样才能发明出更好的东西。1 skip-gram模型Skip-gram模型是一种广泛
Python与算法社区
11