仿极简图床

一、使用技术
后端:Spring Boot+Spring Data JPA+RESTful API+swagger
前端:VUE.js+VUE cli+bootstrap+jQuery+axios
二、效果图


极简主页.png
某个相册.png

三、源码
后端代码


项目目录.png

相册类
@Entity
@Data
public class Album {
@Id
@GeneratedValue
private Integer id;

private String albumCover;

private String albumTitle;

private String albumDescription;

private Integer likes;

}
某个相册内容类
@Entity
@Data
public class AlbumCatena {
@Id
@GeneratedValue
private Integer id;
private String picture;
private String title;
private Integer album_id;

}
相册接口
public interface AlbumRepository extends JpaRepository<Album,Integer>{
@Query("select u from Album u order by u.likes desc")
List<Album>findHot();

List<Album>findAll();

}
某个相册内容接口

public interface AlbumCatenaRepository extends JpaRepository<AlbumCatena,Integer> {
AlbumCatena findAlbumCatenaById(Integer id);

@Query("select u from AlbumCatena u where u.album_id=?1")
List<AlbumCatena>findAlbumCatenas(Integer id);

}
相册service
public interface AlbumService {
List<Album> getall();
}
某个相册内容service
public interface AlbumCatenaService {
List<AlbumCatena>findAlbumCatenas(Integer id);
}
相册service实现类
@Service
public class AlbumImpl implements AlbumService {
@Resource
private AlbumRepository albumRepository;

@Override
public List<Album> getall() {
    return albumRepository.findAll();
}

}
某个相册内容service实现类
@Service
public class AlbumCatenaImpl implements AlbumCatenaService {
@Resource
private AlbumCatenaRepository albumCatenaRepository;
@Override
public List<AlbumCatena> findAlbumCatenas(Integer id) {
return albumCatenaRepository.findAlbumCatenas(id);
}
}
给前端提供接口
@RestController
@CrossOrigin
@RequestMapping(value = "/books")
public class BoController {
@Resource
private AlbumService albumService;
@Resource
private AlbumCatenaService albumCatenaService;

@GetMapping("/album")
public List<Album>getallalbum(){
    return albumService.getall();
}

@GetMapping("/{id}")
public List<AlbumCatena>getcatenas(@PathVariable Integer id){
    System.out.println(albumCatenaService.findAlbumCatenas(id));
    return albumCatenaService.findAlbumCatenas(id);
}

}
前端代码
相册页面
<template>
<div>
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">我的相册</h1>
<p class="lead text-muted">因为还要走很长的路,所以要心无旁骛地望着远方</p >
<p>
<a href="" class="btn btn-primary my-2">查看更多</a >
</p >
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4" v-for="album in albums" :key="album.id">
<div class="card mb-4 box-shadow">
<img class="card-img-center" :src="album.albumCover"/>
<div class="card-body">
<p class="card-text">{{album.albumDescription}}</p >
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<router-link tag="a" :to="{ path:'/albumcatena',query:{id:album.id}}">
<button type="button" class="btn btn-sm btn-outline-secondary">查看</button>
</router-link>
<button type="button" class="btn btn-sm btn-outline-secondary">关注</button>
</div>
<small class="text-muted">数量:{{album.likes}}</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>

</div>

</template>

<script>
import 'bootstrap/dist/css/bootstrap.css'
import 'jquery/dist/jquery.min'
import 'bootstrap/dist/js/bootstrap.min'
export default {
data: function () {
return {
albums: []
}
},
created () {
var _this = this
this.$http.get('http://localhost:8080/books/album')
.then(function (response) {
_this.albums = response.data
})
},
name: 'Album'
}

</script>

<style scoped>
img{
width: 348px;
height: 250px;
}
</style>
某个相册内容页面
<template>
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4" v-for="albumcatena in albumcatenas" :key="albumcatena.id">
<div class="card mb-4 box-shadow">
<img class="card-img-center" :src="albumcatena.picture"/>
<div class="card-body">
<p class="card-text">{{albumcatena.title}}</p >
</div>
</div>
</div>
</div>
</div>
</div>
</template>

<script>
import 'bootstrap/dist/css/bootstrap.css'
import 'jquery/dist/jquery.min'
import 'bootstrap/dist/js/bootstrap.min'
export default {
data: function () {
return {
albumcatenas: []
}
},
created () {
this.id = this.route.query.id var _this = this this.http.get('http://localhost:8080/books/' + this.id)
.then(function (response) {
_this.albumcatenas = response.data
})
},
name: 'AlbumCatena'
}

</script>

<style scoped>
img{
height: 200px;
}
</style>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,282评论 19 139
  • 1 Webpack 1.1 概念简介 1.1.1 WebPack是什么 1、一个打包工具 2、一个模块加载工具 3...
    Kevin_Junbaozi阅读 11,807评论 0 16
  • 失败是沙,成功是金,生活就是沙里淘金。拿破仑老人家也曾说过,“人生之光荣不在永不失败,而在能屡仆屡起” 面对这生活...
    有恒读书阅读 1,774评论 0 2
  • 我是林小影,这是我参与原创文章之第15篇。 温暖|阳光明媚的周末,3月的最后一天,愚人节的前一天,泉州市熊猫父母成...
    林小影Lisa阅读 2,972评论 0 0
  • (一) 小阿不一直有个梦想,去一片从未到过的森林,找到和自己一样只吃草的狼。 听阿不说要离开,阿不爸只是淡淡地说了...
    a6354fdd656b阅读 9,157评论 0 0

友情链接更多精彩内容