├── .idea ├── .gitignore └── vcs.xml ├── L-book-client ├── .gitignore ├── README.md ├── babel.config.js ├── index.html ├── package-lock.json ├── package.json ├── public │ ├── book.png │ ├── css │ │ └── bootstrap.min.css │ ├── images │ │ └── home.png │ └── index.html ├── src │ ├── App.vue │ ├── api │ │ ├── ajax.js │ │ └── index.js │ ├── components │ │ ├── Book │ │ │ └── Book.vue │ │ ├── Navbar │ │ │ └── Navbar.vue │ │ ├── Order │ │ │ └── Order.vue │ │ └── ShopCart │ │ │ └── ShopCart.vue │ ├── main.js │ ├── pages │ │ ├── About │ │ │ └── About.vue │ │ ├── Books │ │ │ └── Books.vue │ │ ├── Home │ │ │ └── Home.vue │ │ ├── Login │ │ │ └── Login.vue │ │ ├── Orders │ │ │ └── Orders.vue │ │ ├── Search │ │ │ └── Search.vue │ │ ├── Statistics │ │ │ └── Statistics.vue │ │ └── Users │ │ │ └── Users.vue │ ├── router │ │ └── index.js │ └── store │ │ ├── index.js │ │ └── modules │ │ ├── Books.js │ │ ├── Orders.js │ │ ├── Person.js │ │ └── ShopCart.js └── vue.config.js ├── L-book-server ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml ├── sql │ ├── create_database.sql │ ├── create_table_books.sql │ ├── create_table_orders.sql │ └── create_table_users.sql └── src │ ├── main │ ├── java │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ └── cn │ │ │ └── liantao │ │ │ └── lbook │ │ │ ├── LBookApplication.java │ │ │ ├── config │ │ │ └── MongoConf.java │ │ │ ├── controller │ │ │ ├── BookController.java │ │ │ ├── MailController.java │ │ │ ├── OrderController.java │ │ │ ├── SrcController.java │ │ │ └── UserController.java │ │ │ ├── entity │ │ │ ├── Book.java │ │ │ ├── DateOrder.java │ │ │ ├── LoginState.java │ │ │ ├── Order.java │ │ │ ├── OrderList.java │ │ │ ├── Orders.java │ │ │ ├── SecurityUser.java │ │ │ ├── User.java │ │ │ └── UserState.java │ │ │ ├── mapper │ │ │ ├── BookMapper.java │ │ │ ├── OrderMapper.java │ │ │ └── UserMapper.java │ │ │ ├── security │ │ │ ├── CustomAuthenticationFilter.java │ │ │ ├── MyUserDetailService.java │ │ │ └── SecurityConfig.java │ │ │ ├── service │ │ │ ├── BookService.java │ │ │ ├── BookServiceImpl.java │ │ │ ├── MailService.java │ │ │ ├── MailServiceImpl.java │ │ │ ├── OrderService.java │ │ │ ├── OrderServiceImpl.java │ │ │ ├── UserService.java │ │ │ └── UserServiceImpl.java │ │ │ └── util │ │ │ ├── GetRequestJson.java │ │ │ ├── Message.java │ │ │ └── RandomNumber.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ └── mybatis │ │ └── mapping │ │ ├── BookMapper.xml │ │ ├── OrderMapper.xml │ │ └── UserMapper.xml │ └── test │ └── java │ └── cn │ └── liantao │ └── lbook │ ├── LBookApplicationTests.java │ └── service │ └── UserServiceImplTest.java ├── README.md ├── readme_img ├── books.png ├── home.png └── login.png └── sql └── lbook.sql /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Default ignored files 3 | /workspace.xml -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /L-book-client/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /L-book-client/README.md: -------------------------------------------------------------------------------- 1 | ## 用户功能 2 | 3 | * 首页 4 | * 登入登出、登录态一定时间保留 5 | * 浏览所有书籍并查看书籍详情 6 | * 购物车 7 | * 书籍搜索 8 | * 下单 9 | * 个人订单查看 10 | 11 | ## 管理员功能 12 | 13 | * 书籍信息管理 14 | * 用户权限管理 15 | * 所有订单管理 16 | * 搜索特定订单 17 | * 统计数据管理(Undo) 18 | 19 | # 快速开始 20 | 21 | 1.克隆项目到本地(欢迎star) 22 | 2.安装依赖``npm install`` 23 | 3.启动项目``npm run server`` 24 | -------------------------------------------------------------------------------- /L-book-client/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /L-book-client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 12 | 13 | 14 |

Welcome to nginx!

15 |

If you see this page, the nginx web server is successfully installed and 16 | working. Further configuration is required.

17 | 18 |

For online documentation and support please refer to 19 | nginx.org.
20 | Commercial support is available at 21 | nginx.com.

22 | 23 |

Thank you for using nginx.

24 | 25 | 26 | -------------------------------------------------------------------------------- /L-book-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "l-book", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.18.0", 12 | "echarts": "^4.2.1", 13 | "element-ui": "^2.6.1", 14 | "v-charts": "^1.19.0", 15 | "vue": "^2.6.6", 16 | "vue-lazyload": "^1.2.6", 17 | "vue-router": "^3.1.2", 18 | "vuex": "^3.1.0" 19 | }, 20 | "devDependencies": { 21 | "@vue/cli-plugin-babel": "^3.4.0", 22 | "@vue/cli-plugin-eslint": "^3.4.0", 23 | "@vue/cli-service": "^3.4.0", 24 | "babel-eslint": "^10.0.1", 25 | "eslint": "^5.8.0", 26 | "eslint-plugin-vue": "^5.0.0", 27 | "vue-template-compiler": "^2.5.21" 28 | }, 29 | "eslintConfig": { 30 | "root": true, 31 | "env": { 32 | "node": true 33 | }, 34 | "extends": [ 35 | "plugin:vue/essential", 36 | "eslint:recommended" 37 | ], 38 | "rules": {}, 39 | "parserOptions": { 40 | "parser": "babel-eslint" 41 | } 42 | }, 43 | "postcss": { 44 | "plugins": { 45 | "autoprefixer": {} 46 | } 47 | }, 48 | "browserslist": [ 49 | "> 1%", 50 | "last 2 versions", 51 | "not ie <= 8" 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /L-book-client/public/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/L-book-client/public/book.png -------------------------------------------------------------------------------- /L-book-client/public/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/L-book-client/public/images/home.png -------------------------------------------------------------------------------- /L-book-client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | l-book 11 | 12 | 13 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /L-book-client/src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 46 | 47 | 67 | -------------------------------------------------------------------------------- /L-book-client/src/api/ajax.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | // 包装的axios ajax请求接口 4 | export default function ajax (url, data={}, method='GET') { 5 | return new Promise(function (resolve, reject) { 6 | let promise 7 | 8 | if (method === 'GET') { 9 | // 准备url query参数数据 10 | let dataStr = '' 11 | Object.keys(data).forEach(key => { 12 | dataStr += key + '=' + data[key] + '&' 13 | }) 14 | if (dataStr !== '') { 15 | dataStr = dataStr.substring(0, dataStr.lastIndexOf('&')) 16 | url = url + '?' + dataStr 17 | } 18 | 19 | promise = axios.get(url) 20 | } else { 21 | promise = axios.post(url, data) 22 | } 23 | 24 | promise.then(function (response) { 25 | resolve(response.data) 26 | }).catch(function (error) { 27 | reject(error) 28 | }) 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /L-book-client/src/api/index.js: -------------------------------------------------------------------------------- 1 | import ajax from './ajax' 2 | 3 | const BASE_URL = '/api' 4 | 5 | // 1、登录 6 | export const reqLogin = ({account, password}) => ajax(BASE_URL+'/login', {account, password}, 'POST') 7 | 8 | // 2、注册 9 | export const reqSignup = ({account, name, password, code, mail}) => ajax(BASE_URL+'/user/signup', {account, name, password, code, mail}, 'POST') 10 | 11 | // 3、改变用户状态 12 | export const reqChangeUser = (account) => ajax(BASE_URL+'/user/change', {account}, 'POST') 13 | 14 | // 4、获取所有用户状态 15 | export const reqGetUserState = () => ajax(BASE_URL+'/user/states') 16 | 17 | // 5、获取所有书籍 18 | export const reqGetAllBook = () => ajax(BASE_URL+'/book/get') 19 | 20 | // 6、添加书籍 21 | export const reqAddBook = (book) => ajax(BASE_URL+'/book/add', { 22 | name: book.name, 23 | author: book.author, 24 | isbn: book.isbn, 25 | outline: book.outline, 26 | price: book.price, 27 | stock: book.stock, 28 | cover: book.cover, 29 | press: book.press, 30 | year: book.year, 31 | pages: book.pages, 32 | }, 'POST') 33 | 34 | // 7、修改书籍 35 | export const reqModifyBook = (book,newisbn,cover) => ajax(BASE_URL+'/book/modify', { 36 | name: book.name, 37 | author: book.author, 38 | isbn: book.isbn, 39 | newisbn: newisbn, 40 | outline: book.outline, 41 | price: book.price, 42 | stock: book.stock, 43 | cover: cover, 44 | press: book.press, 45 | year: book.year, 46 | pages: book.pages, 47 | }, 'POST') 48 | 49 | // 8、获得相应用户订单 50 | export const reqGetOrder = (account) => ajax(BASE_URL+'/order/get',{account}, 'POST') 51 | 52 | // 9、添加订单 53 | export const reqAddOrder = (orders) => ajax(BASE_URL+'/order/add', {orders}, 'POST') 54 | 55 | // 10、获得所有订单 56 | export const reqGetAllOrder = () => ajax(BASE_URL+'/order/getall') 57 | 58 | // 11、搜索书籍 59 | export const reqSearchBook = (filter) => ajax(BASE_URL+'/book/search', {filter}) 60 | 61 | // 12、删除上传的书籍图片 62 | export const reqDeleteImg = (filename) => ajax(BASE_URL+'/delete', {filename}) 63 | 64 | // 13、获得书籍详情 65 | export const reqGetBookDetail = (ISBN) => ajax(BASE_URL+'/book/detail', {ISBN}) 66 | 67 | // 14、删除书籍 68 | export const reqDeleteBook = (ISBN) => ajax(BASE_URL+'/book/delete', {ISBN}) 69 | 70 | // 15、判断用户最近是否登录 71 | export const reqInitLogin = () => ajax(BASE_URL+'/user/init') 72 | 73 | // 16、用户登出 74 | export const reqLogout = () => ajax(BASE_URL+'/logout') 75 | 76 | // 17、搜索订单 77 | export const reqSearchOrder = (filter) => ajax(BASE_URL+'/order/search', {filter}) 78 | 79 | // 18、日期筛选订单 80 | export const reqDateOrderFilter = (beginDate, endDate, account) => ajax(BASE_URL+'/order/date', {beginDate, endDate, account}) 81 | 82 | // 19、日期筛选订单详情 83 | export const reqDateDetailOrderFilter = (beginDate, endDate, account) => ajax(BASE_URL+'/order/dateDetail', {beginDate, endDate, account}) 84 | 85 | // 20、请求手机短信验证码 86 | export const reqPhoneCode = (phoneNumber) => ajax(BASE_URL+'/user/code', {phoneNumber}) 87 | 88 | // 21、请求发送找回密码的电子邮件 89 | export const reqSendMail = (phoneNumber) => ajax(BASE_URL+'/mail', {phoneNumber}) 90 | -------------------------------------------------------------------------------- /L-book-client/src/components/Book/Book.vue: -------------------------------------------------------------------------------- 1 | 165 | 166 | 352 | 353 | 402 | -------------------------------------------------------------------------------- /L-book-client/src/components/Navbar/Navbar.vue: -------------------------------------------------------------------------------- 1 | 81 | 82 | 113 | 114 | 117 | -------------------------------------------------------------------------------- /L-book-client/src/components/Order/Order.vue: -------------------------------------------------------------------------------- 1 | 47 | 48 | 83 | 84 | 119 | -------------------------------------------------------------------------------- /L-book-client/src/components/ShopCart/ShopCart.vue: -------------------------------------------------------------------------------- 1 | 88 | 89 | 177 | 178 | 290 | -------------------------------------------------------------------------------- /L-book-client/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import store from './store' 4 | import router from './router' 5 | import axios from 'axios' 6 | import VCharts from 'v-charts' 7 | import 'element-ui/lib/theme-chalk/index.css' 8 | import ElementUI from 'element-ui' 9 | import VueLazyload from 'vue-lazyload' 10 | 11 | Vue.use(ElementUI) 12 | Vue.use(VCharts) 13 | Vue.use(VueLazyload) 14 | 15 | Vue.config.productionTip = false 16 | Vue.prototype.axios = axios 17 | 18 | new Vue({ 19 | render: h => h(App), 20 | router, 21 | store 22 | }).$mount('#app') 23 | -------------------------------------------------------------------------------- /L-book-client/src/pages/About/About.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 26 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Books/Books.vue: -------------------------------------------------------------------------------- 1 | 89 | 90 | 222 | 223 | 248 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Home/Home.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 26 | 27 | 54 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Login/Login.vue: -------------------------------------------------------------------------------- 1 | 85 | 86 | 339 | 340 | 347 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Orders/Orders.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 52 | 53 | 56 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Search/Search.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 63 | 64 | 67 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Statistics/Statistics.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 198 | 199 | 204 | -------------------------------------------------------------------------------- /L-book-client/src/pages/Users/Users.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 73 | 74 | 79 | -------------------------------------------------------------------------------- /L-book-client/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | import Home from '../pages/Home/Home.vue' 5 | import Login from '../pages/Login/Login.vue' 6 | import Books from '../pages/Books/Books.vue' 7 | import Search from '../pages/Search/Search.vue' 8 | import Orders from '../pages/Orders/Orders.vue' 9 | import Statistics from '../pages/Statistics/Statistics.vue' 10 | import Users from '../pages/Users/Users.vue' 11 | import About from '../pages/About/About.vue' 12 | 13 | 14 | Vue.use(VueRouter) 15 | 16 | export default new VueRouter({ 17 | // 所有路由 18 | routes: [ 19 | { 20 | path: '/login', 21 | component: Login, 22 | meta: { 23 | showNavDetail: false, 24 | } 25 | }, 26 | { 27 | path: '/home', 28 | component: Home, 29 | meta: { 30 | showNavDetail: true, 31 | } 32 | }, 33 | { 34 | path: '/books', 35 | component: Books, 36 | meta: { 37 | showNavDetail: true 38 | } 39 | }, 40 | { 41 | path: '/search', 42 | component: Search, 43 | meta: { 44 | showNavDetail: true 45 | } 46 | }, 47 | { 48 | path: '/orders', 49 | component: Orders, 50 | meta: { 51 | showNavDetail: true 52 | } 53 | }, 54 | { 55 | path: '/statistics', 56 | component: Statistics, 57 | meta: { 58 | showNavDetail: true 59 | } 60 | }, 61 | { 62 | path: '/users', 63 | component: Users, 64 | meta: { 65 | showNavDetail: true 66 | } 67 | }, 68 | { 69 | path: '/about', 70 | component: About, 71 | meta: { 72 | showNavDetail: true 73 | } 74 | }, 75 | { 76 | path: '/', 77 | redirect: '/home' 78 | }, 79 | ] 80 | }) 81 | 82 | -------------------------------------------------------------------------------- /L-book-client/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import ShopCart from './modules/ShopCart' 4 | import Person from './modules/Person' 5 | import Books from './modules/Books' 6 | import Orders from './modules/Orders' 7 | 8 | Vue.use(Vuex) 9 | 10 | export default new Vuex.Store({ 11 | modules: { 12 | ShopCart, 13 | Person, 14 | Books, 15 | Orders 16 | }, 17 | }) 18 | -------------------------------------------------------------------------------- /L-book-client/src/store/modules/Books.js: -------------------------------------------------------------------------------- 1 | import {reqGetAllBook, reqSearchBook} from '../../api' 2 | 3 | const state = { 4 | books: [], 5 | filteredBooks: [] 6 | } 7 | 8 | const mutations = { 9 | updateBook(state, books) { 10 | state.books = books 11 | }, 12 | 13 | updateFilteredBook(state, books) { 14 | state.filteredBooks = books 15 | } 16 | } 17 | 18 | const actions = { 19 | getAllBook({commit}) { 20 | reqGetAllBook().then( (data) => { 21 | commit('updateBook', data) 22 | }) 23 | }, 24 | 25 | searchBook({commit}, filter) { 26 | reqSearchBook(filter).then((data) => { 27 | commit('updateFilteredBook', data) 28 | }) 29 | } 30 | } 31 | 32 | export default { 33 | namespaced: true, 34 | state, 35 | mutations, 36 | actions 37 | } 38 | -------------------------------------------------------------------------------- /L-book-client/src/store/modules/Orders.js: -------------------------------------------------------------------------------- 1 | import {reqGetOrder, reqGetAllOrder, reqSearchOrder} from "../../api"; 2 | 3 | const state = { 4 | orders: [], 5 | filteredOrders: [], 6 | } 7 | 8 | const mutations = { 9 | updateOrder(state, orders) { 10 | state.orders = orders 11 | } 12 | } 13 | 14 | const actions = { 15 | getOrder({commit}, account) { 16 | reqGetOrder(account).then((data) => { 17 | const orders = [] 18 | for (let items of data) { 19 | const order = [] 20 | for (let item of items) { 21 | const book = { 22 | author: item.author, 23 | name: item.bookName, 24 | count: item.count, 25 | price: item.price, 26 | total: item.price*item.count, 27 | cover: item.cover, 28 | userName: item.userName, 29 | date: item.date 30 | } 31 | order.push(book) 32 | } 33 | orders.push(order) 34 | } 35 | commit('updateOrder', orders) 36 | }) 37 | }, 38 | 39 | getAllOrder({commit}) { 40 | reqGetAllOrder().then((data) => { 41 | const orders = [] 42 | for (let items of data.orders) { 43 | const order = [] 44 | for (let item of items) { 45 | const book = { 46 | author: item.author, 47 | name: item.bookName, 48 | count: item.count, 49 | price: item.price, 50 | total: item.price*item.count, 51 | cover: item.cover, 52 | userName: item.userName, 53 | date: item.date 54 | } 55 | order.push(book) 56 | } 57 | orders.push(order) 58 | } 59 | commit('updateOrder', orders) 60 | }) 61 | }, 62 | 63 | searchOrder({commit}, filter) { 64 | reqSearchOrder(filter).then((data) => { 65 | const orders = [] 66 | for (let items of data.orders) { 67 | const order = [] 68 | for (let item of items) { 69 | const book = { 70 | author: item.author, 71 | name: item.bookName, 72 | count: item.count, 73 | price: item.price, 74 | total: item.price*item.count, 75 | cover: item.cover, 76 | userName: item.userName, 77 | date: item.date 78 | } 79 | order.push(book) 80 | } 81 | orders.push(order) 82 | } 83 | commit('updateOrder', orders) 84 | }) 85 | } 86 | } 87 | 88 | export default { 89 | namespaced: true, 90 | state, 91 | mutations, 92 | actions 93 | } 94 | -------------------------------------------------------------------------------- /L-book-client/src/store/modules/Person.js: -------------------------------------------------------------------------------- 1 | import {reqGetUserState} from '../../api' 2 | 3 | const state = { 4 | isManager: false, 5 | isLogin: false, 6 | account: '', 7 | userStates: [], 8 | } 9 | 10 | const mutations = { 11 | changeManager (state) { 12 | state.isManager = !state.isManager 13 | }, 14 | changeLogin (state) { 15 | state.isLogin = !state.isLogin 16 | }, 17 | 18 | updateUserState (state, userStates) { 19 | state.userStates = userStates 20 | }, 21 | 22 | setAccount (state, account) { 23 | state.account = account 24 | } 25 | } 26 | 27 | const actions = { 28 | getUerState ({commit}) { 29 | reqGetUserState().then((data) => { 30 | commit('updateUserState', data) 31 | }) 32 | } 33 | } 34 | 35 | export default { 36 | namespaced: true, 37 | state, 38 | mutations, 39 | actions 40 | } 41 | -------------------------------------------------------------------------------- /L-book-client/src/store/modules/ShopCart.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | books: [], 3 | } 4 | 5 | const mutations = { 6 | deletebook(state, index) { 7 | state.books.splice(index, 1) 8 | }, 9 | 10 | add(state, index){ 11 | state.books[index].count++ 12 | state.books[index].money+= state.books[index].price 13 | }, 14 | 15 | substract(state, index){ 16 | state.books[index].count-- 17 | state.books[index].money-= state.books[index].price 18 | }, 19 | 20 | clearShopCart (state) { 21 | state.books = [] 22 | } 23 | } 24 | 25 | const actions = { 26 | addtocart({state}, book) { 27 | return new Promise((resolve, reject) => { 28 | let repeat = false; 29 | state.books.forEach((item) => { 30 | if (book.name === item.name && book.author === item.author) { 31 | if (book.count+item.count <= item.stock) { 32 | item.money += book.money 33 | item.count += book.count 34 | } else { 35 | reject("exceed") 36 | } 37 | 38 | repeat = true 39 | } 40 | }) 41 | 42 | if (!repeat) { 43 | if (book.stock === 0) { 44 | reject("exceed") 45 | } else { 46 | state.books.push(book) 47 | } 48 | } 49 | 50 | resolve("succeed") 51 | }) 52 | }, 53 | } 54 | 55 | 56 | export default { 57 | namespaced: true, 58 | state, 59 | mutations, 60 | actions 61 | } 62 | -------------------------------------------------------------------------------- /L-book-client/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | // 跨域代理 4 | proxy: { 5 | '/api': { 6 | //target: 'http://47.100.236.223:1211/', 7 | target: 'http://localhost:1211/', 8 | changeOrigin: true, 9 | ws: true, 10 | pathRewrite: { 11 | '^/api': '' 12 | } 13 | }, 14 | } 15 | }, 16 | // 基本路径 17 | publicPath: './', 18 | } 19 | -------------------------------------------------------------------------------- /L-book-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | -------------------------------------------------------------------------------- /L-book-server/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if(mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if(mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if(!outputFile.getParentFile().exists()) { 87 | if(!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /L-book-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/L-book-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /L-book-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /L-book-server/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | -------------------------------------------------------------------------------- /L-book-server/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /L-book-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | cn.liantao 12 | l-book 13 | 0.0.1-SNAPSHOT 14 | L-book 15 | L-book 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-jdbc 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-security 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-mail 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-data-mongodb 51 | 2.1.3.RELEASE 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-actuator 57 | 2.1.3.RELEASE 58 | 59 | 60 | 61 | mysql 62 | mysql-connector-java 63 | 8.0.15 64 | 65 | 66 | 67 | org.apache.commons 68 | commons-text 69 | 1.6 70 | 71 | 72 | 73 | org.mybatis.spring.boot 74 | mybatis-spring-boot-starter 75 | 1.3.2 76 | 77 | 78 | 79 | org.projectlombok 80 | lombok 81 | 1.18.6 82 | 83 | 84 | 85 | com.aliyun 86 | aliyun-java-sdk-core 87 | 4.0.3 88 | 89 | 90 | 91 | com.alibaba 92 | fastjson 93 | 1.2.46 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.springframework.boot 101 | spring-boot-maven-plugin 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /L-book-server/sql/create_database.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE ebook; -------------------------------------------------------------------------------- /L-book-server/sql/create_table_books.sql: -------------------------------------------------------------------------------- 1 | USE ebook; 2 | CREATE TABLE `books` ( 3 | `name` VARCHAR(50) NULL, 4 | `author` VARCHAR(50) NULL, 5 | `ISBN` VARCHAR(50) NOT NULL, 6 | `outline` VARCHAR(1000) NULL, 7 | `stock` INT NULL, 8 | `PRICE` FLOAT NULL, 9 | `url` VARCHAR(100) NULL, 10 | `press` VARCHAR(50) NULL, 11 | `year` VARCHAR(4) NULL, 12 | `pages` INT NULL, 13 | PRIMARY KEY (`ISBN`)); -------------------------------------------------------------------------------- /L-book-server/sql/create_table_orders.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `orders` ( 2 | `id` INT NOT NULL, 3 | `account` VARCHAR(50) NULL DEFAULT NULL, 4 | `ISBN` VARCHAR(50) NOT NULL, 5 | `count` SMALLINT NULL DEFAULT NULL, 6 | `date` DATETIME NULL DEFAULT NULL, 7 | PRIMARY KEY (`id`, `ISBN`), 8 | INDEX `account_idx` (`account` ASC), 9 | INDEX `ISBN_idx` (`ISBN` ASC), 10 | CONSTRAINT `account` 11 | FOREIGN KEY (`account`) 12 | REFERENCES `users` (`account`) 13 | ON DELETE NO ACTION 14 | ON UPDATE NO ACTION, 15 | CONSTRAINT `ISBN` 16 | FOREIGN KEY (`ISBN`) 17 | REFERENCES `books` (`ISBN`) 18 | ON DELETE NO ACTION 19 | ON UPDATE NO ACTION 20 | ); -------------------------------------------------------------------------------- /L-book-server/sql/create_table_users.sql: -------------------------------------------------------------------------------- 1 | USE ebook; 2 | CREATE TABLE `users` ( 3 | `account` VARCHAR(50) NOT NULL, 4 | `password` VARCHAR(50) NULL, 5 | `name` VARCHAR(50) NULL, 6 | `allowed` TINYINT NULL, 7 | `ismanager` TINYINT NULL, 8 | `mail` VARCHAR(30) NOT NULL, 9 | PRIMARY KEY (`account`)); -------------------------------------------------------------------------------- /L-book-server/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: cn.liantao.lbook.LBookApplication 3 | 4 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/LBookApplication.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @MapperScan("cn.liantao.lbook.mapper") 8 | @SpringBootApplication 9 | public class LBookApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LBookApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/config/MongoConf.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.config; 2 | 3 | import com.mongodb.client.MongoDatabase; 4 | import com.mongodb.client.gridfs.GridFSBucket; 5 | import com.mongodb.client.gridfs.GridFSBuckets; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.mongodb.MongoDbFactory; 10 | 11 | @Configuration 12 | public class MongoConf { 13 | @Autowired 14 | private MongoDbFactory mongoDbFactory; 15 | 16 | @Bean 17 | public GridFSBucket getGridFSBuckets() { 18 | MongoDatabase db = mongoDbFactory.getDb(); 19 | return GridFSBuckets.create(db); 20 | } 21 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/controller/BookController.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.controller; 2 | 3 | import cn.liantao.lbook.entity.Book; 4 | import cn.liantao.lbook.service.BookService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.mongodb.core.query.Criteria; 7 | import org.springframework.data.mongodb.core.query.Query; 8 | import org.springframework.data.mongodb.gridfs.GridFsTemplate; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.servlet.http.HttpSession; 12 | import java.io.InputStream; 13 | import java.util.List; 14 | 15 | @RestController 16 | @RequestMapping(value = "/book") 17 | public class BookController { 18 | 19 | // 创建连接数据库的接口实例 20 | @Autowired 21 | private BookService bookService; 22 | 23 | // mongodb操作实例 24 | @Autowired 25 | private GridFsTemplate gridFsTemplate; 26 | 27 | // 监听'/book/get' 返回所有书籍数据 28 | @RequestMapping(value = "/get", method = RequestMethod.GET) 29 | @ResponseBody 30 | public List getBooks() { 31 | List books= bookService.getBooks(); 32 | return books; 33 | } 34 | 35 | // 监听'/book/search' 接受一个参数 返回过滤后的书籍数据 36 | @RequestMapping(value = "/search", method = RequestMethod.GET) 37 | @ResponseBody 38 | public List searchBooks(@RequestParam("filter") String filter) { 39 | List books= bookService.searchBooks(filter); 40 | return books; 41 | } 42 | 43 | // 监听'/book/add' 添加书籍,写入数据库 44 | @RequestMapping(value = "/add", method = RequestMethod.POST) 45 | @ResponseBody 46 | public String addBook(@RequestBody Book book, HttpSession session){ 47 | InputStream inputStream = (InputStream)session.getAttribute("file"); 48 | if (inputStream != null) { 49 | // 将图片写入mongodb中 50 | try { 51 | gridFsTemplate.store(inputStream, book.getCover()); 52 | }catch (Exception e) { 53 | return e.getMessage(); 54 | } 55 | } 56 | 57 | bookService.addBook(book); 58 | Book result = bookService.getBook(book.getISBN()); 59 | 60 | return "添加书籍成功"; 61 | } 62 | 63 | // 监听'/book/modify' 修改相应书籍的相应数据 64 | @RequestMapping(value = "/modify", method = RequestMethod.POST) 65 | @ResponseBody 66 | public String modifyBook(@RequestBody Book book, HttpSession session) { 67 | 68 | // 判断是否需要删除书籍封面图片 69 | String filename = (String)session.getAttribute("fileDelete"); 70 | if (filename != null) { 71 | // mongodb图片数据删除 72 | Query query = Query.query(Criteria.where("filename").is(filename)); 73 | gridFsTemplate.delete(query); 74 | session.removeAttribute("fileDelete"); 75 | } 76 | 77 | // 判断是否需要写入图片至数据库 78 | InputStream inputStream = (InputStream)session.getAttribute("file"); 79 | if (inputStream != null) { 80 | // 将图片写入mongodb中 81 | try { 82 | gridFsTemplate.store(inputStream, book.getCover()); 83 | session.removeAttribute("file"); 84 | }catch (Exception e) { 85 | return e.getMessage(); 86 | } 87 | } 88 | 89 | int row = bookService.modifyBook(book); 90 | if (row<=0){ 91 | return "书籍信息修改失败"; 92 | } 93 | return "书籍信息修改成功"; 94 | } 95 | 96 | // 监听'/book/detail' 返回相应书籍详细信息 97 | @RequestMapping(value = "/detail", method = RequestMethod.GET) 98 | @ResponseBody 99 | public Book modifyBook(@RequestParam("ISBN") String ISBN) { 100 | Book result = bookService.getDetail(ISBN); 101 | return result; 102 | } 103 | 104 | // 监听'/book/delete' 数据库中删除相应书籍 105 | @RequestMapping(value = "/delete", method = RequestMethod.GET) 106 | @ResponseBody 107 | public String deleteBook(@RequestParam("ISBN") String ISBN) { 108 | Book book = bookService.getBook(ISBN); 109 | if (book.getCover() != null){ 110 | Query query = Query.query(Criteria.where("filename").is(book.getCover())); 111 | gridFsTemplate.delete(query); 112 | } 113 | 114 | int result = bookService.deleteBook(ISBN); 115 | if (result > 0) { 116 | return "删除成功"; 117 | } else { 118 | return "删除失败"; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/controller/MailController.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.controller; 2 | 3 | import cn.liantao.lbook.service.MailService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class MailController { 11 | @Autowired 12 | private MailService mailService; 13 | 14 | @GetMapping(value = "/mail") 15 | public String sendMail(@RequestParam("phoneNumber") String phoneNumber) { 16 | return mailService.sendMail(phoneNumber); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.controller; 2 | 3 | import cn.liantao.lbook.entity.*; 4 | import cn.liantao.lbook.service.OrderService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.sql.Timestamp; 9 | import java.text.SimpleDateFormat; 10 | import java.util.Calendar; 11 | import java.util.Date; 12 | import java.util.LinkedList; 13 | import java.util.List; 14 | 15 | @RestController 16 | @RequestMapping(value="/order") 17 | public class OrderController { 18 | 19 | // 创建连接数据库的接口实例 20 | @Autowired 21 | private OrderService orderService; 22 | 23 | // 监听'/order/get' 返回相应用户的订单数据 24 | @RequestMapping(value = "/get", method = RequestMethod.POST) 25 | @ResponseBody 26 | public List> getOrder(@RequestBody User user) { 27 | String account = user.getAccount(); 28 | List orders_raw = orderService.getOrder(account); 29 | List> orders = new LinkedList<>(); 30 | List list = new LinkedList<>(); 31 | 32 | if (orders_raw.size() > 0) { 33 | int id = orders_raw.get(0).getId(); 34 | for (int i=0;i(); 38 | list.add(orders_raw.get(i)); 39 | id = orders_raw.get(i).getId(); 40 | } else { 41 | list.add(orders_raw.get(i)); 42 | } 43 | } 44 | } 45 | orders.add(list); 46 | 47 | return orders; 48 | } 49 | 50 | // 监听'/order/getall' 返回所有用户的订单数据 51 | @RequestMapping(value = "/getall", method = RequestMethod.GET) 52 | @ResponseBody 53 | public OrderList getAllOrders() { 54 | List orders_raw = orderService.getAllOrders(); 55 | List> orders = new LinkedList<>(); 56 | List list = new LinkedList<>(); 57 | int id = orders_raw.get(0).getId().intValue(); 58 | for (int i=0;i(); 62 | list.add(orders_raw.get(i)); 63 | id = orders_raw.get(i).getId(); 64 | } else { 65 | list.add(orders_raw.get(i)); 66 | } 67 | } 68 | orders.add(list); 69 | 70 | OrderList result = new OrderList(); 71 | result.setOrders(orders); 72 | return result; 73 | } 74 | 75 | // 监听'/order/add' 添加订单,写入数据库 76 | @RequestMapping(value = "/add", method = RequestMethod.POST) 77 | @ResponseBody 78 | public List addOrder(@RequestBody Orders orders) { 79 | 80 | int size = orders.getOrders().size(); 81 | for (int i=0;i result = orderService.getOrder(orders.getOrders().get(0).getAccount()); 90 | 91 | return result; 92 | } 93 | 94 | 95 | // 监听'/order/search' 接受一个参数 返回过滤后的订单数据 96 | @RequestMapping(value = "/search", method = RequestMethod.GET) 97 | @ResponseBody 98 | public OrderList searchOrders(@RequestParam("filter") String filter) { 99 | List orders_raw = orderService.searchOrder(filter); 100 | List> orders = new LinkedList<>(); 101 | 102 | if (orders_raw.size() > 0) { 103 | List list = new LinkedList<>(); 104 | int id = orders_raw.get(0).getId().intValue(); 105 | for (int i=0;i(); 109 | list.add(orders_raw.get(i)); 110 | id = orders_raw.get(i).getId(); 111 | } else { 112 | list.add(orders_raw.get(i)); 113 | } 114 | } 115 | orders.add(list); 116 | } 117 | 118 | OrderList result = new OrderList(); 119 | result.setOrders(orders); 120 | return result; 121 | } 122 | 123 | // 监听'/order/date' 返回日期筛选后的订单数据 124 | @RequestMapping(value = "/date", method = RequestMethod.GET) 125 | @ResponseBody 126 | public List dateFilter(@RequestParam("beginDate") String beginDate, @RequestParam("endDate") String endDate, @RequestParam("account") String account) { 127 | // 将结束日期+1 便于sql操作 128 | try { 129 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 130 | Date date = format.parse(endDate); 131 | Calendar calendar = Calendar.getInstance(); 132 | calendar.setTime(date); 133 | calendar.add(Calendar.DAY_OF_MONTH, 1); 134 | date = calendar.getTime(); 135 | endDate = format.format(date); 136 | } catch (Exception e){ 137 | System.out.println(e); 138 | } 139 | 140 | return orderService.dateFilter(beginDate,endDate,account); 141 | } 142 | 143 | // 监听'/order/dateDetail' 返回日期筛选后的详细订单数据 144 | @RequestMapping(value = "/dateDetail", method = RequestMethod.GET) 145 | @ResponseBody 146 | public List dateDetailFilter(@RequestParam("beginDate") String beginDate, @RequestParam("endDate") String endDate, @RequestParam("account") String account) { 147 | // 将结束日期+1 便于sql操作 148 | try { 149 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 150 | Date date = format.parse(endDate); 151 | Calendar calendar = Calendar.getInstance(); 152 | calendar.setTime(date); 153 | calendar.add(Calendar.DAY_OF_MONTH, 1); 154 | date = calendar.getTime(); 155 | endDate = format.format(date); 156 | } catch (Exception e){ 157 | System.out.println(e); 158 | } 159 | 160 | return orderService.dateDetailFilter(beginDate,endDate,account); 161 | } 162 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/controller/SrcController.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.controller; 2 | 3 | import com.mongodb.client.gridfs.GridFSBucket; 4 | import com.mongodb.client.gridfs.model.GridFSFile; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.mongodb.core.MongoTemplate; 7 | import org.springframework.data.mongodb.core.query.Criteria; 8 | import org.springframework.data.mongodb.core.query.Query; 9 | import org.springframework.data.mongodb.gridfs.GridFsResource; 10 | import org.springframework.data.mongodb.gridfs.GridFsTemplate; 11 | import org.springframework.web.bind.annotation.*; 12 | import org.springframework.web.multipart.MultipartFile; 13 | 14 | import javax.imageio.ImageIO; 15 | import javax.servlet.http.HttpServletResponse; 16 | import javax.servlet.http.HttpSession; 17 | import java.awt.*; 18 | import java.awt.image.BufferedImage; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | @RestController 23 | public class SrcController { 24 | 25 | // mongodb操作实例 26 | @Autowired 27 | private GridFsTemplate gridFsTemplate; 28 | @Autowired 29 | private GridFSBucket gridFSBucket; 30 | @Autowired 31 | private MongoTemplate mongoTemplate; 32 | 33 | @RequestMapping(value="/upload", method = RequestMethod.POST) 34 | @ResponseBody 35 | public String upload(@RequestParam("file") MultipartFile file, HttpSession session) throws IOException { 36 | 37 | //获取图片文件名 38 | String fileName = file.getOriginalFilename(); 39 | 40 | // 文件大小控制 41 | if (file.getSize() > 500*1024) { 42 | return "文件过大"; 43 | } 44 | 45 | // 文件格式控制 46 | try { 47 | Image image = ImageIO.read(file.getInputStream()); 48 | if (image == null) 49 | return "不支持的文件类型"; 50 | } catch (IOException e) { 51 | return "不支持的文件类型"; 52 | } 53 | 54 | // 重名检查 55 | { 56 | Query query = Query.query(Criteria.where("filename").is(fileName)); 57 | if (mongoTemplate.exists(query, "fs.files")) 58 | return "文件名已存在"; 59 | } 60 | 61 | // 判断是否需要删除书籍封面图片 62 | String filename = (String)session.getAttribute("fileDelete"); 63 | if (filename != null) { 64 | // mongodb图片数据删除 65 | Query query = Query.query(Criteria.where("filename").is(filename)); 66 | gridFsTemplate.delete(query); 67 | session.removeAttribute("fileDelete"); 68 | } 69 | 70 | session.setAttribute("file", file.getInputStream()); 71 | 72 | // 返回图片名 73 | return fileName; 74 | } 75 | 76 | @RequestMapping(value="/delete", method = RequestMethod.GET) 77 | @ResponseBody 78 | public void delete(@RequestParam("filename") String filename, HttpSession session) { 79 | session.setAttribute("fileDelete", filename); 80 | session.removeAttribute("file"); 81 | return; 82 | } 83 | 84 | @RequestMapping(value = "/images/{filename}") 85 | public void downloadFile(@PathVariable String filename, HttpServletResponse response) throws Exception { 86 | Query query = Query.query(Criteria.where("filename").is(filename)); 87 | // 查询单个文件 88 | GridFSFile gfsfile = gridFsTemplate.findOne(query); 89 | if (gfsfile == null) { 90 | return; 91 | } 92 | 93 | GridFsResource resource = new GridFsResource(gfsfile, gridFSBucket.openDownloadStream(gfsfile.getObjectId())); 94 | InputStream inputStream = resource.getInputStream(); 95 | BufferedImage bi = ImageIO.read(inputStream); 96 | ImageIO.write(bi,"JPG",response.getOutputStream()); 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.controller; 2 | 3 | import cn.liantao.lbook.entity.LoginState; 4 | import cn.liantao.lbook.entity.User; 5 | import cn.liantao.lbook.entity.UserState; 6 | import cn.liantao.lbook.service.UserService; 7 | import cn.liantao.lbook.util.Message; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.servlet.http.HttpSession; 12 | import java.util.List; 13 | 14 | //数据库中关于user表的Restful api 15 | @RestController 16 | @RequestMapping(value="/user") 17 | public class UserController { 18 | 19 | // 创建连接数据库的接口实例 20 | @Autowired 21 | private UserService userservice; 22 | 23 | // 监听'/user/signup',接受json参数 并将用户信息写入数据库中 24 | @RequestMapping(value = "/signup", method = RequestMethod.POST) 25 | @ResponseBody 26 | public String signUp(@RequestBody User user, HttpSession session) { 27 | String code = (String)session.getAttribute("code"); 28 | String phoneNumber = (String)session.getAttribute("phoneNumber"); 29 | System.out.println(user); 30 | System.out.println(user.getMail()); 31 | 32 | if (code != null && code.equals(user.getCode()) && phoneNumber.equals(user.getAccount())) { 33 | if (userservice.ifExist(user.getAccount(),user.getMail())){ 34 | return "邮箱已被注册"; 35 | } else { 36 | userservice.create(user.getAccount(),user.getPassword(),user.getName(), user.getMail()); 37 | return "注册成功"; 38 | } 39 | } else { 40 | return "验证码错误"; 41 | } 42 | } 43 | 44 | // 监听'/user/login', Spring Security下因认证不通过进入的页面 45 | @GetMapping(value = "/login") 46 | @ResponseBody 47 | public String login(){ 48 | return "请先登录"; 49 | } 50 | 51 | // 监听'/user/switch',接受用户json参数 改变用户禁用态 52 | @RequestMapping(value = "/change", method = RequestMethod.POST) 53 | @ResponseBody 54 | public User change(@RequestBody User user) { 55 | String account = user.getAccount(); 56 | User userToChange = userservice.getUser(account); 57 | if (userToChange.getAllowed()) { 58 | userservice.banUser(account); 59 | } else { 60 | userservice.allowUser(account); 61 | } 62 | 63 | userToChange = userservice.getUser(account); 64 | return userToChange; 65 | } 66 | 67 | // 监听'/user/states',获取所有用户的权限 68 | @RequestMapping(value = "/states", method = RequestMethod.GET) 69 | @ResponseBody 70 | public List getUserStates() { 71 | List userStates = userservice.getUserStates(); 72 | return userStates; 73 | } 74 | 75 | // 监听'/user/init',判断用户是否最近登录 76 | @RequestMapping(value = "/init", method = RequestMethod.GET) 77 | @ResponseBody 78 | public LoginState ifUserLogin(HttpSession session) { 79 | LoginState loginState; 80 | loginState = (LoginState)session.getAttribute("loginState"); 81 | if (loginState == null) 82 | loginState = new LoginState(); 83 | return loginState; 84 | } 85 | 86 | // 监听'/user/code' 发送短信验证码到手机 87 | @RequestMapping(value = "/code", method = RequestMethod.GET) 88 | @ResponseBody 89 | public String code(@RequestParam("phoneNumber")String phoneNumber, HttpSession session) { 90 | if (userservice.ifExist(phoneNumber, null)) 91 | return "手机号已被注册"; 92 | try { 93 | String code = Message.sendSMS(phoneNumber); 94 | if (code == "发送失败"){ 95 | return "发送失败"; 96 | } else { 97 | session.setAttribute("code", code); 98 | session.setAttribute("phoneNumber", phoneNumber); 99 | return "发送成功"; 100 | } 101 | } catch (Exception e) { 102 | e.printStackTrace(); 103 | return "发送失败"; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/Book.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | //Book实体定义 6 | @Data 7 | public class Book { 8 | private String name; 9 | private String author; 10 | private String ISBN; 11 | private String newisbn; 12 | private String outline; 13 | private Integer stock; 14 | private Float price; 15 | private String cover; 16 | private String press; 17 | private String year; 18 | private Integer pages; 19 | } 20 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/DateOrder.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.Data; 6 | 7 | import java.sql.Timestamp; 8 | 9 | @Data 10 | @JsonInclude(JsonInclude.Include.NON_NULL) 11 | public class DateOrder { 12 | private int id; 13 | private String account; 14 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") 15 | private Timestamp date; 16 | private Integer count; 17 | private String bookName; 18 | private Float amount; 19 | } 20 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/LoginState.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LoginState { 7 | private Boolean isLogin; 8 | private Integer code; 9 | private String account; 10 | private String name; 11 | private String message; 12 | } 13 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/Order.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.sql.Timestamp; 7 | 8 | // Order实体定义 9 | @Data 10 | public class Order { 11 | private Integer id; 12 | private String account; 13 | private String userName; 14 | private String bookName; 15 | private String author; 16 | private String ISBN; 17 | private String cover; 18 | private Float price; 19 | private Integer count; 20 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 21 | private Timestamp date; 22 | } 23 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/OrderList.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class OrderList { 9 | 10 | private List> orders; 11 | } 12 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/Orders.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class Orders { 9 | 10 | private List orders; 11 | } 12 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/SecurityUser.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collection; 10 | import java.util.List; 11 | 12 | @Data 13 | public class SecurityUser implements UserDetails { 14 | private Long id; 15 | private String username; 16 | private String password; 17 | private boolean enabled; 18 | private List roles; 19 | 20 | @Override 21 | public boolean isAccountNonExpired() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public boolean isAccountNonLocked() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean isCredentialsNonExpired() { 32 | return true; 33 | } 34 | 35 | @Override 36 | public boolean isEnabled() { 37 | return enabled; 38 | } 39 | 40 | public Collection getAuthorities() { 41 | List authorities = new ArrayList<>(); 42 | for (GrantedAuthority role : roles) { 43 | authorities.add(new SimpleGrantedAuthority(role.getAuthority())); 44 | } 45 | return authorities; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/User.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | //User实体定义 6 | @Data 7 | public class User { 8 | private String account; 9 | private String password; 10 | private String name; 11 | private String code; 12 | private Boolean allowed; 13 | private Boolean isManager; 14 | private String mail; 15 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/entity/UserState.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class UserState { 7 | private String account; 8 | private String name; 9 | private Boolean allowed; 10 | } 11 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/mapper/BookMapper.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.mapper; 2 | 3 | import cn.liantao.lbook.entity.Book; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.List; 7 | 8 | @Repository 9 | public interface BookMapper { 10 | Book getBook(String ISBN); 11 | List getBooks(); 12 | List searchBooks(String filter); 13 | int deleteBook(String ISBN); 14 | void addBook(Book book); 15 | int modifyBook(Book book); 16 | Book getDetail(String ISBN); 17 | } 18 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.mapper; 2 | 3 | import cn.liantao.lbook.entity.DateOrder; 4 | import cn.liantao.lbook.entity.Order; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface OrderMapper { 11 | List getAllOrders(); 12 | List searchOrder(String filter); 13 | List getOrder(String account); 14 | int setStock(String ISBN, int stock); 15 | int maxID(); 16 | int selectStock(String ISBN); 17 | void addOrder(Order order); 18 | List dateFilter(String beginDate, String endDate, String account); 19 | List dateDetailFilter(String beginDate, String endDate, String account); 20 | } 21 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.mapper; 2 | 3 | import cn.liantao.lbook.entity.User; 4 | import cn.liantao.lbook.entity.UserState; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface UserMapper { 11 | User getUser(String account); 12 | User getLoginState(String account, String password); 13 | int changeUser(Boolean allowed, String account); 14 | void createUser(String account, String password, String name, Boolean allowed, Boolean isManager, String mail); 15 | List getUserState(); 16 | User getUserWithMail(String mail); 17 | } 18 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/security/CustomAuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.security; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.core.AuthenticationException; 8 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.util.Map; 15 | 16 | public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter { 17 | @Override 18 | public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { 19 | if (request.getContentType().equals(MediaType.APPLICATION_JSON_UTF8_VALUE) 20 | || request.getContentType().equals(MediaType.APPLICATION_JSON_VALUE)) { 21 | ObjectMapper mapper = new ObjectMapper(); 22 | UsernamePasswordAuthenticationToken authRequest = null; 23 | try (InputStream is = request.getInputStream()) { 24 | Map authenticationBean = mapper.readValue(is, Map.class); 25 | authRequest = new UsernamePasswordAuthenticationToken( 26 | authenticationBean.get("account"), authenticationBean.get("password")); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | authRequest = new UsernamePasswordAuthenticationToken( 30 | "", ""); 31 | } finally { 32 | setDetails(request, authRequest); 33 | return this.getAuthenticationManager().authenticate(authRequest); 34 | } 35 | } 36 | else { 37 | return super.attemptAuthentication(request, response); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/security/MyUserDetailService.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.security; 2 | 3 | import cn.liantao.lbook.entity.SecurityUser; 4 | import cn.liantao.lbook.entity.User; 5 | import cn.liantao.lbook.service.UserService; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.security.core.authority.AuthorityUtils; 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | import org.springframework.security.core.userdetails.UserDetailsService; 13 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 14 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 15 | import org.springframework.security.crypto.password.PasswordEncoder; 16 | import org.springframework.stereotype.Component; 17 | 18 | @Component 19 | public class MyUserDetailService implements UserDetailsService { 20 | @Bean 21 | public PasswordEncoder passwordEncoder() { 22 | return new BCryptPasswordEncoder(); 23 | } 24 | 25 | @Autowired 26 | private PasswordEncoder passwordEncoder; 27 | 28 | private Logger logger = LoggerFactory.getLogger(getClass()); 29 | @Autowired 30 | private UserService userService; 31 | 32 | @Override 33 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 34 | User user = userService.getUser(username); 35 | SecurityUser securityUser = new SecurityUser(); 36 | if (user == null) { 37 | securityUser.setEnabled(true); 38 | securityUser.setUsername("wrong"+username); 39 | securityUser.setPassword("wrong"); 40 | } else { 41 | logger.info("登录用户名:" + username + " 数据库密码:" + user.getPassword()); 42 | String password = passwordEncoder.encode(user.getPassword()); 43 | 44 | securityUser.setEnabled(true); 45 | securityUser.setUsername(username); 46 | securityUser.setPassword(password); 47 | String role = user.getIsManager()? "ROLE_ADMIN" : "ROLE_USER"; 48 | securityUser.setRoles(AuthorityUtils.commaSeparatedStringToAuthorityList(role)); 49 | } 50 | 51 | return securityUser; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/security/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.security; 2 | 3 | import cn.liantao.lbook.entity.LoginState; 4 | import cn.liantao.lbook.entity.SecurityUser; 5 | import cn.liantao.lbook.service.UserService; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 11 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 12 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 13 | import org.springframework.security.core.Authentication; 14 | import org.springframework.security.core.AuthenticationException; 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 16 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 17 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 18 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 19 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 20 | 21 | import javax.servlet.ServletException; 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpServletResponse; 24 | import javax.servlet.http.HttpSession; 25 | import java.io.IOException; 26 | import java.io.PrintWriter; 27 | 28 | @Configuration 29 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 30 | @Autowired 31 | private MyUserDetailService myUserDetailService; 32 | @Autowired 33 | private UserService userService; 34 | 35 | @Override 36 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 37 | auth.userDetailsService(myUserDetailService).passwordEncoder(new BCryptPasswordEncoder()); 38 | } 39 | 40 | @Override 41 | protected void configure(HttpSecurity http) throws Exception { 42 | http.authorizeRequests() 43 | .antMatchers("/user/states","/user/switch","/book/modify","/book/add","/book/delete","/order/getall","/order/search","/upload","/delete").hasAnyRole("ADMIN") 44 | .antMatchers("/user/init","/book/get","/user/code","/user/signup","/book/detail","/book/search","/images/*","/mail").permitAll() 45 | .anyRequest().authenticated() 46 | .and() 47 | .formLogin().loginPage("/user/login").permitAll() 48 | .and() 49 | .logout().logoutUrl("/logout").permitAll().logoutSuccessHandler(new LogoutSuccessHandler() { 50 | @Override 51 | public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { 52 | response.setContentType("application/json;charset=utf-8"); 53 | PrintWriter out = response.getWriter(); 54 | HttpSession session = request.getSession(); 55 | session.removeAttribute("loginState"); 56 | out.write(new ObjectMapper().writeValueAsString( "登出成功")); 57 | out.flush(); 58 | out.close(); 59 | } 60 | }) 61 | .and().csrf().disable(); 62 | http.addFilterAt(CAFilter(), UsernamePasswordAuthenticationFilter.class); 63 | } 64 | 65 | @Bean 66 | CustomAuthenticationFilter CAFilter() throws Exception { 67 | CustomAuthenticationFilter filter = new CustomAuthenticationFilter(); 68 | filter.setAuthenticationSuccessHandler(new AuthenticationSuccessHandler() { 69 | @Override 70 | public void onAuthenticationSuccess(HttpServletRequest req, HttpServletResponse resp, Authentication authentication) throws IOException, ServletException { 71 | resp.setContentType("application/json;charset=utf-8"); 72 | PrintWriter out = resp.getWriter(); 73 | SecurityUser user = (SecurityUser)authentication.getPrincipal(); 74 | String password = userService.getUser(user.getUsername()).getPassword(); 75 | LoginState loginState = userService.getLoginState(user.getUsername(), password); 76 | if (loginState.getIsLogin()) { 77 | HttpSession session = req.getSession(); 78 | session.setAttribute("loginState", loginState); 79 | } 80 | out.write(new ObjectMapper().writeValueAsString(loginState)); 81 | out.flush(); 82 | out.close(); 83 | } 84 | }); 85 | filter.setAuthenticationFailureHandler(new AuthenticationFailureHandler() { 86 | @Override 87 | public void onAuthenticationFailure(HttpServletRequest req, HttpServletResponse resp, AuthenticationException e) throws IOException, ServletException { 88 | resp.setContentType("application/json;charset=utf-8"); 89 | PrintWriter out = resp.getWriter(); 90 | LoginState loginState = new LoginState(); 91 | loginState.setIsLogin(false); 92 | loginState.setCode(0); 93 | loginState.setMessage("用户名密码错误"); 94 | out.write(new ObjectMapper().writeValueAsString(loginState)); 95 | out.flush(); 96 | out.close(); 97 | } 98 | }); 99 | filter.setAuthenticationManager(authenticationManagerBean()); 100 | return filter; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/BookService.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.Book; 4 | 5 | import java.util.List; 6 | 7 | public interface BookService { 8 | // 获取所有书籍 9 | List getBooks(); 10 | 11 | // 搜索书籍 12 | List searchBooks(String text); 13 | 14 | // 添加书籍 15 | void addBook(Book book); 16 | 17 | // 查找书籍 18 | Book getBook(String ISBN); 19 | 20 | // 删除书籍 21 | int deleteBook(String ISBN); 22 | 23 | // 修改书籍 24 | int modifyBook(Book book); 25 | 26 | // 获得书籍详细信息 27 | Book getDetail(String ISBN); 28 | } 29 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.Book; 4 | import cn.liantao.lbook.mapper.BookMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.jdbc.core.JdbcTemplate; 7 | import org.springframework.stereotype.Service; 8 | 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class BookServiceImpl implements BookService { 14 | @Autowired 15 | private JdbcTemplate jdbcTemplate; 16 | 17 | @Autowired 18 | private BookMapper bookMapper; 19 | 20 | // 获取所有书籍 21 | @Override 22 | public List getBooks() { 23 | List books = bookMapper.getBooks(); 24 | return books; 25 | } 26 | 27 | @Override 28 | // 搜索书籍 29 | public List searchBooks(String text){ 30 | String filter = "%"+text+"%"; 31 | List books = bookMapper.searchBooks(filter); 32 | return books; 33 | } 34 | 35 | // 添加书籍 36 | @Override 37 | public void addBook(Book book) { 38 | bookMapper.addBook(book); 39 | } 40 | 41 | // 查找书籍 42 | @Override 43 | public Book getBook(String ISBN){ 44 | Book book = bookMapper.getBook(ISBN); 45 | return book; 46 | } 47 | 48 | // 删除书籍 49 | @Override 50 | public int deleteBook(String ISBN) { 51 | int result = bookMapper.deleteBook(ISBN); 52 | return result; 53 | } 54 | 55 | // 修改书籍 56 | @Override 57 | public int modifyBook(Book book) { 58 | int result = bookMapper.modifyBook(book); 59 | return result; 60 | } 61 | 62 | // 获得书籍详细信息 63 | @Override 64 | public Book getDetail(String ISBN){ 65 | Book book = bookMapper.getDetail(ISBN); 66 | return book; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/MailService.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | public interface MailService { 4 | // 发送邮件 5 | String sendMail(String phoneNumber); 6 | } 7 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/MailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.User; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.mail.SimpleMailMessage; 6 | import org.springframework.mail.javamail.JavaMailSender; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class MailServiceImpl implements MailService{ 11 | 12 | private JavaMailSender mailSender; 13 | @Autowired 14 | private UserService userService; 15 | 16 | @Override 17 | public String sendMail(String phoneNumber) { 18 | User user = userService.getUser(phoneNumber); 19 | if (user == null) 20 | return "用户不存在"; 21 | String password = user.getPassword(); 22 | String mail = user.getMail(); 23 | SimpleMailMessage message = new SimpleMailMessage(); 24 | 25 | message.setFrom("756670011@qq.com"); 26 | message.setTo(mail); 27 | message.setSubject("主题:EBook密码找回"); 28 | message.setText("您的密码为 "+password); 29 | 30 | try { 31 | mailSender.send(message); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | return "发送失败"; 35 | } 36 | 37 | return mail; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.DateOrder; 4 | import cn.liantao.lbook.entity.Order; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderService { 9 | 10 | // 添加订单 11 | void addOrder(List order); 12 | 13 | // 获取所有订单 14 | List getAllOrders(); 15 | 16 | // 获取指定用户订单 17 | List getOrder(String account); 18 | 19 | // 搜索订单 20 | List searchOrder(String filter); 21 | 22 | // 筛选指定日期内指定用户的订单 23 | List dateFilter(String beginDate, String endDate, String account); 24 | 25 | // 筛选指定日期内指定用户的详细订单 26 | List dateDetailFilter(String beginDate, String endDate, String account); 27 | } 28 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.DateOrder; 4 | import cn.liantao.lbook.entity.Order; 5 | import cn.liantao.lbook.mapper.OrderMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class OrderServiceImpl implements OrderService{ 14 | 15 | @Autowired 16 | private JdbcTemplate jdbcTemplate; 17 | 18 | @Autowired 19 | private OrderMapper orderMapper; 20 | 21 | // 添加订单 22 | @Override 23 | public void addOrder(List orders) { 24 | int id; 25 | try { 26 | id = orderMapper.maxID() + 1; 27 | } catch(Exception e){ 28 | id = 0; 29 | } 30 | 31 | for (int i=0;i= 0) { 35 | orderMapper.setStock(orders.get(i).getISBN(), stock); 36 | orders.get(i).setId(id); 37 | orderMapper.addOrder(orders.get(i)); 38 | } 39 | } 40 | } 41 | 42 | // 获取所有订单 43 | @Override 44 | public List getAllOrders() { 45 | List orders = orderMapper.getAllOrders(); 46 | return orders; 47 | } 48 | 49 | // 获取指定用户订单 50 | @Override 51 | public List getOrder(String account) { 52 | List orders = orderMapper.getOrder(account); 53 | return orders; 54 | } 55 | 56 | // 搜索订单 57 | @Override 58 | public List searchOrder(String text) { 59 | String filter = "%"+text+"%"; 60 | List orders= orderMapper.searchOrder(filter); 61 | return orders; 62 | } 63 | 64 | // 筛选指定日期内指定用户的订单 65 | @Override 66 | public List dateFilter(String beginDate, String endDate, String account) { 67 | List orders= orderMapper.dateFilter(beginDate,endDate,account); 68 | return orders; 69 | } 70 | 71 | // 筛选指定日期内指定用户的详细订单 72 | @Override 73 | public List dateDetailFilter(String beginDate, String endDate, String account) { 74 | List orders= orderMapper.dateDetailFilter(beginDate,endDate,account); 75 | return orders; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.LoginState; 4 | import cn.liantao.lbook.entity.User; 5 | import cn.liantao.lbook.entity.UserState; 6 | 7 | import java.util.List; 8 | 9 | //连接数据库User表的的抽象类 10 | public interface UserService { 11 | 12 | //新增一个用户 13 | void create(String account, String password, String name, String mail); 14 | void create(String account, String password, String name, Boolean allowed, Boolean isManager, String mail); 15 | 16 | //获取单个用户数据 17 | User getUser(String account); 18 | 19 | //判断用户状态 20 | LoginState getLoginState(String account, String password); 21 | 22 | //禁用用户 23 | int banUser(String account); 24 | 25 | //解禁用户 26 | int allowUser(String account); 27 | 28 | //获得所有用户状态 29 | List getUserStates(); 30 | 31 | //判断用户是否存在 32 | Boolean ifExist(String account, String mail); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | import cn.liantao.lbook.entity.LoginState; 4 | import cn.liantao.lbook.entity.User; 5 | import cn.liantao.lbook.entity.UserState; 6 | import cn.liantao.lbook.mapper.UserMapper; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.jdbc.core.JdbcTemplate; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | //连接数据库User表的的具体实现类 14 | @Service 15 | public class UserServiceImpl implements UserService { 16 | 17 | @Autowired 18 | private JdbcTemplate jdbcTemplate; 19 | 20 | @Autowired 21 | private UserMapper userMapper; 22 | 23 | //新增一个用户 24 | @Override 25 | public void create(String account, String password, String name, String mail) { 26 | userMapper.createUser(account, password, name, true, false, mail); 27 | } 28 | @Override 29 | public void create(String account, String password, String name, Boolean allowed, Boolean isManager, String mail) { 30 | userMapper.createUser(account, password, name, allowed, isManager, mail); 31 | } 32 | 33 | //获取单个用户数据 34 | @Override 35 | public User getUser(String account) { 36 | User user = userMapper.getUser(account); 37 | return user; 38 | } 39 | 40 | //判断用户状态 41 | @Override 42 | public LoginState getLoginState(String account, String password) { 43 | LoginState state = new LoginState(); 44 | User user; 45 | 46 | user = userMapper.getLoginState(account, password); 47 | 48 | if (user == null){ 49 | state.setIsLogin(false); 50 | state.setCode(0); 51 | state.setMessage("用户名密码错误"); 52 | } else { 53 | if (user.getAllowed()) { 54 | if (user.getIsManager()) { 55 | state.setIsLogin(true); 56 | state.setCode(1); 57 | state.setName(user.getName()); 58 | state.setAccount(user.getAccount()); 59 | state.setMessage("用户存在,为管理员"); 60 | } else { 61 | state.setIsLogin(true); 62 | state.setCode(0); 63 | state.setName(user.getName()); 64 | state.setAccount(user.getAccount()); 65 | state.setMessage("用户存在,为普通用户"); 66 | } 67 | } else { 68 | state.setIsLogin(false); 69 | state.setCode(1); 70 | state.setMessage("用户被禁用"); 71 | } 72 | } 73 | 74 | return state; 75 | } 76 | 77 | //禁用用户 78 | @Override 79 | public int banUser(String account) { 80 | int rows = userMapper.changeUser(false, account); 81 | return rows; 82 | } 83 | 84 | //解禁用户 85 | @Override 86 | public int allowUser(String account) { 87 | int rows = userMapper.changeUser(true, account); 88 | return rows; 89 | } 90 | 91 | 92 | @Override //判断用户是否存在 93 | public Boolean ifExist(String account, String mail) { 94 | User user = userMapper.getUser(account); 95 | if(user != null) { 96 | return true; 97 | } else { 98 | user = userMapper.getUserWithMail(mail); 99 | if (user != null) { 100 | return true; 101 | } else { 102 | return false; 103 | } 104 | } 105 | } 106 | 107 | @Override 108 | //获得所有用户状态 109 | public List getUserStates() { 110 | List userStates; 111 | userStates = userMapper.getUserState(); 112 | 113 | return userStates; 114 | } 115 | 116 | 117 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/util/GetRequestJson.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.util; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import java.io.IOException; 7 | 8 | public class GetRequestJson { 9 | public static JSONObject getRequestJsonObject(HttpServletRequest request) throws IOException { 10 | String json = getRequestJsonString(request); 11 | return JSONObject.parseObject(json); 12 | } 13 | 14 | public static String getRequestJsonString(HttpServletRequest request) 15 | throws IOException { 16 | String submitMehtod = request.getMethod(); 17 | // GET 18 | if (submitMehtod.equals("GET")) { 19 | return new String(request.getQueryString().getBytes("iso-8859-1"), "utf-8").replaceAll("%22", "\""); 20 | // POST 21 | } else { 22 | return getRequestPostStr(request); 23 | } 24 | } 25 | 26 | public static byte[] getRequestPostBytes(HttpServletRequest request) 27 | throws IOException { 28 | int contentLength = request.getContentLength(); 29 | if(contentLength<0){ 30 | return null; 31 | } 32 | byte buffer[] = new byte[contentLength]; 33 | for (int i = 0; i < contentLength;) { 34 | 35 | int readlen = request.getInputStream().read(buffer, i, 36 | contentLength - i); 37 | if (readlen == -1) { 38 | break; 39 | } 40 | i += readlen; 41 | } 42 | return buffer; 43 | } 44 | 45 | public static String getRequestPostStr(HttpServletRequest request) 46 | throws IOException { 47 | byte buffer[] = getRequestPostBytes(request); 48 | String charEncoding = request.getCharacterEncoding(); 49 | if (charEncoding == null) { 50 | charEncoding = "UTF-8"; 51 | } 52 | return new String(buffer, charEncoding); 53 | } 54 | } -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/util/Message.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.util; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.aliyuncs.CommonRequest; 5 | import com.aliyuncs.CommonResponse; 6 | import com.aliyuncs.DefaultAcsClient; 7 | import com.aliyuncs.IAcsClient; 8 | import com.aliyuncs.exceptions.ClientException; 9 | import com.aliyuncs.exceptions.ServerException; 10 | import com.aliyuncs.http.MethodType; 11 | import com.aliyuncs.profile.DefaultProfile; 12 | 13 | public class Message { 14 | public static String sendSMS(String phoneNumber) throws ServerException,ClientException { 15 | DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4FgaN63SWd6spjCp81WK", "xxxxx"); //阿里云短信验证需要上线应用的审核,学习使用建议用邮箱 16 | IAcsClient client = new DefaultAcsClient(profile); 17 | 18 | String code = RandomNumber.generate(6); 19 | 20 | CommonRequest request = new CommonRequest(); 21 | request.setMethod(MethodType.POST); 22 | request.setDomain("dysmsapi.aliyuncs.com"); 23 | request.setVersion("2017-05-25"); 24 | request.setAction("SendSms"); 25 | request.putQueryParameter("RegionId", "cn-hangzhou"); 26 | request.putQueryParameter("PhoneNumbers", phoneNumber); 27 | request.putQueryParameter("SignName", "LBook"); 28 | request.putQueryParameter("TemplateCode", "SMS_173343759"); 29 | request.putQueryParameter("TemplateParam", "{\"code\":\""+code+"\"}"); 30 | 31 | CommonResponse response = client.getCommonResponse(request); 32 | System.out.println(response.getData()); 33 | 34 | JSONObject json = JSONObject.parseObject(response.getData()); 35 | String Code = json.getString("Code"); 36 | 37 | if (Code.equals("OK")) { 38 | return code; 39 | } else{ 40 | return "发送失败"; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /L-book-server/src/main/java/cn/liantao/lbook/util/RandomNumber.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.util; 2 | 3 | import java.util.Random; 4 | 5 | public class RandomNumber { 6 | public static String generate(int digit) { 7 | Random random = new Random(); 8 | String result=""; 9 | for (int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 29 | 30 | 35 | 36 | 37 | DELETE FROM books 38 | WHERE isbn = #{ISBN} 39 | 40 | 41 | 42 | INSERT INTO books(name, author, isbn, outline, stock, price, cover, press, year, pages) 43 | VALUES(#{name}, #{author}, #{ISBN}, #{outline}, #{stock}, #{price}, #{cover}, #{press}, #{year}, #{pages}) 44 | 45 | 46 | 47 | UPDATE books 48 | SET name=#{name}, 49 | author=#{author}, 50 | isbn=#{newisbn}, 51 | outline=#{outline}, 52 | stock=#{stock}, 53 | price=#{price}, 54 | 55 | cover=#{cover}, 56 | 57 | 58 | cover= null, 59 | 60 | press=#{press}, 61 | year=#{year}, 62 | pages=#{pages} 63 | WHERE isbn=#{ISBN} 64 | 65 | 66 | 71 | -------------------------------------------------------------------------------- /L-book-server/src/main/resources/mybatis/mapping/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | SELECT * 24 | FROM orders 25 | NATURAL JOIN ( 26 | SELECT name AS bookname, 27 | author,ISBN, 28 | price, 29 | cover 30 | FROM books ) AS bookss 31 | NATURAL JOIN ( 32 | SELECT name AS username, 33 | account 34 | FROM users ) AS users 35 | 36 | 37 | 38 | SELECT * 39 | FROM orders 40 | NATURAL JOIN ( 41 | SELECT name AS bookname,author,ISBN,price,cover 42 | FROM books 43 | ) AS bookss 44 | NATURAL JOIN ( 45 | SELECT name AS username,account 46 | FROM users 47 | ) AS users 48 | 49 | 50 | 51 | 55 | 56 | 57 | 62 | 63 | 64 | 69 | 70 | 71 | 75 | 76 | 77 | 82 | 83 | 84 | 85 | UPDATE books 86 | SET stock=#{stock} WHERE isbn=#{ISBN} 87 | 88 | 89 | 90 | 91 | INSERT INTO orders(id, account, isbn, count, date) 92 | values(#{id}, #{account}, #{ISBN}, #{count}, #{date}) 93 | 94 | 95 | 96 | 106 | 107 | 114 | -------------------------------------------------------------------------------- /L-book-server/src/main/resources/mybatis/mapping/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | UPDATE users 28 | SET allowed= #{allowed} 29 | WHERE account= #{account} 30 | 31 | 32 | 33 | 34 | INSERT INTO users(account, password, name, allowed, isManager, mail) 35 | values(#{account}, #{password}, #{name}, #{allowed}, #{isManager}, #{mail}) 36 | 37 | 38 | 39 | 46 | 47 | 48 | 53 | -------------------------------------------------------------------------------- /L-book-server/src/test/java/cn/liantao/lbook/LBookApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook; 2 | 3 | import org.junit.Ignore; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @Ignore 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class LBookApplicationTests { 12 | 13 | } -------------------------------------------------------------------------------- /L-book-server/src/test/java/cn/liantao/lbook/service/UserServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package cn.liantao.lbook.service; 2 | 3 | 4 | 5 | public class UserServiceImplTest { 6 | 7 | 8 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 技术栈: 2 | ### 后端 3 | 1. Maven 4 | 2. SpringBoot 5 | 3. SpringActuator 6 | 4. SpringSecurity 7 | 5. MyBatis 8 | 6. Jackson 9 | 10 | 11 | 12 | ### 前端 13 | 1. Vue 14 | 2. ElementUI 15 | 3. BootStrap 16 | 4. Axios 17 | 5. vuex 18 | 6. vue-cli 19 | 20 | ## 数据库 21 | - MySQL 22 | - mongoDB 23 | 24 | 25 | ## 功能 26 | - 首页 27 | - 登录,登出 28 | - 书籍展示及详情 29 | - 购物车 30 | - 下单 31 | - 个人订单 32 | - 购买记录 33 | 34 | ## 管理员功能 35 | - 书籍管理 36 | - 用户权限 37 | - 订单管理 38 | - 搜索订单 39 | - 订单统计 40 | 41 | ## 快速开始 42 | clone以下: 43 | #### L-book-client 44 | #### L-book-server 45 | client: 运行:`npm install`,`npm run serve` 46 | server: 运行sql后脏的lbook.sql脚本,run项目即可。 47 | 48 | ## 预览图 49 | #### home 50 | ![home](readme_img/home.png) 51 | #### books 52 | ![books](readme_img/books.png) 53 | #### login 54 | ![login](readme_img/login.png) 55 | -------------------------------------------------------------------------------- /readme_img/books.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/readme_img/books.png -------------------------------------------------------------------------------- /readme_img/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/readme_img/home.png -------------------------------------------------------------------------------- /readme_img/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Famine-Life/Lbook/ae06283f107e6a30269f9b7046c545bff13530df/readme_img/login.png -------------------------------------------------------------------------------- /sql/lbook.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : admin 5 | Source Server Type : MySQL 6 | Source Server Version : 50727 7 | Source Host : localhost:3306 8 | Source Schema : lbook 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50727 12 | File Encoding : 65001 13 | 14 | Date: 19/08/2019 00:35:06 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for books 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `books`; 24 | CREATE TABLE `books` ( 25 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 26 | `author` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 27 | `ISBN` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 28 | `outline` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 29 | `stock` int(11) NULL DEFAULT NULL, 30 | `PRICE` float NULL DEFAULT NULL, 31 | `url` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 32 | `press` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 33 | `year` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 34 | `pages` int(11) NULL DEFAULT NULL, 35 | PRIMARY KEY (`ISBN`) USING BTREE 36 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 37 | 38 | -- ---------------------------- 39 | -- Table structure for orders 40 | -- ---------------------------- 41 | DROP TABLE IF EXISTS `orders`; 42 | CREATE TABLE `orders` ( 43 | `id` int(11) NOT NULL, 44 | `account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 45 | `ISBN` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 46 | `count` smallint(6) NULL DEFAULT NULL, 47 | `date` datetime(0) NULL DEFAULT NULL, 48 | PRIMARY KEY (`id`, `ISBN`) USING BTREE, 49 | INDEX `account_idx`(`account`) USING BTREE, 50 | INDEX `ISBN_idx`(`ISBN`) USING BTREE, 51 | CONSTRAINT `ISBN` FOREIGN KEY (`ISBN`) REFERENCES `books` (`ISBN`) ON DELETE NO ACTION ON UPDATE NO ACTION, 52 | CONSTRAINT `account` FOREIGN KEY (`account`) REFERENCES `users` (`account`) ON DELETE NO ACTION ON UPDATE NO ACTION 53 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 54 | 55 | -- ---------------------------- 56 | -- Table structure for users 57 | -- ---------------------------- 58 | DROP TABLE IF EXISTS `users`; 59 | CREATE TABLE `users` ( 60 | `account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 61 | `password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 62 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 63 | `allowed` tinyint(4) NULL DEFAULT NULL, 64 | `ismanager` tinyint(4) NULL DEFAULT NULL, 65 | `mail` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 66 | PRIMARY KEY (`account`) USING BTREE 67 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 68 | 69 | -- ---------------------------- 70 | -- Records of users 71 | -- ---------------------------- 72 | INSERT INTO `users` VALUES ('13481926610', '123456', 'test', 1, 0, 'xanwidtf@foxmail.com'); 73 | INSERT INTO `users` VALUES ('15707779676', '000000', 'hello', 1, 0, '23333@qq.com'); 74 | 75 | SET FOREIGN_KEY_CHECKS = 1; 76 | --------------------------------------------------------------------------------