Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

37
.gitignore vendored

@ -0,0 +1,37 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target
/.mvn/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.log
*.jar
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

@ -0,0 +1,154 @@
/*
Navicat Premium Data Transfer
Source Server : local
Source Server Type : MySQL
Source Server Version : 80029
Source Host : localhost:3306
Source Schema : DB_flower
Target Server Type : MySQL
Target Server Version : 80029
File Encoding : 65001
Date: 26/01/2024 15:29:41
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for carts
-- ----------------------------
DROP TABLE IF EXISTS `carts`;
CREATE TABLE `carts` (
`id` int NOT NULL AUTO_INCREMENT,
`fid` int DEFAULT NULL,
`flower` varchar(255) DEFAULT NULL,
`amount` int DEFAULT NULL,
`price` float DEFAULT NULL,
`uid` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `flower` (`flower`),
KEY `uid` (`uid`),
KEY `fk2` (`fid`),
CONSTRAINT `carts_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `users` (`id`),
CONSTRAINT `fk2` FOREIGN KEY (`fid`) REFERENCES `flowers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of carts
-- ----------------------------
BEGIN;
INSERT INTO `carts` VALUES (32, 2, '粉色玫瑰花', 1, NULL, 10);
INSERT INTO `carts` VALUES (33, 4, '金枝玉叶玫瑰', 3, NULL, 10);
INSERT INTO `carts` VALUES (34, 1, '杭州水果捞', 1, NULL, 10);
COMMIT;
-- ----------------------------
-- Table structure for flowers
-- ----------------------------
DROP TABLE IF EXISTS `flowers`;
CREATE TABLE `flowers` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`species_name` varchar(255) DEFAULT NULL,
`price` float DEFAULT NULL,
`detail` varchar(255) DEFAULT NULL,
`img_guid` varchar(255) DEFAULT NULL,
`state` int DEFAULT '1' COMMENT '商品状态',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `species_name` (`species_name`),
CONSTRAINT `flowers_ibfk_1` FOREIGN KEY (`species_name`) REFERENCES `species` (`species_name`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of flowers
-- ----------------------------
BEGIN;
INSERT INTO `flowers` VALUES (1, '杭州水果捞', '春日', 10, '杭州水果捞', 'fe71ee4538644b4da67b046d3a6825a8.jpg', 1);
INSERT INTO `flowers` VALUES (2, '粉色玫瑰花', '夏日', 199, '粉色玫瑰花,送爱人~', '67975badf69646c0a70e8154208c7acd.jpg', 1);
INSERT INTO `flowers` VALUES (3, '牡丹', '夏日', 299, '国花,价格优惠', 'hehua.jpg', 1);
INSERT INTO `flowers` VALUES (4, '金枝玉叶玫瑰', '秋日', 999.99, '金枝玉叶玫瑰', '8d59b8723ad6409ab3b10847f86ef196.jpg', 1);
INSERT INTO `flowers` VALUES (5, '紫色小雏菊', '夏日', 188, '紫色小雏菊~', 'eff301d8ca194fb99639ebe4f1d328b9.jpg', 1);
INSERT INTO `flowers` VALUES (6, NULL, NULL, NULL, NULL, '', 1);
INSERT INTO `flowers` VALUES (7, '粉百合', '冬日', 10000, '粉百合', '6d901436d6e84160b04de4cafa79a611.jpg', 1);
COMMIT;
-- ----------------------------
-- Table structure for orders
-- ----------------------------
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`id` int NOT NULL AUTO_INCREMENT,
`order_guid` varchar(255) DEFAULT NULL,
`flower` varchar(255) DEFAULT NULL,
`amount` int DEFAULT NULL,
`price` float DEFAULT NULL,
`state` int DEFAULT NULL,
`uid` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `flower` (`flower`),
KEY `uid` (`uid`),
CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of orders
-- ----------------------------
BEGIN;
INSERT INTO `orders` VALUES (27, NULL, '杭州水果捞', 3, 30, 0, 10);
INSERT INTO `orders` VALUES (28, NULL, '金枝玉叶玫瑰', 1, 999.99, 0, 10);
COMMIT;
-- ----------------------------
-- Table structure for species
-- ----------------------------
DROP TABLE IF EXISTS `species`;
CREATE TABLE `species` (
`id` int NOT NULL AUTO_INCREMENT,
`species_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `species` (`species_name`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of species
-- ----------------------------
BEGIN;
INSERT INTO `species` VALUES (8, NULL);
INSERT INTO `species` VALUES (7, '冬日');
INSERT INTO `species` VALUES (11, '友情花');
INSERT INTO `species` VALUES (2, '夏日');
INSERT INTO `species` VALUES (9, '情人花');
INSERT INTO `species` VALUES (1, '春日');
INSERT INTO `species` VALUES (3, '秋日');
COMMIT;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT,
`account` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL COMMENT '角色',
PRIMARY KEY (`id`),
UNIQUE KEY `account` (`account`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO `users` VALUES (1, 'user2', 'user2', '123456', '13566662222', '北京市昌平区2号', 'user');
INSERT INTO `users` VALUES (2, 'admin', '系统管理员', '123456', '123456', '上海市黄浦区南京西路8号', 'admin');
INSERT INTO `users` VALUES (10, 'user', '杭州水果捞', '123456', '18679121111', '杭州余杭区', 'user');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;

@ -1,2 +0,0 @@
# test

@ -1,12 +0,0 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}

@ -1,9 +0,0 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

@ -1,25 +0,0 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files`
`
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -1,10 +0,0 @@
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}

@ -1,41 +0,0 @@
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

@ -1,54 +0,0 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,101 +0,0 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}

@ -1,22 +0,0 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

@ -1,82 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}

@ -1,95 +0,0 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)
}
})
})

@ -1,145 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

@ -1,7 +0,0 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})

@ -1,70 +0,0 @@
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
// 打包后访问返回 404/ 改为 ./
assetsPublicPath: './',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
};

@ -1,4 +0,0 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>花卉市场</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -1,66 +0,0 @@
{
"name": "flower-mall",
"version": "1.0.0",
"description": "a project for nursing home ",
"author": "hide",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js"
},
"dependencies": {
"axios": "^0.21.1",
"element-ui": "^2.15.2",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vue-wechat-title": "^2.0.7",
"vuex": "^3.6.2"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}

@ -1,25 +0,0 @@
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
}
},
methods: {
},
}
</script>
<style scoped>
.el-input {
width: 180px;
}
</style>

@ -1,108 +0,0 @@
html, body, #app {
height: 100%;
margin: 0;
}
.el-card {
margin-top: 15px;
}
.el-pagination {
margin-top: 45px;
}
.el-table {
font-size: 18px;
}
.my-left {
float: left;
padding: 20px;
margin-top: -10px;
}
/* 标签 */
.el-tag {
font-size: 15px;
}
.my-title {
color: cornflowerblue;
float: left;
margin: 10px;
}
.create-btn {
float: right;
margin-top: -5px;
margin-right: 10px;
}
.small-input {
width: 150px;
float: left;
}
.search {
float: left;
margin-top: 80px;
margin-left: -100px;
margin-bottom: 20px;
}
.create {
float: right;
margin-right: 20px;
margin-top: 80px;
}
.mid-input {
width: 240px;
float: left;
}
.my-mid-input {
width: 240px;
}
.logout {
float: right;
margin-right: 30px;
margin-top: 10px;
}
.info-first-card {
margin: 20px;
margin-bottom: 20px;
}
.el-form-item {
margin-left: 30%;
}
.create-dialog-btn {
text-align: center;
}
.long-text {
margin-left: 20%;
}
.long-text-input {
float: left;
width: 400px;
}
.my-time-select {
float: left;
}
.detail {
margin-top: 40px;
text-align: center;
color: cornflowerblue;
font-size: 20px;
font-weight: bold;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

@ -1,158 +0,0 @@
<!--
* 用户购买首页
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card class="goods-card">
<div>
<el-input v-model="param.searchKey" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="内容"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
</el-card>
<el-card class="main-card">
<el-row>
<el-col :span="8" v-for="(o, index) in list" :key="o" :offset="0.1">
<el-card style="padding:0px;margin:2px">
<img :src="list[index].img_guid">
<div style="padding: 14px;">
<div>
<el-tag>{{list[index].name}}</el-tag>
<br><br>
<span style="font-size: 20px;">价格</span><span style="color: #ff6a00;font-size: 20px;">{{list[index].price}}</span>
</div>
<br>
<div style="color: #d39696">{{list[index].detail}}</div>
<div class="bottom clearfix">
<el-button class="button button-add-cart" icon="el-icon-shopping-cart-1" type="success"
@click="addCart(list[index])">购买</el-button>
</div>
</div>
</el-card>
</el-col>
</el-row>
<!-- 分页 -->
<div>
<el-pagination
background
layout="prev, pager, next"
:total="pagination.total"
:page-size="pagination.pageSize"
:current-page="pagination.currentPage"
@current-change="pageChange">
</el-pagination>
</div>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
types: [],
param: {
page: 1,
searchKey: '',
searchType: '',
},
addParam: {
fid: 1,
flower: '',
account: window.sessionStorage.getItem("token"),
},
list: [],
pagination: {
total: 1,
pageSize: 9,
currentPage: 1,
},
}
},
methods: {
pageChange(page) {
this.refresh(page);
},
addCart(flower) {
this.addParam.fid = flower.id;
this.addParam.flower = flower.name;
console.log(this.addParam)
this.$http.post("/cart/create", this.addParam).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
} else {
this.$message.error(R.msg);
}
});
},
refresh(page) {
if (page === undefined) {
page = 1;
}
//window.sessionStorage.getItem('token')
this.$http.get("/flower/find?page=" + page + "&searchKey=" + this.param.searchKey
+ "&searchType=" + this.param.searchType
).then(result => {
let R = result.data;
this.list = R.data.items;
console.log(this.list);
this.pagination.total = R.data.len;
this.pagination.currentPage = page;
})
},
},
created() {
this.refresh(1);
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
img {
margin-top: 10px;
width: 160px;
height: 160px;
}
.main-card {
background: #B3C0D1;
}
.button-add-cart {
float: right;
margin: 5px;
}
</style>

@ -1,123 +0,0 @@
<!--
* 网站首页
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card class="goods-card">
<div>
<el-input v-model="param.searchKey" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="内容"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
</el-card>
<el-card class="main-card">
<el-row>
<el-col :span="8" v-for="(o, index) in list" :key="o" :offset="0.1">
<el-card style="padding:0px;margin:2px">
<img v-if=" list[index].img_guid==='static/imgs/'" src="static/imgs/back.jpg">
<img v-if=" list[index].img_guid.indexOf('.jpg') !== -1" :src="list[index].img_guid">
<div style="padding: 14px;">
<div><el-tag>{{list[index].name}}</el-tag>
<br><br>
<span style="font-size: 20px;">价格</span><span style="color: #ff6a00;font-size: 20px;">{{list[index].price}}</span>
</div>
<br>
<div style="color: #d39696">{{list[index].detail}}</div>
</div>
</el-card>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
types: [],
param: {
page: 1,
searchKey: '',
searchType: '',
},
list: [],
pagination: {
total: 1,
pageSize: 9,
currentPage: 1,
},
}
},
methods: {
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
this.$http.get("/flower/find?page=" + page + "&searchKey=" + this.param.searchKey
+ "&searchType=" + this.param.searchType
).then(result => {
let R = result.data;
this.list = R.data.items;
this.pagination.total = R.data.len;
this.pagination.currentPage = page;
})
},
},
created() {
this.refresh(1);
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
img {
margin-top: 10px;
width: 160px;
height: 160px;
}
.main-card {
background: #B3C0D1;
}
.button-add-cart{
float: right;
margin: 5px;
}
</style>

@ -1,204 +0,0 @@
<!--
* 登录页面
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div class="whole">
<div class="login">
<div class="title" style="color: #ff6a00">
<img src="../assets/imgs/logo.png" style="width: 40px;position: relative; top: 13px;right: 0px"/>
<span style="font-size: 20px">鲜花管理系统</span>
</div>
<div class="my-form">
<el-form :model="loginForm" status-icon size="small">
<el-form-item prop="account">
<el-input type="text" prefix-icon="el-icon-user-solid" v-model="loginForm.account"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" prefix-icon="el-icon-s-cooperation" v-model="loginForm.password"
autocomplete="off"></el-input>
</el-form-item>
<el-form-item class="btns">
<el-radio v-model="loginForm.role" label="user"></el-radio>
<el-radio v-model="loginForm.role" label="admin"></el-radio>
</el-form-item>
<el-form-item class="btns">
<el-button type="primary" @click="login()"></el-button>
<el-button type="warning" @click="reset()"></el-button>
<el-button type="success" @click="create"></el-button>
</el-form-item>
</el-form>
</div>
</div>
<!-- 注册 -->
<div >
<el-dialog
title="注册用户"
:visible.sync="createDialogVisible"
width="30%"
center
>
<div >
<el-form :model="addUser" label-width="80px" size="small">
<el-form-item label="账号">
<el-input class="mid-input" v-model="addUser.account"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input class="mid-input" v-model="addUser.name"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input class="mid-input" v-model="addUser.password"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input class="mid-input" type="number" v-model="addUser.phone"></el-input>
</el-form-item>
<el-form-item label="地址">
<el-input class="mid-input" v-model="addUser.address"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doCreate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
// import backImg from '../assets/imgs/1.jpg'
export default {
name: 'Login',
data() {
return {
createDialogVisible: false,
addUser: {
account: '',
name: '',
password: '',
phone: '',
address: ''
},
loginForm: {
account: '',
password: '',
role: 'user',
},
}
},
methods: {
changePage(path) {
this.$router.push(path)
},
create() {
this.reset();
this.createDialogVisible = true;
},
verify(user) {
return true;
},
doCreate() {
let flag = this.verify(this.addUser);
if (flag) {
this.$http.post("/user/create", this.addUser).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(1);
} else {
this.$message.error(R.msg);
}
this.createDialogVisible = false;
});
}
},
cancel() {
this.createDialogVisible = false;
},
login() {
this.$http.post("/login/doLogin", this.loginForm).then(result => {
// result.data = R
let R = result.data;
let user = R.data;
if (R.code === 2000) {
window.sessionStorage.setItem('token', user.account);// account
window.sessionStorage.setItem('role', user.role);// account
this.$message.success(R.msg);
if (user.role === 'admin') {
this.$router.push('/home');
} else if (user.role === 'user') {
this.$router.push('/user');
} else {
this.$router.push('/404');
}
} else {
this.$message.error(R.msg);
}
})
},
reset() {
this.loginForm = {
account: '',
password: '',
role: 'user',
};
}
}
}
</script>
<style scoped>
body{
}
.whole {
background-image: url("~@/assets/imgs/bghalf-2.jpg") ;
background-size:100%;
height: 100%;
}
.login {
width: 450px;
height: 300px;
background-color: #fff;
border-radius: 3px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
opacity: 0.95;
}
.my-form {
margin-top: 75px;
width: 300px;
position: absolute;
left: 50%;
top: 36%;
transform: translate(-50%, -50%);
}
.btns {
text-align: center;
}
.title {
margin-top: 20px;
text-align: center;
color: dodgerblue;
}
.el-form-item {
margin-left: 5%;
}
</style>

@ -1,161 +0,0 @@
<template>
<div class="whole">
<el-container>
<el-header><div><b style="float: left;margin-top: -20px"><h2 style="color: #c09494">鲜花后台管理系统</h2></b>
<el-button class="logout" type="warning" @click="logout">退</el-button>
</div></el-header>
<el-container>
<el-aside width="200px">
<!-- #575757 -->
<el-menu
router
default-active="index"
class="el-menu-vertical-demo"
background-color="#545c64"
text-color="#fff"
active-text-color="#c09494">
<el-menu-item index="index">
<i class="el-icon-menu"></i>
网站首页
</el-menu-item>
<el-menu-item index="users">
<i class="el-icon-document"></i>
<span>用户管理</span>
</el-menu-item>
<el-menu-item index="flowers">
<i class="el-icon-document"></i>
<span>商品管理</span>
</el-menu-item>
<el-menu-item index="flower_type">
<i class="el-icon-document"></i>
<span>种类管理</span>
</el-menu-item>
<el-menu-item index="orders">
<i class="el-icon-document"></i>
<span>订单管理</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-container>
<!-- 主体区域 -->
<el-main>
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</el-container>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
activeIndex: 1,
}
},
methods: {
changePage(path) {
this.$router.push(path)
},
logout(){
this.$router.push('/login');
},
},
}
</script>
<style scoped>
.whole {
height: 100%;
}
.el-header, .el-footer {
background-color: #B3C0D1;
color: #333;
text-align: center;
line-height: 60px;
}
.el-aside {
background-color: #D3DCE6;
color: #333;
text-align: center;
line-height: 200px;
}
.el-menu {
border-right: none;
}
.el-main {
background-color: #E9EEF3;
color: #333;
text-align: center;
line-height: 20px;
}
body > .el-container {
margin-bottom: 40px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
}
.el-container .el-aside {
line-height: 320px;
}
.my-menu {
position: absolute;
margin-top: 10px;
margin-left: 10px;
}
.main {
height: 80%;
}
.el-container {
height: 100%;
}
.el-header {
background-color: #ffffff;
}
.el-aside {
height: 100%;
background-color: #545c64;
}
.el-main {
background-color: #efe8e8;
}
.menu-child-item {
margin-left: 20px;
}
.el-footer {
background-color: cornflowerblue;
}
.welcome {
float: left;
color: cornflowerblue;
}
</style>

@ -1,474 +0,0 @@
<!--
* 鲜花管理页面
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title">商品管理</h2>
</div>
<div class="search">
<el-input v-model="param" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="名称"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
<div class="create">
<el-button type="success" @click="create"></el-button>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
>
<el-table-column
label="#"
align="center"
width="200">
<template slot-scope="scope">
<img v-if="scope.row.img_guid.indexOf('.jpg') === -1" src="static/imgs/img.jpg">
<img v-if="scope.row.img_guid.indexOf('.jpg') !== -1" :src="scope.row.img_guid">
</template>
</el-table-column>
<el-table-column
prop="name"
label="名称"
align="center"
>
</el-table-column>
<el-table-column
prop="species_name"
label="分类"
align="center"
>
</el-table-column>
<el-table-column
prop="price"
label="价格"
align="center"
>
</el-table-column>
<el-table-column
prop="detail"
label="详细介绍"
align="center"
>
</el-table-column>
<el-table-column
prop="species_name"
label="状态"
align="center"
>
<template slot-scope="scope">
<el-switch
v-model="scope.row.state === 1"
@change="changeState(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
width="300px"
>
<template slot-scope="scope">
<el-button type="primary" @click="update(scope.row)"></el-button>
<el-button type="success" @click="updateImg(scope.row)"></el-button>
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div>
<el-pagination
background
layout="prev, pager, next"
:total="pagination.total"
:page-size="pagination.pageSize"
:current-page="pagination.currentPage"
@current-change="pageChange">
</el-pagination>
</div>
</el-card>
<!-- 修改 -->
<div>
<el-dialog
title="修改商品信息"
:visible.sync="updateDialogVisible"
width="50%"
>
<div>
<el-form :model="updateFlower" label-width="80px" size="small">
<el-form-item label="名称">
<el-input class="small-input" v-model="updateFlower.name"></el-input>
</el-form-item>
<el-form-item label="分类">
<el-select v-model="updateFlower.species_name" placeholder="请选择">
<el-option
:key="key"
v-for="item in species"
:label="item.species_name"
:value="item.species_name"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="价格">
<el-input class="small-input" type="number" v-model="updateFlower.price"></el-input>
</el-form-item>
<el-form-item label="详情">
<el-input class="small-input" v-model="updateFlower.detail"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doUpdate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
<!-- 更新商品图片 -->
<div>
<el-dialog
title="更新图片"
:visible.sync="imgDialogVisible"
width="50%"
>
<div>
<el-form :model="addFlower" label-width="80px" size="small">
<el-upload
class="upload-demo"
action="http://localhost:8081/flower/updateImg"
:on-change="handleChange"
:on-success="uploadImgOK"
:file-list="fileList"
accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
</el-form>
</div>
</el-dialog>
</div>
<!-- 新增 -->
<div>
<el-dialog
title="新建商品"
:visible.sync="createDialogVisible"
width="50%"
>
<div>
<el-form :model="addFlower" label-width="80px" size="small">
<el-form-item label="名称">
<el-input class="small-input" v-model="addFlower.name"></el-input>
</el-form-item>
<el-form-item label="分类">
<el-select v-model="addFlower.species_name" placeholder="请选择">
<el-option
:key="key"
v-for="item in species"
:label="item.species_name"
:value="item.species_name"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="价格">
<el-input class="small-input" type="number" v-model="addFlower.price"></el-input>
</el-form-item>
<el-form-item label="详情">
<el-input class="small-input" v-model="addFlower.detail"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doCreate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
data() {
return {
fileList: [],
updateImgId: 0,
param: '',
imgDialogVisible: false,
updateDialogVisible: false,
createDialogVisible: false,
//
species:[
{
id: 1,
species_name: '春日'
},
{
id: 1,
species_name: '夏日'
},
{
id: 1,
species_name: '秋日'
}
],
updateFlower: {
id: '',
name: '',
species_name: '',
price: '',
detail: '',
},
addFlower: {
name: '',
species_name: '',
price: '',
detail: '',
},
leader_accounts: [],
list: [],
delId: 0,
pagination: {
total: 1,
pageSize: 5,
currentPage: 1,
},
file: '',
}
},
methods: {
handleChange(file, fileList) {
// this.$refs
// this.fileList = fileList.slice(0);
},
// {code: 2000
// data: "1a8b9301f2744833ad48529fba672198.jpg"
// msg: ""}
uploadImgOK(response, file, fileList) {
this.$http.put("/flower/updateImgGuid?guid="+response.data + "&id="+this.updateImgId).then(result => {
let R = result.data; // R
this.imgDialogVisible = false;
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
})
},
// updateFile(event) {
// let file = event.target.files;
// event.preventDefault();
// let formData = new FormData();
// formData.append('id',this.updateImgId);
// formData.append('file', file);
// let config = {
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// };
// this.$http.post('/flower/updateImg', formData, config).then(function (response) {
// let R = result.data; // R
// if (R.code === 2000) {
// this.$message.success(R.msg);
// this.refresh(this.pagination.currentPage);
// } else {
// this.$message.error(R.msg);
// }});
// this.imgDialogVisible = false;
// // (console.logfile)
// // let file = event.target.files;
// // console.log(file);
// // this.file = file;
// // do something...
// },
cancel() {
this.imgDialogVisible = false;
this.updateDialogVisible = false;
this.createDialogVisible = false;
},
updateImg(row) {
this.updateImgId = row.id;
this.imgDialogVisible = true;
},
changeState(row) {
let obj = {
id: row.id,
state: row.state===0?1:0
};
this.$http.put("/flower/changeState", obj).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
})
},
update(row) {
this.updateDialogVisible = true;
this.updateFlower.id = row.id;
this.updateFlower.name = row.name;
this.updateFlower.price = row.price;
this.updateFlower.species_name = row.species_name;
this.updateFlower.detail = row.detail;
},
doUpdate() {
this.$http.put("/flower/update", this.updateFlower).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
this.updateDialogVisible = false;
})
},
del(id) {
this.delId = id;
},
doDelete() {
this.$http.delete("/flower/delete?id=" + this.delId).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(1);
} else {
this.$message.error(R.msg);
}
})
},
create() {
this.reset();
this.$http.get("/species/findAll").then(result => {
let R = result.data;
this.species = R.data;
});
this.createDialogVisible = true;
},
verify(flower) {
if (flower.name.length < 2 || flower.species_name === undefined || flower.price.length < 1 || flower.detail.length < 2) {
this.$message.warning('商品名称至少为 2 个字符,请修改');
return false;
}
return true;
},
reset() {
this.addFlower = {
id: '',
name: '',
price: '',
detail: '',
};
},
doCreate() {
console.log(this.addFlower);
let flag = this.verify(this.addFlower);
if (flag) {
this.$http.post("/flower/create", this.addFlower).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.createDialogVisible = false;
this.refresh(1);
} else {
this.$message.error(R.msg);
}
});
}
},
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
//window.sessionStorage.getItem('token')
this.$http.get("/flower/findAll?page=" + page + "&searchKey=" + this.param).then(result => {
let R = result.data;
this.list = R.data.items;
this.pagination.total = R.data.len * this.pagination.pageSize;
this.pagination.currentPage = page;
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
img{
width: 200px;
height: 200px;
}
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
.my-el-table {
text-align: center;
}
.el-select{
margin-left: -53%;
}
</style>

@ -1,194 +0,0 @@
<!--
* 订单管理页面
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title">订单管理</h2>
</div>
<div class="search">
<el-input v-model="searchKey" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="商品名称"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
class="my-el-table"
>
<el-table-column
label="#"
type="index"
width="150">
</el-table-column>
<el-table-column
prop="username"
label="买家"
>
</el-table-column>
<el-table-column
prop="flower"
label="商品"
>
</el-table-column>
<el-table-column
prop="amount"
label="数量"
>
</el-table-column>
<el-table-column
prop="price"
label="价格(元)"
>
</el-table-column>
<el-table-column
prop="phone"
label="联系电话"
>
</el-table-column>
<el-table-column
prop="address"
label="地址"
>
</el-table-column>
<el-table-column
label="状态"
>
<template slot-scope="scope">
<el-switch
v-model="scope.row.state === 1"
@change="changeState(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<div>
<el-pagination
background
layout="prev, pager, next"
:total="pagination.total"
:page-size="pagination.pageSize"
:current-page="pagination.currentPage"
@current-change="pageChange">
</el-pagination>
</div>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
searchKey: '',
accounts: [],
list: [],
delId: 0,
pagination: {
total: 1,
pageSize: 5,
currentPage: 1,
},
}
},
methods: {
pageChange(page) {
this.refresh(page);
},
changeState(order) {
let obj = {
id: order.id,
state: order.state===0?1:0
};
this.$http.put("/order/changeState", obj).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
})
},
refresh(page) {
if (page === undefined) {
page = 1;
}
this.$http.get("/order/findAll?page=" + page + "&searchKey=" + this.searchKey ).then(result => {
let R = result.data;
this.list = R.data.items;
this.pagination.total = R.data.len;
this.pagination.currentPage = page;
})
},
del(id) {
this.delId = id;
},
doDelete() {
this.$http.delete("/order/delete?id=" + this.delId).then(result => {
let R = result.data;
this.$message.success(R.msg);
this.refresh(1);
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
</style>

@ -1,274 +0,0 @@
<!--
* 鲜花类型管理
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title">类型管理</h2>
</div>
<div class="search">
<el-input v-model="param" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="名称"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
<div class="create">
<el-button type="success" @click="create"></el-button>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
>
<el-table-column
label="#"
type="index"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="species_name"
label="名称"
align="center"
>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<el-button type="primary" @click="update(scope.row)"></el-button>
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div>
<el-pagination
background
layout="prev, pager, next"
:total="pagination.total"
:page-size="pagination.pageSize"
:current-page="pagination.currentPage"
@current-change="pageChange">
</el-pagination>
</div>
</el-card>
<!-- 修改 -->
<div>
<el-dialog
title="修改类型信息"
:visible.sync="updateDialogVisible"
width="50%"
>
<div>
<el-form :model="updateSpecies" label-width="80px" size="small">
<el-form-item label="">
<el-input class="small-input" type="hidden" v-model="updateSpecies.id"></el-input>
</el-form-item>
<el-form-item label="类型">
<el-input class="small-input" v-model="updateSpecies.species_name"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doUpdate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
<!-- 新增 -->
<div>
<el-dialog
title="新建类型"
:visible.sync="createDialogVisible"
width="50%"
>
<div>
<el-form :model="addSpecies" label-width="80px" size="small">
<el-form-item label="类型">
<el-input class="small-input" v-model="addSpecies.species_name"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doCreate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
data() {
return {
param: '',
updateDialogVisible: false,
createDialogVisible: false,
updateSpecies: {
id: '',
species_name: '',
},
addSpecies: {
id: 0,
species_name: '',
},
leader_accounts: [],
list: [],
delId: 0,
pagination: {
total: 1,
pageSize: 5,
currentPage: 1,
},
}
},
methods: {
cancel() {
this.updateDialogVisible = false;
this.createDialogVisible = false;
},
update(row) {
this.updateDialogVisible = true;
this.updateSpecies.id = row.id;
this.updateSpecies.species_name = row.species_name;
},
doUpdate() {
this.$http.put("/species/update", this.updateSpecies).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.updateDialogVisible = false;
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
this.updateDialogVisible = false;
})
},
del(id) {
this.delId = id;
},
doDelete() {
this.$http.delete("/species/delete?id=" + this.delId).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(1);
} else {
this.$message.error(R.msg);
}
})
},
create() {
this.reset();
this.createDialogVisible = true;
},
verify() {
if (this.addSpecies.species_name === undefined || this.addSpecies.species_name.length < 2) {
this.$message.warning('类型名称至少为 2 个字符,请修改');
return false;
}
return true;
},
reset() {
this.addSpecies = {
account: '',
password: '',
name: '',
phone: '',
address: ''
};
},
doCreate() {
let flag = this.verify();
if (flag) {
this.$http.post("/species/create", this.addSpecies).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.createDialogVisible = false;
this.refresh(1);
} else {
this.$message.error(R.msg);
}
});
}
},
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
//window.sessionStorage.getItem('token')
this.$http.get("/species/find?page=" + page + "&searchKey=" + this.param).then(result => {
let R = result.data;
this.list = R.data.items;
this.pagination.total = R.data.len * this.pagination.pageSize;
this.pagination.currentPage = page;
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
.my-el-table {
text-align: center;
}
</style>

@ -1,336 +0,0 @@
<!--
* 用户管理
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title">用户管理</h2>
</div>
<div class="search">
<el-input v-model="param" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="账号 / 姓名"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
<div class="create">
<el-button type="success" @click="create"></el-button>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
>
<el-table-column
label="#"
type="index"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="account"
label="账号"
align="center"
>
</el-table-column>
<el-table-column
prop="name"
label="姓名"
align="center"
>
</el-table-column>
<el-table-column
prop="password"
label="密码"
align="center"
>
</el-table-column>
<el-table-column
prop="phone"
label="电话"
width="150"
align="center"
>
</el-table-column>
<el-table-column
prop="address"
label="地址"
width="300"
align="center"
>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<el-button type="primary" @click="update(scope.row)"></el-button>
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div>
<el-pagination
background
layout="prev, pager, next"
:total="pagination.total"
:page-size="pagination.pageSize"
:current-page="pagination.currentPage"
@current-change="pageChange">
</el-pagination>
</div>
</el-card>
<!-- 修改 -->
<div>
<el-dialog
title="修改用户信息"
:visible.sync="updateDialogVisible"
width="50%"
>
<div>
<el-form :model="updateUser" label-width="80px" size="small">
<el-form-item label="">
<el-input class="small-input" type="hidden" v-model="updateUser.id"></el-input>
</el-form-item>
<el-form-item label="账号">
<el-input class="small-input" readonly="readonly" v-model="updateUser.account"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input class="small-input" v-model="updateUser.name"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input class="small-input" v-model="updateUser.password"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input class="small-input" type="number" v-model="updateUser.phone"></el-input>
</el-form-item>
<el-form-item label="地址">
<el-input class="small-input" v-model="updateUser.address"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doUpdate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
<!-- 新增 -->
<div>
<el-dialog
title="新建用户"
:visible.sync="createDialogVisible"
width="50%"
>
<div>
<el-form :model="addUser" label-width="80px" size="small">
<el-form-item label="账号">
<el-input class="small-input" v-model="addUser.account"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input class="small-input" v-model="addUser.name"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input class="small-input" v-model="addUser.password"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input class="small-input" type="number" v-model="addUser.phone"></el-input>
</el-form-item>
<el-form-item label="地址">
<el-input class="small-input" v-model="addUser.address"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doCreate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
data() {
return {
param: '',
createDialogVisible: false,
updateDialogVisible: false,
updateUser: {
id: '',
account: '',
name: '',
password: '',
phone: '',
address: ''
},
addUser: {
account: '',
name: '',
password: '',
phone: '',
address: ''
},
list: [],
delId: 0,
pagination: {
total: 1,
pageSize: 5,
currentPage: 1,
},
}
},
methods: {
cancel() {
this.updateDialogVisible = false;
this.createDialogVisible = false;
},
update(row) {
this.updateDialogVisible = true;
this.updateUser = row;
},
doUpdate() {
this.$http.put("/user/update", this.updateUser).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.updateDialogVisible = false;
this.$message.success(R.msg);
this.refresh(this.pagination.currentPage);
} else {
this.$message.error(R.msg);
}
})
},
del(id) {
this.delId = id;
},
doDelete() {
this.$http.delete("/user/delete?id=" + this.delId).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.refresh(1);
} else {
this.$message.error(R.msg);
}
})
},
create() {
this.reset();
this.createDialogVisible = true;
},
verify(user) {
return true;
},
reset() {
this.addUser = {
account: '',
password: '',
name: '',
phone: '',
address: ''
};
},
doCreate() {
let flag = this.verify(this.addUser);
if (flag) {
this.$http.post("/user/create", this.addUser).then(result => {
let R = result.data; // R
if (R.code === 2000) {
this.$message.success(R.msg);
this.createDialogVisible = false;
this.refresh(1);
} else {
this.$message.error(R.msg);
}
});
}
},
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
//window.sessionStorage.getItem('token')
this.$http.get("/user/find?page=" + page + "&searchKey=" + this.param).then(result => {
let R = result.data;
this.list = R.data.items;
this.pagination.total = R.data.len * this.pagination.pageSize;
this.pagination.currentPage = page;
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
.my-el-table {
text-align: center;
}
</style>

@ -1,168 +0,0 @@
<template>
<div class="whole">
<el-container>
<el-header>
<div><b style="float: left;margin-top: -20px"><h2 style="color: #d79797">鲜花管理系统</h2></b>
<el-button class="logout" type="warning" @click="logout">退</el-button>
</div>
</el-header>
<el-container>
<el-aside width="200px">
<el-menu
router
:default-active="defaultUrl"
class="el-menu-vertical-demo"
background-color="#545c64"
text-color="#fff"
active-text-color="#d79797"
>
<el-menu-item index="goods">
<i class="el-icon-menu"></i>
商品列表
</el-menu-item>
<el-menu-item index="cart">
<i class="el-icon-document"></i>
<span>购物车</span>
</el-menu-item>
<el-menu-item index="order">
<i class="el-icon-document"></i>
<span>我的订单</span>
</el-menu-item>
<el-menu-item index="updateInfo">
<i class="el-icon-document"></i>
<span>个人信息</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-container>
<!-- 主体区域 -->
<el-main>
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</el-container>
</div>
</template>
<script>
export default {
data() {
return {
activeIndex: 1,
defaultUrl: 'goods',
}
},
//
watch: {
'$route': 'getPath'
},
methods: {
getPath() {
this.defaultUrl = this.$route.path.replace('/', '');
console.log(this.defaultUrl)
},
changePage(path) {
this.$router.push(path)
},
logout() {
this.$router.push('/login');
},
},
}
</script>
<style scoped>
.whole {
height: 100%;
}
.el-header, .el-footer {
background-color: #B3C0D1;
color: #333;
text-align: center;
line-height: 60px;
}
.el-aside {
background-color: #D3DCE6;
color: #333;
text-align: center;
line-height: 200px;
}
.el-menu {
border-right: none;
}
.el-main {
background-color: #E9EEF3;
color: #333;
text-align: center;
line-height: 20px;
}
body > .el-container {
margin-bottom: 40px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
}
.el-container .el-aside {
line-height: 320px;
}
.my-menu {
position: absolute;
margin-top: 10px;
margin-left: 10px;
}
.main {
height: 80%;
}
.el-container {
height: 100%;
}
.el-header {
background-color: #ffffff;
}
.el-aside {
height: 100%;
background-color: #545c64;
}
.el-main {
background-color: #efe8e8;
}
.menu-child-item {
margin-left: 20px;
}
.el-footer {
background-color: cornflowerblue;
}
.welcome {
float: left;
color: cornflowerblue;
}
</style>

@ -1,156 +0,0 @@
<!--
* 购物车挂历页面
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title" style="margin-bottom: 20px">我的购物车</h2>
<el-popconfirm
:title="orderMsg"
@confirm="doBuy"
>
<el-button class="buy" type="primary" slot="reference" @click="buy()"></el-button>
</el-popconfirm>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
class="my-el-table"
>
<el-table-column
label="#"
type="index"
width="150">
</el-table-column>
<el-table-column
prop="flower"
label="商品"
>
</el-table-column>
<el-table-column
prop="amount"
label="数量"
>
</el-table-column>
<el-table-column
prop="price"
label="价格(元)"
>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
list: [],
orderMsg: '',
delId: 0,
}
},
methods: {
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
//window.sessionStorage.getItem('token')
this.$http.get("/cart/queryByAccount?account=" + window.sessionStorage.getItem('token')).then(result => {
let R = result.data;
this.list = R.data;
})
},
del(id){
this.delId = id;
},
buy(){
let amount = 0;
for (let i = 0; i < this.list.length; i++) {
amount = amount + this.list[i].price;
}
this.orderMsg = '总计 ' + amount +' 元,确认购买?';
},
doDelete(){
this.$http.delete("/cart/delete?id=" + this.delId).then(result => {
let R = result.data;
this.$message.success(R.msg);
this.refresh(1);
})
},
doBuy(){
this.$http.get("/cart/buy?account=" + window.sessionStorage.getItem("token")).then(result => {
let R = result.data;
this.$message.success(R.msg);
this.refresh(1);
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
.buy{
float: right;
margin-right: 20px;
margin-bottom: 10px;
}
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
</style>

@ -1,148 +0,0 @@
<!--
* 我的订单
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<!-- 操作面板 -->
<el-card>
<div>
<h2 class="my-title">我的订单</h2>
</div>
<div class="search">
<el-input v-model="searchKey" style="width: 240px" @keyup.enter.native="refresh(1)"
placeholder="账号 / 姓名"></el-input>
<el-button type="primary" icon="el-icon-search" @click="refresh(1)"></el-button>
</div>
</el-card>
<!-- 表格面板 -->
<el-card>
<el-table
:data="list"
class="my-el-table"
>
<el-table-column
label="#"
type="index"
width="150">
</el-table-column>
<el-table-column
prop="flower"
label="商品"
>
</el-table-column>
<el-table-column
prop="amount"
label="数量"
>
</el-table-column>
<el-table-column
prop="price"
label="价格(元)"
>
</el-table-column>
<el-table-column
label="状态"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.state === 1" type="success"></el-tag>
<el-tag v-if="scope.row.state === 0" type="warning"></el-tag>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<el-popconfirm
title="确定删除吗?"
@confirm="doDelete"
>
<el-button type="danger" slot="reference" @click="del(scope.row.id)"></el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
searchKey: '',
accounts: [],
list: [],
delId: 0,
pagination: {
total: 1,
pageSize: 5,
currentPage: 1,
},
}
},
methods: {
pageChange(page) {
this.refresh(page);
},
refresh(page) {
if (page === undefined) {
page = 1;
}
this.$http.get("/order/find?page=" + page + "&searchKey=" + this.searchKey + "&account=" + window.sessionStorage.getItem('token')).then(result => {
let res = result.data;
this.list = res.data.items;
this.pagination.total = res.data.len;
this.pagination.currentPage = page;
})
},
del(id) {
this.delId = id;
},
doDelete() {
this.$http.delete("/order/delete?id=" + this.delId).then(result => {
let R = result.data;
this.$message.success(R.msg);
this.refresh(1);
})
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
.search-input {
width: 300px;
}
.updateForm {
width: 80%;
}
.btn-release {
float: right;
margin-top: 10px;
margin-right: 50px;
}
.form-releaseTask {
height: 300px;
}
.input-content-task {
width: 500px;
}
</style>

@ -1,182 +0,0 @@
<!--
* 个人信息修改页面
*
* @Author: ShanZhu
* @Date: 2024-01-24
-->
<template>
<div>
<el-card>
<div class="info-first-card">
<h2 class="user-info-title">我的个人信息</h2>
<el-button class="save" @click="update" type="primary" style="margin-bottom: 20px">修改</el-button>
</div>
</el-card>
<el-card class="box-card user-info-card">
<div>
<div class="user-info-data">
<el-form :model="user" label-width="120px">
<el-form-item label="姓名:">
{{user.name}}
</el-form-item>
<el-form-item label="账号:">
{{user.account}}
</el-form-item>
<el-form-item label="密码:">
{{user.password}}
</el-form-item>
<el-form-item label="手机:">
{{user.phone}}
</el-form-item>
<el-form-item label="地址:">
{{user.address}}
</el-form-item>
</el-form>
</div>
</div>
<div>
<el-dialog
title="修改用户信息"
:visible.sync="updateDialogVisible"
width="50%"
>
<div>
<el-form :model="updateUser" label-width="80px" size="small">
<el-form-item label="">
<el-input class="small-input" type="hidden" v-model="updateUser.id"></el-input>
</el-form-item>
<el-form-item label="账号">
<el-input class="small-input" readonly="readonly" v-model="updateUser.account"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input class="small-input" v-model="updateUser.name"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input class="small-input" v-model="updateUser.password"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input class="small-input" type="number" v-model="updateUser.phone"></el-input>
</el-form-item>
<el-form-item label="地址">
<el-input class="small-input" v-model="updateUser.address"></el-input>
</el-form-item>
<div class="create-dialog-btn">
<el-button type="primary" @click="doUpdate"></el-button>
<el-button type="warning" @click="cancel"></el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
user: {
id: "",
account: window.sessionStorage.getItem('token'),
name: '',
password: '',
phone: '',
address: '',
},
updateDialogVisible: false,
updateUser: {
id: '',
account: '',
name: '',
password: '',
phone: '',
address: ''
},
}
},
methods: {
cancel() {
this.updateDialogVisible = false;
this.createDialogVisible = false;
},
update() {
this.updateDialogVisible = true;
this.updateUser.id = this.user.id;
this.updateUser.name = this.user.name;
this.updateUser.account = this.user.account;
this.updateUser.password = this.user.password;
this.updateUser.phone = this.user.phone;
this.updateUser.address = this.user.address;
},
doUpdate() {
this.$http.put("/user/update", this.updateUser).then(res => {
let ans = res.data;
if (ans.code === 2000) {
this.freshPage();
this.updateDialogVisible = false;
this.$message.success(ans.msg);
} else {
this.$message.error(ans.msg);
}
})
},
freshPage() {
this.$http.get("/user/queryInfoByAccount?account=" + window.sessionStorage.getItem('token')).then(res => {
let R = res.data; // R
this.user = R.data;
})
},
},
created() {
this.freshPage();
}
}
</script>
<style scoped>
.user-info-card {
margin-top: 60px;
}
.user-info-title {
color: cornflowerblue;
float: left;
margin-top: -5px;
}
.user-info-data {
margin-top: 15px;
margin-left: 45%;
}
br {
margin-top: 10px;
}
b {
margin-left: 100px;
}
.el-form-item {
width: 300px;
}
.save {
float: right;
margin-right: 10px;
margin-top: -10px;
}
.el-form-item{
margin-left: -5%;
}
</style>

@ -1,29 +0,0 @@
<template>
<div>
<el-card>
<h1>403</h1>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
refresh() {
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
</style>

@ -1,29 +0,0 @@
<template>
<div>
<el-card>
<h1>404</h1>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
refresh() {
},
},
created() {
this.refresh();
}
}
</script>
<style scoped>
</style>

@ -1,57 +0,0 @@
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Vuex from 'vuex';
import axios from 'axios'
import global from './assets/css/global.css'
import VueWechatTitle from 'vue-wechat-title';
Vue.use(Vuex);
Vue.use(VueWechatTitle);
// axios 请求拦截器
axios.interceptors.request.use(config => {
config.headers.Authorization = window.sessionStorage.getItem('token');
return config;
});
// 配置页面标题
router.afterEach(function (to, from) {
if(to.meta.title){
document.title = to.meta.title;
}
});
Vue.prototype.$http = axios;
const store = new Vuex.Store({
state: {
// 存储token
Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
},
mutations: {
// 修改token并将token存入localStorage
changeLogin(state, user) {
state.Authorization = user.Authorization;
localStorage.setItem('Authorization', user.Authorization);
}
}
});
export default store;
Vue.use(ElementUI);
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
render: h => h(App),
components: {App},
template: '<App/>'
});
axios.defaults.baseURL = 'http://localhost:8081';

@ -1,105 +0,0 @@
import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Index from '@/components/Index'
import Error from '@/components/utils/404'
import Forbidden from '@/components/utils/403'
import Goods from '@/components/Goods'
// admin/menu
import Home from '@/components/admin/Home'
import UserList from '@/components/admin/menu/UserList'
import TypeList from '@/components/admin/menu/TypeList'
import FlowerList from '@/components/admin/menu/FlowerList'
import OrderList from '@/components/admin/menu/OrderList'
// user
import UserHome from '@/components/user/UserHome'
import UpdateInfo from '@/components/user/menu/UpdateInfo'
import Cart from '@/components/user/menu/Cart'
import Order from '@/components/user/menu/Order'
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
redirect: 'login',
},
{
path: '/404',
meta: {title: "页面走丢了"},
component: Error
},
{
path: '/403',
meta: {title: "没有权限"},
component: Forbidden
},
{
path: '/login',
meta: {title: "登录"},
component: Login
},
// 用户页面
{
path: '/user',
component: UserHome,
redirect: '/goods',
children: [
{
path: '/goods',
meta: {title: "商品列表"},
component: Goods
}, {
path: '/updateInfo',
meta: {title: "个人信息"},
component: UpdateInfo
},
{
path: '/order',
meta: {title: "我的订单"},
component: Order
},
{
path: '/cart',
meta: {title: "购物车"},
component: Cart
},
]
},
// 管理员页面
{
path: '/home',
component: Home,
// 为 Home 页创建子路由,并默认跳转。
redirect: '/index',
children: [
{
path: '/index',
meta: {title: "网站首页"},
component: Index
},
{
path: '/users',
meta: {title: "用户管理"},
component: UserList
},
{
path: '/flowers',
meta: {title: "商品管理"},
component: FlowerList
},
{
path: '/flower_type',
meta: {title: "种类管理"},
component: TypeList
},
{
path: '/orders',
meta: {title: "订单管理"},
component: OrderList
},
]
}
]
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 816 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/>
</parent>
<groupId>com.shanzhu</groupId>
<artifactId>flower-backend</artifactId>
<version>1.0.0-RELEASE</version>
<name>flower-backend</name>
<packaging>jar</packaging>
<description>花店商城后台</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,31 @@
package com.shanzhu.flower;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* SpringBoot
* "run BackendApplication"
* <p>
* SpringBoothttps://www.php.cn/faq/498384.html
*
* @author: ShanZhu
* @date: 2023-01-24
*/
@Slf4j
@SpringBootApplication
@MapperScan("com.shanzhu.flower.dao")
public class BackendApplication {
public static void main(String[] args) {
//SpringBoot 执行启动
SpringApplication.run(BackendApplication.class, args);
log.info("=====================项目后端启动成功============================");
}
}

@ -0,0 +1,29 @@
package com.shanzhu.flower.config;
/**
*
*
*
*/
public class Constant {
// 默认分页大小,用于分页查询时每页显示的记录数。
// 默认值为5可根据实际需求调整。
public static int PAGE_SIZE = 5;
//
// 商品展示页面的分页大小。
// 用于商品列表展示时每页显示的商品数量。
// 默认值为9可根据页面布局调整。
//
public static int SHOW_PAGE_SIZE = 9;
// 图片静态文件的存储路径。
// 用于存放项目中使用的图片资源。
// 路径为项目根目录下的static/imgs/文件夹。
public static String IMG_USE_PATH = "static/imgs/";
// 默认图片文件名。
// 当没有指定图片时,使用此默认图片作为占位图。
// 文件名为img.jpg位于IMG_USE_PATH路径下。
public static String DEFAULT_IMG = "img.jpg";
}

@ -0,0 +1,186 @@
package com.shanzhu.flower.config;
/**
* HTTP
* HTTP便
*
*
* @author: ShanZhu
* @date: 2024-01-24
*/
public class HttpMsg {
// 表单输入错误的提示信息。
// 当用户提交的表单数据不符合要求时返回此消息。
public static String ERROR_INPUT = "表单信息不正确";
// 用户名或密码错误的提示信息。
// 当用户登录时输入的用户名或密码不匹配时返回此消息。
public static String ERROR_VERIFY = "用户名或密码错误";
// 新建用户成功的提示信息。
// 当用户注册成功时返回此消息。
public static String ADD_USER_OK = "新建用户成功";
// 新建用户失败的提示信息(账号已存在)。
// 当用户注册时输入的账号已存在时返回此消息。
public static String ADD_USER_FAILED = "新建用户失败,该账号已存在";
// 修改用户信息成功的提示信息。
// 当用户更新个人信息成功时返回此消息。
public static String UPDATE_USER_OK = "修改用户信息成功";
// 修改用户信息失败的提示信息。
// 当用户更新个人信息失败时返回此消息。
public static String UPDATE_USER_FAILED = "修改用户信息失败";
// 删除用户信息成功的提示信息。
// 当管理员删除用户信息成功时返回此消息。
public static String DELETE_USER_OK = "删除用户信息成功";
// 删除用户信息失败的提示信息。
// 当管理员删除用户信息失败时返回此消息。
public static String DELETE_USER_FAILED = "删除用户信息失败";
// 删除类型成功的提示信息。
// 当管理员删除花朵类型成功时返回此消息。
public static String DELETE_TYPE_OK = "删除类型成功";
// 删除类型失败的提示信息(有商品绑定此类型)。
// 当管理员删除花朵类型失败(因为有商品绑定此类型)时返回此消息。
//
public static String DELETE_TYPE_FAILED = "有商品绑定此类型,删除类型失败";
// 修改类型成功的提示信息。
// 当管理员修改花朵类型成功时返回此消息。
public static String UPDATE_TYPE_OK = "修改类型成功";
// 修改类型失败的提示信息(有商品绑定此类型)。
// 当管理员修改花朵类型失败(因为有商品绑定此类型)时返回此消息。
public static String UPDATE_TYPE_FAILED = "有商品绑定此类型,修改类型失败";
// 新建类型成功的提示信息。
// 当管理员新建花朵类型成功时返回此消息。
public static String ADD_TYPE_OK = "新建类型成功";
// 新建类型失败的提示信息(该类型名称已存在)。
// 当管理员新建花朵类型失败(因为该类型名称已存在)时返回此消息。
public static String ADD_TYPE_FAILED = "新建类型失败,该类型名称已存在";
// 删除商品成功的提示信息。
// 当管理员删除商品成功时返回此消息。
public static String DELETE_FLOWER_OK = "删除商品成功";
//
// 删除商品失败的提示信息(有商品绑定此类型)。
// 当管理员删除商品失败(因为有商品绑定此类型)时返回此消息。
//
public static String DELETE_FLOWER_FAILED = "有商品绑定此类型,删除商品失败";
//
// 修改商品成功的提示信息。
// 当管理员修改商品成功时返回此消息。
//
public static String UPDATE_FLOWER_OK = "修改商品成功";
//
// 修改商品失败的提示信息(有商品绑定此类型)。
// 当管理员修改商品失败(因为有商品绑定此类型)时返回此消息。
//
public static String UPDATE_FLOWER_FAILED = "有商品绑定此类型,修改商品失败";
//
// 新建商品成功的提示信息。
// 当管理员新建商品成功时返回此消息。
//
public static String ADD_FLOWER_OK = "新建商品成功";
//
// 新建商品失败的提示信息(该商品名称已存在)。
// 当管理员新建商品失败(因为该商品名称已存在)时返回此消息。
//
public static String ADD_FLOWER_FAILED = "新建商品失败,该商品名称已存在";
//
// 当前没有花朵种类的提示信息。
// 当系统中没有花朵种类时返回此消息,提示管理员需要先创建种类。
//
public static String NO_TYPE_NOW = "当前没有花朵种类,请先创建!";
//
// 更新图片成功的提示信息。
// 当用户或管理员更新图片成功时返回此消息。
//
public static String UPDATE_PIC_OK = "更新图片成功";
//
// 更新图片失败的提示信息。
// 当用户或管理员更新图片失败时返回此消息。
//
public static String UPDATE_PIC_FAILED = "更新图片失败";
//
// 参数不合法的提示信息。
// 当请求中包含的参数不符合要求时返回此消息。
//
public static String INVALID_PARAM = "参数不合法";
//
// 登录失效的提示信息。
// 当用户登录状态失效时返回此消息,提示用户重新登录。
//
public static String INVALID_USER = "登录失效,请重新登录";
//
// 加入购物车成功的提示信息。
// 当用户将商品加入购物车成功时返回此消息。
//
public static String ADD_CART_OK = "加入购物车成功";
//
// 加入购物车失败的提示信息。
// 当用户将商品加入购物车失败时返回此消息。
//
public static String ADD_CART_FAILED = "加入购物车失败";
//
// 下单成功的提示信息。
// 当用户下单成功时返回此消息。
//
public static String BUY_OK = "下单成功";
//
// 订单发货状态更新成功的提示信息。
// 当管理员更新订单发货状态成功时返回此消息。
//
public static String UPDATE_ORDER_OK = "订单发货状态更新成功";
//
// 错误的文件类型的提示信息。
// 当上传的文件类型不符合要求时返回此消息。
//
public static String ERROR_FILE_TYPE = "错误的文件类型";
//
// 商品上架成功的提示信息。
// 当管理员将商品上架成功时返回此消息。
//
public static String GOODS_UP_OK = "商品上架成功";
//
// 商品下架成功的提示信息。
// 当管理员将商品下架成功时返回此消息。
//
public static String GOODS_DOWN_OK = "商品下架成功";
}

@ -0,0 +1,56 @@
package com.shanzhu.flower.config;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* OPTIONS
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@Component
public class ProcessInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
// 设置允许跨域访问的来源,允许所有来源
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
// 设置允许的请求头字段
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
// 设置允许的请求方法
httpServletResponse.setHeader("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
// 设置服务器信息头,表明服务器使用的服务器软件
httpServletResponse.setHeader("X-Powered-By", "Jetty");
// 获取请求的方法类型
String method = httpServletRequest.getMethod();
// 判断是否为OPTIONS预请求
if (method.equals("OPTIONS")) {
// 如果是OPTIONS请求直接返回200状态码表示预请求通过
httpServletResponse.setStatus(200);
return false; // 不继续处理后续的请求
}
// 如果不是OPTIONS请求继续后续的处理流程
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
// 在请求处理之后进行调用在Controller方法之后
// 用于修改ModelAndView对象例如添加额外的模型数据或修改视图
// 本拦截器中未实现具体逻辑
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
// 在整个请求结束之后被调用,主要用于进行资源清理工作
// 例如关闭数据库连接、释放资源等
// 本拦截器中未实现具体逻辑
}
}

@ -0,0 +1,27 @@
package com.shanzhu.flower.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Web MVCSpring MVC
*
* -
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 添加自定义的拦截器ProcessInterceptor
// ProcessInterceptor用于处理跨域请求和预请求OPTIONS方法
registry.addInterceptor(new ProcessInterceptor())
// 指定拦截器的应用路径模式
// 使用"/**"表示拦截所有请求路径
.addPathPatterns("/**");
}
}

@ -0,0 +1,166 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.Constant;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.dao.FlowersDao;
import com.shanzhu.flower.entity.Cart;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.service.CartService;
import com.shanzhu.flower.service.OrderService;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.util.StringUtil;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* RESTful API
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@RestController
@RequestMapping("cart")
public class CartController {
@Resource
private CartService cartService; // 注入购物车服务层
@Resource
private OrderService orderService; // 注入订单服务层
@Resource
private FlowersDao flowersDao; // 注入花朵数据访问对象
/**
*
*
*
* @param account
* @return
*/
@RequestMapping("/queryByAccount")
R queryByAccount(@RequestParam("account") String account) {
R r = new R(); // 创建响应对象
// 检查用户账号是否为空
if (StringUtil.isEmpty(account)) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM); // 参数不合法
}
// 查询购物车中的商品
List<Cart> carts = cartService.queryByAccount(account);
// 计算每个商品的总价
for (Cart cart : carts) {
float price = flowersDao.queryPrice(cart.getFid()); // 查询商品单价
cart.setPrice(cart.getAmount() * price); // 设置总价
}
return r.setCode(2000).setData(carts); // 返回成功响应
}
/**
*
*
*
* @param page
* @param searchKey
* @param account
* @return
*/
@RequestMapping("/find")
R find(
@RequestParam("page") int page,
@RequestParam("searchKey") String searchKey,
@RequestParam("account") String account
) {
R r = new R(); // 创建响应对象
// 创建返回数据的Map
Map map = new HashMap<>();
// 查询购物车中的商品
List carts = cartService.find(searchKey, account);
// 如果查询结果为空,直接返回
if (carts == null) {
return r.setCode(2000);
}
// 计算分页信息
int totalSize = carts.size(); // 总记录数
int pageSize = Constant.PAGE_SIZE; // 每页大小
int totalPages = (totalSize + pageSize - 1) / pageSize; // 总页数
// 获取当前页的数据
int start = (page - 1) * pageSize;
int end = Math.min(start + pageSize, totalSize);
List items = carts.subList(start, end);
// 将分页信息和当前页数据放入Map
map.put("items", items);
map.put("len", totalPages);
return r.setCode(2000).setData(map); // 返回成功响应
}
/**
*
*
*
* @param account
* @return
*/
@RequestMapping("/buy")
R buy(@RequestParam("account") String account) {
R r = new R(); // 创建响应对象
// 查询该用户的购物车
List<Cart> carts = (List) queryByAccount(account).getData();
// 遍历购物车中的商品
for (Cart cart : carts) {
// 增加订单数据
orderService.add(cart);
// 删除购物车数据
cartService.delete(cart.getId());
}
return r.setCode(2000).setMsg(HttpMsg.BUY_OK); // 返回购买成功响应
}
/**
*
*
*
* @param cart
* @return
*/
@RequestMapping("/create")
R create(@RequestBody Cart cart) {
R r = new R(); // 创建响应对象
// 调用服务层添加购物车
int ans = cartService.add(cart);
// 根据返回结果设置响应
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.ADD_CART_OK); // 添加成功
}
return r.setCode(4000).setMsg(HttpMsg.ADD_CART_FAILED); // 添加失败
}
/**
*
*
*
* @param cart
* @return
*/
@RequestMapping("/update")
R update(@RequestBody Cart cart) {
R r = new R(); // 创建响应对象
// 调用服务层更新购物车
int ans = cartService.update(cart);
// 根据返回结果设置响应
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK); // 更新成功
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED); // 更新失败
}
/**
*
* ID
*
* @param id ID
* @return
*/
@DeleteMapping("/delete")
R delete(@RequestParam("id") int id) {
R r = new R(); // 创建响应对象
// 调用服务层删除购物车
int ans = cartService.delete(id);
// 根据返回结果设置响应
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK); // 删除成功
}
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED); // 删除失败
}
}

@ -0,0 +1,259 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.Constant;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.dao.FlowersDao;
import com.shanzhu.flower.entity.Flower;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.service.FlowersService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
*
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@RestController
@RequestMapping("flower")
public class FlowerController {
@Value("${uploadPath}")
private String uploadPath; // 注入文件上传路径配置
@Resource
private FlowersService flowerService; // 注入鲜花业务逻辑服务
@Resource
private FlowersDao flowersDao; // 注入鲜花数据访问对象
/**
*
*
* @param page
* @param searchKey
* @param searchType
* @return
*/
@RequestMapping("/find")
R find(
@RequestParam("page") int page,
@RequestParam("searchKey") String searchKey,
@RequestParam("searchType") String searchType
) {
R r = new R();
List<Flower> flowers = flowerService.find(searchKey, searchType); // 调用服务层查询鲜花列表
if (flowers == null) {
return r.setCode(2000); // 返回查询失败状态码
}
return getResponse(flowers, page, Constant.SHOW_PAGE_SIZE, r); // 构建分页响应数据
}
/**
*
*
* @param page
* @param searchKey
* @return
*/
@RequestMapping("/findAll")
R findAll(@RequestParam("page") int page, @RequestParam("searchKey") String searchKey) {
R r = new R();
List<Flower> flowers = flowerService.findAll(searchKey); // 调用服务层查询所有鲜花
if (flowers == null) {
return r.setCode(2000); // 返回查询失败状态码
}
return getResponse(flowers, page, Constant.PAGE_SIZE, r); // 构建分页响应数据
}
/**
*
*
* @param flower
* @return
*/
@RequestMapping("/create")
R create(@RequestBody Flower flower) {
R r = new R();
int ans = flowerService.add(flower); // 调用服务层添加鲜花
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.ADD_FLOWER_OK); // 返回添加成功信息
}
return r.setCode(4000).setMsg(HttpMsg.ADD_FLOWER_FAILED); // 返回添加失败信息
}
/**
*
*
* @param flower
* @return
*/
@RequestMapping("/update")
R update(@RequestBody Flower flower) {
R r = new R();
int ans = flowerService.update(flower); // 调用服务层更新鲜花信息
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_FLOWER_OK); // 返回更新成功信息
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_FLOWER_FAILED); // 返回更新失败信息
}
/**
*
*
* @param flower
* @return
*/
@RequestMapping("/changeState")
R changeState(@RequestBody Flower flower) {
R r = new R();
flowersDao.changeState(flower); // 直接调用DAO层修改商品状态
String msg = flower.getState() == 1 ? HttpMsg.GOODS_UP_OK : HttpMsg.GOODS_DOWN_OK; // 判断上下架状态
return r.setCode(2000).setMsg(msg); // 返回操作成功信息
}
/**
*
*
* @param file
* @return
*/
@RequestMapping("/updateImg")
R updateImg(@RequestParam("file") MultipartFile file) {
R r = new R();
// 只接收 jpg/png 图片
String filename = file.getOriginalFilename();
if (!filename.endsWith(".jpg") && !filename.endsWith(".png")) {
return r.setCode(4000).setMsg(HttpMsg.ERROR_FILE_TYPE); // 返回文件类型错误信息
}
String img_guid = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg"; // 生成唯一图片文件名
try {
savePic(file.getInputStream(), img_guid); // 保存图片文件
return r.setCode(2000).setMsg(HttpMsg.UPDATE_PIC_OK).setData(img_guid); // 返回上传成功信息
} catch (IOException e) {
return r.setCode(4000).setMsg(HttpMsg.UPDATE_PIC_FAILED); // 返回上传失败信息
}
}
/**
* guid
*
* @param guid guid
* @param id id
* @return
*/
@PutMapping("/updateImgGuid")
R updateImgGuid(@RequestParam("guid") String guid, @RequestParam("id") int id) {
R r = new R();
int ans = flowerService.updateImg(guid, id); // 调用服务层更新图片GUID
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_PIC_OK); // 返回更新成功信息
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_PIC_FAILED); // 返回更新失败信息
}
/**
*
*
* @param id id
* @return
*/
@DeleteMapping("/delete")
R delete(@RequestParam("id") int id) {
R r = new R();
int ans = flowerService.delete(id); // 调用服务层删除鲜花
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_FLOWER_OK); // 返回删除成功信息
}
return r.setCode(4000).setMsg(HttpMsg.DELETE_FLOWER_FAILED); // 返回删除失败信息
}
/**
*
* @param inputStream
* @param fileName
*/
private void savePic(InputStream inputStream, String fileName) {
OutputStream os = null;
try {
String path = uploadPath;
// 1K的数据缓冲
byte[] bs = new byte[1024];
// 读取到的数据长度
int len;
// 输出的文件流保存到本地文件
os = new FileOutputStream(new File(path + fileName));
// 开始读取
while ((len = inputStream.read(bs)) != -1) {
os.write(bs, 0, len); // 将数据写入文件
}
} catch (Exception e) {
e.printStackTrace(); // 打印异常堆栈信息
} finally {
// 完毕,关闭所有链接
try {
os.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace(); // 打印关闭流异常信息
}
}
}
/**
*
* @param flowers
* @param page
* @param pageSize
* @param r
* @return
*/
private R getResponse(List<Flower> flowers, int page, int pageSize, R r) {
Map<String, Object> map = new HashMap<>();
// 计算当前页数据
List<Flower> items = flowers.size() >= page * pageSize ?
flowers.subList((page - 1) * pageSize, page * pageSize)
: flowers.subList((page - 1) * pageSize, flowers.size());
// 计算总页数
int len = flowers.size() % pageSize == 0 ? flowers.size() / pageSize
: (flowers.size() / pageSize + 1);
// 处理图片路径
for (Flower item : items) {
if (item.getImg_guid() == null) {
item.setImg_guid(Constant.DEFAULT_IMG); // 设置默认图片
}
item.setImg_guid(Constant.IMG_USE_PATH + item.getImg_guid()); // 添加图片访问路径前缀
}
map.put("items", items); // 分页数据
map.put("len", len); // 总页数
return r.setCode(2000).setData(map); // 返回分页响应
}
}

@ -0,0 +1,117 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.Constant;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.entity.Species;
import com.shanzhu.flower.service.SpeciesService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
@RestController
@RequestMapping("species")
public class FlowerTypeController {
@Resource
private SpeciesService speciesService; // 注入鲜花种类业务逻辑服务
/**
*
* @return
*/
@RequestMapping("/findAll")
R findAll() {
R r = new R();
List<Species> all = speciesService.findAll(); // 调用服务层查询所有鲜花种类
if (all.size() <= 0) {
return r.setCode(4000).setMsg(HttpMsg.NO_TYPE_NOW); // 返回无种类信息
}
return r.setCode(2000).setData(all); // 返回成功及种类列表
}
/**
*
* @param page
* @param searchKey
* @return
*/
@RequestMapping("/find")
R find(@RequestParam("page") int page, @RequestParam("searchKey") String searchKey) {
R r = new R();
Map<String, Object> map = new HashMap<>();
List<Species> list = speciesService.find(searchKey); // 调用服务层查询符合条件的种类
if (list == null) {
return r.setCode(2000); // 返回查询失败状态
}
// 分页逻辑 - 获取当前页数据
List<Species> items = list.size() >= page * Constant.PAGE_SIZE ?
list.subList((page - 1) * Constant.PAGE_SIZE, page * Constant.PAGE_SIZE)
: list.subList((page - 1) * Constant.PAGE_SIZE, list.size());
// 计算总页数
int len = list.size() % Constant.PAGE_SIZE == 0 ? list.size() / Constant.PAGE_SIZE
: (list.size() / Constant.PAGE_SIZE + 1);
map.put("items", items); // 当前页数据
map.put("len", len); // 总页数
return r.setCode(2000).setData(map); // 返回分页结果
}
/**
*
* @param species
* @return
*/
@RequestMapping("/create")
R create(@RequestBody Species species) {
R r = new R();
try {
speciesService.add(species); // 调用服务层添加种类
return r.setCode(2000).setMsg(HttpMsg.ADD_TYPE_OK); // 返回添加成功信息
} catch (Exception e) {
return r.setCode(4000).setMsg(HttpMsg.ADD_TYPE_FAILED); // 返回添加失败信息
}
}
/**
*
* @param species
* @return
*/
@RequestMapping("/update")
R update(@RequestBody Species species) {
R r = new R();
try {
speciesService.update(species); // 调用服务层更新种类信息
return r.setCode(2000).setMsg(HttpMsg.UPDATE_TYPE_OK); // 返回更新成功信息
} catch (Exception e) {
return r.setCode(4000).setMsg(HttpMsg.UPDATE_TYPE_FAILED); // 返回更新失败信息
}
}
/**
*
* @param id ID
* @return
*/
@DeleteMapping("/delete")
R delete(@RequestParam("id") int id) {
R r = new R();
try {
speciesService.delete(id); // 调用服务层删除种类
return r.setCode(2000).setMsg(HttpMsg.DELETE_TYPE_OK); // 返回删除成功信息
} catch (Exception e) {
return r.setCode(4000).setMsg(HttpMsg.DELETE_TYPE_FAILED); // 返回删除失败信息
}
}
}

@ -0,0 +1,55 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.dao.LoginDao;
import com.shanzhu.flower.entity.LoginForm;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.entity.User;
import com.shanzhu.flower.util.VerifyUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
*
* RESTful API
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@RestController
@RequestMapping("login")
public class LoginController {
@Resource
private LoginDao loginDao; // 注入登录数据访问对象
/**
*
*
*
* @param form
* @return
*/
@RequestMapping("/doLogin")
R doLogin(@RequestBody LoginForm form) {
R r = new R(); // 创建响应对象
// 验证登录表单信息
if (!VerifyUtil.verifyLoginForm(form)) {
return r.setCode(4000).setMsg(HttpMsg.ERROR_INPUT); // 表单信息不正确
}
// 查询用户信息
User loginUser = loginDao.login(form);
if (loginUser != null) {
// 登录成功,返回用户信息和欢迎消息
return r.setCode(2000).setMsg("欢迎您:" + loginUser.getName()).setData(loginUser);
}
// 登录失败,返回错误信息
return r.setCode(4000).setMsg(HttpMsg.ERROR_VERIFY);
}
}

@ -0,0 +1,164 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.Constant;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.dao.OrderDao;
import com.shanzhu.flower.dao.UserDao;
import com.shanzhu.flower.entity.Order;
import com.shanzhu.flower.entity.OrderVo;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.entity.User;
import com.shanzhu.flower.service.OrderService;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.util.StringUtil;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* RESTful API
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@RestController
@RequestMapping("order")
public class OrderController {
@Resource
private OrderService orderService; // 注入订单服务层
@Resource
private UserDao userDao; // 注入用户数据访问对象
@Resource
private OrderDao orderDao; // 注入订单数据访问对象
/**
*
*
*
* @param account
* @return
*/
@RequestMapping("/queryByAccount")
R queryByAccount(@RequestParam("account") String account) {
R r = new R(); // 创建响应对象
// 检查账号是否为空
if (StringUtil.isEmpty(account)) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM); // 参数不合法
}
// 查询订单
List orders = orderService.queryByAccount(account);
return r.setCode(2000).setData(orders); // 返回订单列表
}
/**
*
*
*
* @param page
* @param searchKey
* @param account
* @return
*/
@RequestMapping("/find")
R find(@RequestParam("page") int page, @RequestParam("searchKey") String searchKey, @RequestParam("account") String account) {
R r = new R(); // 创建响应对象
Map map = new HashMap<>(); // 创建返回数据的Map
// 查询订单列表
List orders = orderService.find(searchKey, account);
if (orders == null) {
return r.setCode(2000); // 没有查询到数据
}
// 将订单列表放入Map
map.put("items", orders);
map.put("len", orders.size());
return r.setCode(2000).setData(map); // 返回分页后的订单列表
}
/**
*
*
*
* @param page
* @param searchKey
* @return
*/
@RequestMapping("/findAll")
R findAll(@RequestParam("page") int page, @RequestParam("searchKey") String searchKey) {
R r = new R(); // 创建响应对象
Map map = new HashMap<>(); // 创建返回数据的Map
// 查询所有订单
List orders = orderService.findAll(searchKey);
if (orders == null) {
return r.setCode(2000); // 没有查询到数据
}
// 计算分页信息
int totalSize = orders.size(); // 总记录数
int pageSize = Constant.PAGE_SIZE; // 每页大小
int totalPages = (totalSize + pageSize - 1) / pageSize; // 总页数
// 获取当前页的数据
int start = (page - 1) * pageSize;
int end = Math.min(start + pageSize, totalSize);
List<Order> items = orders.subList(start, end);
// 将订单信息转换为OrderVo
List vos = new ArrayList<>();
for (Order item : items) {
User user = userDao.queryById(item.getUid()); // 查询用户信息
OrderVo vo = new OrderVo(); // 创建OrderVo对象
vo.setAddress(user.getAddress()).setPhone(user.getPhone()).setUsername(user.getName())
.setAmount(item.getAmount()).setFlower(item.getFlower()).setId(item.getId())
.setUid(item.getUid()).setOrder_guid(item.getOrder_guid()).setPrice(item.getPrice())
.setState(item.getState());
vos.add(vo); // 添加到列表
}
// 将分页信息和订单列表放入Map
map.put("items", vos);
map.put("len", totalPages);
return r.setCode(2000).setData(map); // 返回分页后的订单列表
}
/**
*
*
*
* @param order
* @return
*/
@RequestMapping("/update")
R update(@RequestBody Order order) {
R r = new R(); // 创建响应对象
// 调用服务层更新订单
int ans = orderService.update(order);
// 根据返回结果设置响应
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK); // 更新成功
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED); // 更新失败
}
/**
*
*
*
* @param order
* @return
*/
@RequestMapping("/changeState")
R changeState(@RequestBody Order order) {
orderDao.changeState(order); // 调用数据访问对象更新订单状态
return new R().setCode(2000).setMsg(HttpMsg.UPDATE_ORDER_OK); // 返回成功响应
}
/**
*
* ID
*
* @param id ID
* @return
*/
@DeleteMapping("/delete")
R delete(@RequestParam("id") int id) {
R r = new R(); // 创建响应对象
// 调用服务层删除订单
int ans = orderService.delete(id);
// 根据返回结果设置响应
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK); // 删除成功
}
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED); // 删除失败
}
}

@ -0,0 +1,156 @@
package com.shanzhu.flower.controller;
import com.shanzhu.flower.config.Constant;
import com.shanzhu.flower.config.HttpMsg;
import com.shanzhu.flower.entity.R;
import com.shanzhu.flower.entity.User;
import com.shanzhu.flower.service.UserService;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.util.StringUtil;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* RESTful API
*
* @author: ShanZhu
* @date: 2024-01-24
*/
@RestController
@RequestMapping("user")
public class UserController {
@Resource
private UserService userService; // 注入用户服务层
/**
*
*
*
* @param account
* @return
*/
@RequestMapping("/queryInfoByAccount")
R queryInfoByAccount(@RequestParam("account") String account) {
R r = new R(); // 创建响应对象
// 检查账号是否为空
if (StringUtil.isEmpty(account)) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_PARAM); // 参数不合法
}
// 查询用户信息
User loginUser = userService.queryInfo(account);
if (loginUser == null) {
return r.setCode(4000).setMsg(HttpMsg.INVALID_USER); // 用户不存在
}
return r.setCode(2000).setData(loginUser); // 返回用户信息
}
/**
*
*
*
* @param page
* @param searchKey
* @return
*/
@RequestMapping("/find")
R find(@RequestParam("page") int page, @RequestParam("searchKey") String searchKey) {
R r = new R(); // 创建响应对象
Map<String, Object> map = new HashMap<>(); // 创建返回数据的Map
// 查询用户列表
List<User> users = userService.find(searchKey);
if (users == null) {
return r.setCode(2000); // 没有查询到数据
}
// 计算分页信息
int totalSize = users.size(); // 总记录数
int pageSize = Constant.PAGE_SIZE; // 每页大小
int totalPages = (totalSize + pageSize - 1) / pageSize; // 总页数
// 获取当前页的数据
int start = (page - 1) * pageSize;
int end = Math.min(start + pageSize, totalSize);
List<User> items = users.subList(start, end);
// 将分页信息和当前页数据放入Map
map.put("items", items);
map.put("len", totalPages);
return r.setCode(2000).setData(map); // 返回分页后的用户列表
}
/**
*
*
*
* @param user
* @return
*/
@RequestMapping("/create")
R create(@RequestBody User user) {
R r = new R(); // 创建响应对象
// 调用服务层添加用户
int ans = userService.add(user);
// 根据返回结果设置响应
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.ADD_USER_OK); // 添加成功
}
return r.setCode(4000).setMsg(HttpMsg.ADD_USER_FAILED); // 添加失败
}
/**
*
*
*
* @param user
* @return
*/
@RequestMapping("/update")
R update(@RequestBody User user) {
R r = new R(); // 创建响应对象
// 调用服务层更新用户
int ans = userService.update(user);
// 根据返回结果设置响应
if (ans >= 0) {
return r.setCode(2000).setMsg(HttpMsg.UPDATE_USER_OK); // 更新成功
}
return r.setCode(4000).setMsg(HttpMsg.UPDATE_USER_FAILED); // 更新失败
}
/**
*
* ID
*
* @param id ID
* @return
*/
@DeleteMapping("/delete")
R delete(@RequestParam("id") int id) {
R r = new R(); // 创建响应对象
// 调用服务层删除用户
int ans = userService.delete(id);
// 根据返回结果设置响应
if (ans == 1) {
return r.setCode(2000).setMsg(HttpMsg.DELETE_USER_OK); // 删除成功
}
return r.setCode(4000).setMsg(HttpMsg.DELETE_USER_FAILED); // 删除失败
}
}

@ -0,0 +1,92 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.Cart;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CartDao {
//
// 根据搜索关键词和用户账号查询购物车
// 查询购物车中包含指定搜索关键词的商品,并且属于指定用户账号的记录。
//
// @param searchKey 搜索关键词
// @param account 用户账号
// @return 购物车列表
//
@Select("select * from carts where flower like concat('%',#{searchKey},'%') and account = #{account};")
List<Cart> find(@Param("searchKey") String searchKey, @Param("account") String account);
//
// 查询所有购物车记录
// 查询购物车表中的所有记录。
//
// @return 购物车记录列表
//
@Select("select * from carts;")
List<Cart> findAll();
//
// 检查商品是否已添加到购物车
// 查询指定用户是否已将指定商品添加到购物车。
//
// @param cart 购物车对象包含商品IDfid和用户IDuid
// @return 购物车记录如果已添加则返回记录否则返回null
//
@Select("select * from carts where fid = #{fid} and uid = #{uid};")
Cart checkIsAdded(Cart cart);
//
// 增加购物车中商品的数量
// 将指定用户购物车中指定商品的数量加1。
//
// @param cart 购物车对象包含商品IDfid和用户IDuid
// @return 影响的行数成功返回1失败返回0
//
@Update("update carts set amount = amount + 1 where fid = #{fid} and uid = #{uid};")
int addAmount(Cart cart);
//
// 根据用户ID查询购物车
// 查询指定用户购物车中的所有商品。
//
// @param uid 用户ID
// @return 购物车列表
//
@Select("select * from carts where uid = #{uid};")
List<Cart> queryByUid(int uid);
//
// 更新购物车记录
// 更新购物车中的记录,包括商品名称、密码、电话和地址。
//
// @param cart 购物车对象,包含需要更新的字段
// @return 影响的行数成功返回1失败返回0
//
@Update("update carts set name = #{name},password = #{password},phone = #{phone},address = #{address} where id = #{id};")
int update(Cart cart);
//
// 删除购物车记录
// 根据购物车ID删除记录。
//
// @param id 购物车ID
// @return 影响的行数成功返回1失败返回0
//
@Delete("delete from carts where id = #{id};")
int delete(int id);
//
// 添加购物车记录
// 将新的购物车记录插入到数据库中。
//
// @param cart 购物车对象包含商品ID、商品名称、数量和用户ID
// @return 影响的行数成功返回1失败返回0
//
@Insert("insert into carts(fid,flower,amount,uid) " +
"values(#{fid},#{flower},1,#{uid});")
int add(Cart cart);
}

@ -0,0 +1,81 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.Flower;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
//
// 鲜花数据访问接口,定义与鲜花表相关的数据库操作
//
@Repository
public interface FlowersDao {
//
// 根据搜索关键词和种类分页查询上架鲜花
// @param searchKey 搜索关键词,匹配鲜花名称
// @param searchType 种类名称,匹配鲜花种类
// @return 符合条件的鲜花列表
//
@Select("select * from flowers where name like concat('%',#{searchKey},'%') " +
"and species_name like concat('%',#{searchType},'%') and state = 1;")
List<Flower> find(@Param("searchKey") String searchKey, @Param("searchType") String searchType);
//
// 管理员查询所有鲜花(含未上架)
// @param searchKey 搜索关键词,匹配鲜花名称
// @return 符合条件的鲜花列表
//
@Select("select * from flowers where name like concat('%',#{searchKey},'%');")
List<Flower> findAll(String searchKey);
//
// 查询指定ID鲜花的价格
// @param fid 鲜花ID
// @return 鲜花价格
//
@Select("select price from flowers where id = #{fid};")
Float queryPrice(int fid);
//
// 更新鲜花基本信息
// @param flower 包含ID和要更新信息的鲜花对象
// @return 受影响的行数
//
@Update("update flowers set name = #{name}, species_name = #{species_name}, price = #{price}, detail = #{detail} where id = #{id};")
Integer update(Flower flower);
//
// 更新鲜花图片GUID
// @param img_guid 新的图片GUID
// @param id 鲜花ID
// @return 受影响的行数
//
@Update("update flowers set img_guid = #{img_guid} where id = #{id};")
Integer updateImg(@Param("img_guid") String img_guid, @Param("id") Integer id);
//
// 修改鲜花状态(上架/下架)
// @param flower 包含ID和状态的鲜花对象
// @return 受影响的行数
//
@Update("update flowers set state = ${state} where id = #{id};")
Integer changeState(Flower flower);
//
// 删除指定ID的鲜花
// @param id 鲜花ID
// @return 受影响的行数
//
@Delete("delete from flowers where id = #{id};")
Integer delete(int id);
//
// 添加新鲜花
// @param flower 鲜花对象ID自增状态默认为1-上架)
// @return 受影响的行数
//
@Insert("insert into flowers(name,species_name,price,detail,state) values(#{name},#{species_name},${price},#{detail},1);")
Integer add(Flower flower);
}

@ -0,0 +1,21 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.LoginForm;
import com.shanzhu.flower.entity.User;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
@Repository
public interface LoginDao {
//
//
// 用户登录验证
// 根据登录表单信息(账号、密码和角色)查询用户信息。
// 如果查询到用户记录,则表示登录成功;否则登录失败。
//
// @param form 登录表单信息包含账号account、密码password和角色role
// @return 查询到的用户信息如果登录成功返回User对象否则返回null
//
@Select("select * from users where account = #{account} and password = #{password} and role = #{role};")
User login(LoginForm form);
}

@ -0,0 +1,94 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.Cart;
import com.shanzhu.flower.entity.Order;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderDao {
//
// 根据搜索关键词和用户ID查询订单
// 查询指定用户的所有订单,订单中的商品名称包含指定的搜索关键词。
//
// @param searchKey 搜索关键词
// @param uid 用户ID
// @return 订单列表
//
@Select("select * from orders where flower like concat('%',#{searchKey},'%') and uid = #{uid};")
List<Order> find(@Param("searchKey") String searchKey, @Param("uid") int uid);
//
// 根据搜索关键词查询所有订单
// 查询所有订单,订单中的商品名称包含指定的搜索关键词。
//
// @param searchKey 搜索关键词
// @return 订单列表
//
@Select("select * from orders where flower like concat('%',#{searchKey},'%');")
List<Order> findAll(String searchKey);
//
// 检查订单是否已存在
// 查询指定用户是否已存在指定商品的订单。
//
// @param order 订单对象包含商品IDfid和用户IDuid
// @return 订单记录如果已存在则返回订单对象否则返回null
//
@Select("select * from orders where fid = #{fid} and uid = #{uid};")
Order checkIsAdded(Order order);
//
// 更新订单状态
// 根据订单ID更新订单的状态。
//
// @param order 订单对象包含订单IDid和新状态state
// @return 影响的行数成功返回1失败返回0
//
@Update("update orders set state = #{state} where id = #{id};")
int changeState(Order order);
//
// 根据用户ID查询订单
// 查询指定用户的所有订单。
//
// @param uid 用户ID
// @return 订单列表
//
@Select("select * from orders where uid = #{uid};")
List<Order> queryByUid(int uid);
//
// 更新订单信息
// 更新订单的详细信息,包括商品名称、密码、电话和地址。
//
// @param order 订单对象,包含需要更新的字段
// @return 影响的行数成功返回1失败返回0
//
@Update("update orders set name = #{name},password = #{password},phone = #{phone},address = #{address} where id = #{id};")
int update(Order order);
//
// 删除订单
// 根据订单ID删除订单。
//
// @param id 订单ID
// @return 影响的行数成功返回1失败返回0
//
@Delete("delete from orders where id = #{id};")
int delete(int id);
//
// 添加订单
// 将新的订单记录插入到数据库中。
//
// @param cart 购物车对象包含商品名称、数量、价格和用户ID
// @return 影响的行数成功返回1失败返回0
//
@Insert("insert into orders(flower,amount,price,state,uid) " +
"values(#{flower},#{amount},#{price},0,#{uid});")
int add(Cart cart);
}

@ -0,0 +1,59 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.Species;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.util.List;
//
// 鲜花种类数据访问对象接口,用于定义对鲜花种类表的数据库操作方法
//
@Repository
public interface SpeciesDao {
//
// 根据模糊查询关键词搜索鲜花种类
// 使用 LIKE 语句进行模糊匹配,查询数据库中名称包含指定关键词的鲜花种类记录
// @param searchKey 用于模糊查询的关键词,会拼接在 SQL 的 LIKE 语句中
// @return 符合查询条件的鲜花种类列表,若没有匹配记录则返回空列表
//
@Select("select * from species where species_name like concat('%',#{searchKey},'%');")
List<Species> find(String searchKey);
//
// 查询数据库中所有的鲜花种类记录
// @return 包含所有鲜花种类的列表,若表中没有记录则返回空列表
//
@Select("select * from species;")
List<Species> findAll();
//
// 更新鲜花种类的名称
// 根据传入的鲜花种类对象中的 ID更新数据库中对应记录的种类名称
// @param species 包含要更新的鲜花种类信息的对象,其中包含 ID 和新的种类名称
// @return 受影响的行数,若成功更新则返回大于 0 的值,若未找到对应记录则返回 0
//
@Update("update species set species_name = #{species_name} where id = #{id};")
int update(Species species);
//
// 根据 ID 删除数据库中的鲜花种类记录
// @param id 要删除的鲜花种类的 ID
// @return 受影响的行数,若成功删除则返回 1若未找到对应记录则返回 0
//
@Delete("delete from species where id = #{id};")
int delete(int id);
//
// 向数据库中插入新的鲜花种类记录
// @param species 包含要插入的鲜花种类名称的对象
// @return 受影响的行数,若成功插入则返回 1若插入失败则返回 0
//
@Insert("insert into species(species_name) values(#{species_name});")
int add(Species species);
}

@ -0,0 +1,94 @@
package com.shanzhu.flower.dao;
import com.shanzhu.flower.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserDao {
//
// 根据搜索关键词查询用户
// 查询用户表中账号或姓名包含指定搜索关键词的普通用户(角色为'user')。
//
// @param searchKey 搜索关键词
// @return 用户列表
//
@Select("select * from users where (account like concat('%',#{searchKey},'%') or name like concat('%',#{searchKey},'%')) and role = 'user';")
List<User> find(String searchKey);
//
// 根据用户ID查询用户
// 查询指定ID的用户信息。
//
// @param id 用户ID
// @return 用户信息
//
@Select("select * from users where id = #{id};")
User queryById(Integer id);
//
// 查询所有用户
// 查询用户表中的所有用户信息。
//
// @return 用户列表
//
@Select("select * from users;")
List<User> findAll();
//
// 根据账号查询用户信息
// 查询指定账号的普通用户信息(角色为'user')。
//
// @param account 用户账号
// @return 用户信息
//
@Select("select * from users where account = #{account} and role = 'user';")
User queryInfo(String account);
//
// 根据账号查询用户ID
// 查询指定账号的普通用户的ID。
//
// @param account 用户账号
// @return 用户ID
//
@Select("select id from users where account = #{account} and role = 'user';")
Integer queryIdByAccount(String account);
//
// 更新用户信息
// 更新用户的基本信息,包括姓名、密码、电话和地址。
//
// @param user 用户对象,包含需要更新的字段
// @return 影响的行数成功返回1失败返回0
//
@Update("update users set name = #{name},password = #{password},phone = #{phone},address = #{address} where id = #{id};")
int update(User user);
//
// 删除用户
// 根据用户ID删除用户记录。
//
// @param id 用户ID
// @return 影响的行数成功返回1失败返回0
//
@Delete("delete from users where id = #{id};")
int delete(int id);
//
// 添加用户
// 将新的用户记录插入到数据库中,用户角色默认为'user'。
//
// @param user 用户对象,包含账号、姓名、密码、电话和地址
// @return 影响的行数成功返回1失败返回0
//
@Insert("insert into users(account,name,password,phone,address,role) " +
"values(#{account},#{name},#{password},#{phone},#{address},'user');")
int add(User user);
}

@ -0,0 +1,45 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Cart {
//
// 购物车记录的唯一标识符。
// 用于在数据库中唯一标识每条购物车记录。
//
private int id;
//
// 商品的唯一标识符。
// 用于标识购物车中的具体商品。
//
private int fid;
//
// 商品名称。
// 用于存储购物车中商品的名称。
//
private String flower;
//
// 商品数量。
// 用于存储购物车中商品的数量。
//
private int amount;
//
// 商品总价。
// 用于存储购物车中商品的总价,计算方式为单价乘以数量。
//
private float price;
// 用户的唯一标识符。
// 用于标识购物车记录所属的用户。
private int uid;
// 用户账号。
// 用于存储购物车记录所属用户的账号信息。
private String account;
}

@ -0,0 +1,25 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
// 鲜花实体类,用于封装鲜花相关的信息
@Data
@Accessors(chain = true)
public class Flower {
// 鲜花的唯一标识 ID数据库表中的主键通常用于唯一确定一条鲜花记录
private int id;
// 鲜花的名称,用于描述鲜花的具体品种或类型
private String name;
// 鲜花所属的种类名称,用于分类管理不同种类的鲜花
private String species_name;
// 鲜花的价格,记录该鲜花的售卖价格,以浮点数类型存储
private float price;
// 鲜花的详细描述信息,可包含鲜花的特征、产地、养护方法等内容
private String detail;
// 鲜花图片的唯一标识符GUID用于关联存储在服务器上的鲜花图片资源
private String img_guid;
// 鲜花的状态,通常 1 表示上架可售卖0 表示下架(不可售卖)
private int state;
}

@ -0,0 +1,15 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class LoginForm {
// 计数
private String account;
// 密码
private String password;
// 角色
private String role;
}

@ -0,0 +1,51 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Order {
//
// 订单的唯一标识符。
// 用于在数据库中唯一标识每条订单记录。
//
private int id;
//
// 订单的全局唯一标识符GUID
// 用于在系统中唯一标识订单,便于跟踪和管理。
//
private String order_guid;
//
// 订单中的商品名称。
// 用于存储订单中商品的名称。
//
private String flower;
//
// 商品数量。
// 用于存储订单中商品的数量。
//
private int amount;
//
// 商品总价。
// 用于存储订单中商品的总价,计算方式为单价乘以数量。
//
private float price;
//
// 订单状态。
// 用于标识订单的当前状态例如0表示未发货1表示已发货2表示已完成等。
//
private float state;
//
// 用户ID。
// 用于标识订单所属的用户。
//
private int uid; // 用户 id
}

@ -0,0 +1,19 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class OrderVo extends Order{
//姓名
private String username;
// 电话
private String phone;
// 地址
private String address;
}

@ -0,0 +1,13 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Param {
// 秘钥
private String searchKey;
// 张数
private int page;
}

@ -0,0 +1,16 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class R {
private int code;
private String msg;
private Object data;
}

@ -0,0 +1,17 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class Species {
// ID
private int id;
// 重命名
private String species_name;
}

@ -0,0 +1,50 @@
package com.shanzhu.flower.entity;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class User {
//
// 用户的唯一标识符。
// 用于在数据库中唯一标识每个用户。
//
private int id;
//
// 用户账号。
// 用于用户登录和身份验证。
//
private String account;
//
// 用户姓名。
// 用于存储用户的真实姓名或昵称。
//
private String name;
//
// 用户密码。
// 用于用户登录验证,存储时应加密处理以保证安全。
//
private String password;
//
// 用户电话号码。
// 用于联系用户或验证用户身份。
//
private String phone;
//
// 用户地址。
// 用于存储用户的配送地址或其他联系地址。
//
private String address;
//
// 用户角色。
// 用于标识用户在系统中的权限级别,例如:"admin" 表示管理员,"user" 表示普通用户。
//
private String role;
}

@ -0,0 +1,60 @@
package com.shanzhu.flower.service;
import com.shanzhu.flower.entity.Cart;
import java.util.List;
/**
*
*
*
* @author: ShanZhu
* @date: 2024-01-24
*/
public interface CartService {
//
// 添加商品到购物车
// 如果商品已存在于购物车中,则增加该商品的数量;否则,将商品作为新的记录添加到购物车。
//
// @param cart 购物车对象,包含商品信息和用户账号
// @return 添加结果成功返回1失败返回0
//
int add(Cart cart);
//
// 删除购物车中的商品
// 根据用户ID删除购物车中的所有商品。
//
// @param uid 用户ID
// @return 删除结果成功返回1失败返回0
//
int delete(int uid);
//
// 更新购物车中的商品信息
// 更新购物车中指定商品的数量或其他信息。
//
// @param cart 购物车对象,包含需要更新的商品信息
// @return 更新结果成功返回1失败返回0
//
int update(Cart cart);
//
// 根据搜索关键词和用户账号查询购物车
// 查询购物车中商品名称包含指定搜索关键词的记录,并且属于指定用户账号。
//
// @param searchKey 搜索关键词
// @param account 用户账号
// @return 购物车记录列表
//
List<Cart> find(String searchKey, String account);
//
// 根据用户账号查询购物车
// 查询指定用户账号的购物车中的所有商品。
//
// @param account 用户账号
// @return 购物车记录列表
//
List<Cart> queryByAccount(String account);
}

@ -0,0 +1,65 @@
package com.shanzhu.flower.service;
import com.shanzhu.flower.entity.Flower;
import java.util.List;
//
// * 鲜花商品 服务层接口,定义了与鲜花商品相关的业务操作方法,
// * 具体的实现由实现类来完成,用于处理鲜花商品的增删改查以及图片更新等业务逻辑。
// *
// * @author: ShanZhu
// * @date: 2024-01-24
//
public interface FlowersService {
//
// * 向系统中添加一个新的鲜花商品记录。
// *
// * @param flower 要添加的鲜花商品对象,包含了鲜花的详细信息,如名称、种类、价格等。
// * @return 成功添加时返回 1添加失败返回 0可以根据具体业务逻辑扩展返回值含义
//
int add(Flower flower);
//
// * 根据给定的鲜花商品 ID从系统中删除对应的鲜花商品记录。
// *
// * @param id 要删除的鲜花商品的 ID。
// * @return 成功删除时返回 1删除失败返回 0可以根据具体业务逻辑扩展返回值含义
//
int delete(int id);
//
// * 更新系统中已有的鲜花商品记录信息。
// *
// * @param flower 包含更新后鲜花商品信息的对象,其中 ID 用于定位要更新的记录。
// * @return 成功更新时返回大于等于 0 的值,该值表示受影响的行数;更新失败返回 0。
//
int update(Flower flower);
//
// * 根据给定的搜索关键词和搜索类型,从系统中查询匹配的鲜花商品记录。
// *
// * @param searchKey 用于模糊查询的关键词,会根据该关键词搜索鲜花的名称或其他相关信息。
// * @param searchType 搜索的类型,例如可以是鲜花的种类等,用于更精确地筛选查询结果。
// * @return 包含所有符合查询条件的鲜花商品对象的列表,如果没有匹配的记录则返回空列表。
//
List<Flower> find(String searchKey, String searchType);
//
// * 根据给定的搜索关键词,从系统中查询所有匹配的鲜花商品记录(包括上架和下架的商品)。
// *
// * @param searchKey 用于模糊查询的关键词,会根据该关键词搜索鲜花的名称或其他相关信息。
// * @return 包含所有符合查询条件的鲜花商品对象的列表,如果没有匹配的记录则返回空列表。
//
List<Flower> findAll(String searchKey);
//
// * 根据给定的图片唯一标识符GUID和鲜花商品 ID更新系统中对应鲜花商品的图片信息。
// *
// * @param img_guid 新的图片唯一标识符,用于关联新的图片资源。
// * @param id 要更新图片的鲜花商品的 ID。
// * @return 成功更新时返回 1更新失败返回 0可以根据具体业务逻辑扩展返回值含义
//
int updateImg(String img_guid, Integer id);
}

@ -0,0 +1,36 @@
package com.shanzhu.flower.service;
import com.shanzhu.flower.entity.Cart;
import com.shanzhu.flower.entity.Order;
import java.util.List;
/**
*
*
*
* @author: ShanZhu
* @date: 2024-01-24
*/
public interface OrderService {
//
// 添加订单
// 将购物车中的商品转换为订单并插入到数据库中。
// 如果购物车中的商品已存在订单中,则更新订单数量。
//
// @param cart 购物车对象,包含商品信息和用户账号
// @return 添加结果成功返回1失败返回0
//
int add(Cart cart);
int delete(int uid);
int update(Order order);
List<Order> find(String searchKey, String account);
List<Order> findAll(String searchKey);
List<Order> queryByAccount(String account);
}

@ -0,0 +1,51 @@
package com.shanzhu.flower.service;
import com.shanzhu.flower.entity.Species;
import java.util.List;
//
// * 鲜花种类服务层接口,定义了与鲜花种类相关的业务操作方法,
// * 具体的实现由对应的实现类来完成,用于处理鲜花种类的增删改查等业务逻辑。
//
public interface SpeciesService {
//
// * 向系统中添加一个新的鲜花种类记录。
// *
// * @param species 要添加的鲜花种类对象,包含了种类的名称等信息。
// * @return 成功添加时返回 1添加失败返回 0可根据实际业务逻辑扩展返回值含义
//
int add(Species species);
//
// * 根据给定的鲜花种类 ID从系统中删除对应的鲜花种类记录。
// *
// * @param id 要删除的鲜花种类的 ID。
// * @return 成功删除时返回 1删除失败返回 0可根据实际业务逻辑扩展返回值含义
//
int delete(int id);
//
// * 更新系统中已有的鲜花种类记录信息。
// *
// * @param species 包含更新后鲜花种类信息的对象,其中 ID 用于定位要更新的记录。
// * @return 成功更新时返回大于等于 0 的值,该值表示受影响的行数;更新失败返回 0。
//
int update(Species species);
//
// * 根据给定的搜索关键词,从系统中查询匹配的鲜花种类记录。
// *
// * @param searchKey 用于模糊查询的关键词,会根据该关键词搜索种类名称中包含它的记录。
// * @return 包含所有符合查询条件的鲜花种类对象的列表,如果没有匹配的记录则返回空列表。
//
List<Species> find(String searchKey);
//
// * 从系统中查询所有的鲜花种类记录。
// *
// * @return 包含所有鲜花种类对象的列表,如果系统中没有记录则返回空列表。
//
List<Species> findAll();
}

@ -0,0 +1,59 @@
package com.shanzhu.flower.service;
import com.shanzhu.flower.entity.User;
import java.util.List;
/**
*
*
*
* @author: ShanZhu
* @date: 2024-01-24
*/
public interface UserService {
//
// 添加用户
// 将新的用户记录插入到数据库中。
//
// @param user 用户对象,包含用户的基本信息(账号、姓名、密码等)
// @return 添加结果成功返回1失败返回0
//
int add(User user);
//
// 删除用户
// 根据用户ID删除用户记录。
//
// @param uid 用户ID
// @return 删除结果成功返回1失败返回0
//
int delete(int uid);
//
// 更新用户信息
// 更新用户的基本信息,如姓名、密码、电话和地址。
//
// @param user 用户对象,包含需要更新的用户信息
// @return 更新结果成功返回1失败返回0
//
int update(User user);
//
// 根据搜索关键词查询用户
// 查询用户表中账号或姓名包含指定搜索关键词的用户。
//
// @param searchKey 搜索关键词
// @return 用户列表
//
List<User> find(String searchKey);
//
// 根据账号查询用户信息
// 查询指定账号的用户详细信息。
//
// @param account 用户账号
// @return 用户信息如果查询不到返回null
//
User queryInfo(String account);
}

@ -0,0 +1,63 @@
package com.shanzhu.flower.service.impl;
import com.shanzhu.flower.dao.CartDao;
import com.shanzhu.flower.dao.UserDao;
import com.shanzhu.flower.entity.Cart;
import com.shanzhu.flower.service.CartService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class CartServiceImpl implements CartService {
@Resource
private CartDao cartDao; // 注入购物车数据访问对象
@Resource
private UserDao userDao; // 注入用户数据访问对象
@Override
public int add(Cart cart) {
// 根据用户账号查询用户ID
int uid = userDao.queryIdByAccount(cart.getAccount());
cart.setUid(uid); // 设置购物车记录的用户ID
// 检查该用户是否已将该商品添加到购物车
Cart cart1 = cartDao.checkIsAdded(cart);
if (cart1 == null) {
// 如果未添加,直接插入新的购物车记录
return cartDao.add(cart);
} else {
// 如果已添加,增加该商品的数量
return cartDao.addAmount(cart);
}
}
@Override
public int delete(int uid) {
// 根据用户ID删除购物车记录
return cartDao.delete(uid);
}
@Override
public int update(Cart cart) {
// 更新购物车记录
return cartDao.update(cart);
}
@Override
public List<Cart> find(String searchKey, String account) {
// 根据搜索关键词和用户账号查询购物车记录
return cartDao.find(searchKey, account);
}
@Override
public List<Cart> queryByAccount(String account) {
// 根据用户账号查询用户ID
Integer uid = userDao.queryIdByAccount(account);
// 根据用户ID查询购物车记录
return cartDao.queryByUid(uid);
}
}

@ -0,0 +1,81 @@
package com.shanzhu.flower.service.impl;
import com.shanzhu.flower.dao.FlowersDao;
import com.shanzhu.flower.entity.Flower;
import com.shanzhu.flower.service.FlowersService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
//
// * 鲜花业务逻辑实现类,处理鲜花相关的业务操作
//
@Service
public class FlowersServiceImpl implements FlowersService {
@Resource
private FlowersDao flowersDao; // 注入鲜花数据访问对象
//
// * 添加鲜花信息
// * @param flower 鲜花实体对象
// * @return 数据库操作影响的行数
//
@Override
public int add(Flower flower) {
return flowersDao.add(flower); // 调用DAO层添加鲜花
}
//
// * 根据ID删除鲜花
// * @param id 鲜花ID
// * @return 数据库操作影响的行数
//
@Override
public int delete(int id) {
return flowersDao.delete(id); // 调用DAO层删除鲜花
}
//
// * 更新鲜花信息
// * @param flower 包含更新信息的鲜花实体对象
// * @return 数据库操作影响的行数
//
@Override
public int update(Flower flower) {
return flowersDao.update(flower); // 调用DAO层更新鲜花信息
}
//
// * 根据搜索条件查询鲜花列表(用户视角,仅包含上架商品)
// * @param searchKey 搜索关键词(名称)
// * @param searchType 搜索类型(种类)
// * @return 符合条件的鲜花列表
//
@Override
public List<Flower> find(String searchKey, String searchType) {
return flowersDao.find(searchKey, searchType); // 调用DAO层查询鲜花列表
}
//
// * 管理员查询所有鲜花(包含下架商品)
// * @param searchKey 搜索关键词(名称)
// * @return 符合条件的鲜花列表
//
@Override
public List<Flower> findAll(String searchKey) {
return flowersDao.findAll(searchKey); // 调用DAO层查询所有鲜花
}
//
// * 更新鲜花图片
// * @param img_guid 图片唯一标识
// * @param id 鲜花ID
// * @return 数据库操作影响的行数
//
@Override
public int updateImg(String img_guid, Integer id) {
return flowersDao.updateImg(img_guid, id); // 调用DAO层更新鲜花图片
}
}

@ -0,0 +1,67 @@
package com.shanzhu.flower.service.impl;
import com.shanzhu.flower.dao.OrderDao;
import com.shanzhu.flower.dao.UserDao;
import com.shanzhu.flower.entity.Cart;
import com.shanzhu.flower.entity.Order;
import com.shanzhu.flower.service.OrderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {
@Resource
private OrderDao orderdao; // 注入订单数据访问对象
@Resource
private UserDao userDao; // 注入用户数据访问对象
@Override
public int add(Cart cart) {
// 将购物车中的商品添加为订单
// 直接调用订单数据访问对象的add方法将购物车对象转换为订单对象后插入数据库
return orderdao.add(cart);
}
@Override
public int delete(int uid) {
// 根据用户ID删除订单
// 调用订单数据访问对象的delete方法删除指定用户ID的所有订单
return orderdao.delete(uid);
}
@Override
public int update(Order order) {
// 更新订单信息
// 调用订单数据访问对象的update方法更新指定订单的详细信息
return orderdao.update(order);
}
@Override
public List<Order> find(String searchKey, String account) {
// 根据搜索关键词和用户账号查询订单
// 首先根据用户账号查询用户ID
Integer uid = userDao.queryIdByAccount(account);
// 然后根据搜索关键词和用户ID查询订单
return orderdao.find(searchKey, uid);
}
@Override
public List<Order> findAll(String searchKey) {
// 根据搜索关键词查询所有订单
// 调用订单数据访问对象的findAll方法查询所有包含搜索关键词的订单
return orderdao.findAll(searchKey);
}
@Override
public List<Order> queryByAccount(String account) {
// 根据用户账号查询订单
// 首先根据用户账号查询用户ID
Integer uid = userDao.queryIdByAccount(account);
// 然后根据用户ID查询订单
return orderdao.queryByUid(uid);
}
}

@ -0,0 +1,74 @@
package com.shanzhu.flower.service.impl;
import com.shanzhu.flower.dao.SpeciesDao;
import com.shanzhu.flower.entity.Species;
import com.shanzhu.flower.service.SpeciesService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* SpeciesService
* SpeciesDao 访
*/
@Service
public class SpeciesServiceImpl implements SpeciesService {
@Resource
private SpeciesDao speciesDao; // 注入鲜花种类数据访问对象,用于操作数据库
//
// * 向数据库中添加一个新的鲜花种类记录。
// *
// * @param species 要添加的鲜花种类对象,包含种类名称等信息。
// * @return 执行数据库插入操作后受影响的行数,成功插入时返回 1失败返回 0。
//
@Override
public int add(Species species) {
return speciesDao.add(species); // 调用 SpeciesDao 的 add 方法执行插入操作
}
//
// * 根据给定的鲜花种类 ID从数据库中删除对应的鲜花种类记录。
// *
// * @param uid 要删除的鲜花种类的 ID。
// * @return 执行数据库删除操作后受影响的行数,成功删除时返回 1失败返回 0。
//
@Override
public int delete(int uid) {
return speciesDao.delete(uid); // 调用 SpeciesDao 的 delete 方法执行删除操作
}
//
// * 更新数据库中指定鲜花种类的记录信息。
// *
// * @param species 包含更新后鲜花种类信息的对象,其中 ID 用于定位要更新的记录。
// * @return 执行数据库更新操作后受影响的行数,成功更新时返回大于 0 的值,未找到对应记录返回 0。
//
@Override
public int update(Species species) {
return speciesDao.update(species); // 调用 SpeciesDao 的 update 方法执行更新操作
}
//
// * 根据给定的搜索关键词,从数据库中查询匹配的鲜花种类记录。
// *
// * @param searchKey 用于模糊查询的关键词,会根据该关键词搜索种类名称中包含它的记录。
// * @return 包含所有符合查询条件的鲜花种类对象的列表,如果没有匹配的记录则返回空列表。
//
@Override
public List<Species> find(String searchKey) {
return speciesDao.find(searchKey); // 调用 SpeciesDao 的 find 方法执行查询操作
}
//
// * 从数据库中查询所有的鲜花种类记录。
// *
// * @return 包含所有鲜花种类对象的列表,如果数据库中没有记录则返回空列表。
//
@Override
public List<Species> findAll() {
return speciesDao.findAll(); // 调用 SpeciesDao 的 findAll 方法执行查询操作
}
}

@ -0,0 +1,56 @@
package com.shanzhu.flower.service.impl;
import com.shanzhu.flower.dao.UserDao;
import com.shanzhu.flower.entity.User;
import com.shanzhu.flower.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Resource
private UserDao userdao; // 注入用户数据访问对象
@Override
public int add(User user) {
try {
// 尝试添加用户记录
// 调用用户数据访问对象的add方法将用户对象插入数据库
return userdao.add(user);
} catch (Exception e) {
// 如果发生异常返回0表示添加失败
return 0;
}
}
@Override
public int delete(int uid) {
// 根据用户ID删除用户记录
// 调用用户数据访问对象的delete方法删除指定用户ID的用户记录
return userdao.delete(uid);
}
@Override
public int update(User user) {
// 更新用户信息
// 调用用户数据访问对象的update方法更新指定用户的详细信息
return userdao.update(user);
}
@Override
public List<User> find(String searchKey) {
// 根据搜索关键词查询用户
// 调用用户数据访问对象的find方法查询用户表中账号或姓名包含指定搜索关键词的用户
return userdao.find(searchKey);
}
@Override
public User queryInfo(String account) {
// 根据账号查询用户信息
// 调用用户数据访问对象的queryInfo方法查询指定账号的用户信息
return userdao.queryInfo(account);
}
}

@ -0,0 +1,33 @@
package com.shanzhu.flower.util;
import com.shanzhu.flower.entity.LoginForm;
import tk.mybatis.mapper.util.StringUtil;
/**
*
*/
public class VerifyUtil {
/**
*
* @param form
* @return truefalse
*/
public static boolean verifyLoginForm(LoginForm form) {
// 检查表单对象是否为空,或必填字段是否为空
if (form == null
|| StringUtil.isEmpty(form.getAccount())
|| StringUtil.isEmpty(form.getPassword())
|| StringUtil.isEmpty(form.getRole())) {
return false;
}
// 检查角色是否为允许的类型
if (form.getRole().equals("user") || form.getRole().equals("admin")) {
return true;
}
// 角色类型不合法
return false;
}
}

@ -0,0 +1,22 @@
#后端服务端口
server:
port: 8081
spring:
#数据库配置
datasource:
url: jdbc:mysql://localhost:3306/DB_flower?characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: 123456
resources:
chain:
strategy:
content:
enabled: true
paths: /**
mybatis:
type-aliases-package: com.shanzhu.flower.entity
#图片上传路径 图片所在的路径位置
uploadPath: /Users/jiawang/saleProject/花店商城/flower-frontend/static/imgs/
Loading…
Cancel
Save