test
This commit is contained in:
parent
ac38d1ae30
commit
aa735edcf8
|
@ -1,8 +0,0 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="vueDemo" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="vueDemo" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.sql.Connection,prepareStatement" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="spring-milestones" />
|
||||
<option name="name" value="Spring Milestones" />
|
||||
<option name="url" value="https://repo.spring.io/milestone" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="spring-snapshots" />
|
||||
<option name="name" value="Spring Snapshots" />
|
||||
<option name="url" value="https://repo.spring.io/snapshot" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (2)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (3)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (4)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (5)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (6)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (7)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="mysql-connector-j-8.0.33 (8)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-j-8.0.33.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
|
@ -1,18 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
|
@ -1,3 +0,0 @@
|
|||
> 1%
|
||||
last 2 versions
|
||||
not dead
|
|
@ -1,17 +0,0 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
'extends': [
|
||||
'plugin:vue/essential',
|
||||
'eslint:recommended'
|
||||
],
|
||||
parserOptions: {
|
||||
parser: '@babel/eslint-parser'
|
||||
},
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
||||
}
|
||||
}
|
|
@ -1,23 +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 +0,0 @@
|
|||
shamefully-hoist=true
|
|
@ -1,24 +0,0 @@
|
|||
# vue-demo
|
||||
|
||||
## Project setup
|
||||
```
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
pnpm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
pnpm run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@ -1,5 +0,0 @@
|
|||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "esnext",
|
||||
"baseUrl": "./",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "vue-demo",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.5.0",
|
||||
"core-js": "^3.8.3",
|
||||
"vue": "^2.6.14",
|
||||
"vue-router": "^3.5.1",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/eslint-parser": "^7.12.16",
|
||||
"@vue/cli-plugin-babel": "~5.0.0",
|
||||
"@vue/cli-plugin-eslint": "~5.0.0",
|
||||
"@vue/cli-plugin-router": "~5.0.0",
|
||||
"@vue/cli-plugin-vuex": "~5.0.0",
|
||||
"@vue/cli-service": "~5.0.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-vue": "^8.0.3",
|
||||
"sass": "^1.32.7",
|
||||
"sass-loader": "^12.0.0",
|
||||
"vue-template-compiler": "^2.6.14"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
|
@ -1,17 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
|
@ -1,8 +0,0 @@
|
|||
<template>
|
||||
<div id="app">
|
||||
<router-view/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
</style>
|
Binary file not shown.
Before Width: | Height: | Size: 6.7 KiB |
|
@ -1,5 +0,0 @@
|
|||
body, div, dl,dt,dd,ul,ol,li,h2,h3,h4,h5,h6,pre,form,fieldset,legend,input,textarea{
|
||||
margin: 0;padding:0;}
|
||||
body{text-align: center;}
|
||||
a{ text-decoration: none;}
|
||||
li{ list-style: none;}
|
|
@ -1,33 +0,0 @@
|
|||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import axios from 'axios'
|
||||
import "./css/common.css"
|
||||
|
||||
Vue.prototype.$http = axios
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
import ElementUI from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
Vue.use(ElementUI);
|
||||
|
||||
// 添加请求拦截器,在请求头中加token
|
||||
//使用 axios 的请求拦截器来实现在请求头中自动带上 token 的功能:
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
if (localStorage.getItem('token')) {
|
||||
config.headers.token = localStorage.getItem('token');
|
||||
}
|
||||
return config;
|
||||
},
|
||||
error => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
store,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
|
@ -1,52 +0,0 @@
|
|||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
import Home from "../views/Home.vue"
|
||||
import Login from "../views/Login.vue"
|
||||
import Product from "../views/Product.vue"
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/",
|
||||
name: "Home",
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: "/product",
|
||||
name: "Product",
|
||||
component: Product
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode:"history",
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
//to 将要访问的路径
|
||||
//from 代表从哪个路径而来
|
||||
//next() 代表放行 next('xxx') 强制放行的xxx的路径
|
||||
if(to.path==='/login'){
|
||||
next();
|
||||
}else{
|
||||
const tokenStr = window.localStorage.getItem('token');
|
||||
console.log(tokenStr);
|
||||
if(!tokenStr){
|
||||
return next('/login')
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
export default router
|
|
@ -1,25 +0,0 @@
|
|||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex);
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
//定义一个state存储token信息
|
||||
token: localStorage.getItem('token') ? localStorage.getItem('token') : ''
|
||||
},
|
||||
mutations: {
|
||||
//登录后通过setToken存入token token保存在state和localStorage中
|
||||
setToken (state,token) {
|
||||
state.token =token;
|
||||
localStorage.setItem("token",token.token); //存储token
|
||||
},
|
||||
//登出后通过delToken清除token
|
||||
delToken (state) {
|
||||
state.token = '';
|
||||
localStorage.removeItem("token"); //删除token
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default store;
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<p>这是Home页面</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "HomePage"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
|
@ -1,171 +0,0 @@
|
|||
<template>
|
||||
<div class="login">
|
||||
<el-card class="box-card">
|
||||
<div class="clearfix">
|
||||
<span>大数据专业实验室</span>
|
||||
</div>
|
||||
<div>
|
||||
<el-tabs stretch>
|
||||
<el-tab-pane label="登陆">
|
||||
<el-form :model="loginForm" status-icon :rules="rules" label-width="80px" ref="loginForm">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input type="text" v-model="loginForm.username"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input type="password" v-model="loginForm.password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitLoginForm()">登陆</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="注册">
|
||||
<el-form :model="registerForm" status-icon :rules="rules" label-width="80px" ref="loginForm">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input type="text" v-model="registerForm.username"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input type="password" v-model="registerForm.password"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="确认密码" prop="configurePassword">
|
||||
<el-input type="password" v-model="registerForm.configurePassword"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitRegisterForm()">注册</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import { mapMutations } from 'vuex';//引入vuex下的方法
|
||||
|
||||
export default {
|
||||
data() {
|
||||
var validateUsername = (rule, value, callback) => {
|
||||
if (value === "") {
|
||||
callback(new Error("请输入用户名"));
|
||||
} else if (value.length < 4) {
|
||||
callback(new Error("长度不够"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
var validatePassword = (rule, value, callback) => {
|
||||
if (value === "") {
|
||||
callback(new Error("请输入密码"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
var validateConfigurePassword = (rule, value, callback) => {
|
||||
if (value === "") {
|
||||
callback(new Error("请输入密码")); //callback的作用是显示那个图标的
|
||||
} else if (value !== this.registerForm.password) {
|
||||
callback(new Error("两次密码不一致"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
loginForm: {
|
||||
username: "",
|
||||
password: "",
|
||||
},
|
||||
registerForm: {
|
||||
username: "",
|
||||
password: "",
|
||||
configurePassword: ""
|
||||
},
|
||||
|
||||
|
||||
|
||||
rules: {
|
||||
username: [
|
||||
{
|
||||
validator: validateUsername,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
password: [
|
||||
{
|
||||
validator: validatePassword,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
configurePassword: [
|
||||
{
|
||||
validator: validateConfigurePassword,
|
||||
trigger: "blur",
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
//映射mapMutations 辅助函数映射 Vuex mutations
|
||||
// - 让组件可以直接调用 Vuex 中的 mutations 方法
|
||||
...mapMutations(['setToken']),
|
||||
|
||||
submitLoginForm() {
|
||||
let self = this //在回调函数中调用this会创建与this对象的新绑定,而不是正则函数表达式中的 Vue 对象。
|
||||
var url = "http://localhost:8081/login?username=" + this.loginForm.username + "&password=" + this.loginForm.password
|
||||
axios.get(url).then(function (response) { //匿名回调函数,导致回调函数中的 this 不再指向 Vue 实例
|
||||
var jsonObject = response.data;
|
||||
var jsonString = JSON.stringify(jsonObject)
|
||||
if (jsonString !== "false") {
|
||||
window.localStorage.setItem("token", jsonString);
|
||||
self.setToken({ token: jsonString });
|
||||
self.$router.push('/product')
|
||||
} else {
|
||||
alert("账号或密码错误!")
|
||||
}
|
||||
})
|
||||
},
|
||||
submitRegisterForm() {
|
||||
var url = "http://127.0.0.1:8081/register?username=" + this.registerForm.username + "&password=" + this.registerForm.password
|
||||
axios.get(url).then(function (response) {
|
||||
var jsonObject = response.data;
|
||||
var jsonString = JSON.stringify(jsonObject)
|
||||
if (jsonString === "true") {
|
||||
alert("注册成功!")
|
||||
} else {
|
||||
alert("该用户已注册!")
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
name: "LoginPage",
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.login {
|
||||
width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
width: 500px;
|
||||
margin: 100px auto;
|
||||
}
|
||||
</style>
|
|
@ -1,188 +0,0 @@
|
|||
<template>
|
||||
<div class="">
|
||||
<div class="inline">
|
||||
<p>审批状态:</p>
|
||||
<el-select v-model="value" clearable placeholder="请选择">
|
||||
<el-option v-for="item in stateOptions" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
<!-- 中间来个空格隔开 -->
|
||||
<div style="width: 20px"></div>
|
||||
<p>采购类别:</p>
|
||||
<el-select v-model="categoryValue" clearable placeholder="请选择">
|
||||
<el-option v-for="item in categoryOptions" :key="item.categoryValue" :label="item.label"
|
||||
:value="item.categoryValue"></el-option>
|
||||
</el-select>
|
||||
<div style="width: 20px"></div>
|
||||
<el-button type="primary">查询</el-button>
|
||||
<div style="width: 20px"></div>
|
||||
|
||||
<el-button type="primary">重置</el-button>
|
||||
</div>
|
||||
<!-- 设置按钮在最左边 type属性会改变按钮的样式,表示不同的意义。-->
|
||||
<div class="left">
|
||||
<el-button type="primary" @click="increase()">新增</el-button>
|
||||
<el-dialog title="新增" :visible.sync="dialogFormVisible">
|
||||
<el-form :model="form">
|
||||
<el-form-item label="审批状态">
|
||||
<el-input v-model="form.state" autocomplete="off" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人">
|
||||
<el-input v-model="form.approver" autocomplete="off" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="审核结果">
|
||||
<el-input v-model="form.result" autocomplete="off" clearable></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div>
|
||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="sureIncrease()">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<br>
|
||||
<!-- 缩小表格以适应屏幕 -->
|
||||
<div style="width: 100%; overflow-x: auto" class="table">
|
||||
<el-table :data="tableData" style="width: 100%" border>
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="state" label="审批状态" width="100"></el-table-column>
|
||||
<el-table-column prop="approver" label="审批人" width="100"></el-table-column>
|
||||
<el-table-column prop="result" label="审核结果" width="100"></el-table-column>
|
||||
<el-table-column label="操作" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="handleClick(scope.row)" type="primary" size=20px>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
export default {
|
||||
props: {
|
||||
data: {
|
||||
type: [Array, String]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const formData = {
|
||||
state: this.form.state,
|
||||
approver: this.form.approver,
|
||||
result: this.form.result,
|
||||
};
|
||||
axios.post('http://127.0.0.1:8081/product', formData).then((response) => {
|
||||
this.tableData = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleClick(row) {
|
||||
axios.post("http://127.0.0.1:8081/deleteProduct", row).then((res) => {
|
||||
const productList = res.data;
|
||||
this.tableData = productList;
|
||||
this.$message.success('删除产品成功');
|
||||
console.log(res.data);
|
||||
});
|
||||
console.log(row);
|
||||
|
||||
},
|
||||
//新增功能
|
||||
|
||||
increase() {
|
||||
this.dialogFormVisible = true;
|
||||
},
|
||||
sureIncrease() {
|
||||
const formData = {
|
||||
state: this.form.state,
|
||||
approver: this.form.approver,
|
||||
result: this.form.result,
|
||||
};
|
||||
var url = "http://127.0.0.1:8081/addProduct"
|
||||
axios.post(url, formData).then((res) => {
|
||||
const productList = res.data;
|
||||
this.tableData = productList;
|
||||
this.$message.success('新增产品成功');
|
||||
console.log(res.data);
|
||||
});
|
||||
this.dialogFormVisible = false;
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
|
||||
data() {
|
||||
return {
|
||||
stateOptions: [
|
||||
{
|
||||
value: "选项1",
|
||||
label: "待审批",
|
||||
},
|
||||
{
|
||||
value: "选项2",
|
||||
label: "已通过",
|
||||
},
|
||||
{
|
||||
value: "选项3",
|
||||
label: "未通过",
|
||||
},
|
||||
],
|
||||
value: "",
|
||||
categoryOptions: [
|
||||
{
|
||||
categoryValue: "选项1",
|
||||
label: "办公用具",
|
||||
},
|
||||
{
|
||||
categoryValue: "选项2",
|
||||
label: "生产材料",
|
||||
},
|
||||
{
|
||||
categoryValue: "选项3",
|
||||
label: "部门活动",
|
||||
},
|
||||
],
|
||||
categoryValue: "",
|
||||
tableData: [],
|
||||
|
||||
dialogFormVisible: false,
|
||||
form: {
|
||||
state: "",
|
||||
approver: "",
|
||||
result: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
name: "ProductPage",
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 使整个项目居中显示 */
|
||||
.parent {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* 将left类中的按钮设置在审批状态下方 */
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
margin-left: 350px;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-left: 350px;
|
||||
}
|
||||
</style>
|
|
@ -1,4 +0,0 @@
|
|||
const { defineConfig } = require('@vue/cli-service')
|
||||
module.exports = defineConfig({
|
||||
transpileDependencies: true
|
||||
})
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
95
pom.xml
95
pom.xml
|
@ -1,95 +0,0 @@
|
|||
<?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.7.16-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>vueDemo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>vueDemo</name>
|
||||
<description>vueDemo</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!--jsonwebtoken 生成token的库 -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
|
@ -1,29 +0,0 @@
|
|||
package com.example.vuedemo;
|
||||
|
||||
public class Product {
|
||||
private String state;
|
||||
private String approver;
|
||||
private String result;
|
||||
//补全getset方法
|
||||
public String getState() {
|
||||
return state;
|
||||
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getApprover() {
|
||||
return approver;
|
||||
|
||||
}
|
||||
public void setApprover(String approver) {
|
||||
this.approver = approver;
|
||||
}
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.example.vuedemo.Token;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//入口拦截,设置哪些接口需要拦截或不拦截(保护后端接口 防止未经授权的访问)
|
||||
@Configuration
|
||||
public class IntercepterConfig implements WebMvcConfigurer {
|
||||
private final TokenInterceptor tokenInterceptor;
|
||||
|
||||
// 构造方法
|
||||
public IntercepterConfig(TokenInterceptor tokenInterceptor) {
|
||||
this.tokenInterceptor = tokenInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//excludePathPatterns用来配置不需要拦截的路径
|
||||
List<String> excludePath = new ArrayList<>();//List用来保存所有不需要拦截的路径
|
||||
excludePath.add("/register"); //注册
|
||||
excludePath.add("/login"); //登录
|
||||
excludePath.add("/product");
|
||||
excludePath.add("/addProduct");
|
||||
excludePath.add("/deleteProduct");
|
||||
|
||||
|
||||
|
||||
registry.addInterceptor(tokenInterceptor)//添加名为tokenInterceptor的拦截器
|
||||
.addPathPatterns("/**") //指定拦截所有路径
|
||||
.excludePathPatterns(excludePath);//排除不需要拦截的路径
|
||||
WebMvcConfigurer.super.addInterceptors(registry);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.example.vuedemo.Token;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
public class TokenGenerate {
|
||||
|
||||
private static final long EXPIRE_TIME= 15*60*1000;
|
||||
private static final String TOKEN_SECRET="tokenqkj"; //密钥盐
|
||||
public String generateToken(String username){
|
||||
String token = null;
|
||||
try{
|
||||
Date expiresAt = new Date(System.currentTimeMillis() + EXPIRE_TIME);
|
||||
token = JWT.create()
|
||||
.withIssuer("auth0")
|
||||
.withClaim("username", username)
|
||||
.withExpiresAt(expiresAt)
|
||||
.sign(Algorithm.HMAC256(TOKEN_SECRET));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* 签名验证
|
||||
*/
|
||||
public static boolean verify(String token){
|
||||
System.out.println("执行了token验证代码");
|
||||
|
||||
try {
|
||||
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(TOKEN_SECRET)).withIssuer("auth0").build();
|
||||
DecodedJWT jwt = verifier.verify(token);
|
||||
System.out.println("认证通过:");
|
||||
System.out.println("issuer: " + jwt.getIssuer());
|
||||
System.out.println("username: " + jwt.getClaim("username").asString());
|
||||
System.out.println("过期时间: " + jwt.getExpiresAt());
|
||||
return true;
|
||||
} catch (Exception e){
|
||||
System.out.println("没通过");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.example.vuedemo.Token;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
//token拦截器,对拦截下的接口检查其的token是否符合只有
|
||||
// 在提供一个有效的token时才能通过验证,否则给出认证失败的响应。
|
||||
@Component
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception{
|
||||
//Axios 发起跨域请求前,浏览器也会首先发起 OPTIONS 预检请求。检查服务器是否允许跨域访问。
|
||||
if(request.getMethod().equals("OPTIONS")){
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
System.out.println("允许跨域访问");
|
||||
return true;
|
||||
}
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String token = request.getHeader("token");
|
||||
if(token != null){
|
||||
boolean result = TokenGenerate.verify(token);
|
||||
if(result){
|
||||
System.out.println("通过拦截器");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = null;
|
||||
response.getWriter().write("认证失败,错误码:50000");
|
||||
return false;//原为false
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.example.vuedemo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class VueDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(VueDemoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package com.example.vuedemo;
|
||||
|
||||
import com.example.vuedemo.Token.TokenGenerate;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import mysql.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin //加上CrossOrigin可解决跨域问题
|
||||
public class vueControll {
|
||||
String token;
|
||||
@RequestMapping("/login")
|
||||
public String tologin(@RequestParam("username") String username,@RequestParam("password") String password) throws SQLException {
|
||||
ResultSet resultRegister = CheckRegister.MyAccount(username);
|
||||
if(resultRegister.next()) {
|
||||
if(username.equals(resultRegister.getString("username"))&&password.equals(resultRegister.getString("password"))) {
|
||||
token = new TokenGenerate().generateToken(username);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
@RequestMapping("/register")
|
||||
public String toRegister(@RequestParam("username") String username,@RequestParam("password") String password) throws SQLException {
|
||||
ResultSet resultRegister = CheckRegister.MyAccount(username);
|
||||
//还没有注册过
|
||||
if(resultRegister.next()){
|
||||
resultRegister.getString("username").equals(username);
|
||||
return "false";
|
||||
}
|
||||
AddRegister.add(username, password);
|
||||
return "true";
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/product")
|
||||
public ResponseEntity<List<Product>> getProduct(@RequestBody Product product) throws SQLException {
|
||||
//提取数据到List
|
||||
ResultSet resultProduct = CheckProduct.MyAccount();
|
||||
// 封装结果集到Product列表
|
||||
List<Product> productList = new ArrayList<>();
|
||||
while (resultProduct.next()) {
|
||||
Product p = new Product();
|
||||
p.setState(resultProduct.getString("state"));
|
||||
p.setApprover(resultProduct.getString("approver"));
|
||||
p.setResult(resultProduct.getString("result"));
|
||||
productList.add(p);
|
||||
}
|
||||
return ResponseEntity.ok(productList);
|
||||
}
|
||||
|
||||
@PostMapping("/addProduct")
|
||||
public ResponseEntity<List<Product>> addProduct(@RequestBody Product product) throws SQLException {
|
||||
//存入数据库
|
||||
AddProduct.add(product.getState(),product.getApprover(),product.getResult());
|
||||
//进行整体数据传输
|
||||
ResultSet resultProduct = CheckProduct.MyAccount();
|
||||
// 封装结果集到Product列表
|
||||
List<Product> productList = new ArrayList<>();
|
||||
while (resultProduct.next()) {
|
||||
Product p = new Product();
|
||||
p.setState(resultProduct.getString("state"));
|
||||
p.setApprover(resultProduct.getString("approver"));
|
||||
p.setResult(resultProduct.getString("result"));
|
||||
productList.add(p);
|
||||
}
|
||||
return ResponseEntity.ok(productList);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteProduct")
|
||||
public ResponseEntity<List<Product>> deleteProduct(@RequestBody Product product) throws Exception {
|
||||
DeleteProduct.delete(product.getState(), product.getApprover(), product.getResult());
|
||||
//进行整体数据传输
|
||||
ResultSet resultProduct = CheckProduct.MyAccount();
|
||||
// 封装结果集到Product列表
|
||||
List<Product> productList = new ArrayList<>();
|
||||
while (resultProduct.next()) {
|
||||
Product p = new Product();
|
||||
p.setState(resultProduct.getString("state"));
|
||||
p.setApprover(resultProduct.getString("approver"));
|
||||
p.setResult(resultProduct.getString("result"));
|
||||
productList.add(p);
|
||||
}
|
||||
return ResponseEntity.ok(productList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AddProduct {
|
||||
public static void add(String state,String approver,String result) throws SQLException {
|
||||
String sql ="INSERT INTO product(state,approver,result) VALUES (?,?,?) ";
|
||||
PreparedStatement preparedStatement;
|
||||
preparedStatement = JDBC.getConnection().prepareStatement(sql);
|
||||
preparedStatement.setString(1,state);
|
||||
preparedStatement.setString(2,approver);
|
||||
preparedStatement.setString(3,result);
|
||||
|
||||
|
||||
preparedStatement.executeLargeUpdate();//插入数据
|
||||
preparedStatement.close();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AddRegister {
|
||||
public static void add(String username,String password) throws SQLException {
|
||||
String sql ="INSERT INTO register(username,password) VALUES (?,?) ";
|
||||
PreparedStatement preparedStatement;
|
||||
preparedStatement = JDBC.getConnection().prepareStatement(sql);
|
||||
preparedStatement.setString(1,username);
|
||||
preparedStatement.setString(2,password);
|
||||
|
||||
|
||||
preparedStatement.executeLargeUpdate();//插入数据
|
||||
preparedStatement.close();
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CheckProduct {
|
||||
public static ResultSet MyAccount() throws SQLException {
|
||||
String sql = "SELECT* FROM product";
|
||||
ResultSet resultSet;
|
||||
PreparedStatement preparedStatement;
|
||||
preparedStatement = JDBC.getConnection().prepareStatement(sql);
|
||||
resultSet = preparedStatement.executeQuery();//查询数据
|
||||
return resultSet;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CheckRegister {
|
||||
public static ResultSet MyAccount(String username) throws SQLException {
|
||||
String sql = "SELECT* FROM register where username = ?";
|
||||
ResultSet resultSet;
|
||||
PreparedStatement preparedStatement;
|
||||
preparedStatement = JDBC.getConnection().prepareStatement(sql);
|
||||
preparedStatement.setString(1, username);
|
||||
resultSet = preparedStatement.executeQuery();//查询数据
|
||||
return resultSet;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
public class DeleteProduct {
|
||||
public static void delete(String state,String approver,String result ) throws Exception{
|
||||
String sql = "delete from product where state=? AND approver = ? AND result = ?";
|
||||
PreparedStatement preparedStatement;
|
||||
preparedStatement = JDBC.getConnection().prepareStatement(sql);
|
||||
|
||||
preparedStatement.setString(1, state);
|
||||
preparedStatement.setString(2, approver);
|
||||
preparedStatement.setString(3, result);
|
||||
|
||||
preparedStatement.executeUpdate();//插入数据
|
||||
preparedStatement.close();
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package mysql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class JDBC {
|
||||
// static {
|
||||
// try {
|
||||
// Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
private static String url="jdbc:mysql://127.0.0.1:3306/vue";
|
||||
private static String username="root";
|
||||
private static String password="123456";
|
||||
|
||||
public static Connection getConnection() {
|
||||
Connection connection;
|
||||
try {
|
||||
connection= DriverManager.getConnection(url,username,password);
|
||||
return connection;
|
||||
} catch (SQLException e) {
|
||||
System.out.println("数据库未连接");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
server.port=8081
|
||||
|
||||
spring.datasource.url="jdbc:mysql://127.0.0.1:3306/vue"
|
||||
spring.datasource.username="root"
|
||||
spring.datasource.password="123456"
|
|
@ -1,5 +0,0 @@
|
|||
server.port=8081
|
||||
|
||||
spring.datasource.url="jdbc:mysql://127.0.0.1:3306/vue"
|
||||
spring.datasource.username="root"
|
||||
spring.datasource.password="123456"
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
artifactId=vueDemo
|
||||
groupId=com.example
|
||||
version=0.0.1-SNAPSHOT
|
|
@ -1,12 +0,0 @@
|
|||
mysql\AddProduct.class
|
||||
mysql\AddRegister.class
|
||||
com\example\vuedemo\Token\IntercepterConfig.class
|
||||
mysql\CheckRegister.class
|
||||
mysql\DeleteProduct.class
|
||||
mysql\CheckProduct.class
|
||||
com\example\vuedemo\Product.class
|
||||
com\example\vuedemo\Token\TokenGenerate.class
|
||||
com\example\vuedemo\vueControll.class
|
||||
mysql\JDBC.class
|
||||
com\example\vuedemo\Token\TokenInterceptor.class
|
||||
com\example\vuedemo\VueDemoApplication.class
|
|
@ -1,12 +0,0 @@
|
|||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\VueDemoApplication.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\Token\IntercepterConfig.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\AddRegister.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\JDBC.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\Token\TokenInterceptor.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\AddProduct.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\CheckRegister.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\Token\TokenGenerate.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\CheckProduct.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\Product.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\com\example\vuedemo\vueControll.java
|
||||
C:\Users\Xubx\IdeaProjects\vueDemo\src\main\java\mysql\DeleteProduct.java
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue