基于SpringBoot零食销售系统的设计与实现【Java毕业设计·安装调试·代码讲解·文档报告】
🍊作者:计算机编程-吉哥
🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。
🍊心愿:点赞 👍 收藏 ⭐评论 📝
🍅 文末获取源码联系
技术选型
springboot、mybatis、mybatisplus、vue、elementui、layui、html、css、mysql、jdk1.8
数据库表结构
14张
开发工具
idea或者eclipse、vscode、navicat
⭐功能
【角色】管理员、用户
【前台功能】:登录、注册、首页、零食信息、零食资讯、个人中心、后台管理、购物车、在线客服
【后台功能】: 登录、首页、个人中心、用户管理、零食分类管理、零食信息管理、订单评价管理、系统管理、订单管理
🏆项目演示截图:
1、前台首页
2、前台零食商品推荐
3、前台零食信息
4、前台零食信息详情
5、前台注册
6、前台登录
7、前台购物车
8、前台个人中心
9、前台确认下单
10、前台零食资讯
11、前台零食资讯详情
12、前台我的订单
13、前台我的地址
14、后台登录
15、后台用户管理
16、后台零食分类管理
17、后台零食信息管理
18、后台订单评价管理
19、后台零食资讯管理
20、后台订单管理
核心代码功能实现
1、零食信息页面
<template>
<div class="main-content">
<!-- 列表页 -->
<div v-if="showFlag">
<el-form :inline="true" :model="searchForm" class="form-content">
<el-row :gutter="20" class="slt" :style="{justifyContent:contents.searchBoxPosition=='1'?'flex-start':contents.searchBoxPosition=='2'?'center':'flex-end'}">
<el-form-item :label="contents.inputTitle == 1 ? '零食名称' : ''">
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 1" prefix-icon="el-icon-search" v-model="searchForm.lingshimingcheng" placeholder="零食名称" clearable></el-input>
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 2" suffix-icon="el-icon-search" v-model="searchForm.lingshimingcheng" placeholder="零食名称" clearable></el-input>
<el-input v-if="contents.inputIcon == 0" v-model="searchForm.lingshimingcheng" placeholder="零食名称" clearable></el-input>
</el-form-item>
<el-form-item :label="contents.inputTitle == 1 ? '品牌' : ''">
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 1" prefix-icon="el-icon-search" v-model="searchForm.pinpai" placeholder="品牌" clearable></el-input>
<el-input v-if="contents.inputIcon == 1 && contents.inputIconPosition == 2" suffix-icon="el-icon-search" v-model="searchForm.pinpai" placeholder="品牌" clearable></el-input>
<el-input v-if="contents.inputIcon == 0" v-model="searchForm.pinpai" placeholder="品牌" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button v-if="contents.searchBtnIcon == 1 && contents.searchBtnIconPosition == 1" icon="el-icon-search" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}</el-button>
<el-button v-if="contents.searchBtnIcon == 1 && contents.searchBtnIconPosition == 2" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}<i class="el-icon-search el-icon--right"/></el-button>
<el-button v-if="contents.searchBtnIcon == 0" type="success" @click="search()">{{ contents.searchBtnFont == 1?'查询':'' }}</el-button>
</el-form-item>
</el-row>
<el-row class="ad" :style="{justifyContent:contents.btnAdAllBoxPosition=='1'?'flex-start':contents.btnAdAllBoxPosition=='2'?'center':'flex-end'}">
<el-form-item>
<el-button
v-if="isAuth('lingshixinxi','新增') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 1"
type="success"
icon="el-icon-plus"
@click="addOrUpdateHandler()"
>{{ contents.btnAdAllFont == 1?'新增':'' }}</el-button>
<el-button
v-if="isAuth('lingshixinxi','新增') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 2"
type="success"
@click="addOrUpdateHandler()"
>{{ contents.btnAdAllFont == 1?'新增':'' }}<i class="el-icon-plus el-icon--right" /></el-button>
<el-button
v-if="isAuth('lingshixinxi','新增') && contents.btnAdAllIcon == 0"
type="success"
@click="addOrUpdateHandler()"
>{{ contents.btnAdAllFont == 1?'新增':'' }}</el-button>
<el-button
v-if="isAuth('lingshixinxi','删除') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 1 && contents.tableSelection"
:disabled="dataListSelections.length <= 0"
type="danger"
icon="el-icon-delete"
@click="deleteHandler()"
>{{ contents.btnAdAllFont == 1?'删除':'' }}</el-button>
<el-button
v-if="isAuth('lingshixinxi','删除') && contents.btnAdAllIcon == 1 && contents.btnAdAllIconPosition == 2 && contents.tableSelection"
:disabled="dataListSelections.length <= 0"
type="danger"
@click="deleteHandler()"
>{{ contents.btnAdAllFont == 1?'删除':'' }}<i class="el-icon-delete el-icon--right" /></el-button>
<el-button
v-if="isAuth('lingshixinxi','删除') && contents.btnAdAllIcon == 0 && contents.tableSelection"
:disabled="dataListSelections.length <= 0"
type="danger"
@click="deleteHandler()"
>{{ contents.btnAdAllFont == 1?'删除':'' }}</el-button>
</el-form-item>
</el-row>
</el-form>
<div class="table-content">
<el-table class="tables" :size="contents.tableSize" :show-header="contents.tableShowHeader"
:header-row-style="headerRowStyle" :header-cell-style="headerCellStyle"
:border="contents.tableBorder"
:fit="contents.tableFit"
:stripe="contents.tableStripe"
:row-style="rowStyle"
:cell-style="cellStyle"
:style="{width: '100%',fontSize:contents.tableContentFontSize,color:contents.tableContentFontColor}"
v-if="isAuth('lingshixinxi','查看')"
:data="dataList"
v-loading="dataListLoading"
@selection-change="selectionChangeHandler">
<el-table-column v-if="contents.tableSelection"
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column label="索引" v-if="contents.tableIndex" type="index" width="50" />
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="lingshimingcheng"
header-align="center"
label="零食名称">
<template slot-scope="scope">
{{scope.row.lingshimingcheng}}
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="lingshifenlei"
header-align="center"
label="零食分类">
<template slot-scope="scope">
{{scope.row.lingshifenlei}}
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign" prop="tupian"
header-align="center"
width="200"
label="图片">
<template slot-scope="scope">
<div v-if="scope.row.tupian">
<img :src="scope.row.tupian.split(',')[0]" width="100" height="100">
</div>
<div v-else>无图片</div>
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="pinpai"
header-align="center"
label="品牌">
<template slot-scope="scope">
{{scope.row.pinpai}}
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="guige"
header-align="center"
label="规格">
<template slot-scope="scope">
{{scope.row.guige}}
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="baozhiqi"
header-align="center"
label="保质期">
<template slot-scope="scope">
{{scope.row.baozhiqi}}
</template>
</el-table-column>
<el-table-column :sortable="contents.tableSortable" :align="contents.tableAlign"
prop="price"
header-align="center"
label="价格">
<template slot-scope="scope">
{{scope.row.price}}
</template>
</el-table-column>
<el-table-column width="300" :align="contents.tableAlign"
header-align="center"
label="操作">
<template slot-scope="scope">
<el-button v-if="isAuth('lingshixinxi','查看') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="success" icon="el-icon-tickets" size="mini" @click="addOrUpdateHandler(scope.row.id,'info')">{{ contents.tableBtnFont == 1?'详情':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','查看') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 2" type="success" size="mini" @click="addOrUpdateHandler(scope.row.id,'info')">{{ contents.tableBtnFont == 1?'详情':'' }}<i class="el-icon-tickets el-icon--right" /></el-button>
<el-button v-if="isAuth('lingshixinxi','查看') && contents.tableBtnIcon == 0" type="success" size="mini" @click="addOrUpdateHandler(scope.row.id,'info')">{{ contents.tableBtnFont == 1?'详情':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','修改') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="primary" icon="el-icon-edit" size="mini" @click="addOrUpdateHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'修改':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','修改') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 2" type="primary" size="mini" @click="addOrUpdateHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'修改':'' }}<i class="el-icon-edit el-icon--right" /></el-button>
<el-button v-if="isAuth('lingshixinxi','修改') && contents.tableBtnIcon == 0" type="primary" size="mini" @click="addOrUpdateHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'修改':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','查看评论') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="primary" icon="el-icon-edit" size="mini" @click="disscussListHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'查看评论':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','查看评论') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 2" type="primary" size="mini" @click="disscussListHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'查看评论':'' }}<i class="el-icon-edit el-icon--right" /></el-button>
<el-button v-if="isAuth('lingshixinxi','查看评论') && contents.tableBtnIcon == 0" type="primary" size="mini" @click="disscussListHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'查看评论':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','删除') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 1" type="danger" icon="el-icon-delete" size="mini" @click="deleteHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'删除':'' }}</el-button>
<el-button v-if="isAuth('lingshixinxi','删除') && contents.tableBtnIcon == 1 && contents.tableBtnIconPosition == 2" type="danger" size="mini" @click="deleteHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'删除':'' }}<i class="el-icon-delete el-icon--right" /></el-button>
<el-button v-if="isAuth('lingshixinxi','删除') && contents.tableBtnIcon == 0" type="danger" size="mini" @click="deleteHandler(scope.row.id)">{{ contents.tableBtnFont == 1?'删除':'' }}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
clsss="pages"
:layout="layouts"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="Number(contents.pageEachNum)"
:total="totalPage"
:small="contents.pageStyle"
class="pagination-content"
:background="contents.pageBtnBG"
:style="{textAlign:contents.pagePosition==1?'left':contents.pagePosition==2?'center':'right'}"
></el-pagination>
</div>
</div>
<!-- 添加/修改页面 将父组件的search方法传递给子组件-->
<add-or-update v-if="addOrUpdateFlag" :parent="this" ref="addOrUpdate"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from "./add-or-update";
export default {
data() {
return {
searchForm: {
key: ""
},
form:{},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
showFlag: true,
sfshVisiable: false,
shForm: {},
chartVisiable: false,
addOrUpdateFlag:false,
contents:{"searchBtnFontColor":"#333","pagePosition":"2","inputFontSize":"14px","inputBorderRadius":"4px","tableBtnDelFontColor":"rgba(249, 104, 104, 1)","tableBtnIconPosition":"1","searchBtnHeight":"40px","inputIconColor":"#C0C4CC","searchBtnBorderRadius":"4px","tableStripe":true,"btnAdAllWarnFontColor":"rgba(252, 197, 37, 1)","tableBtnDelBgColor":"#fff","searchBtnIcon":"1","tableSize":"medium","searchBtnBorderStyle":"solid","tableSelection":true,"searchBtnBorderWidth":"1px","tableContentFontSize":"14px","searchBtnBgColor":"rgba(228, 231, 234, 1)","inputTitleSize":"14px","btnAdAllBorderColor":"#F7B8B8","pageJumper":true,"btnAdAllIconPosition":"1","searchBoxPosition":"1","tableBtnDetailFontColor":"rgba(87, 199, 212, 1)","tableBtnHeight":"40px","pagePager":true,"searchBtnBorderColor":"#DCDFE6","tableHeaderFontColor":"rgba(255, 255, 255, 1)","inputTitle":"1","tableBtnBorderRadius":"4px","btnAdAllFont":"1","btnAdAllDelFontColor":"rgba(249, 104, 104, 1)","tableBtnIcon":"0","btnAdAllHeight":"40px","btnAdAllWarnBgColor":"#fff","btnAdAllBorderWidth":"1px","tableStripeFontColor":"#606266","tableBtnBorderStyle":"solid","inputHeight":"40px","btnAdAllBorderRadius":"4px","btnAdAllDelBgColor":"#fff","pagePrevNext":true,"btnAdAllAddBgColor":"#fff","searchBtnFont":"1","tableIndex":true,"btnAdAllIcon":"1","tableSortable":true,"pageSizes":true,"tableFit":true,"pageBtnBG":false,"searchBtnFontSize":"14px","tableBtnEditBgColor":"#fff","inputBorderWidth":"1px","inputFontPosition":"1","inputFontColor":"#333","pageEachNum":10,"tableHeaderBgColor":"#F7B8B8","inputTitleColor":"#333","btnAdAllBoxPosition":"1","tableBtnDetailBgColor":"#fff","inputIcon":"0","searchBtnIconPosition":"1","btnAdAllFontSize":"14px","inputBorderStyle":"solid","inputBgColor":"#fff","pageStyle":false,"pageTotal":true,"btnAdAllAddFontColor":"rgba(51, 202, 187, 1)","tableBtnFont":"1","tableContentFontColor":"rgba(72, 72, 72, 1)","inputBorderColor":"rgba(223, 230, 236, 1)","tableShowHeader":true,"tableBtnFontSize":"14px","tableBtnBorderColor":"#F7B8B8","inputIconPosition":"1","tableBorder":true,"btnAdAllBorderStyle":"solid","tableBtnBorderWidth":"1px","tableStripeBgColor":"rgba(252, 253, 254, 1)","tableBtnEditFontColor":"rgba(249, 97, 151, 1)","tableAlign":"center"},
layouts: '',
};
},
created() {
this.init();
this.getDataList();
this.contentStyleChange()
},
mounted() {
},
filters: {
htmlfilter: function (val) {
return val.replace(/<[^>]*>/g).replace(/undefined/g,'');
}
},
components: {
AddOrUpdate,
},
methods: {
contentStyleChange() {
this.contentSearchStyleChange()
this.contentBtnAdAllStyleChange()
this.contentSearchBtnStyleChange()
this.contentTableBtnStyleChange()
this.contentPageStyleChange()
},
contentSearchStyleChange() {
this.$nextTick(()=>{
document.querySelectorAll('.form-content .slt .el-input__inner').forEach(el=>{
let textAlign = 'left'
if(this.contents.inputFontPosition == 2) textAlign = 'center'
if(this.contents.inputFontPosition == 3) textAlign = 'right'
el.style.textAlign = textAlign
el.style.height = this.contents.inputHeight
el.style.lineHeight = this.contents.inputHeight
el.style.color = this.contents.inputFontColor
el.style.fontSize = this.contents.inputFontSize
el.style.borderWidth = this.contents.inputBorderWidth
el.style.borderStyle = this.contents.inputBorderStyle
el.style.borderColor = this.contents.inputBorderColor
el.style.borderRadius = this.contents.inputBorderRadius
el.style.backgroundColor = this.contents.inputBgColor
})
if(this.contents.inputTitle) {
document.querySelectorAll('.form-content .slt .el-form-item__label').forEach(el=>{
el.style.color = this.contents.inputTitleColor
el.style.fontSize = this.contents.inputTitleSize
el.style.lineHeight = this.contents.inputHeight
})
}
setTimeout(()=>{
document.querySelectorAll('.form-content .slt .el-input__prefix').forEach(el=>{
el.style.color = this.contents.inputIconColor
el.style.lineHeight = this.contents.inputHeight
})
document.querySelectorAll('.form-content .slt .el-input__suffix').forEach(el=>{
el.style.color = this.contents.inputIconColor
el.style.lineHeight = this.contents.inputHeight
})
document.querySelectorAll('.form-content .slt .el-input__icon').forEach(el=>{
el.style.lineHeight = this.contents.inputHeight
})
},10)
})
},
// 搜索按钮
contentSearchBtnStyleChange() {
this.$nextTick(()=>{
document.querySelectorAll('.form-content .slt .el-button--success').forEach(el=>{
el.style.height = this.contents.searchBtnHeight
el.style.color = this.contents.searchBtnFontColor
el.style.fontSize = this.contents.searchBtnFontSize
el.style.borderWidth = this.contents.searchBtnBorderWidth
el.style.borderStyle = this.contents.searchBtnBorderStyle
el.style.borderColor = this.contents.searchBtnBorderColor
el.style.borderRadius = this.contents.searchBtnBorderRadius
el.style.backgroundColor = this.contents.searchBtnBgColor
})
})
},
// 新增、批量删除
contentBtnAdAllStyleChange() {
this.$nextTick(()=>{
document.querySelectorAll('.form-content .ad .el-button--success').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight
el.style.color = this.contents.btnAdAllAddFontColor
el.style.fontSize = this.contents.btnAdAllFontSize
el.style.borderWidth = this.contents.btnAdAllBorderWidth
el.style.borderStyle = this.contents.btnAdAllBorderStyle
el.style.borderColor = this.contents.btnAdAllBorderColor
el.style.borderRadius = this.contents.btnAdAllBorderRadius
el.style.backgroundColor = this.contents.btnAdAllAddBgColor
})
document.querySelectorAll('.form-content .ad .el-button--danger').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight
el.style.color = this.contents.btnAdAllDelFontColor
el.style.fontSize = this.contents.btnAdAllFontSize
el.style.borderWidth = this.contents.btnAdAllBorderWidth
el.style.borderStyle = this.contents.btnAdAllBorderStyle
el.style.borderColor = this.contents.btnAdAllBorderColor
el.style.borderRadius = this.contents.btnAdAllBorderRadius
el.style.backgroundColor = this.contents.btnAdAllDelBgColor
})
document.querySelectorAll('.form-content .ad .el-button--warning').forEach(el=>{
el.style.height = this.contents.btnAdAllHeight
el.style.color = this.contents.btnAdAllWarnFontColor
el.style.fontSize = this.contents.btnAdAllFontSize
el.style.borderWidth = this.contents.btnAdAllBorderWidth
el.style.borderStyle = this.contents.btnAdAllBorderStyle
el.style.borderColor = this.contents.btnAdAllBorderColor
el.style.borderRadius = this.contents.btnAdAllBorderRadius
el.style.backgroundColor = this.contents.btnAdAllWarnBgColor
})
})
},
// 表格
rowStyle({ row, rowIndex}) {
if (rowIndex % 2 == 1) {
if(this.contents.tableStripe) {
return {color:this.contents.tableStripeFontColor}
}
} else {
return ''
}
},
cellStyle({ row, rowIndex}){
if (rowIndex % 2 == 1) {
if(this.contents.tableStripe) {
return {backgroundColor:this.contents.tableStripeBgColor}
}
} else {
return ''
}
},
headerRowStyle({ row, rowIndex}){
return {color: this.contents.tableHeaderFontColor}
},
headerCellStyle({ row, rowIndex}){
return {backgroundColor: this.contents.tableHeaderBgColor}
},
// 表格按钮
contentTableBtnStyleChange(){
},
// 分页
contentPageStyleChange(){
let arr = []
if(this.contents.pageTotal) arr.push('total')
if(this.contents.pageSizes) arr.push('sizes')
if(this.contents.pagePrevNext){
arr.push('prev')
if(this.contents.pagePager) arr.push('pager')
arr.push('next')
}
if(this.contents.pageJumper) arr.push('jumper')
this.layouts = arr.join()
this.contents.pageEachNum = 10
},
init () {
},
search() {
this.pageIndex = 1;
this.getDataList();
},
// 获取数据列表
getDataList() {
this.dataListLoading = true;
let params = {
page: this.pageIndex,
limit: this.pageSize,
sort: 'id',
}
if(this.searchForm.lingshimingcheng!='' && this.searchForm.lingshimingcheng!=undefined){
params['lingshimingcheng'] = '%' + this.searchForm.lingshimingcheng + '%'
}
if(this.searchForm.pinpai!='' && this.searchForm.pinpai!=undefined){
params['pinpai'] = '%' + this.searchForm.pinpai + '%'
}
this.$http({
url: "lingshixinxi/page",
method: "get",
params: params
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.data.list;
this.totalPage = data.data.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
});
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
// 多选
selectionChangeHandler(val) {
this.dataListSelections = val;
},
// 添加/修改
addOrUpdateHandler(id,type) {
this.showFlag = false;
this.addOrUpdateFlag = true;
this.crossAddOrUpdateFlag = false;
if(type!='info'){
type = 'else';
}
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id,type);
});
},
// 查看评论
disscussListHandler(id,type) {
this.$router.push({path:'/discusslingshixinxi',query:{refid:id}});
},
// 下载
download(file){
window.open(`${file}`)
},
// 删除
deleteHandler(id) {
var ids = id
? [Number(id)]
: this.dataListSelections.map(item => {
return Number(item.id);
});
this.$confirm(`确定进行[${id ? "删除" : "批量删除"}]操作?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$http({
url: "lingshixinxi/delete",
method: "post",
data: ids
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.search();
}
});
} else {
this.$message.error(data.msg);
}
});
});
},
}
};
</script>
<style lang="scss" scoped>
.slt {
margin: 0 !important;
display: flex;
}
.ad {
margin: 0 !important;
display: flex;
}
.pages {
& /deep/ el-pagination__sizes{
& /deep/ el-input__inner {
height: 22px;
line-height: 22px;
}
}
}
.el-button+.el-button {
margin:0;
}
.tables {
& /deep/ .el-button--success {
height: 40px;
color: rgba(87, 199, 212, 1);
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: #F7B8B8;
border-radius: 4px;
background-color: #fff;
}
& /deep/ .el-button--primary {
height: 40px;
color: rgba(249, 97, 151, 1);
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: #F7B8B8;
border-radius: 4px;
background-color: #fff;
}
& /deep/ .el-button--danger {
height: 40px;
color: rgba(249, 104, 104, 1);
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: #F7B8B8;
border-radius: 4px;
background-color: #fff;
}
& /deep/ .el-button {
margin: 4px;
}
}
</style>
2、零食信息Controller
package com.controller;
/**
* 零食信息
* 后端接口
* @author 计算机编程-吉哥
*/
@RestController
@RequestMapping("/lingshixinxi")
public class LingshixinxiController {
@Autowired
private LingshixinxiService lingshixinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,LingshixinxiEntity lingshixinxi,
HttpServletRequest request){
EntityWrapper<LingshixinxiEntity> ew = new EntityWrapper<LingshixinxiEntity>();
PageUtils page = lingshixinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, lingshixinxi), params), params));
return R.ok().put("data", page);
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(LingshixinxiEntity lingshixinxi){
EntityWrapper< LingshixinxiEntity> ew = new EntityWrapper< LingshixinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( lingshixinxi, "lingshixinxi"));
LingshixinxiView lingshixinxiView = lingshixinxiService.selectView(ew);
return R.ok("查询零食信息成功").put("data", lingshixinxiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
LingshixinxiEntity lingshixinxi = lingshixinxiService.selectById(id);
lingshixinxi.setClicknum(lingshixinxi.getClicknum()+1);
lingshixinxi.setClicktime(new Date());
lingshixinxiService.updateById(lingshixinxi);
return R.ok().put("data", lingshixinxi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody LingshixinxiEntity lingshixinxi, HttpServletRequest request){
lingshixinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(lingshixinxi);
lingshixinxiService.insert(lingshixinxi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody LingshixinxiEntity lingshixinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(lingshixinxi);
lingshixinxiService.updateById(lingshixinxi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
lingshixinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
3、零食信息Service
package com.service;
/**
* LingshixinxiService接口
* @author 计算机编程-吉哥
*/
/**
* 零食信息
*
*/
public interface LingshixinxiService extends IService<LingshixinxiEntity> {
PageUtils queryPage(Map<String, Object> params);
List<LingshixinxiVO> selectListVO(Wrapper<LingshixinxiEntity> wrapper);
LingshixinxiVO selectVO(@Param("ew") Wrapper<LingshixinxiEntity> wrapper);
List<LingshixinxiView> selectListView(Wrapper<LingshixinxiEntity> wrapper);
LingshixinxiView selectView(@Param("ew") Wrapper<LingshixinxiEntity> wrapper);
PageUtils queryPage(Map<String, Object> params,Wrapper<LingshixinxiEntity> wrapper);
}
4、零食信息ServiceImpl
package com.service.impl;
/**
* @author 计算机编程-吉哥
*/
@Service("lingshixinxiService")
public class LingshixinxiServiceImpl extends ServiceImpl<LingshixinxiDao, LingshixinxiEntity> implements LingshixinxiService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
Page<LingshixinxiEntity> page = this.selectPage(
new Query<LingshixinxiEntity>(params).getPage(),
new EntityWrapper<LingshixinxiEntity>()
);
return new PageUtils(page);
}
@Override
public PageUtils queryPage(Map<String, Object> params, Wrapper<LingshixinxiEntity> wrapper) {
Page<LingshixinxiView> page =new Query<LingshixinxiView>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper));
PageUtils pageUtil = new PageUtils(page);
return pageUtil;
}
@Override
public List<LingshixinxiVO> selectListVO(Wrapper<LingshixinxiEntity> wrapper) {
return baseMapper.selectListVO(wrapper);
}
@Override
public LingshixinxiVO selectVO(Wrapper<LingshixinxiEntity> wrapper) {
return baseMapper.selectVO(wrapper);
}
@Override
public List<LingshixinxiView> selectListView(Wrapper<LingshixinxiEntity> wrapper) {
return baseMapper.selectListView(wrapper);
}
@Override
public LingshixinxiView selectView(Wrapper<LingshixinxiEntity> wrapper) {
return baseMapper.selectView(wrapper);
}
}
5、零食信息Mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dao.LingshixinxiDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.entity.LingshixinxiEntity" id="lingshixinxiMap">
<result property="lingshimingcheng" column="lingshimingcheng"/>
<result property="lingshifenlei" column="lingshifenlei"/>
<result property="tupian" column="tupian"/>
<result property="pinpai" column="pinpai"/>
<result property="guige" column="guige"/>
<result property="baozhiqi" column="baozhiqi"/>
<result property="lingshixiangqing" column="lingshixiangqing"/>
<result property="clicktime" column="clicktime"/>
<result property="clicknum" column="clicknum"/>
<result property="price" column="price"/>
</resultMap>
<select id="selectListVO"
resultType="com.entity.vo.LingshixinxiVO" >
SELECT * FROM lingshixinxi lingshixinxi
<where> 1=1 ${ew.sqlSegment}</where>
</select>
<select id="selectVO"
resultType="com.entity.vo.LingshixinxiVO" >
SELECT lingshixinxi.* FROM lingshixinxi lingshixinxi
<where> 1=1 ${ew.sqlSegment}</where>
</select>
<select id="selectListView"
resultType="com.entity.view.LingshixinxiView" >
SELECT lingshixinxi.* FROM lingshixinxi lingshixinxi
<where> 1=1 ${ew.sqlSegment}</where>
</select>
<select id="selectView"
resultType="com.entity.view.LingshixinxiView" >
SELECT * FROM lingshixinxi lingshixinxi <where> 1=1 ${ew.sqlSegment}</where>
</select>
</mapper>
更多项目推荐:计算机毕业设计项目
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓如果大家有任何疑虑,请在下方位置详细咨询。