├── .gitignore ├── public ├── img │ └── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── api_project.json ├── api_project.js ├── vendor │ ├── prettify │ │ ├── prettify.css │ │ ├── lang-rd.js │ │ ├── lang-tex.js │ │ ├── lang-latex.js │ │ ├── lang-go.js │ │ ├── lang-proto.js │ │ ├── lang-ll.js │ │ ├── lang-llvm.js │ │ ├── lang-yaml.js │ │ ├── lang-yml.js │ │ ├── lang-basic.js │ │ ├── lang-cbm.js │ │ ├── lang-wiki.js │ │ ├── lang-lua.js │ │ ├── lang-erl.js │ │ ├── lang-erlang.js │ │ ├── lang-hs.js │ │ ├── lang-tcl.js │ │ ├── lang-pascal.js │ │ ├── lang-Splus.js │ │ ├── lang-r.js │ │ ├── lang-s.js │ │ ├── lang-cl.js │ │ ├── lang-el.js │ │ ├── lang-lisp.js │ │ ├── lang-lsp.js │ │ ├── lang-rkt.js │ │ ├── lang-scm.js │ │ ├── lang-ss.js │ │ ├── lang-lgt.js │ │ ├── lang-logtalk.js │ │ ├── lang-clj.js │ │ ├── lang-mumps.js │ │ ├── lang-css.js │ │ ├── lang-scala.js │ │ ├── lang-aea.js │ │ ├── lang-agc.js │ │ ├── lang-apollo.js │ │ ├── lang-dart.js │ │ ├── lang-fs.js │ │ ├── lang-ml.js │ │ ├── lang-swift.js │ │ ├── lang-vhd.js │ │ ├── lang-vhdl.js │ │ ├── lang-n.js │ │ ├── lang-nemerle.js │ │ ├── lang-rust.js │ │ ├── lang-sql.js │ │ ├── lang-vb.js │ │ ├── lang-vbs.js │ │ ├── lang-ls.js │ │ ├── lang-lasso.js │ │ └── lang-lassoscript.js │ ├── path-to-regexp │ │ ├── LICENSE │ │ └── index.js │ ├── prettify.css │ ├── polyfill.js │ └── webfontloader.js ├── locales │ ├── zh.js │ ├── zh_cn.js │ ├── tr.js │ ├── pl.js │ ├── ca.js │ ├── cs.js │ ├── vi.js │ ├── ro.js │ ├── de.js │ ├── pt_br.js │ ├── ru.js │ ├── es.js │ ├── nl.js │ ├── fr.js │ ├── it.js │ └── locale.js └── utils │ ├── send_sample_request.js │ └── handlebars_helper.js ├── config └── index.js ├── views ├── error.ejs └── index.ejs ├── controller ├── index.js ├── home.js ├── cart.js ├── news.js ├── goods.js └── users.js ├── routes └── v1 │ ├── index.js │ ├── home.js │ ├── cart.js │ ├── goods.js │ └── users.js ├── models ├── ResBody.js └── Cart.js ├── db ├── db.js └── index.js ├── middlewares ├── users.js └── common.js ├── LICENSE ├── package.json ├── README.md ├── bin └── www └── app.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | logs 3 | .vscode 4 | .idea 5 | docs 6 | -------------------------------------------------------------------------------- /public/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TianchengLee/node-shop/HEAD/public/img/favicon.ico -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | secret: 'itcast-wh', 3 | tokenExpire: 2592000 // 一个月到期时间 单位为秒 4 | } -------------------------------------------------------------------------------- /views/error.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

2 |

<%= error.status %>

3 |
<%= error.stack %>
4 | -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TianchengLee/node-shop/HEAD/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TianchengLee/node-shop/HEAD/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TianchengLee/node-shop/HEAD/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TianchengLee/node-shop/HEAD/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /controller/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | users: require('./users'), 3 | news: require('./news'), 4 | goods: require('./goods'), 5 | cart: require('./cart'), 6 | home: require('./home') 7 | } -------------------------------------------------------------------------------- /routes/v1/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | 4 | router.get('/', function(req, res, next) { 5 | res.render('index', { title: 'Node Shop' }); 6 | }); 7 | 8 | module.exports = router; 9 | -------------------------------------------------------------------------------- /views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | 12 | -------------------------------------------------------------------------------- /controller/home.js: -------------------------------------------------------------------------------- 1 | const sqlExcute = require('../db') 2 | module.exports = { 3 | getBanners(req, res) { 4 | sqlExcute('SELECT id, img, ctime FROM banner WHERE del_state = 0 LIMIT 0, 5') 5 | .then(result => { 6 | res.sendSucc('获取轮播图列表成功!', result) 7 | }) 8 | .catch(e => { 9 | res.sendErr(500, e.message) 10 | }) 11 | } 12 | } -------------------------------------------------------------------------------- /public/api_project.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "node-shop接口文档", 3 | "url": "http://litc.pro:9999", 4 | "name": "node-shop", 5 | "version": "1.0.0", 6 | "description": "", 7 | "sampleUrl": false, 8 | "defaultVersion": "0.0.0", 9 | "apidoc": "0.3.0", 10 | "generator": { 11 | "name": "apidoc", 12 | "time": "2019-01-06T12:08:42.918Z", 13 | "url": "http://apidocjs.com", 14 | "version": "0.17.7" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /models/ResBody.js: -------------------------------------------------------------------------------- 1 | class ResBody { 2 | /** 3 | * 响应对象构造函数 4 | * @param {number} status 状态码 5 | * @param {Object} data 数据 6 | * @param {string} succMsg 成功响应的消息 7 | * @param {string} errMsg 错误响应的消息 8 | */ 9 | constructor(status, data, succMsg, errMsg) { 10 | this.status = status 11 | this.data = data 12 | this.succMsg = succMsg 13 | this.errMsg = errMsg 14 | } 15 | } 16 | 17 | module.exports = ResBody -------------------------------------------------------------------------------- /db/db.js: -------------------------------------------------------------------------------- 1 | const Sequelize = require('sequelize'); 2 | module.exports = new Sequelize('shop', 'root', 'root', { 3 | host: 'localhost', 4 | dialect: 'mysql', 5 | 6 | pool: { 7 | max: 5, 8 | min: 0, 9 | acquire: 30000, 10 | idle: 10000 11 | }, 12 | 13 | // 仅限 SQLite 14 | // storage: 'path/to/database.sqlite', 15 | 16 | // 请参考 Querying - 查询 操作符 章节 17 | operatorsAliases: false, 18 | timezone: '+08:00' 19 | }) 20 | -------------------------------------------------------------------------------- /db/index.js: -------------------------------------------------------------------------------- 1 | const mysql = require('mysql'); 2 | const conn = mysql.createConnection({ 3 | host: 'localhost', 4 | user: 'root', 5 | password: 'root', 6 | database: 'shop', 7 | multipleStatements: true 8 | }) 9 | 10 | module.exports = (sql, data) => { 11 | return new Promise((resovle, reject) => { 12 | conn.query(sql, data, (err, result) => { 13 | if (err) reject(err) 14 | resovle(result) 15 | }) 16 | }) 17 | } -------------------------------------------------------------------------------- /public/api_project.js: -------------------------------------------------------------------------------- 1 | define({ 2 | "title": "node-shop接口文档", 3 | "url": "http://litc.pro:9999", 4 | "name": "node-shop", 5 | "version": "1.0.0", 6 | "description": "", 7 | "sampleUrl": false, 8 | "defaultVersion": "0.0.0", 9 | "apidoc": "0.3.0", 10 | "generator": { 11 | "name": "apidoc", 12 | "time": "2019-01-06T12:08:42.918Z", 13 | "url": "http://apidocjs.com", 14 | "version": "0.17.7" 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /public/vendor/prettify/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} -------------------------------------------------------------------------------- /middlewares/users.js: -------------------------------------------------------------------------------- 1 | const sqlExcute = require('../db') 2 | const getUserInfoByTokenSql = `SELECT u.id, u.username, u.mobile, u.nickname, ua.token 3 | FROM users AS u 4 | LEFT JOIN users_auth AS ua 5 | ON u.id = ua.user_id 6 | WHERE token = ? 7 | ORDER BY ua.ctime DESC` 8 | 9 | module.exports = { 10 | getUserInfo(req, res, next) { 11 | sqlExcute(getUserInfoByTokenSql, req.headers.authorization) 12 | .then(result => { 13 | req.userInfo = result[0] 14 | next() 15 | }, err => { 16 | next() 17 | }) 18 | .catch(e => { 19 | next() 20 | }) 21 | }, 22 | } -------------------------------------------------------------------------------- /public/vendor/prettify/lang-rd.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[a-zA-Z@]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[{}()\[\]]+/]]),["Rd","rd"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-tex.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Martin S. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-latex.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Martin S. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-go.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["pln",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/],["pln",/^(?:[^\/\"\'`]|\/(?![\/\*]))+/i]]),["go"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-proto.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2006 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-ll.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Nikhil Dabas 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-llvm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Nikhil Dabas 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-yaml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 ribrdb @ code.google.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln", 18 | /^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-yml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 ribrdb @ code.google.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln", 18 | /^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /public/locales/zh.js: -------------------------------------------------------------------------------- 1 | define({ 2 | zh: { 3 | 'Allowed values​​:' : '允許值:', 4 | 'Compare all with predecessor': '預先比較所有', 5 | 'compare changes to:' : '比較變更:', 6 | 'compared to' : '對比', 7 | 'Default value:' : '默認值:', 8 | 'Description' : '描述', 9 | 'Field' : '字段', 10 | 'General' : '概括', 11 | 'Generated with' : '生成工具', 12 | 'Name' : '名稱', 13 | 'No response values​​.' : '無對應資料.', 14 | 'optional' : '選項', 15 | 'Parameter' : '參數', 16 | 'Permission:' : '允許:', 17 | 'Response' : '回應', 18 | 'Send' : '發送', 19 | 'Send a Sample Request' : '發送試用需求', 20 | 'show up to version:' : '顯示到版本:', 21 | 'Size range:' : '尺寸範圍:', 22 | 'Type' : '類型', 23 | 'url' : '網址' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 itcast-wh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /public/locales/zh_cn.js: -------------------------------------------------------------------------------- 1 | define({ 2 | 'zh_cn': { 3 | 'Allowed values:' : '允许值:', 4 | 'Compare all with predecessor': '与所有较早的比较', 5 | 'compare changes to:' : '将当前版本与指定版本比较:', 6 | 'compared to' : '相比于', 7 | 'Default value:' : '默认值:', 8 | 'Description' : '描述', 9 | 'Field' : '字段', 10 | 'General' : '概要', 11 | 'Generated with' : '基于', 12 | 'Name' : '名称', 13 | 'No response values.' : '无返回值.', 14 | 'optional' : '可选', 15 | 'Parameter' : '参数', 16 | 'Permission:' : '权限:', 17 | 'Response' : '返回', 18 | 'Send' : '发送', 19 | 'Send a Sample Request' : '发送示例请求', 20 | 'show up to version:' : '显示到指定版本:', 21 | 'Size range:' : '取值范围:', 22 | 'Type' : '类型', 23 | 'url' : '网址' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-basic.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, 18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-cbm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, 18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]); 19 | -------------------------------------------------------------------------------- /public/vendor/path-to-regexp/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-wiki.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t \xA0a-gi-z0-9]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[=*~\^\[\]]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/],["lang-",/^\{\{\{([\s\S]+?)\}\}\}/],["lang-",/^`([^\r\n`]+)`/],["str",/^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]]),["wiki"]); 18 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lua.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/],["str",/^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], 18 | ["pln",/^[a-z_]\w*/i],["pun",/^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/]]),["lua"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-erl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Andrew Allen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-erlang.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Andrew Allen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-hs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])\'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:(?:--+(?:[^\r\n\x0C]*)?)|(?:\{-(?:[^-]|-+[^-\}])*-\}))/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\']|$)/, 18 | null],["pln",/^(?:[A-Z][\w\']*\.)*[a-zA-Z][\w\']*/],["pun",/^[^\t\n\x0B\x0C\r a-zA-Z0-9\'\"]+/]]),["hs"]); 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-shop", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "nodemon ./bin/www" 7 | }, 8 | "dependencies": { 9 | "bcryptjs": "^2.4.3", 10 | "cookie-parser": "~1.4.3", 11 | "cors": "^2.8.5", 12 | "debug": "~2.6.9", 13 | "ejs": "~2.5.7", 14 | "express": "~4.16.0", 15 | "express-jwt": "^5.3.1", 16 | "express-session": "^1.15.6", 17 | "file-stream-rotator": "^0.4.1", 18 | "http-errors": "~1.6.2", 19 | "jsonwebtoken": "^8.4.0", 20 | "moment": "^2.22.2", 21 | "morgan": "~1.9.0", 22 | "mount-routes": "^1.0.8", 23 | "mysql": "^2.16.0", 24 | "mysql2": "^1.6.4", 25 | "sequelize": "^4.42.0", 26 | "svg-captcha": "^1.3.12" 27 | }, 28 | "main": "app.js", 29 | "devDependencies": {}, 30 | "repository": { 31 | "type": "git", 32 | "url": "git+https://github.com/itcast-wh/node-shop.git" 33 | }, 34 | "keywords": [], 35 | "author": "", 36 | "license": "ISC", 37 | "bugs": { 38 | "url": "https://github.com/itcast-wh/node-shop/issues" 39 | }, 40 | "homepage": "https://github.com/itcast-wh/node-shop#readme", 41 | "description": "", 42 | "apidoc": { 43 | "title": "node-shop接口文档", 44 | "url": "http://litc.pro:9999" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Node Shop](https://github.com/itcast-wh/node-shop) 2 | 3 | ## 技术栈 4 | 5 | node.js + express + middleware + morgan + mysql 6 | 7 | ## 下载源码 8 | git clone https://github.com/itcast-wh/node-shop.git 9 | 10 | ## 开始使用 11 | 12 | #### 安装依赖 13 | 14 | npm install 15 | 16 | #### 启动项目 17 | 18 | npm start 19 | 20 | ## 线上接口文档地址 21 | 22 | [http://litc.pro:9999](http://litc.pro:9999) 23 | 24 | ## 模块划分 25 | 26 | 1. 用户模块 27 | 28 | * [x] 注册 29 | 30 | * [x] 登录 31 | 32 | * [x] 获取个人信息 33 | 34 | * [x] 修改个人信息 35 | 36 | * [x] 修改密码 37 | 38 | * [x] 获取收货地址 39 | 40 | * [x] 删除收货地址 41 | 42 | * [x] 添加收货地址 43 | 44 | * [x] 修改收货地址 45 | 46 | 2. 新闻模块 47 | 48 | * [x] 获取新闻列表 49 | 50 | * [x] 分页 51 | 52 | * [x] 模糊查询 53 | 54 | * [x] 获取新闻分类列表 55 | 56 | * [x] 获取分类新闻列表 57 | 58 | * [x] 获取新闻详情 59 | 60 | * [x] 获取评论信息 61 | 62 | * [x] 发表评论信息 63 | 64 | * [ ] 点赞收藏 65 | 66 | 3. 分类模块 67 | 68 | * [x] 一级分类 69 | 70 | * [x] 二级分类 71 | 72 | 4. 商品模块 73 | 74 | * [x] 获取商品列表 75 | 76 | * [x] 获取商品详情 77 | 78 | * [x] 分页 79 | 80 | * [x] 分类获取商品列表 81 | 82 | 5. 购物车模块 83 | 84 | * [x] 添加商品到购物车 85 | 86 | * [x] 删除购物车商品 87 | 88 | * [x] 修改购物车商品数量(添加购物车时设置count为多少就修改为多少) 89 | 90 | * [x] 获取当前用户的购物车信息 91 | -------------------------------------------------------------------------------- /public/locales/tr.js: -------------------------------------------------------------------------------- 1 | define({ 2 | tr: { 3 | 'Allowed values:' : 'İzin verilen değerler:', 4 | 'Compare all with predecessor': 'Tümünü öncekiler ile karşılaştır', 5 | 'compare changes to:' : 'değişiklikleri karşılaştır:', 6 | 'compared to' : 'karşılaştır', 7 | 'Default value:' : 'Varsayılan değer:', 8 | 'Description' : 'Açıklama', 9 | 'Field' : 'Alan', 10 | 'General' : 'Genel', 11 | 'Generated with' : 'Oluşturan', 12 | 'Name' : 'İsim', 13 | 'No response values.' : 'Dönüş verisi yok.', 14 | 'optional' : 'opsiyonel', 15 | 'Parameter' : 'Parametre', 16 | 'Permission:' : 'İzin:', 17 | 'Response' : 'Dönüş', 18 | 'Send' : 'Gönder', 19 | 'Send a Sample Request' : 'Örnek istek gönder', 20 | 'show up to version:' : 'bu versiyona kadar göster:', 21 | 'Size range:' : 'Boyut aralığı:', 22 | 'Type' : 'Tip', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/pl.js: -------------------------------------------------------------------------------- 1 | define({ 2 | pl: { 3 | 'Allowed values:' : 'Dozwolone wartości:', 4 | 'Compare all with predecessor': 'Porównaj z poprzednimi wersjami', 5 | 'compare changes to:' : 'porównaj zmiany do:', 6 | 'compared to' : 'porównaj do:', 7 | 'Default value:' : 'Wartość domyślna:', 8 | 'Description' : 'Opis', 9 | 'Field' : 'Pole', 10 | 'General' : 'Generalnie', 11 | 'Generated with' : 'Wygenerowano z', 12 | 'Name' : 'Nazwa', 13 | 'No response values.' : 'Brak odpowiedzi.', 14 | 'optional' : 'opcjonalny', 15 | 'Parameter' : 'Parametr', 16 | 'Permission:' : 'Uprawnienia:', 17 | 'Response' : 'Odpowiedź', 18 | 'Send' : 'Wyślij', 19 | 'Send a Sample Request' : 'Wyślij przykładowe żądanie', 20 | 'show up to version:' : 'pokaż do wersji:', 21 | 'Size range:' : 'Zakres rozmiaru:', 22 | 'Type' : 'Typ', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/ca.js: -------------------------------------------------------------------------------- 1 | define({ 2 | ca: { 3 | 'Allowed values:' : 'Valors permesos:', 4 | 'Compare all with predecessor': 'Comparar tot amb versió anterior', 5 | 'compare changes to:' : 'comparar canvis amb:', 6 | 'compared to' : 'comparat amb', 7 | 'Default value:' : 'Valor per defecte:', 8 | 'Description' : 'Descripció', 9 | 'Field' : 'Camp', 10 | 'General' : 'General', 11 | 'Generated with' : 'Generat amb', 12 | 'Name' : 'Nom', 13 | 'No response values.' : 'Sense valors en la resposta.', 14 | 'optional' : 'opcional', 15 | 'Parameter' : 'Paràmetre', 16 | 'Permission:' : 'Permisos:', 17 | 'Response' : 'Resposta', 18 | 'Send' : 'Enviar', 19 | 'Send a Sample Request' : 'Enviar una petició d\'exemple', 20 | 'show up to version:' : 'mostrar versió:', 21 | 'Size range:' : 'Tamany de rang:', 22 | 'Type' : 'Tipus', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/cs.js: -------------------------------------------------------------------------------- 1 | define({ 2 | cs: { 3 | 'Allowed values:' : 'Povolené hodnoty:', 4 | 'Compare all with predecessor': 'Porovnat vše s předchozími verzemi', 5 | 'compare changes to:' : 'porovnat změny s:', 6 | 'compared to' : 'porovnat s', 7 | 'Default value:' : 'Výchozí hodnota:', 8 | 'Description' : 'Popis', 9 | 'Field' : 'Pole', 10 | 'General' : 'Obecné', 11 | 'Generated with' : 'Vygenerováno pomocí', 12 | 'Name' : 'Název', 13 | 'No response values.' : 'Nebyly vráceny žádné hodnoty.', 14 | 'optional' : 'volitelné', 15 | 'Parameter' : 'Parametr', 16 | 'Permission:' : 'Oprávnění:', 17 | 'Response' : 'Odpověď', 18 | 'Send' : 'Odeslat', 19 | 'Send a Sample Request' : 'Odeslat ukázkový požadavek', 20 | 'show up to version:' : 'zobrazit po verzi:', 21 | 'Size range:' : 'Rozsah velikosti:', 22 | 'Type' : 'Typ', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/vi.js: -------------------------------------------------------------------------------- 1 | define({ 2 | vi: { 3 | 'Allowed values:' : 'Giá trị chấp nhận:', 4 | 'Compare all with predecessor': 'So sánh với tất cả phiên bản trước', 5 | 'compare changes to:' : 'so sánh sự thay đổi với:', 6 | 'compared to' : 'so sánh với', 7 | 'Default value:' : 'Giá trị mặc định:', 8 | 'Description' : 'Chú thích', 9 | 'Field' : 'Trường dữ liệu', 10 | 'General' : 'Tổng quan', 11 | 'Generated with' : 'Được tạo bởi', 12 | 'Name' : 'Tên', 13 | 'No response values.' : 'Không có kết quả trả về.', 14 | 'optional' : 'Tùy chọn', 15 | 'Parameter' : 'Tham số', 16 | 'Permission:' : 'Quyền hạn:', 17 | 'Response' : 'Kết quả', 18 | 'Send' : 'Gửi', 19 | 'Send a Sample Request' : 'Gửi một yêu cầu mẫu', 20 | 'show up to version:' : 'hiển thị phiên bản:', 21 | 'Size range:' : 'Kích cỡ:', 22 | 'Type' : 'Kiểu', 23 | 'url' : 'liên kết' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-tcl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Pyrios 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\{+/,null,"{"],["clo",/^\}+/,null,"}"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/,null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i], 18 | ["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["tcl"]); 19 | -------------------------------------------------------------------------------- /public/locales/ro.js: -------------------------------------------------------------------------------- 1 | define({ 2 | ro: { 3 | 'Allowed values:' : 'Valori permise:', 4 | 'Compare all with predecessor': 'Compară toate cu versiunea precedentă', 5 | 'compare changes to:' : 'compară cu versiunea:', 6 | 'compared to' : 'comparat cu', 7 | 'Default value:' : 'Valoare implicită:', 8 | 'Description' : 'Descriere', 9 | 'Field' : 'Câmp', 10 | 'General' : 'General', 11 | 'Generated with' : 'Generat cu', 12 | 'Name' : 'Nume', 13 | 'No response values.' : 'Nici o valoare returnată.', 14 | 'optional' : 'opțional', 15 | 'Parameter' : 'Parametru', 16 | 'Permission:' : 'Permisiune:', 17 | 'Response' : 'Răspuns', 18 | 'Send' : 'Trimite', 19 | 'Send a Sample Request' : 'Trimite o cerere de probă', 20 | 'show up to version:' : 'arată până la versiunea:', 21 | 'Size range:' : 'Interval permis:', 22 | 'Type' : 'Tip', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/de.js: -------------------------------------------------------------------------------- 1 | define({ 2 | de: { 3 | 'Allowed values:' : 'Erlaubte Werte:', 4 | 'Compare all with predecessor': 'Vergleiche alle mit ihren Vorgängern', 5 | 'compare changes to:' : 'vergleiche Änderungen mit:', 6 | 'compared to' : 'verglichen mit', 7 | 'Default value:' : 'Standardwert:', 8 | 'Description' : 'Beschreibung', 9 | 'Field' : 'Feld', 10 | 'General' : 'Allgemein', 11 | 'Generated with' : 'Erstellt mit', 12 | 'Name' : 'Name', 13 | 'No response values.' : 'Keine Rückgabewerte.', 14 | 'optional' : 'optional', 15 | 'Parameter' : 'Parameter', 16 | 'Permission:' : 'Berechtigung:', 17 | 'Response' : 'Antwort', 18 | 'Send' : 'Senden', 19 | 'Send a Sample Request' : 'Eine Beispielanfrage senden', 20 | 'show up to version:' : 'zeige bis zur Version:', 21 | 'Size range:' : 'Größenbereich:', 22 | 'Type' : 'Typ', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/pt_br.js: -------------------------------------------------------------------------------- 1 | define({ 2 | 'pt_br': { 3 | 'Allowed values:' : 'Valores permitidos:', 4 | 'Compare all with predecessor': 'Compare todos com antecessores', 5 | 'compare changes to:' : 'comparar alterações com:', 6 | 'compared to' : 'comparado com', 7 | 'Default value:' : 'Valor padrão:', 8 | 'Description' : 'Descrição', 9 | 'Field' : 'Campo', 10 | 'General' : 'Geral', 11 | 'Generated with' : 'Gerado com', 12 | 'Name' : 'Nome', 13 | 'No response values.' : 'Sem valores de resposta.', 14 | 'optional' : 'opcional', 15 | 'Parameter' : 'Parâmetro', 16 | 'Permission:' : 'Permissão:', 17 | 'Response' : 'Resposta', 18 | 'Send' : 'Enviar', 19 | 'Send a Sample Request' : 'Enviar um Exemplo de Pedido', 20 | 'show up to version:' : 'aparecer para a versão:', 21 | 'Size range:' : 'Faixa de tamanho:', 22 | 'Type' : 'Tipo', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/ru.js: -------------------------------------------------------------------------------- 1 | define({ 2 | ru: { 3 | 'Allowed values:' : 'Допустимые значения:', 4 | 'Compare all with predecessor': 'Сравнить с предыдущей версией', 5 | 'compare changes to:' : 'сравнить с:', 6 | 'compared to' : 'в сравнении с', 7 | 'Default value:' : 'По умолчанию:', 8 | 'Description' : 'Описание', 9 | 'Field' : 'Название', 10 | 'General' : 'Общая информация', 11 | 'Generated with' : 'Сгенерировано с помощью', 12 | 'Name' : 'Название', 13 | 'No response values.' : 'Нет значений для ответа.', 14 | 'optional' : 'необязательный', 15 | 'Parameter' : 'Параметр', 16 | 'Permission:' : 'Разрешено:', 17 | 'Response' : 'Ответ', 18 | 'Send' : 'Отправить', 19 | 'Send a Sample Request' : 'Отправить тестовый запрос', 20 | 'show up to version:' : 'показать версию:', 21 | 'Size range:' : 'Ограничения:', 22 | 'Type' : 'Тип', 23 | 'url' : 'URL' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/es.js: -------------------------------------------------------------------------------- 1 | define({ 2 | es: { 3 | 'Allowed values:' : 'Valores permitidos:', 4 | 'Compare all with predecessor': 'Comparar todo con versión anterior', 5 | 'compare changes to:' : 'comparar cambios con:', 6 | 'compared to' : 'comparado con', 7 | 'Default value:' : 'Valor por defecto:', 8 | 'Description' : 'Descripción', 9 | 'Field' : 'Campo', 10 | 'General' : 'General', 11 | 'Generated with' : 'Generado con', 12 | 'Name' : 'Nombre', 13 | 'No response values.' : 'Sin valores en la respuesta.', 14 | 'optional' : 'opcional', 15 | 'Parameter' : 'Parámetro', 16 | 'Permission:' : 'Permisos:', 17 | 'Response' : 'Respuesta', 18 | 'Send' : 'Enviar', 19 | 'Send a Sample Request' : 'Enviar una petición de ejemplo', 20 | 'show up to version:' : 'mostrar a versión:', 21 | 'Size range:' : 'Tamaño de rango:', 22 | 'Type' : 'Tipo', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/nl.js: -------------------------------------------------------------------------------- 1 | define({ 2 | nl: { 3 | 'Allowed values:' : 'Toegestane waarden:', 4 | 'Compare all with predecessor': 'Vergelijk alle met voorgaande versie', 5 | 'compare changes to:' : 'vergelijk veranderingen met:', 6 | 'compared to' : 'vergelijk met', 7 | 'Default value:' : 'Standaard waarde:', 8 | 'Description' : 'Omschrijving', 9 | 'Field' : 'Veld', 10 | 'General' : 'Algemeen', 11 | 'Generated with' : 'Gegenereerd met', 12 | 'Name' : 'Naam', 13 | 'No response values.' : 'Geen response waardes.', 14 | 'optional' : 'optioneel', 15 | 'Parameter' : 'Parameter', 16 | 'Permission:' : 'Permissie:', 17 | 'Response' : 'Antwoorden', 18 | 'Send' : 'Sturen', 19 | 'Send a Sample Request' : 'Stuur een sample aanvragen', 20 | 'show up to version:' : 'toon tot en met versie:', 21 | 'Size range:' : 'Maatbereik:', 22 | 'Type' : 'Type', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/fr.js: -------------------------------------------------------------------------------- 1 | define({ 2 | fr: { 3 | 'Allowed values:' : 'Valeurs autorisées :', 4 | 'Compare all with predecessor': 'Tout comparer avec ...', 5 | 'compare changes to:' : 'comparer les changements à :', 6 | 'compared to' : 'comparer à', 7 | 'Default value:' : 'Valeur par défaut :', 8 | 'Description' : 'Description', 9 | 'Field' : 'Champ', 10 | 'General' : 'Général', 11 | 'Generated with' : 'Généré avec', 12 | 'Name' : 'Nom', 13 | 'No response values.' : 'Aucune valeur de réponse.', 14 | 'optional' : 'optionnel', 15 | 'Parameter' : 'Paramètre', 16 | 'Permission:' : 'Permission :', 17 | 'Response' : 'Réponse', 18 | 'Send' : 'Envoyer', 19 | 'Send a Sample Request' : 'Envoyer une requête représentative', 20 | 'show up to version:' : 'Montrer à partir de la version :', 21 | 'Size range:' : 'Ordre de grandeur :', 22 | 'Type' : 'Type', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /public/locales/it.js: -------------------------------------------------------------------------------- 1 | define({ 2 | it: { 3 | 'Allowed values:' : 'Valori permessi:', 4 | 'Compare all with predecessor': 'Confronta tutto con versioni precedenti', 5 | 'compare changes to:' : 'confronta modifiche con:', 6 | 'compared to' : 'confrontato con', 7 | 'Default value:' : 'Valore predefinito:', 8 | 'Description' : 'Descrizione', 9 | 'Field' : 'Campo', 10 | 'General' : 'Generale', 11 | 'Generated with' : 'Creato con', 12 | 'Name' : 'Nome', 13 | 'No response values.' : 'Nessun valore di risposta.', 14 | 'optional' : 'opzionale', 15 | 'Parameter' : 'Parametro', 16 | 'Permission:' : 'Permessi:', 17 | 'Response' : 'Risposta', 18 | 'Send' : 'Invia', 19 | 'Send a Sample Request' : 'Invia una richiesta di esempio', 20 | 'show up to version:' : 'mostra alla versione:', 21 | 'Size range:' : 'Intervallo dimensione:', 22 | 'Type' : 'Tipo', 23 | 'url' : 'url' 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /middlewares/common.js: -------------------------------------------------------------------------------- 1 | const ResBody = require('../models/ResBody') 2 | 3 | function sendErr(status, msg) { 4 | this.status(status).send(new ResBody(status, null, null, msg)) 5 | } 6 | 7 | function sendSucc(msg, data = null) { 8 | this.status(200).send(new ResBody(200, data, msg, null)) 9 | } 10 | 11 | function checkFormBody(attrs = [], res) { 12 | let pass = true 13 | let keywords = [] 14 | attrs.forEach(item => { 15 | if (!(item in this.body) && !(item in this.params) && !(item in this.query)) { 16 | keywords.push(item) 17 | pass = false 18 | } 19 | }) 20 | 21 | let checkBodies = [this.body, this.params, this.query] 22 | 23 | checkBodies.forEach(item => { 24 | for (let k in item) { 25 | if (attrs.indexOf(k) === -1) continue; 26 | let val = item[k] 27 | if (!val || !val.toString().trim()) { 28 | keywords.push(k) 29 | pass = false 30 | } 31 | } 32 | }) 33 | !pass && res && res.sendErr(400, keywords.join(',') + '未填写!') 34 | return pass 35 | } 36 | 37 | module.exports = { 38 | sendSucc(req, res, next) { 39 | res.sendErr = sendErr 40 | res.sendSucc = sendSucc 41 | next() 42 | }, 43 | sendErr(err, req, res, next) { 44 | res.sendErr = sendErr 45 | next() 46 | }, 47 | checkFormBody(req, res, next) { 48 | req.checkFormBody = checkFormBody 49 | next() 50 | } 51 | } -------------------------------------------------------------------------------- /controller/cart.js: -------------------------------------------------------------------------------- 1 | const Cart = require('../models/Cart') 2 | 3 | module.exports = { 4 | postGoodsToCart(req, res) { 5 | if (!req.checkFormBody(['id', 'count'], res)) return 6 | const goods_id = parseInt(req.params.id) 7 | const user_id = parseInt(req.userInfo.id) 8 | const count = parseInt(req.body.count) 9 | 10 | Cart.addGoods({ goods_id, user_id, count }, (result, err) => { 11 | if (result) return res.sendSucc('添加购物车成功!') 12 | else res.sendErr(400, '添加购物车失败!' + err.message) 13 | }) 14 | }, 15 | deleteGoodsFromCart(req, res) { 16 | if (!req.checkFormBody(['id'], res)) return 17 | const goods_id = parseInt(req.params.id) 18 | const user_id = parseInt(req.userInfo.id) 19 | Cart.deleteGoods({ goods_id, user_id }, (result, err) => { 20 | if (result) return res.sendSucc('删除购物车商品成功!') 21 | else res.sendErr(400, '删除购物车商品失败!' + err.message) 22 | }) 23 | }, 24 | getGoodsFromCart(req, res) { 25 | if (!req.checkFormBody(['page', 'pageSize'], res)) return 26 | const user_id = parseInt(req.userInfo.id) 27 | const page = parseInt(req.query.page) 28 | const pageSize = parseInt(req.query.pageSize) 29 | Cart.getGoods({user_id, page, pageSize}, (result, err) => { 30 | if (result) return res.sendSucc('获取购物车商品信息成功!', result) 31 | else res.sendErr(400, '获取购物车商品信息失败!' + err.message) 32 | }) 33 | } 34 | } -------------------------------------------------------------------------------- /public/vendor/prettify/lang-pascal.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$))/,null,"'"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/,null],["kwd",/^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\b/i, 18 | null],["lit",/^(?:true|false|self|nil)/i,null],["pln",/^[a-z][a-z0-9]*/i,null],["lit",/^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\/]*/,null]]),["pascal"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-Splus.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-r.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-s.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-cl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-el.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lisp.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lsp.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-rkt.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-scm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-ss.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /routes/v1/home.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const ctrl = require('../../controller') 4 | 5 | /** 6 | * @api {get} /v1/home/getBanners 获取轮播图信息 7 | * @apiDescription 获取轮播图信息 8 | * @apiName getBanners 9 | * @apiGroup 0.Home 10 | * @apiSuccess {number} status 状态码 11 | * @apiSuccess {json} data 轮播图列表数据 12 | * @apiSuccess {string} succMsg 成功消息 13 | * @apiSuccess {string} succMsg 错误消息 14 | * @apiSuccessExample {json} Success-Response: 15 | * { 16 | "status": 200, 17 | "data": [ 18 | { 19 | "id": 1, 20 | "img": "https://res.purcotton.com/activity/2018/12/25/ni/750-380.jpg", 21 | "ctime": "2018-12-27 17:35:00" 22 | }, 23 | { 24 | "id": 2, 25 | "img": "https://res.purcotton.com/activity/2018/12/13/ychx/750-380.jpg", 26 | "ctime": "2018-12-27 17:35:00" 27 | }, 28 | { 29 | "id": 3, 30 | "img": "https://res.purcotton.com/activity/2018/12/19/xkmrj/750-380.jpg", 31 | "ctime": "2018-12-27 17:35:00" 32 | }, 33 | { 34 | "id": 4, 35 | "img": "https://res.purcotton.com/activity/2018/12/21/sr/750-380.jpg", 36 | "ctime": "2018-12-27 17:35:00" 37 | } 38 | ], 39 | "succMsg": "获取轮播图列表成功!", 40 | "errMsg": null 41 | } 42 | * @apiSampleRequest /v1/home/getBanners 43 | * @apiVersion 1.0.0 44 | */ 45 | router.get('/getBanners', ctrl.home.getBanners) 46 | 47 | module.exports = router; 48 | -------------------------------------------------------------------------------- /public/locales/locale.js: -------------------------------------------------------------------------------- 1 | define([ 2 | './locales/ca.js', 3 | './locales/cs.js', 4 | './locales/de.js', 5 | './locales/es.js', 6 | './locales/fr.js', 7 | './locales/it.js', 8 | './locales/nl.js', 9 | './locales/pl.js', 10 | './locales/pt_br.js', 11 | './locales/ro.js', 12 | './locales/ru.js', 13 | './locales/tr.js', 14 | './locales/vi.js', 15 | './locales/zh.js', 16 | './locales/zh_cn.js' 17 | ], function() { 18 | var langId = (navigator.language || navigator.userLanguage).toLowerCase().replace('-', '_'); 19 | var language = langId.substr(0, 2); 20 | var locales = {}; 21 | 22 | for (index in arguments) { 23 | for (property in arguments[index]) 24 | locales[property] = arguments[index][property]; 25 | } 26 | if ( ! locales['en']) 27 | locales['en'] = {}; 28 | 29 | if ( ! locales[langId] && ! locales[language]) 30 | language = 'en'; 31 | 32 | var locale = (locales[langId] ? locales[langId] : locales[language]); 33 | 34 | function __(text) { 35 | var index = locale[text]; 36 | if (index === undefined) 37 | return text; 38 | return index; 39 | }; 40 | 41 | function setLanguage(language) { 42 | locale = locales[language]; 43 | } 44 | 45 | return { 46 | __ : __, 47 | locales : locales, 48 | locale : locale, 49 | setLanguage: setLanguage 50 | }; 51 | }); 52 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lgt.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2014 Paulo Moura 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/], 18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-logtalk.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2014 Paulo Moura 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/], 18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-clj.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[\(\{\[]+/,null,"([{"],["clo",/^[\)\}\]]+/,null,")]}"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/, 17 | null],["typ",/^:[0-9a-zA-Z\-]+/]]),["clj"]); 18 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-mumps.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Kitware Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"]|\\.)*")/,null,'"']],[["com",/^;[^\r\n]*/,null,";"],["dec",/^(?:\$(?:D|DEVICE|EC|ECODE|ES|ESTACK|ET|ETRAP|H|HOROLOG|I|IO|J|JOB|K|KEY|P|PRINCIPAL|Q|QUIT|ST|STACK|S|STORAGE|SY|SYSTEM|T|TEST|TL|TLEVEL|TR|TRESTART|X|Y|Z[A-Z]*|A|ASCII|C|CHAR|D|DATA|E|EXTRACT|F|FIND|FN|FNUMBER|G|GET|J|JUSTIFY|L|LENGTH|NA|NAME|O|ORDER|P|PIECE|QL|QLENGTH|QS|QSUBSCRIPT|Q|QUERY|R|RANDOM|RE|REVERSE|S|SELECT|ST|STACK|T|TEXT|TR|TRANSLATE|NaN))\b/i, 18 | null],["kwd",/^(?:[^\$]B|BREAK|C|CLOSE|D|DO|E|ELSE|F|FOR|G|GOTO|H|HALT|H|HANG|I|IF|J|JOB|K|KILL|L|LOCK|M|MERGE|N|NEW|O|OPEN|Q|QUIT|R|READ|S|SET|TC|TCOMMIT|TRE|TRESTART|TRO|TROLLBACK|TS|TSTART|U|USE|V|VIEW|W|WRITE|X|XECUTE)\b/i,null],["lit",/^[+-]?(?:(?:\.\d+|\d+(?:\.\d*)?)(?:E[+\-]?\d+)?)/i],["pln",/^[a-z][a-zA-Z0-9]*/i],["pun",/^[^\w\t\n\r\xA0\"\$;%\^]|_/]]),["mumps"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[["str",/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],["str",/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']+)\)/i],["kwd",/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], 18 | ["com",/^(?:\x3c!--|--\x3e)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#(?:[0-9a-f]{3}){1,2}\b/i],["pln",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],["pun",/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^\)\"\']+/]]),["css-str"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-scala.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/,null,'"'],["lit",/^`(?:[^\r\n\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/],["lit",/^'[a-zA-Z_$][\w$]*(?!['$\w])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/], 18 | ["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i],["typ",/^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/],["pln",/^[$a-zA-Z_][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-aea.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-agc.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-apollo.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-dart.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["com",/^#!(?:.*)/],["kwd",/^\b(?:import|library|part of|part|as|show|hide)\b/i],["com",/^\/\/(?:.*)/],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],["kwd",/^\b(?:class|interface)\b/i],["kwd",/^\b(?:assert|async|await|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|sync|this|throw|try|while)\b/i],["kwd",/^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i], 18 | ["typ",/^\b(?:bool|double|Dynamic|int|num|Object|String|void)\b/i],["kwd",/^\b(?:false|null|true)\b/i],["str",/^r?[\']{3}[\s|\S]*?[^\\][\']{3}/],["str",/^r?[\"]{3}[\s|\S]*?[^\\][\"]{3}/],["str",/^r?\'(\'|(?:[^\n\r\f])*?[^\\]\')/],["str",/^r?\"(\"|(?:[^\n\r\f])*?[^\\]\")/],["typ",/^[A-Z]\w*/],["pln",/^[a-z_$][a-z0-9_]*/i],["pun",/^[~!%^&*+=|?:<>/-]/],["lit",/^\b0x[0-9a-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit", 19 | /^\b\.\d+(?:e[+-]?\d+)?/i],["pun",/^[(){}\[\],.;]/]]),["dart"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-fs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-ml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | const app = require('../app'); 8 | const debug = require('debug')('node-shop:server'); 9 | const http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | const port = normalizePort(process.env.PORT || '9999'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | const server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-swift.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 Google Inc. 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \n\r\t\v\f\0]+/,null," \n\r\t\v\f\x00"],["str",/^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/,null,'"']],[["lit",/^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/,null],["lit",/^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/,null],["lit",/^(?:true|false|nil)\b/,null],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|fallthrough|final|for|func|get|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/, 16 | null],["com",/^\/\/.*?[\n\r]/,null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["pun",/^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|~|\(|\)|\[|\]|{|}|@|#|;|\.|,|:|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|\/|\+|!|\*|%|<|>|&|\||\^|\?|=|-|_/,null],["typ",/^\b(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null]]),["swift"]); 17 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-vhd.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 benoit@ryder.fr 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, 18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i], 19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-vhdl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 benoit@ryder.fr 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, 18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i], 19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-n.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Zimin A.V. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/, 18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-nemerle.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Zimin A.V. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/, 18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | /* Vim sunburst theme by David Leibovic */ 3 | 4 | pre .str, code .str { color: #65B042; } /* string - green */ 5 | pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */ 6 | pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */ 7 | pre .typ, code .typ { color: #89bdff; } /* type - light blue */ 8 | pre .lit, code .lit { color: #3387CC; } /* literal - blue */ 9 | pre .pun, code .pun { color: #fff; } /* punctuation - white */ 10 | pre .pln, code .pln { color: #fff; } /* plaintext - white */ 11 | pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */ 12 | pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */ 13 | pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */ 14 | pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ 15 | 16 | pre.prettyprint, code.prettyprint { 17 | background-color: #000; 18 | -moz-border-radius: 8px; 19 | -webkit-border-radius: 8px; 20 | -o-border-radius: 8px; 21 | -ms-border-radius: 8px; 22 | -khtml-border-radius: 8px; 23 | border-radius: 8px; 24 | } 25 | 26 | pre.prettyprint { 27 | width: 95%; 28 | margin: 1em auto; 29 | padding: 1em; 30 | white-space: pre-wrap; 31 | } 32 | 33 | 34 | /* Specify class=linenums on a pre to get line numbering */ 35 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */ 36 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 37 | /* Alternate shading for lines */ 38 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 39 | 40 | @media print { 41 | pre .str, code .str { color: #060; } 42 | pre .kwd, code .kwd { color: #006; font-weight: bold; } 43 | pre .com, code .com { color: #600; font-style: italic; } 44 | pre .typ, code .typ { color: #404; font-weight: bold; } 45 | pre .lit, code .lit { color: #044; } 46 | pre .pun, code .pun { color: #440; } 47 | pre .pln, code .pln { color: #000; } 48 | pre .tag, code .tag { color: #006; font-weight: bold; } 49 | pre .atn, code .atn { color: #404; } 50 | pre .atv, code .atv { color: #060; } 51 | } 52 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-rust.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 Chris Morgan 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([],[["pln",/^[\t\n\r \xA0]+/],["com",/^\/\/.*/],["com",/^\/\*[\s\S]*?(?:\*\/|$)/],["str",/^b"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}))*?"/],["str",/^"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}|u\{\[\da-fA-F]{1,6}\}))*?"/],["str",/^b?r(#*)\"[\s\S]*?\"\1/],["str",/^b'([^\\]|\\(.|x[\da-fA-F]{2}))'/],["str",/^'([^\\]|\\(.|x[\da-fA-F]{2}|u\{[\da-fA-F]{1,6}\}))'/],["tag",/^'\w+?\b/],["kwd",/^(?:match|if|else|as|break|box|continue|extern|fn|for|in|if|impl|let|loop|pub|return|super|unsafe|where|while|use|mod|trait|struct|enum|type|move|mut|ref|static|const|crate)\b/], 18 | ["kwd",/^(?:alignof|become|do|offsetof|priv|pure|sizeof|typeof|unsized|yield|abstract|virtual|final|override|macro)\b/],["typ",/^(?:[iu](8|16|32|64|size)|char|bool|f32|f64|str|Self)\b/],["typ",/^(?:Copy|Send|Sized|Sync|Drop|Fn|FnMut|FnOnce|Box|ToOwned|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator|Option|Some|None|Result|Ok|Err|SliceConcatExt|String|ToString|Vec)\b/],["lit",/^(self|true|false|null)\b/], 19 | ["lit",/^\d[0-9_]*(?:[iu](?:size|8|16|32|64))?/],["lit",/^0x[a-fA-F0-9_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0o[0-7_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0b[01_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^\d[0-9_]*\.(?![^\s\d.])/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)(?:[eE][+-]?[0-9_]+)?(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)?(?:f32|f64)/], 20 | ["atn",/^[a-z_]\w*!/i],["pln",/^[a-z_]\w*/i],["atv",/^#!?\[[\s\S]*?\]/],["pun",/^[+\-/*=^&|!<>%[\](){}?:.,;]/],["pln",/./]]),["rust"]); 21 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-sql.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],["kwd",/^(?:ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONNECT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOLLOWING|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|MATCH|MATCHED|MERGE|NATURAL|NATIONAL|NOCHECK|NONCLUSTERED|NOCYCLE|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PARTITION|PERCENT|PIVOT|PLAN|PRECEDING|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|ROWS?|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|START|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNBOUNDED|UNION|UNIQUE|UNPIVOT|UPDATE|UPDATETEXT|USE|USER|USING|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WITHIN|WRITETEXT|XML)(?=[^\w-]|$)/i, 18 | null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^[a-z_][\w-]*/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]]),["sql"]); 19 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-vb.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, 18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb", 19 | "vbs"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-vbs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, 18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb", 19 | "vbs"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-ls.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^#\d+|[#$][a-z_][\w.]*|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//], 18 | ["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|infinity\b|NaN\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 19 | ["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i],["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]/]]),["lasso","ls","lassoscript"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lasso.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^#\d+|[#$][a-z_][\w.]*|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//], 18 | ["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|infinity\b|NaN\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 19 | ["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i],["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]/]]),["lasso","ls","lassoscript"]); 20 | -------------------------------------------------------------------------------- /public/vendor/prettify/lang-lassoscript.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^#\d+|[#$][a-z_][\w.]*|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//], 18 | ["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|infinity\b|NaN\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 19 | ["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i],["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]/]]),["lasso","ls","lassoscript"]); 20 | -------------------------------------------------------------------------------- /models/Cart.js: -------------------------------------------------------------------------------- 1 | const Sequelize = require('sequelize') 2 | const sequelize = require('../db/db') 3 | const sqlExcute = require('../db') 4 | const Cart = sequelize.define('shopping_cart', { 5 | goods_id: Sequelize.INTEGER, 6 | user_id: Sequelize.INTEGER, 7 | count: Sequelize.INTEGER, 8 | del_state: Sequelize.TINYINT 9 | }, { 10 | timestamps: true, 11 | createdAt: false, 12 | updatedAt: 'utime', 13 | freezeTableName: true, 14 | }) 15 | 16 | Cart.addGoods = async function (goodsInfo, callback) { 17 | 18 | let { goods_id, user_id, count } = goodsInfo 19 | 20 | let result = await sqlExcute(`SELECT COUNT(*) AS count FROM goods WHERE id = ${goods_id}`) 21 | if (result[0].count == 0) return callback(null, new Error('商品不存在!')) 22 | 23 | Cart.findOrCreate({ 24 | where: { 25 | goods_id, 26 | user_id 27 | }, 28 | defaults: goodsInfo 29 | }) 30 | .spread((result, created) => { 31 | if (created) return callback(created) 32 | let cartInfo = result.dataValues 33 | cartInfo.count = count 34 | cartInfo.del_state = 0 35 | return Cart.update(cartInfo, { 36 | where: { 37 | id: cartInfo.id 38 | } 39 | }) 40 | }) 41 | .then(result => { 42 | callback(true) 43 | }) 44 | .catch(err => { 45 | callback(null, err) 46 | }) 47 | } 48 | 49 | Cart.deleteGoods = async function (goodsInfo, callback) { 50 | let { goods_id, user_id } = goodsInfo 51 | 52 | let result = await sqlExcute(`SELECT COUNT(*) AS count FROM goods WHERE id = ${goods_id}`) 53 | if (result[0].count == 0) return callback(null, new Error('商品不存在!')) 54 | 55 | Cart.update({ 56 | del_state: 1, 57 | count: 0 58 | }, { 59 | where: { 60 | goods_id, 61 | user_id 62 | } 63 | }) 64 | .then(result => { 65 | callback(true) 66 | }) 67 | .catch(err => { 68 | callback(null, err) 69 | }) 70 | } 71 | 72 | Cart.getGoods = function (data, callback) { 73 | let { user_id, page, pageSize } = data 74 | const getGoodsSql = `SELECT g.id, g.name, g.discount_info, g.price, g.sale_price, g.stock, g.sale_count, g.ctime, sc.count, GROUP_CONCAT(gp.small_img) AS small_img 75 | FROM shopping_cart AS sc 76 | LEFT JOIN goods AS g 77 | ON sc.goods_id = g.id 78 | LEFT JOIN goods_img gp 79 | ON g.id = gp.gid 80 | WHERE sc.user_id = ${user_id} 81 | AND sc.del_state = 0 82 | GROUP BY g.id 83 | ORDER BY g.id DESC 84 | LIMIT ${(page - 1) * pageSize}, ${pageSize}` 85 | sequelize.query(getGoodsSql) 86 | .then(result => { 87 | callback(result[0]) 88 | }) 89 | .catch(err => { 90 | callback(null, err) 91 | }) 92 | } 93 | 94 | module.exports = Cart -------------------------------------------------------------------------------- /public/vendor/polyfill.js: -------------------------------------------------------------------------------- 1 | // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys 2 | if (!Object.keys) { 3 | Object.keys = (function () { 4 | 'use strict'; 5 | var hasOwnProperty = Object.prototype.hasOwnProperty, 6 | hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), 7 | dontEnums = [ 8 | 'toString', 9 | 'toLocaleString', 10 | 'valueOf', 11 | 'hasOwnProperty', 12 | 'isPrototypeOf', 13 | 'propertyIsEnumerable', 14 | 'constructor' 15 | ], 16 | dontEnumsLength = dontEnums.length; 17 | 18 | return function (obj) { 19 | if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { 20 | throw new TypeError('Object.keys called on non-object'); 21 | } 22 | 23 | var result = [], prop, i; 24 | 25 | for (prop in obj) { 26 | if (hasOwnProperty.call(obj, prop)) { 27 | result.push(prop); 28 | } 29 | } 30 | 31 | if (hasDontEnumBug) { 32 | for (i = 0; i < dontEnumsLength; i++) { 33 | if (hasOwnProperty.call(obj, dontEnums[i])) { 34 | result.push(dontEnums[i]); 35 | } 36 | } 37 | } 38 | return result; 39 | }; 40 | }()); 41 | } 42 | 43 | //Production steps of ECMA-262, Edition 5, 15.4.4.18 44 | //Reference: http://es5.github.com/#x15.4.4.18 45 | if (!Array.prototype.forEach) { 46 | Array.prototype.forEach = function (callback, thisArg) { 47 | var T, k; 48 | 49 | if (this == null) { 50 | throw new TypeError(' this is null or not defined'); 51 | } 52 | 53 | // 1. Let O be the result of calling ToObject passing the |this| value as the argument. 54 | var O = Object(this); 55 | 56 | // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length". 57 | // 3. Let len be ToUint32(lenValue). 58 | var len = O.length >>> 0; 59 | 60 | // 4. If IsCallable(callback) is false, throw a TypeError exception. 61 | // See: http://es5.github.com/#x9.11 62 | if (typeof callback !== "function") { 63 | throw new TypeError(callback + " is not a function"); 64 | } 65 | 66 | // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. 67 | if (arguments.length > 1) { 68 | T = thisArg; 69 | } 70 | 71 | // 6. Let k be 0 72 | k = 0; 73 | 74 | // 7. Repeat, while k < len 75 | while (k < len) { 76 | var kValue; 77 | 78 | // a. Let Pk be ToString(k). 79 | // This is implicit for LHS operands of the in operator 80 | // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk. 81 | // This step can be combined with c 82 | // c. If kPresent is true, then 83 | if (k in O) { 84 | // i. Let kValue be the result of calling the Get internal method of O with argument Pk. 85 | kValue = O[k]; 86 | 87 | // ii. Call the Call internal method of callback with T as the this value and 88 | // argument list containing kValue, k, and O. 89 | callback.call(T, kValue, k, O); 90 | } 91 | // d. Increase k by 1. 92 | k++; 93 | } 94 | // 8. return undefined 95 | }; 96 | } 97 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const createError = require('http-errors') 2 | const express = require('express') 3 | const path = require('path') 4 | const cookieParser = require('cookie-parser') 5 | // const logger = require('morgan') 6 | // const fs = require('fs') 7 | // const FileStreamRotator = require('file-stream-rotator'); 8 | const session = require('express-session') 9 | const cors = require('cors') 10 | const expressJwt = require('express-jwt') 11 | const mount = require('mount-routes') 12 | 13 | const usersMiddleware = require('./middlewares/users') 14 | 15 | const commonMiddleware = require('./middlewares/common') 16 | 17 | const app = express() 18 | 19 | app.set('views', path.join(__dirname, 'views')) 20 | app.set('view engine', 'ejs') 21 | 22 | // const logDirectory = __dirname + '/logs' 23 | // fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory) 24 | 25 | // const accessLogStream = FileStreamRotator.getStream({ 26 | // filename: logDirectory + '/accss-%DATE%.log', 27 | // frequency: 'daily', 28 | // verbose: false 29 | // }) 30 | 31 | // 响应错误和响应成功的方法封装 32 | app.use(commonMiddleware.sendSucc) 33 | app.use(commonMiddleware.sendErr) 34 | app.use(commonMiddleware.checkFormBody) 35 | app.use(cors({ 36 | origin: /.*/, 37 | credentials: true 38 | })) 39 | // app.use(logger('dev')) 40 | // app.use(logger('combined', { stream: accessLogStream })) 41 | app.use(express.json()) 42 | app.use(express.urlencoded({ extended: false })) 43 | app.use(cookieParser()) 44 | 45 | //导入签名 46 | const config = require('./config') 47 | const secret = config.secret 48 | 49 | app.use(session({ 50 | secret, 51 | name: 'itcast-wh-name', 52 | resave: false, 53 | saveUninitialized: true, 54 | cookie: { maxAge: 8000000000 } 55 | })) 56 | 57 | //使用中间件验证token合法性 58 | app.use(expressJwt({ 59 | secret, getToken(req) { 60 | if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') { 61 | return req.headers.authorization.split(' ')[1] 62 | } else if (req.query && req.query.token) { 63 | return req.query.token 64 | } else if (req.body && req.body.token) { 65 | return req.body.token 66 | } 67 | return req.headers.authorization 68 | } 69 | }).unless({ 70 | //除了这些地址, 其他的URL都需要验证, 支持正则 71 | path: [ 72 | '/', 73 | /(css|js|png|jpg|jpeg|ico)/, 74 | '/index.html', 75 | '/v1/users/login', 76 | '/v1/users/register', 77 | '/v1/users/getVCode', 78 | /\/v1\/users\/checkUsername\/\w*/, 79 | /\/news\/get\w*/, 80 | /\/goods\/get\w*/, 81 | /\/home\/get\w*/, 82 | ] 83 | })) 84 | 85 | app.use(express.static(path.join(__dirname, 'public'))) 86 | 87 | app.use((err, req, res, next) => { 88 | //当token验证失败时会抛出如下错误 89 | if (err.name === 'UnauthorizedError') { 90 | res.sendErr(401, '无效的token!') 91 | } 92 | }) 93 | 94 | // 获取用户信息存储在req.userInfo中 95 | app.use(usersMiddleware.getUserInfo) 96 | 97 | mount(app, path.join(process.cwd(), "/routes"), true) 98 | 99 | app.use((req, res, next) => { 100 | next(createError(404)) 101 | }) 102 | 103 | app.use((err, req, res, next) => { 104 | res.locals.message = err.message 105 | res.locals.error = req.app.get('env') === 'development' ? err : {} 106 | 107 | res.status(err.status || 500) 108 | res.render('error') 109 | }) 110 | 111 | module.exports = app -------------------------------------------------------------------------------- /routes/v1/cart.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const ctrl = require('../../controller') 4 | 5 | /** 6 | * @api {post} /v1/cart/postGoodsToCart/:id 添加商品到购物车(需要token) 7 | * @apiDescription 添加商品到购物车 8 | * @apiName postGoodsToCart 9 | * @apiGroup 7.Shopping-Cart 10 | * @apiHeader {string} Authorization token 11 | * @apiParam {number} id 将指定id的商品添加到购物车 12 | * @apiParam {number} count 要添加到购物车的商品数量 13 | * @apiSuccess {number} status 状态码 14 | * @apiSuccess {null} data null 15 | * @apiSuccess {string} succMsg 成功消息 16 | * @apiSuccess {string} succMsg 错误消息 17 | * @apiSuccessExample {json} Success-Response: 18 | * { 19 | "status": 200, 20 | "data": null, 21 | "succMsg": "添加购物车成功!", 22 | "errMsg": null 23 | } 24 | * @apiSampleRequest /v1/cart/postGoodsToCart/:id 25 | * @apiVersion 1.0.0 26 | */ 27 | router.post('/postGoodsToCart/:id', ctrl.cart.postGoodsToCart) 28 | 29 | /** 30 | * @api {get} /v1/cart/deleteGoodsFromCart/:id 删除购物车中的商品(需要token) 31 | * @apiDescription 删除购物车中的商品 32 | * @apiName deleteGoodsFromCart 33 | * @apiGroup 7.Shopping-Cart 34 | * @apiHeader {string} Authorization token 35 | * @apiParam {number} id 指定要删除的商品id 36 | * @apiSuccess {number} status 状态码 37 | * @apiSuccess {null} data null 38 | * @apiSuccess {string} succMsg 成功消息 39 | * @apiSuccess {string} succMsg 错误消息 40 | * @apiSuccessExample {json} Success-Response: 41 | * { 42 | "status": 200, 43 | "data": null, 44 | "succMsg": "删除购物车商品成功!", 45 | "errMsg": null 46 | } 47 | * @apiSampleRequest /v1/cart/deleteGoodsFromCart/:id 48 | * @apiVersion 1.0.0 49 | */ 50 | router.get('/deleteGoodsFromCart/:id', ctrl.cart.deleteGoodsFromCart) 51 | 52 | /** 53 | * @api {get} /v1/cart/getGoodsFromCart 获取当前用户的购物车信息(需要token) 54 | * @apiDescription 获取当前用户的购物车信息 55 | * @apiName getGoodsFromCart 56 | * @apiGroup 7.Shopping-Cart 57 | * @apiHeader {string} Authorization token 58 | * @apiParam {number} page 页码数 59 | * @apiParam {number} pageSize 每页条数 60 | * @apiSuccess {number} status 状态码 61 | * @apiSuccess {json} data 商品列表数据 62 | * @apiSuccess {string} succMsg 成功消息 63 | * @apiSuccess {string} succMsg 错误消息 64 | * @apiSuccessExample {json} Success-Response: 65 | * { 66 | "status": 200, 67 | "data": [ 68 | { 69 | "id": 100, 70 | "name": "春夏婴幼儿纱布侧开睡袋70x55(帆船小鱼)袋装,1件/袋", 71 | "discount_info": "【限时活动】圣诞欢乐颂到手价5折起【满赠】圣诞节全场单笔满338送卫生巾2包,满468送汗巾3条,满658送书籍1本(单笔订单限赠1份)", 72 | "price": "368", 73 | "sale_price": "368", 74 | "stock": 0, 75 | "sale_count": 2525, 76 | "ctime": "2018-12-24 22:47:16", 77 | "count": 1, 78 | "small_img": "https://res.purcotton.com//images/commodity/002001002/80000000/002000000596/10000001_00000559/05C427D668A3FF7272DB9631FAB82DB7.jpg_100x100.jpg,https://res.purcotton.com//images/commodity/002001002/80000000/002000000596/10000001_00000559/51C4A2F683F3C2C81C40101C7FEC8059.jpg_100x100.jpg,https://res.purcotton.com//images/commodity/002001002/80000000/002000000596/10000001_00000559/B9612C9D301F1E7248CEE657A1C59125.jpg_100x100.jpg,https://res.purcotton.com//images/commodity/002001002/80000000/002000000596/10000001_00000559/5A60CFE0505855A94B5B820AB7A48A87.jpg_100x100.jpg,https://res.purcotton.com//images/commodity/002001002/80000000/002000000596/10000001_00000559/C6B7095789B0AC22E188D3C4378E8AEF.jpg_100x100.jpg" 79 | } 80 | ], 81 | "succMsg": "获取购物车商品信息成功!", 82 | "errMsg": null 83 | } 84 | * @apiSampleRequest /v1/cart/getGoodsFromCart 85 | * @apiVersion 1.0.0 86 | */ 87 | router.get('/getGoodsFromCart', ctrl.cart.getGoodsFromCart) 88 | 89 | module.exports = router; 90 | -------------------------------------------------------------------------------- /controller/news.js: -------------------------------------------------------------------------------- 1 | const sqlExcute = require('../db') 2 | const moment = require('moment') 3 | 4 | const getNewsSql = `SELECT id, title, ctime, icon, description, views 5 | FROM news 6 | WHERE del_state = 0 7 | LIMIT ?, ?; 8 | SELECT COUNT(*) as count 9 | FROM news 10 | WHERE del_state = 0` 11 | 12 | const getNewsByKeysSql = `SELECT id, title, ctime, icon, description, views 13 | FROM news 14 | WHERE del_state = 0 15 | AND CONCAT(title, description, content) LIKE ? 16 | ORDER BY ctime desc 17 | LIMIT ?, ?; 18 | SELECT COUNT(*) as count 19 | FROM news 20 | WHERE del_state = 0 21 | AND CONCAT(title, description, content) LIKE ?` 22 | 23 | const getNewsByCategoriesSql = `SELECT id, title, ctime, icon, description, views 24 | FROM news 25 | WHERE del_state = 0 26 | AND cate_id = ? 27 | ORDER BY ctime desc 28 | LIMIT ?, ?; 29 | SELECT COUNT(*) as count 30 | FROM news 31 | WHERE del_state = 0 32 | AND cate_id = ?` 33 | 34 | const getNewsInfoByIdSql = `SELECT id, title, ctime, icon, description, content, views 35 | FROM news 36 | WHERE del_state = 0 37 | AND id = ? 38 | LIMIT 0, 1` 39 | 40 | const getNewsCategoriesSql = `SELECT * FROM news_cate` 41 | 42 | const getCommentListSql = `SELECT nc.id, nc.comment, nc.user_id, nc.ctime, u.nickname 43 | FROM news_comment as nc 44 | LEFT JOIN users as u 45 | ON u.id = nc.user_id 46 | WHERE del_state = 0 47 | AND news_id = ? 48 | ORDER BY nc.ctime desc 49 | LIMIT ?, ?; 50 | SELECT COUNT(*) as count 51 | FROM news_comment 52 | WHERE del_state = 0 53 | AND news_id = ?` 54 | 55 | const postCommentSql = `INSERT INTO news_comment SET ?` 56 | function checkNewsSql(req) { 57 | 58 | const pageSize = parseInt(req.query.pageSize) 59 | 60 | if ('cate' in req.query) { 61 | return sqlExcute(getNewsByCategoriesSql, [req.query.cate, (req.query.page - 1) * pageSize, pageSize, req.query.cate]) 62 | } 63 | 64 | if (req.query.keys) { 65 | return sqlExcute(getNewsByKeysSql, ['%' + req.query.keys + '%', (req.query.page - 1) * pageSize, pageSize, '%' + req.query.keys + '%']) 66 | } 67 | 68 | return sqlExcute(getNewsSql, [(req.query.page - 1) * pageSize, pageSize]) 69 | } 70 | 71 | module.exports = { 72 | getNewsListAction(req, res) { 73 | 74 | const attrs = ['page', 'pageSize'] 75 | if (!req.checkFormBody(attrs, res)) return 76 | 77 | // sqlExcute(getNewsSql, [req.query.page - 1, parseInt(req.query.pageSize)]) 78 | checkNewsSql(req) 79 | .then(result => { 80 | // console.log(result[0]) 81 | // console.log(result[1]) 82 | res.sendSucc('获取新闻列表数据成功!', { news: result[0], totalCount: result[1][0].count }) 83 | }) 84 | .catch(e => { 85 | res.sendErr(400, e.message) 86 | }) 87 | }, 88 | getNewsCategoriesAction(req, res) { 89 | sqlExcute(getNewsCategoriesSql) 90 | .then(result => { 91 | res.sendSucc('获取新闻分类列表成功!', result) 92 | }) 93 | .catch(e => { 94 | res.sendErr(400, e.message) 95 | }) 96 | }, 97 | getNewsInfoAction(req, res) { 98 | const newsId = parseInt(req.params.id) 99 | if (!newsId) return res.sendErr(400, '请传入正确的新闻Id!') 100 | sqlExcute(getNewsInfoByIdSql, newsId) 101 | .then(result => { 102 | res.sendSucc('获取新闻详情成功!', result[0]) 103 | }) 104 | .catch(e => { 105 | res.sendErr(400, e.message) 106 | }) 107 | }, 108 | getCommentListAction(req, res) { 109 | if (!req.checkFormBody(['id', 'page', 'pageSize'], res)) return 110 | 111 | const pageSize = parseInt(req.query.pageSize) 112 | sqlExcute(getCommentListSql, [req.params.id, (req.query.page - 1) * pageSize, pageSize, req.params.id]) 113 | .then(result => { 114 | res.sendSucc('获取评论列表成功!', { comments: result[0], totalCount: result[1][0].count }) 115 | }) 116 | .catch(e => { 117 | res.sendErr(400, e.message) 118 | }) 119 | }, 120 | postCommentAction(req, res) { 121 | if (!req.checkFormBody(['id', 'comment'], res)) reutrn 122 | 123 | const comment = req.body.comment 124 | const news_id = req.params.id 125 | const user_id = req.userInfo.id 126 | const ctime = moment().format('YYYY-MM-DD HH:mm:ss') 127 | 128 | sqlExcute(getNewsInfoByIdSql, news_id) 129 | .then(result => { 130 | if (result.length > 0) return sqlExcute(postCommentSql, { comment, ctime, news_id, user_id }) 131 | }) 132 | .then(result => { 133 | if (!result) throw new Error('新闻信息不存在!请传入正确的新闻id!') 134 | console.log(req.userInfo) 135 | res.sendSucc('发表评论成功!', { id: result.insertId, comment, user_id, ctime, nickname: req.userInfo.nickname }) 136 | }) 137 | .catch(e => { 138 | res.sendErr(400, e.message) 139 | }) 140 | } 141 | } -------------------------------------------------------------------------------- /controller/goods.js: -------------------------------------------------------------------------------- 1 | const sqlExcute = require('../db') 2 | const moment = require('moment') 3 | 4 | const getGoodsCategoriesSql = `SELECT id, name FROM goods_cate WHERE p_cate_id IS NULL` 5 | const getGoodsSubCategoriesSql = `SELECT id, name, img 6 | FROM goods_cate 7 | WHERE p_cate_id IS NOT NULL 8 | LIMIT ?, ?; 9 | SELECT COUNT(*) AS count 10 | FROM goods_cate 11 | WHERE p_cate_id IS NOT NULL` 12 | const getGoodsSubCategoriesByIdSql = `SELECT id, name, img 13 | FROM goods_cate 14 | WHERE p_cate_id = ?` 15 | 16 | module.exports = { 17 | getGoodsCategoriesAction(req, res) { 18 | sqlExcute(getGoodsCategoriesSql) 19 | .then(result => { 20 | res.sendSucc('获取商品一级分类列表数据成功!', result) 21 | }) 22 | .catch(e => { 23 | res.sendErr(400, e.message) 24 | }) 25 | }, 26 | getGoodsSubCategoriesAction(req, res) { 27 | if (!req.checkFormBody(['page', 'pageSize'], res)) return 28 | const pageSize = parseInt(req.query.pageSize) 29 | sqlExcute(getGoodsSubCategoriesSql, [(req.query.page - 1) * pageSize, pageSize]) 30 | .then(result => { 31 | res.sendSucc('获取商品所有二级分类数据成功!', { cates: result[0], totalCount: result[1][0].count }) 32 | }) 33 | .catch(e => { 34 | res.sendErr(400, e.message) 35 | }) 36 | }, 37 | getGoodsSubCategoriesByIdAction(req, res) { 38 | const cateId = parseInt(req.params.id) 39 | sqlExcute(getGoodsSubCategoriesByIdSql, cateId) 40 | .then(result => { 41 | res.sendSucc('获取商品分类数据成功!', result) 42 | }) 43 | .catch(e => { 44 | res.sendErr(400, e.message) 45 | }) 46 | }, 47 | getGoodsListAction(req, res) { 48 | if (!req.checkFormBody(['page', 'pageSize'], res)) return 49 | 50 | // 分页参数 51 | const pageSize = parseInt(req.query.pageSize) 52 | let queryParams = [(req.query.page - 1) * pageSize, pageSize] 53 | let queryParamsResult = [] 54 | 55 | // 分类条件 56 | let queryCondition = `` 57 | if (req.checkFormBody(['keys'])) { 58 | queryCondition = `WHERE g.name LIKE ? 59 | OR g.description LIKE ?` 60 | queryParamsResult = ['%' + req.query.keys + '%', '%' + req.query.keys + '%'] 61 | } 62 | 63 | // 检测是否有需要分类查询 64 | if (req.checkFormBody(['cateId'])) { 65 | queryCondition = `WHERE g.cate_id = ? 66 | OR g.sub_cate_id = ?` 67 | queryParamsResult = [req.query.cateId, req.query.cateId] 68 | // 拼接6个问号的查询参数 69 | } 70 | 71 | queryParams = queryParamsResult.concat(queryParams).concat(queryParamsResult) 72 | 73 | const getGoodsListSql = `SELECT g.id, g.name, g.cover_img, g.description, g.discount_info, g.price, g.sale_price, g.stock, g.sale_count, g.ctime 74 | FROM goods g 75 | LEFT JOIN goods_color gc 76 | ON g.id = gc.gid 77 | LEFT JOIN goods_size gs 78 | ON g.id = gs.gid 79 | LEFT JOIN goods_img gp 80 | ON g.id = gp.gid 81 | ${queryCondition} 82 | GROUP BY g.id 83 | LIMIT ?, ?; 84 | SELECT COUNT(*) AS count 85 | FROM goods as g 86 | ${queryCondition}` 87 | 88 | sqlExcute(getGoodsListSql, queryParams) 89 | .then(result => { 90 | result[0].forEach(item => { 91 | item.color && (item.color = item.color.split(',')) 92 | item.size && (item.size = item.size.split(',')) 93 | item.small_img && (item.small_img = item.small_img.split(',')) 94 | item.big_img && (item.big_img = item.big_img.split(',')) 95 | }) 96 | res.sendSucc('获取商品列表成功!', { goods: result[0], totalCount: result[1][0].count }) 97 | }) 98 | .catch(e => { 99 | res.sendErr(400, e.message) 100 | }) 101 | }, 102 | getGoodsInfoAction(req, res) { 103 | if (!req.checkFormBody(['id'], res)) return 104 | 105 | const getGoodsInfoSql = `SELECT g.id, g.name, g.description, g.discount_info, g.content, g.price, g.sale_price, g.stock, g.sale_count, g.ctime, GROUP_CONCAT(distinct gc.color) AS color, GROUP_CONCAT(distinct gs.size) AS size, GROUP_CONCAT(distinct gp.small_img) AS small_img, GROUP_CONCAT(distinct gp.big_img) AS big_img 106 | FROM goods g 107 | LEFT JOIN goods_color gc 108 | ON g.id = gc.gid 109 | LEFT JOIN goods_size gs 110 | ON g.id = gs.gid 111 | LEFT JOIN goods_img gp 112 | ON g.id = gp.gid 113 | WHERE g.id = ? 114 | GROUP BY g.id 115 | LIMIT 0, 1` 116 | 117 | sqlExcute(getGoodsInfoSql, req.params.id) 118 | .then(result => { 119 | let goodsInfo = result[0] 120 | goodsInfo.color && (goodsInfo.color = goodsInfo.color.split(',')) 121 | goodsInfo.size && (goodsInfo.size = goodsInfo.size.split(',')) 122 | goodsInfo.small_img && (goodsInfo.small_img = goodsInfo.small_img.split(',')) 123 | goodsInfo.big_img && (goodsInfo.big_img = goodsInfo.big_img.split(',')) 124 | res.sendSucc('获取商品详情成功!', goodsInfo) 125 | }) 126 | .catch(err => { 127 | res.sendErr(400, '获取商品详情失败!请检查id是否正确!') 128 | }) 129 | } 130 | } -------------------------------------------------------------------------------- /public/vendor/path-to-regexp/index.js: -------------------------------------------------------------------------------- 1 | var isArray = Array.isArray || function (arr) { 2 | return Object.prototype.toString.call(arr) == '[object Array]'; 3 | }; 4 | 5 | /** 6 | * Expose `pathToRegexp`. 7 | */ 8 | // module.exports = pathToRegexp 9 | 10 | /** 11 | * The main path matching regexp utility. 12 | * 13 | * @type {RegExp} 14 | */ 15 | var PATH_REGEXP = new RegExp([ 16 | // Match escaped characters that would otherwise appear in future matches. 17 | // This allows the user to escape special characters that won't transform. 18 | '(\\\\.)', 19 | // Match Express-style parameters and un-named parameters with a prefix 20 | // and optional suffixes. Matches appear as: 21 | // 22 | // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"] 23 | // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined] 24 | '([\\/.])?(?:\\:(\\w+)(?:\\(((?:\\\\.|[^)])*)\\))?|\\(((?:\\\\.|[^)])*)\\))([+*?])?', 25 | // Match regexp special characters that are always escaped. 26 | '([.+*?=^!:${}()[\\]|\\/])' 27 | ].join('|'), 'g'); 28 | 29 | /** 30 | * Escape the capturing group by escaping special characters and meaning. 31 | * 32 | * @param {String} group 33 | * @return {String} 34 | */ 35 | function escapeGroup (group) { 36 | return group.replace(/([=!:$\/()])/g, '\\$1'); 37 | } 38 | 39 | /** 40 | * Attach the keys as a property of the regexp. 41 | * 42 | * @param {RegExp} re 43 | * @param {Array} keys 44 | * @return {RegExp} 45 | */ 46 | function attachKeys (re, keys) { 47 | re.keys = keys; 48 | return re; 49 | } 50 | 51 | /** 52 | * Get the flags for a regexp from the options. 53 | * 54 | * @param {Object} options 55 | * @return {String} 56 | */ 57 | function flags (options) { 58 | return options.sensitive ? '' : 'i'; 59 | } 60 | 61 | /** 62 | * Pull out keys from a regexp. 63 | * 64 | * @param {RegExp} path 65 | * @param {Array} keys 66 | * @return {RegExp} 67 | */ 68 | function regexpToRegexp (path, keys) { 69 | // Use a negative lookahead to match only capturing groups. 70 | var groups = path.source.match(/\((?!\?)/g); 71 | 72 | if (groups) { 73 | for (var i = 0; i < groups.length; i++) { 74 | keys.push({ 75 | name: i, 76 | delimiter: null, 77 | optional: false, 78 | repeat: false 79 | }); 80 | } 81 | } 82 | 83 | return attachKeys(path, keys); 84 | } 85 | 86 | /** 87 | * Transform an array into a regexp. 88 | * 89 | * @param {Array} path 90 | * @param {Array} keys 91 | * @param {Object} options 92 | * @return {RegExp} 93 | */ 94 | function arrayToRegexp (path, keys, options) { 95 | var parts = []; 96 | 97 | for (var i = 0; i < path.length; i++) { 98 | parts.push(pathToRegexp(path[i], keys, options).source); 99 | } 100 | 101 | var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)); 102 | return attachKeys(regexp, keys); 103 | } 104 | 105 | /** 106 | * Replace the specific tags with regexp strings. 107 | * 108 | * @param {String} path 109 | * @param {Array} keys 110 | * @return {String} 111 | */ 112 | function replacePath (path, keys) { 113 | var index = 0; 114 | 115 | function replace (_, escaped, prefix, key, capture, group, suffix, escape) { 116 | if (escaped) { 117 | return escaped; 118 | } 119 | 120 | if (escape) { 121 | return '\\' + escape; 122 | } 123 | 124 | var repeat = suffix === '+' || suffix === '*'; 125 | var optional = suffix === '?' || suffix === '*'; 126 | 127 | keys.push({ 128 | name: key || index++, 129 | delimiter: prefix || '/', 130 | optional: optional, 131 | repeat: repeat 132 | }); 133 | 134 | prefix = prefix ? ('\\' + prefix) : ''; 135 | capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?'); 136 | 137 | if (repeat) { 138 | capture = capture + '(?:' + prefix + capture + ')*'; 139 | } 140 | 141 | if (optional) { 142 | return '(?:' + prefix + '(' + capture + '))?'; 143 | } 144 | 145 | // Basic parameter support. 146 | return prefix + '(' + capture + ')'; 147 | } 148 | 149 | return path.replace(PATH_REGEXP, replace); 150 | } 151 | 152 | /** 153 | * Normalize the given path string, returning a regular expression. 154 | * 155 | * An empty array can be passed in for the keys, which will hold the 156 | * placeholder key descriptions. For example, using `/user/:id`, `keys` will 157 | * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. 158 | * 159 | * @param {(String|RegExp|Array)} path 160 | * @param {Array} [keys] 161 | * @param {Object} [options] 162 | * @return {RegExp} 163 | */ 164 | function pathToRegexp (path, keys, options) { 165 | keys = keys || []; 166 | 167 | if (!isArray(keys)) { 168 | options = keys; 169 | keys = []; 170 | } else if (!options) { 171 | options = {}; 172 | } 173 | 174 | if (path instanceof RegExp) { 175 | return regexpToRegexp(path, keys, options); 176 | } 177 | 178 | if (isArray(path)) { 179 | return arrayToRegexp(path, keys, options); 180 | } 181 | 182 | var strict = options.strict; 183 | var end = options.end !== false; 184 | var route = replacePath(path, keys); 185 | var endsWithSlash = path.charAt(path.length - 1) === '/'; 186 | 187 | // In non-strict mode we allow a slash at the end of match. If the path to 188 | // match already ends with a slash, we remove it for consistency. The slash 189 | // is valid at the end of a path match, not in the middle. This is important 190 | // in non-ending mode, where "/test/" shouldn't match "/test//route". 191 | if (!strict) { 192 | route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?'; 193 | } 194 | 195 | if (end) { 196 | route += '$'; 197 | } else { 198 | // In non-ending mode, we need the capturing groups to match as much as 199 | // possible by using a positive lookahead to the end or next path segment. 200 | route += strict && endsWithSlash ? '' : '(?=\\/|$)'; 201 | } 202 | 203 | return attachKeys(new RegExp('^' + route, flags(options)), keys); 204 | } 205 | -------------------------------------------------------------------------------- /public/utils/send_sample_request.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'lodash' 4 | ], function($, _) { 5 | 6 | var initDynamic = function() { 7 | // Button send 8 | $(".sample-request-send").off("click"); 9 | $(".sample-request-send").on("click", function(e) { 10 | e.preventDefault(); 11 | var $root = $(this).parents("article"); 12 | var group = $root.data("group"); 13 | var name = $root.data("name"); 14 | var version = $root.data("version"); 15 | sendSampleRequest(group, name, version, $(this).data("sample-request-type")); 16 | }); 17 | 18 | // Button clear 19 | $(".sample-request-clear").off("click"); 20 | $(".sample-request-clear").on("click", function(e) { 21 | e.preventDefault(); 22 | var $root = $(this).parents("article"); 23 | var group = $root.data("group"); 24 | var name = $root.data("name"); 25 | var version = $root.data("version"); 26 | clearSampleRequest(group, name, version); 27 | }); 28 | }; // initDynamic 29 | 30 | function sendSampleRequest(group, name, version, type) 31 | { 32 | var $root = $('article[data-group="' + group + '"][data-name="' + name + '"][data-version="' + version + '"]'); 33 | 34 | // Optional header 35 | var header = {}; 36 | $root.find(".sample-request-header:checked").each(function(i, element) { 37 | var group = $(element).data("sample-request-header-group-id"); 38 | $root.find("[data-sample-request-header-group=\"" + group + "\"]").each(function(i, element) { 39 | var key = $(element).data("sample-request-header-name"); 40 | var value = element.value; 41 | if ( ! element.optional && element.defaultValue !== '') { 42 | value = element.defaultValue; 43 | } 44 | header[key] = value; 45 | }); 46 | }); 47 | 48 | // create JSON dictionary of parameters 49 | var param = {}; 50 | var paramType = {}; 51 | $root.find(".sample-request-param:checked").each(function(i, element) { 52 | var group = $(element).data("sample-request-param-group-id"); 53 | $root.find("[data-sample-request-param-group=\"" + group + "\"]").not(function(){ 54 | return $(this).val() == "" && $(this).is("[data-sample-request-param-optional='true']"); 55 | }).each(function(i, element) { 56 | var key = $(element).data("sample-request-param-name"); 57 | var value = element.value; 58 | if ( ! element.optional && element.defaultValue !== '') { 59 | value = element.defaultValue; 60 | } 61 | param[key] = value; 62 | paramType[key] = $(element).next().text(); 63 | }); 64 | }); 65 | 66 | // grab user-inputted URL 67 | var url = $root.find(".sample-request-url").val(); 68 | 69 | // Insert url parameter 70 | var pattern = pathToRegexp(url, null); 71 | var matches = pattern.exec(url); 72 | for (var i = 1; i < matches.length; i++) { 73 | var key = matches[i].substr(1); 74 | if (param[key] !== undefined) { 75 | url = url.replace(matches[i], encodeURIComponent(param[key])); 76 | 77 | // remove URL parameters from list 78 | delete param[key]; 79 | } 80 | } // for 81 | 82 | $root.find(".sample-request-response").fadeTo(250, 1); 83 | $root.find(".sample-request-response-json").html("Loading..."); 84 | refreshScrollSpy(); 85 | 86 | _.each( param, function( val, key ) { 87 | var t = paramType[ key ].toLowerCase(); 88 | if ( t === 'object' || t === 'array' ) { 89 | try { 90 | param[ key ] = JSON.parse( val ); 91 | } catch (e) { 92 | } 93 | } 94 | }); 95 | 96 | // send AJAX request, catch success or error callback 97 | var ajaxRequest = { 98 | url : url, 99 | headers : header, 100 | data : param, 101 | type : type.toUpperCase(), 102 | success : displaySuccess, 103 | error : displayError 104 | }; 105 | 106 | $.ajax(ajaxRequest); 107 | 108 | 109 | function displaySuccess(data, status, jqXHR) { 110 | var jsonResponse; 111 | try { 112 | jsonResponse = JSON.parse(jqXHR.responseText); 113 | jsonResponse = JSON.stringify(jsonResponse, null, 4); 114 | } catch (e) { 115 | jsonResponse = data; 116 | } 117 | $root.find(".sample-request-response-json").html(jsonResponse); 118 | refreshScrollSpy(); 119 | }; 120 | 121 | function displayError(jqXHR, textStatus, error) { 122 | var message = "Error " + jqXHR.status + ": " + error; 123 | var jsonResponse; 124 | try { 125 | jsonResponse = JSON.parse(jqXHR.responseText); 126 | jsonResponse = JSON.stringify(jsonResponse, null, 4); 127 | } catch (e) { 128 | jsonResponse = escape(jqXHR.responseText); 129 | } 130 | 131 | if (jsonResponse) 132 | message += "
" + jsonResponse; 133 | 134 | // flicker on previous error to make clear that there is a new response 135 | if($root.find(".sample-request-response").is(":visible")) 136 | $root.find(".sample-request-response").fadeTo(1, 0.1); 137 | 138 | $root.find(".sample-request-response").fadeTo(250, 1); 139 | $root.find(".sample-request-response-json").html(message); 140 | refreshScrollSpy(); 141 | }; 142 | } 143 | 144 | function clearSampleRequest(group, name, version) 145 | { 146 | var $root = $('article[data-group="' + group + '"][data-name="' + name + '"][data-version="' + version + '"]'); 147 | 148 | // hide sample response 149 | $root.find(".sample-request-response-json").html(""); 150 | $root.find(".sample-request-response").hide(); 151 | 152 | // reset value of parameters 153 | $root.find(".sample-request-param").each(function(i, element) { 154 | element.value = ""; 155 | }); 156 | 157 | // restore default URL 158 | var $urlElement = $root.find(".sample-request-url"); 159 | $urlElement.val($urlElement.prop("defaultValue")); 160 | 161 | refreshScrollSpy(); 162 | } 163 | 164 | function refreshScrollSpy() 165 | { 166 | $('[data-spy="scroll"]').each(function () { 167 | $(this).scrollspy("refresh"); 168 | }); 169 | } 170 | 171 | function escapeHtml(str) { 172 | var div = document.createElement("div"); 173 | div.appendChild(document.createTextNode(str)); 174 | return div.innerHTML; 175 | } 176 | 177 | /** 178 | * Exports. 179 | */ 180 | return { 181 | initDynamic: initDynamic 182 | }; 183 | 184 | }); 185 | -------------------------------------------------------------------------------- /routes/v1/goods.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const ctrl = require('../../controller') 4 | 5 | /** 6 | * @api {get} /v1/goods/getGoodsCategories 获取商品一级分类列表信息 7 | * @apiDescription 获取商品一级分类列表信息 8 | * @apiName getGoodsCategories 9 | * @apiGroup 5.Goods-Category 10 | * @apiSuccess {number} status 状态码 11 | * @apiSuccess {json} data 分类数据 12 | * @apiSuccess {string} succMsg 成功消息 13 | * @apiSuccess {string} succMsg 错误消息 14 | * @apiSuccessExample {json} Success-Response: 15 | * { 16 | "status": 200, 17 | "data": [ 18 | { 19 | "id": 1, 20 | "name": "婴童" 21 | }, 22 | { 23 | "id": 2, 24 | "name": "女士" 25 | }, 26 | { 27 | "id": 3, 28 | "name": "家居" 29 | }, 30 | { 31 | "id": 4, 32 | "name": "男士" 33 | } 34 | ], 35 | "succMsg": "获取商品一级分类列表数据成功!", 36 | "errMsg": null 37 | } 38 | * @apiSampleRequest /v1/goods/getGoodsCategories 39 | * @apiVersion 1.0.0 40 | */ 41 | router.get('/getGoodsCategories', ctrl.goods.getGoodsCategoriesAction) 42 | 43 | /** 44 | * @api {get} /v1/goods/getGoodsSubCategories 获取商品所有二级分类列表信息 45 | * @apiDescription 获取商品所有二级分类列表信息 46 | * @apiName getGoodsSubCategories 47 | * @apiGroup 5.Goods-Category 48 | * @apiParam {number} page 页码数 49 | * @apiParam {number} pageSize 每页条数 50 | * @apiSuccess {number} status 状态码 51 | * @apiSuccess {json} data 分类数据 52 | * @apiSuccess {string} succMsg 成功消息 53 | * @apiSuccess {string} succMsg 错误消息 54 | * @apiSuccessExample {json} Success-Response: 55 | * { 56 | "status": 200, 57 | "data": { 58 | "cates": [ 59 | { 60 | "id": 15, 61 | "name": "孕产用品", 62 | "img": "https://res.purcotton.com/category/002004.jpg" 63 | }, 64 | { 65 | "id": 16, 66 | "name": "厨房用品", 67 | "img": "https://res.purcotton.com/category/003001.jpg" 68 | }, 69 | { 70 | "id": 17, 71 | "name": "床上用品", 72 | "img": "https://res.purcotton.com/category/003002.jpg" 73 | }, 74 | { 75 | "id": 18, 76 | "name": "护理用品", 77 | "img": "https://res.purcotton.com/category/003003.jpg" 78 | }, 79 | { 80 | "id": 19, 81 | "name": "旅游户外", 82 | "img": "https://res.purcotton.com/category/003004.jpg" 83 | } 84 | ], 85 | "totalCount": 20 86 | }, 87 | "succMsg": "获取商品所有二级分类数据成功!", 88 | "errMsg": null 89 | } 90 | * @apiSampleRequest /v1/goods/getGoodsSubCategories 91 | * @apiVersion 1.0.0 92 | */ 93 | router.get('/getGoodsSubCategories', ctrl.goods.getGoodsSubCategoriesAction) 94 | 95 | /** 96 | * @api {get} /v1/goods/getGoodsSubCategories/:id 获取指定的二级分类列表信息 97 | * @apiDescription 获取指定的二级分类列表信息 98 | * @apiName getGoodsSubCategoriesById 99 | * @apiGroup 5.Goods-Category 100 | * @apiParam {number} id 一级分类id 101 | * @apiSuccess {number} status 状态码 102 | * @apiSuccess {json} data 分类列表数据 103 | * @apiSuccess {string} succMsg 成功消息 104 | * @apiSuccess {string} succMsg 错误消息 105 | * @apiSuccessExample {json} Success-Response: 106 | * { 107 | "status": 200, 108 | "data": [ 109 | { 110 | "id": 5, 111 | "name": "婴童护理", 112 | "img": "https://res.purcotton.com/category/001006.jpg" 113 | }, 114 | { 115 | "id": 6, 116 | "name": "婴童卫浴", 117 | "img": "https://res.purcotton.com/category/001007.jpg" 118 | }, 119 | { 120 | "id": 7, 121 | "name": "婴童床品", 122 | "img": "https://res.purcotton.com/category/001001.jpg" 123 | }, 124 | { 125 | "id": 8, 126 | "name": "婴童服装(0-1岁)", 127 | "img": "https://res.purcotton.com/category/001003.jpg" 128 | }, 129 | { 130 | "id": 9, 131 | "name": "婴童服装(1-4岁)", 132 | "img": "https://res.purcotton.com/category/001004.jpg" 133 | }, 134 | { 135 | "id": 10, 136 | "name": "婴童服装(4岁以上) ", 137 | "img": "https://res.purcotton.com/category/001005.jpg" 138 | }, 139 | { 140 | "id": 11, 141 | "name": "婴童服饰", 142 | "img": "https://res.purcotton.com/category/001002.jpg" 143 | } 144 | ], 145 | "succMsg": "获取商品分类数据成功!", 146 | "errMsg": null 147 | } 148 | * @apiSampleRequest /v1/goods/getGoodsSubCategories/:id 149 | * @apiVersion 1.0.0 150 | */ 151 | router.get('/getGoodsSubCategories/:id', ctrl.goods.getGoodsSubCategoriesByIdAction) 152 | 153 | /** 154 | * @api {get} /v1/goods/getGoodsList 获取商品列表信息 155 | * @apiDescription 获取商品列表信息 156 | * @apiName getGoodsList 157 | * @apiGroup 6.Goods-Info 158 | * @apiParam {number} [keys] 搜索关键字,不传表示获取所有 159 | * @apiParam {number} [cateId] 分类id,不传表示获取所有新闻,权重高于keys,如果传入cate则不会进行搜索关键字 160 | * @apiParam {number} page 页码数 161 | * @apiParam {number} pageSize 每页条数 162 | * @apiSuccess {number} status 状态码 163 | * @apiSuccess {json} data 商品列表数据 164 | * @apiSuccess {string} succMsg 成功消息 165 | * @apiSuccess {string} succMsg 错误消息 166 | * @apiSuccessExample {json} Success-Response: 167 | * { 168 | "status": 200, 169 | "data": { 170 | "goods": [ 171 | { 172 | "id": 1, 173 | "name": "婴儿纱布夹棉侧开睡袋90x58cm, 1条装", 174 | "cover_img": "https://res.purcotton.com//images/commodity/002010009/80000000/002000001384/10000001_00000695/06FF87611C685BC71FA2C921058564CC.jpg_350x350.jpg", 175 | "description": "双层纱布面料,中间100%棉填充,亲肤保暖;袖子可拆卸,伸展更自由。", 176 | "discount_info": "【限时活动】圣诞欢乐颂到手价5折起【满赠】圣诞节全场单笔满338送卫生巾2包,满468送汗巾3条,满658送书籍1本(单笔订单限赠1份)", 177 | "price": "398", 178 | "sale_price": "398", 179 | "kucun": 1230, 180 | "sale_count": 2360, 181 | "ctime": "2018-12-19 18:30:00" 182 | }, 183 | { 184 | "id": 2, 185 | "name": "幼儿纱布床品7件套件(带被芯)幼儿床适用, 1套装", 186 | "cover_img": "https://res.purcotton.com//images/commodity/002011002/80000000/002000001378/10000001_00000695/62C44938FF4B0D57DB31EFEC869AF7C5.jpg_350x350.jpg", 187 | "description": "透气-优质纱布面料, 舒适透气, 让宝宝享受高质量睡眠。", 188 | "discount_info": "【限时活动】圣诞欢乐颂到手价5折起【满赠】圣诞节全场单笔满338送卫生巾2包,满468送汗巾3条,满658送书籍1本(单笔订单限赠1份)", 189 | "price": "1568", 190 | "sale_price": "1019.2", 191 | "kucun": 1020, 192 | "sale_count": 2323, 193 | "ctime": "2018-12-18 18:30:00" 194 | }, 195 | { 196 | "id": 4, 197 | "name": "盒装水洗纱布面巾25x50-5P,3片/盒(水洗后成型尺寸)", 198 | "cover_img": "https://res.purcotton.com//images/commodity/002004001/80000000/002000000276/10000001_00000607/3C9E19B7D6BA02964C19E6476E79FFD9.jpg_350x350.jpg", 199 | "description": "纯棉5层纱布吸水迅速 易洗易干", 200 | "discount_info": "【满折】棉苗会员正价商品92折,棉桃会员88折,棉花会员85折【满赠】圣诞节全场单笔满338送卫生巾2包,满468送汗巾3条,满658送书籍1本(单笔订单限赠1份)", 201 | "price": "98", 202 | "sale_price": "98", 203 | "kucun": 0, 204 | "sale_count": 4998, 205 | "ctime": "2018-12-20 18:30:00" 206 | } 207 | ], 208 | "totalCount": 3 209 | }, 210 | "succMsg": "获取商品列表成功!", 211 | "errMsg": null 212 | } 213 | * @apiSampleRequest /v1/goods/getGoodsList 214 | * @apiVersion 1.0.0 215 | */ 216 | router.get('/getGoodsList', ctrl.goods.getGoodsListAction) 217 | 218 | /** 219 | * @api {get} /v1/goods/getGoodsInfo/:id 获取商品详情 220 | * @apiDescription 获取商品详情 221 | * @apiName getGoodsInfo 222 | * @apiGroup 6.Goods-Info 223 | * @apiParam {number} id 根据商品id获取商品详细信息 224 | * @apiSuccess {number} status 状态码 225 | * @apiSuccess {json} data 商品列表数据 226 | * @apiSuccess {string} succMsg 成功消息 227 | * @apiSuccess {string} succMsg 错误消息 228 | * @apiSuccessExample {json} Success-Response: 229 | * { 230 | "status": 200, 231 | "data": { 232 | "id": 1, 233 | "name": "婴儿纱布夹棉侧开睡袋90x58cm, 1条装", 234 | "description": "双层纱布面料,中间100%棉填充,亲肤保暖;袖子可拆卸,伸展更自由。", 235 | "discount_info": "【限时活动】圣诞欢乐颂到手价5折起【满赠】圣诞节全场单笔满338送卫生巾2包,满468送汗巾3条,满658送书籍1本(单笔订单限赠1份)", 236 | "content": "
\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t

\r\n\t\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"

\r\n\r\n\t\t\t\t
\r\n\t\t\t
", 237 | "price": "398", 238 | "sale_price": "398", 239 | "stock": 1230, 240 | "sale_count": 2360, 241 | "ctime": "2018-12-19 18:30:00", 242 | "color": "星际呦呦,森林乐章,绿底白树", 243 | "size": null, 244 | "small_img": null, 245 | "big_img": null 246 | }, 247 | "succMsg": "获取商品详情成功!", 248 | "errMsg": null 249 | } 250 | * @apiSampleRequest /v1/goods/getGoodsInfo/:id 251 | * @apiVersion 1.0.0 252 | */ 253 | router.get('/getGoodsInfo/:id', ctrl.goods.getGoodsInfoAction) 254 | 255 | module.exports = router; 256 | -------------------------------------------------------------------------------- /controller/users.js: -------------------------------------------------------------------------------- 1 | const sqlExcute = require('../db') 2 | const svgCaptcha = require('svg-captcha') 3 | const bcrypt = require('bcryptjs') 4 | const jwt = require('jsonwebtoken') 5 | const config = require('../config') 6 | const secret = config.secret 7 | 8 | const moment = require('moment') 9 | 10 | // SQL语句 11 | const getUserCountSql = 'SELECT count(*) as count FROM users WHERE username = ?' 12 | const addUserSql = 'INSERT INTO users SET ?' 13 | const addUserTokenSql = 'INSERT INTO users_auth SET ?' 14 | const getUserInfoSql = `SELECT u.id, u.nickname, u.password, u.mobile ,ua.token, ua.ctime 15 | FROM users AS u 16 | LEFT JOIN users_auth AS ua 17 | ON u.id = ua.user_id 18 | WHERE username = ? 19 | ORDER BY ua.ctime DESC 20 | LIMIT 0, 1` 21 | const updateUserInfoSql = `UPDATE users 22 | SET ? 23 | WHERE id = ?` 24 | const getReceiverAddressSql = `SELECT id, receiver_name, mobile, postcode, province, city, area, detailed_address, common_used 25 | FROM receiver_address 26 | WHERE del_state = 0 27 | AND user_id = ?` 28 | const deleteReceiverAddressSql = `UPDATE receiver_address 29 | SET del_state = 1 30 | WHERE id = ?` 31 | const addReceiverAddressSql = `INSERT INTO receiver_address SET ?` 32 | 33 | const getReceiverAddressByIdSql = getReceiverAddressSql + ' AND id = ?' 34 | 35 | const updateReceiverAddressSql = `UPDATE receiver_address 36 | SET ? 37 | WHERE id = ? 38 | AND user_id = ?` 39 | 40 | const setAllReceiverCommonUsedToZeroSql = 'UPDATE receiver_address SET common_used = 0 WHERE user_id = ?' 41 | 42 | module.exports = { 43 | registerAction(req, res) { 44 | 45 | let attrs = ['username', 'nickname', 'password', 'vCode', 'mobile'] 46 | 47 | if (!req.checkFormBody(attrs, res)) return 48 | 49 | if (!req.session.vCode || req.session.vCode.toLowerCase() != req.body.vCode.toLowerCase()) return res.sendErr(400, '验证码错误!') 50 | 51 | req.body.password = bcrypt.hashSync(req.body.password, 10) 52 | 53 | let userInfo = { ctime: moment().format('YYYY-MM-DD HH:mm:ss') } 54 | 55 | attrs.forEach(attr => { 56 | userInfo[attr] = req.body[attr] 57 | }) 58 | 59 | delete userInfo.vCode 60 | 61 | sqlExcute(getUserCountSql, userInfo.username) 62 | .then(result => { 63 | if (result[0].count > 0) { 64 | throw new Error('用户名已存在!') 65 | } 66 | return sqlExcute(addUserSql, userInfo) 67 | }) 68 | .then(result => { 69 | if (result.affectedRows) { 70 | delete userInfo.password 71 | 72 | let token = jwt.sign({ secret }, secret, { 73 | expiresIn: config.tokenExpire 74 | }) 75 | let ctime = moment().format('YYYY-MM-DD HH:mm:ss') 76 | const tokenInfo = { 77 | user_id: result.insertId, 78 | token, 79 | ctime 80 | } 81 | userInfo.token = token 82 | userInfo.id = result.insertId 83 | return sqlExcute(addUserTokenSql, tokenInfo) 84 | } 85 | }) 86 | .then(result => { 87 | if (result.affectedRows) { 88 | res.sendSucc('注册成功!', userInfo) 89 | } 90 | }) 91 | .catch(e => { 92 | res.sendErr(400, e.message) 93 | }) 94 | 95 | }, 96 | getVCodeAction(req, res) { 97 | const codeConfig = { 98 | size: 4,// 验证码长度 99 | ignoreChars: '0o1i', // 验证码字符中排除 0o1i 100 | noise: 5, // 干扰线条的数量 101 | width: 100 102 | } 103 | const vCode = svgCaptcha.create(codeConfig) 104 | req.session.vCode = vCode.text 105 | console.log(vCode.text) 106 | // res.type('svg') 107 | res.send(vCode.data) 108 | }, 109 | checkUsernameAction(req, res) { 110 | 111 | let attrs = ['username'] 112 | 113 | if (!req.checkFormBody(attrs, res)) return 114 | 115 | sqlExcute(getUserCountSql, req.params.username) 116 | .then(result => { 117 | if (result[0].count > 0) throw new Error(req.params.username + '用户名已存在!') 118 | res.sendSucc(req.params.username + '用户名可用!') 119 | }) 120 | .catch(e => { 121 | res.sendErr(400, e.message) 122 | }) 123 | }, 124 | loginAction(req, res) { 125 | 126 | let attrs = ['username', 'password'] 127 | 128 | if (!req.checkFormBody(attrs, res)) return 129 | 130 | const userInfo = { 131 | username: req.body.username, 132 | password: req.body.password 133 | } 134 | 135 | sqlExcute(getUserInfoSql, userInfo.username) 136 | .then(result => { 137 | if (!result || result.length === 0) throw new Error('用户名不存在!') 138 | const hash = result[0].password 139 | if (bcrypt.compareSync(req.body.password, hash)) { 140 | userInfo.id = result[0].id 141 | userInfo.nickname = result[0].nickname 142 | userInfo.mobile = result[0].mobile 143 | userInfo.token = result[0].token 144 | if (!userInfo.token || (Date.now() - new Date(result[0].ctime)) / 1000 >= config.tokenExpire) { 145 | userInfo.token = jwt.sign({ secret }, secret, { 146 | expiresIn: config.tokenExpire 147 | }) 148 | let tokenInfo = { 149 | user_id: userInfo.id, 150 | token: userInfo.token, 151 | ctime: moment().format('YYYY-MM-DD HH:mm:ss') 152 | } 153 | sqlExcute(addUserTokenSql, tokenInfo) 154 | } 155 | delete userInfo.password 156 | res.sendSucc('登录成功!', userInfo) 157 | } else { 158 | throw new Error('登录失败!密码错误!') 159 | } 160 | }) 161 | .catch(e => { 162 | res.sendErr(400, e.message) 163 | }) 164 | }, 165 | 166 | getUserInfoAction(req, res) { 167 | res.sendSucc('获取用户信息成功!', req.userInfo) 168 | }, 169 | updateUserInfoAction(req, res) { 170 | 171 | let attrs = ['mobile'] 172 | 173 | if (!req.checkFormBody(attrs, res)) return 174 | 175 | let userInfo = { mobile: req.body.mobile } 176 | 177 | sqlExcute(updateUserInfoSql, [userInfo, req.userInfo.id]) 178 | .then(result => { 179 | if (result.affectedRows) { 180 | req.userInfo.mobile = req.body.mobile 181 | res.sendSucc('用户信息修改成功!', req.userInfo) 182 | } 183 | }) 184 | .catch(e => { 185 | res.sendErr(400, e.message) 186 | }) 187 | }, 188 | updatePasswordAction(req, res) { 189 | 190 | let attrs = ['oldPassword', 'newPassword'] 191 | 192 | if (!req.checkFormBody(attrs, res)) return 193 | 194 | sqlExcute(getUserInfoSql, req.userInfo.username) 195 | .then(result => { 196 | if (!result || result.length === 0) throw new Error('用户名不存在!') 197 | const hash = result[0].password 198 | if (bcrypt.compareSync(req.body.oldPassword, hash)) { 199 | let password = bcrypt.hashSync(req.body.newPassword, 10) 200 | return sqlExcute(updateUserInfoSql, [{ password }, req.userInfo.id]) 201 | } else { 202 | throw new Error('修改密码失败!密码错误!') 203 | } 204 | }) 205 | .then(result => { 206 | if (result.affectedRows) { 207 | res.sendSucc('修改密码成功!') 208 | } 209 | }) 210 | .catch(e => { 211 | res.sendErr(400, e.message) 212 | }) 213 | }, 214 | getReceiverAddressAction(req, res) { 215 | sqlExcute(getReceiverAddressSql, req.userInfo.id) 216 | .then(result => { 217 | res.sendSucc('获取收货人列表成功!', result) 218 | }) 219 | .catch(e => { 220 | res.sendErr(400, e.message) 221 | }) 222 | }, 223 | 224 | getReceiverAddressByIdAction(req, res) { 225 | sqlExcute(getReceiverAddressSql + ' AND id = ? LIMIT 0, 1', [req.userInfo.id, req.params.id]) 226 | .then(result => { 227 | if (result.length === 0) throw new Error('获取收货人信息失败!请检查id是否正确!') 228 | res.sendSucc('获取收货人信息成功!', result[0]) 229 | }) 230 | .catch(e => { 231 | res.sendErr(400, e.message) 232 | }) 233 | }, 234 | deleteReceiverAddressAction(req, res) { 235 | const receiverId = req.params.id 236 | sqlExcute(deleteReceiverAddressSql, receiverId) 237 | .then(result => { 238 | if (result.affectedRows) res.sendSucc('删除收货人成功!') 239 | else throw new Error('删除收货人失败!请检查id是否正确!') 240 | }) 241 | .catch(e => { 242 | res.sendErr(400, e.message) 243 | }) 244 | }, 245 | async addReceiverAddressAction(req, res) { 246 | 247 | let attrs = ['receiver_name', 'mobile', 'postcode', 'province', 'city', 'area', 'detailed_address', 'common_used'] 248 | 249 | if (!req.checkFormBody(attrs, res)) return 250 | 251 | let receiverInfo = {} 252 | attrs.forEach(attr => { 253 | receiverInfo[attr] = req.body[attr] 254 | }) 255 | receiverInfo.user_id = req.userInfo.id 256 | 257 | if (receiverInfo.common_used == 1) await sqlExcute(setAllReceiverCommonUsedToZeroSql, receiverInfo.user_id) 258 | 259 | sqlExcute(addReceiverAddressSql, receiverInfo) 260 | .then(result => { 261 | if (result.affectedRows) { 262 | receiverInfo.id = result.insertId 263 | res.sendSucc('添加收货人成功!', receiverInfo) 264 | } else { 265 | throw new Error('添加收货人失败!') 266 | } 267 | }) 268 | .catch(e => { 269 | res.sendErr(400, e.message) 270 | }) 271 | }, 272 | updateReceiverAddressAction(req, res) { 273 | const receiverId = req.params.id 274 | let receiverInfo = null 275 | sqlExcute(getReceiverAddressByIdSql, [req.userInfo.id, receiverId]) 276 | .then(async result => { 277 | if (!result || result.length === 0) throw new Error('收货人信息不存在!') 278 | 279 | if (req.body.common_used == 1) await sqlExcute(setAllReceiverCommonUsedToZeroSql, req.userInfo.id) 280 | 281 | receiverInfo = result[0] 282 | for (let k in receiverInfo) { 283 | req.body[k] && (receiverInfo[k] = req.body[k]) 284 | } 285 | return sqlExcute(updateReceiverAddressSql, [receiverInfo, receiverInfo.id, req.userInfo.id]) 286 | }) 287 | .then(result => { 288 | if (result.affectedRows) res.sendSucc('修改收货人信息成功!', receiverInfo) 289 | else throw new Error('修改收货人失败!') 290 | }) 291 | .catch(e => { 292 | res.sendErr(400, e.message) 293 | }) 294 | } 295 | } -------------------------------------------------------------------------------- /public/utils/handlebars_helper.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'locales', 3 | 'handlebars', 4 | 'diffMatchPatch' 5 | ], function(locale, Handlebars, DiffMatchPatch) { 6 | 7 | /** 8 | * Return a text as markdown. 9 | * Currently only a little helper to replace apidoc-inline Links (#Group:Name). 10 | * Should be replaced with a full markdown lib. 11 | * @param string text 12 | */ 13 | Handlebars.registerHelper('markdown', function(text) { 14 | if ( ! text ) { 15 | return text; 16 | } 17 | text = text.replace(/((\[(.*?)\])?\(#)((.+?):(.+?))(\))/mg, function(match, p1, p2, p3, p4, p5, p6) { 18 | var link = p3 || p5 + '/' + p6; 19 | return '' + link + ''; 20 | }); 21 | return text; 22 | }); 23 | 24 | /** 25 | * start/stop timer for simple performance check. 26 | */ 27 | var timer; 28 | Handlebars.registerHelper('startTimer', function(text) { 29 | timer = new Date(); 30 | return ''; 31 | }); 32 | 33 | Handlebars.registerHelper('stopTimer', function(text) { 34 | console.log(new Date() - timer); 35 | return ''; 36 | }); 37 | 38 | /** 39 | * Return localized Text. 40 | * @param string text 41 | */ 42 | Handlebars.registerHelper('__', function(text) { 43 | return locale.__(text); 44 | }); 45 | 46 | /** 47 | * Console log. 48 | * @param mixed obj 49 | */ 50 | Handlebars.registerHelper('cl', function(obj) { 51 | console.log(obj); 52 | return ''; 53 | }); 54 | 55 | /** 56 | * Replace underscore with space. 57 | * @param string text 58 | */ 59 | Handlebars.registerHelper('underscoreToSpace', function(text) { 60 | return text.replace(/(_+)/g, ' '); 61 | }); 62 | 63 | /** 64 | * 65 | */ 66 | Handlebars.registerHelper('assign', function(name) { 67 | if(arguments.length > 0) { 68 | var type = typeof(arguments[1]); 69 | var arg = null; 70 | if(type === 'string' || type === 'number' || type === 'boolean') arg = arguments[1]; 71 | Handlebars.registerHelper(name, function() { return arg; }); 72 | } 73 | return ''; 74 | }); 75 | 76 | /** 77 | * 78 | */ 79 | Handlebars.registerHelper('nl2br', function(text) { 80 | return _handlebarsNewlineToBreak(text); 81 | }); 82 | 83 | /** 84 | * 85 | */ 86 | Handlebars.registerHelper('if_eq', function(context, options) { 87 | var compare = context; 88 | // Get length if context is an object 89 | if (context instanceof Object && ! (options.hash.compare instanceof Object)) 90 | compare = Object.keys(context).length; 91 | 92 | if (compare === options.hash.compare) 93 | return options.fn(this); 94 | 95 | return options.inverse(this); 96 | }); 97 | 98 | /** 99 | * 100 | */ 101 | Handlebars.registerHelper('if_gt', function(context, options) { 102 | var compare = context; 103 | // Get length if context is an object 104 | if (context instanceof Object && ! (options.hash.compare instanceof Object)) 105 | compare = Object.keys(context).length; 106 | 107 | if(compare > options.hash.compare) 108 | return options.fn(this); 109 | 110 | return options.inverse(this); 111 | }); 112 | 113 | /** 114 | * 115 | */ 116 | var templateCache = {}; 117 | Handlebars.registerHelper('subTemplate', function(name, sourceContext) { 118 | if ( ! templateCache[name]) 119 | templateCache[name] = Handlebars.compile($('#template-' + name).html()); 120 | 121 | var template = templateCache[name]; 122 | var templateContext = $.extend({}, this, sourceContext.hash); 123 | return new Handlebars.SafeString( template(templateContext) ); 124 | }); 125 | 126 | /** 127 | * 128 | */ 129 | Handlebars.registerHelper('toLowerCase', function(value) { 130 | return (value && typeof value === 'string') ? value.toLowerCase() : ''; 131 | }); 132 | 133 | /** 134 | * 135 | */ 136 | Handlebars.registerHelper('splitFill', function(value, splitChar, fillChar) { 137 | var splits = value.split(splitChar); 138 | return new Array(splits.length).join(fillChar) + splits[splits.length - 1]; 139 | }); 140 | 141 | /** 142 | * Convert Newline to HTML-Break (nl2br). 143 | * 144 | * @param {String} text 145 | * @returns {String} 146 | */ 147 | function _handlebarsNewlineToBreak(text) { 148 | return ('' + text).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '
' + '$2'); 149 | } 150 | 151 | /** 152 | * 153 | */ 154 | Handlebars.registerHelper('each_compare_list_field', function(source, compare, options) { 155 | var fieldName = options.hash.field; 156 | var newSource = []; 157 | if (source) { 158 | source.forEach(function(entry) { 159 | var values = entry; 160 | values['key'] = entry[fieldName]; 161 | newSource.push(values); 162 | }); 163 | } 164 | 165 | var newCompare = []; 166 | if (compare) { 167 | compare.forEach(function(entry) { 168 | var values = entry; 169 | values['key'] = entry[fieldName]; 170 | newCompare.push(values); 171 | }); 172 | } 173 | return _handlebarsEachCompared('key', newSource, newCompare, options); 174 | }); 175 | 176 | /** 177 | * 178 | */ 179 | Handlebars.registerHelper('each_compare_keys', function(source, compare, options) { 180 | var newSource = []; 181 | if (source) { 182 | var sourceFields = Object.keys(source); 183 | sourceFields.forEach(function(name) { 184 | var values = {}; 185 | values['value'] = source[name]; 186 | values['key'] = name; 187 | newSource.push(values); 188 | }); 189 | } 190 | 191 | var newCompare = []; 192 | if (compare) { 193 | var compareFields = Object.keys(compare); 194 | compareFields.forEach(function(name) { 195 | var values = {}; 196 | values['value'] = compare[name]; 197 | values['key'] = name; 198 | newCompare.push(values); 199 | }); 200 | } 201 | return _handlebarsEachCompared('key', newSource, newCompare, options); 202 | }); 203 | 204 | /** 205 | * 206 | */ 207 | Handlebars.registerHelper('each_compare_field', function(source, compare, options) { 208 | return _handlebarsEachCompared('field', source, compare, options); 209 | }); 210 | 211 | /** 212 | * 213 | */ 214 | Handlebars.registerHelper('each_compare_title', function(source, compare, options) { 215 | return _handlebarsEachCompared('title', source, compare, options); 216 | }); 217 | 218 | /** 219 | * 220 | */ 221 | Handlebars.registerHelper('reformat', function(source, type){ 222 | if (type == 'json') 223 | try { 224 | return JSON.stringify(JSON.parse(source.trim()),null, " "); 225 | } catch(e) { 226 | 227 | } 228 | return source 229 | }); 230 | 231 | /** 232 | * 233 | */ 234 | Handlebars.registerHelper('showDiff', function(source, compare, options) { 235 | var ds = ''; 236 | if(source === compare) { 237 | ds = source; 238 | } else { 239 | if( ! source) 240 | return compare; 241 | 242 | if( ! compare) 243 | return source; 244 | 245 | var d = diffMatchPatch.diff_main(compare, source); 246 | diffMatchPatch.diff_cleanupSemantic(d); 247 | ds = diffMatchPatch.diff_prettyHtml(d); 248 | ds = ds.replace(/¶/gm, ''); 249 | } 250 | if(options === 'nl2br') 251 | ds = _handlebarsNewlineToBreak(ds); 252 | 253 | return ds; 254 | }); 255 | 256 | /** 257 | * 258 | */ 259 | function _handlebarsEachCompared(fieldname, source, compare, options) 260 | { 261 | var dataList = []; 262 | var index = 0; 263 | if(source) { 264 | source.forEach(function(sourceEntry) { 265 | var found = false; 266 | if (compare) { 267 | compare.forEach(function(compareEntry) { 268 | if(sourceEntry[fieldname] === compareEntry[fieldname]) { 269 | var data = { 270 | typeSame: true, 271 | source: sourceEntry, 272 | compare: compareEntry, 273 | index: index 274 | }; 275 | dataList.push(data); 276 | found = true; 277 | index++; 278 | } 279 | }); 280 | } 281 | if ( ! found) { 282 | var data = { 283 | typeIns: true, 284 | source: sourceEntry, 285 | index: index 286 | }; 287 | dataList.push(data); 288 | index++; 289 | } 290 | }); 291 | } 292 | 293 | if (compare) { 294 | compare.forEach(function(compareEntry) { 295 | var found = false; 296 | if (source) { 297 | source.forEach(function(sourceEntry) { 298 | if(sourceEntry[fieldname] === compareEntry[fieldname]) 299 | found = true; 300 | }); 301 | } 302 | if ( ! found) { 303 | var data = { 304 | typeDel: true, 305 | compare: compareEntry, 306 | index: index 307 | }; 308 | dataList.push(data); 309 | index++; 310 | } 311 | }); 312 | } 313 | 314 | var ret = ''; 315 | var length = dataList.length; 316 | for (var index in dataList) { 317 | if(index == (length - 1)) 318 | dataList[index]['_last'] = true; 319 | ret = ret + options.fn(dataList[index]); 320 | } 321 | return ret; 322 | } 323 | 324 | var diffMatchPatch = new DiffMatchPatch(); 325 | 326 | /** 327 | * Overwrite Colors 328 | */ 329 | DiffMatchPatch.prototype.diff_prettyHtml = function(diffs) { 330 | var html = []; 331 | var pattern_amp = /&/g; 332 | var pattern_lt = //g; 334 | var pattern_para = /\n/g; 335 | for (var x = 0; x < diffs.length; x++) { 336 | var op = diffs[x][0]; // Operation (insert, delete, equal) 337 | var data = diffs[x][1]; // Text of change. 338 | var text = data.replace(pattern_amp, '&').replace(pattern_lt, '<') 339 | .replace(pattern_gt, '>').replace(pattern_para, '¶
'); 340 | switch (op) { 341 | case DIFF_INSERT: 342 | html[x] = '' + text + ''; 343 | break; 344 | case DIFF_DELETE: 345 | html[x] = '' + text + ''; 346 | break; 347 | case DIFF_EQUAL: 348 | html[x] = '' + text + ''; 349 | break; 350 | } 351 | } 352 | return html.join(''); 353 | }; 354 | 355 | // Exports 356 | return Handlebars; 357 | }); 358 | -------------------------------------------------------------------------------- /public/vendor/webfontloader.js: -------------------------------------------------------------------------------- 1 | /* Web Font Loader v1.6.24 - (c) Adobe Systems, Google. License: Apache 2.0 */ 2 | (function(){function aa(a,b,d){return a.call.apply(a.bind,arguments)}function ba(a,b,d){if(!a)throw Error();if(2=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?c():setTimeout(k,25)},function(){e()})}k()}),e=new Promise(function(a,c){setTimeout(c,b.f)});Promise.race([e,c]).then(function(){b.g(b.a)},function(){b.j(b.a)})};function R(a,b,d,c,e,f,g){this.v=a;this.B=b;this.c=d;this.a=c;this.s=g||"BESbswy";this.f={};this.w=e||3E3;this.u=f||null;this.o=this.j=this.h=this.g=null;this.g=new N(this.c,this.s);this.h=new N(this.c,this.s);this.j=new N(this.c,this.s);this.o=new N(this.c,this.s);a=new H(this.a.c+",serif",K(this.a));a=P(a);this.g.a.style.cssText=a;a=new H(this.a.c+",sans-serif",K(this.a));a=P(a);this.h.a.style.cssText=a;a=new H("serif",K(this.a));a=P(a);this.j.a.style.cssText=a;a=new H("sans-serif",K(this.a));a= 8 | P(a);this.o.a.style.cssText=a;O(this.g);O(this.h);O(this.j);O(this.o)}var S={D:"serif",C:"sans-serif"},T=null;function U(){if(null===T){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);T=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return T}R.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f["sans-serif"]=this.o.a.offsetWidth;this.A=q();la(this)}; 9 | function ma(a,b,d){for(var c in S)if(S.hasOwnProperty(c)&&b===a.f[S[c]]&&d===a.f[S[c]])return!0;return!1}function la(a){var b=a.g.a.offsetWidth,d=a.h.a.offsetWidth,c;(c=b===a.f.serif&&d===a.f["sans-serif"])||(c=U()&&ma(a,b,d));c?q()-a.A>=a.w?U()&&ma(a,b,d)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):na(a):V(a,a.v)}function na(a){setTimeout(p(function(){la(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.o.a);b(this.a)},a),0)};function W(a,b,d){this.c=a;this.a=b;this.f=0;this.o=this.j=!1;this.s=d}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c("wf",a.c,K(a).toString(),"active")],[b.a.c("wf",a.c,K(a).toString(),"loading"),b.a.c("wf",a.c,K(a).toString(),"inactive")]);L(b,"fontactive",a);this.o=!0;oa(this)}; 10 | W.prototype.h=function(a){var b=this.a;if(b.g){var d=y(b.f,b.a.c("wf",a.c,K(a).toString(),"active")),c=[],e=[b.a.c("wf",a.c,K(a).toString(),"loading")];d||c.push(b.a.c("wf",a.c,K(a).toString(),"inactive"));w(b.f,c,e)}L(b,"fontinactive",a);oa(this)};function oa(a){0==--a.f&&a.j&&(a.o?(a=a.a,a.g&&w(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),L(a,"active")):M(a.a))};function pa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}pa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;qa(this,new ha(this.c,a),a)}; 11 | function ra(a,b,d,c,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,k=c||null||{};if(0===d.length&&f)M(b.a);else{b.f+=d.length;f&&(b.j=f);var h,m=[];for(h=0;h 46 | * @apiSampleRequest /v1/users/getVCode 47 | * @apiVersion 1.0.0 48 | */ 49 | router.get('/getVCode', ctrl.users.getVCodeAction) 50 | 51 | /** 52 | * @api {get} /v1/users/checkUsername/:username 检查用户名是否可用 53 | * @apiDescription 检查用户名是否可用 54 | * @apiName checkUsername 55 | * @apiGroup 1.Users-Sign 56 | * @apiParam {string} username 要检查的用户名 57 | * @apiSuccess {number} status 状态码 58 | * @apiSuccess {json} data 数据 59 | * @apiSuccess {string} succMsg 成功消息 60 | * @apiSuccess {string} succMsg 错误消息 61 | * @apiSuccessExample {json} Success-Response: 62 | * { 63 | * "status": 200, 64 | * "data": null, 65 | * "succMsg": "用户名可用!", 66 | * "errMsg": null 67 | * } 68 | * @apiSampleRequest /v1/users/checkUsername/:username 69 | * @apiVersion 1.0.0 70 | */ 71 | router.get('/checkUsername/:username', ctrl.users.checkUsernameAction) 72 | 73 | /** 74 | * @api {post} /v1/users/login 用户登录 75 | * @apiDescription 用户登录 76 | * @apiName login 77 | * @apiGroup 1.Users-Sign 78 | * @apiParam {string} username 用户名 79 | * @apiParam {string} password 密码 80 | * @apiSuccess {number} status 状态码 81 | * @apiSuccess {json} data 用户信息(带token) 82 | * @apiSuccess {string} succMsg 成功消息 83 | * @apiSuccess {string} errMsg 错误消息 84 | * @apiSuccessExample {json} Success-Response: 85 | * { 86 | * "status": 200, 87 | * "data": { 88 | * "nickname": "ltc", 89 | * "username": "ltc", 90 | * "id": 1, 91 | * "mobile": "13888888888", 92 | * "token":"eyJzxcciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZWNyZXQiOiJpdGNhc3Qtd2giLCJpYXQiOjE1NDQ3OTQwMzgsImV4cCI6MTU0NzM4NjAzOH0.BTSqwVIHsT8UPT2T7AYVCnG7pc_zCv9UrBAIoCmcR1Y", 93 | * }, 94 | * "succMsg": "登录成功!", 95 | * "errMsg": null 96 | * } 97 | * @apiSampleRequest /v1/users/login 98 | * @apiVersion 1.0.0 99 | */ 100 | router.post('/login', ctrl.users.loginAction) 101 | 102 | /** 103 | * @api {get} /v1/users/getUserInfo 获取当前登录的用户信息 (需要token) 104 | * @apiDescription 获取当前登录的用户信息 105 | * @apiName getUserInfo 106 | * @apiGroup 2.Users-Profile 107 | * @apiHeader {string} Authorization token 108 | * @apiSuccess {number} status 状态码 109 | * @apiSuccess {json} data 数据 110 | * @apiSuccess {string} succMsg 成功消息 111 | * @apiSuccess {string} succMsg 错误消息 112 | * @apiSuccessExample {json} Success-Response: 113 | * { 114 | * "status": 200, 115 | * "data": { 116 | * "id": 33, 117 | * "nickname": "ltc", 118 | * "username": "ltc", 119 | * "mobile": "13888888888", 120 | * "token":"eyJzxcciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZWNyZXQiOiJpdGNhc3Qtd2giLCJpYXQiOjE1NDQ3OTQwMzgsImV4cCI6MTU0NzM4NjAzOH0.BTSqwVIHsT8UPT2T7AYVCnG7pc_zCv9UrBAIoCmcR1Y", 121 | * }, 122 | * "succMsg": "获取用户信息成功!", 123 | * "errMsg": null 124 | * } 125 | * @apiSampleRequest /v1/users/getUserInfo 126 | * @apiVersion 1.0.0 127 | */ 128 | router.get('/getUserInfo', ctrl.users.getUserInfoAction) 129 | 130 | /** 131 | * @api {post} /v1/users/updateUserInfo 修改个人信息 (需要token) 132 | * @apiDescription 修改个人信息 133 | * @apiName updateUserInfo 134 | * @apiGroup 2.Users-Profile 135 | * @apiHeader {string} Authorization token 136 | * @apiParam {string} mobile 手机号 137 | * @apiSuccess {number} status 状态码 138 | * @apiSuccess {json} data 用户信息(带token) 139 | * @apiSuccess {string} succMsg 成功消息 140 | * @apiSuccess {string} errMsg 错误消息 141 | * @apiSuccessExample {json} Success-Response: 142 | * { 143 | * "status": 200, 144 | * "data": { 145 | * "id": 1, 146 | * "nickname": "ltc", 147 | * "username": "ltc", 148 | * "mobile": "13888888888", 149 | * "token":"eyJzxcciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZWNyZXQiOiJpdGNhc3Qtd2giLCJpYXQiOjE1NDQ3OTQwMzgsImV4cCI6MTU0NzM4NjAzOH0.BTSqwVIHsT8UPT2T7AYVCnG7pc_zCv9UrBAIoCmcR1Y", 150 | * }, 151 | * "succMsg": "用户信息修改成功!", 152 | * "errMsg": null 153 | * } 154 | * @apiSampleRequest /v1/users/updateUserInfo 155 | * @apiVersion 1.0.0 156 | */ 157 | router.post('/updateUserInfo', ctrl.users.updateUserInfoAction) 158 | 159 | /** 160 | * @api {post} /v1/users/updatePassword 修改密码 (需要token) 161 | * @apiDescription 修改密码 162 | * @apiName updatePassword 163 | * @apiGroup 2.Users-Profile 164 | * @apiHeader {string} Authorization token 165 | * @apiParam {string} oldPassword 旧密码 166 | * @apiParam {string} newPassword 新密码 167 | * @apiSuccess {number} status 状态码 168 | * @apiSuccess {null} data 数据 169 | * @apiSuccess {string} succMsg 成功消息 170 | * @apiSuccess {string} errMsg 错误消息 171 | * @apiSuccessExample {json} Success-Response: 172 | * { 173 | * "status": 200, 174 | * "data": null, 175 | * "succMsg": "修改密码成功!", 176 | * "errMsg": null 177 | * } 178 | * @apiSampleRequest /v1/users/updatePassword 179 | * @apiVersion 1.0.0 180 | */ 181 | router.post('/updatePassword', ctrl.users.updatePasswordAction) 182 | 183 | /** 184 | * @api {get} /v1/users/getReceiverAddress 获取所有收货人信息 (需要token) 185 | * @apiDescription 获取所有收货人信息 186 | * @apiName getReceiverAddress 187 | * @apiGroup 3.Users-Receiver 188 | * @apiHeader {string} Authorization token 189 | * @apiSuccess {number} status 状态码 190 | * @apiSuccess {json} data 所有收货人信息 191 | * @apiSuccess {string} succMsg 成功消息 192 | * @apiSuccess {string} succMsg 错误消息 193 | * @apiSuccessExample {json} Success-Response: 194 | * { 195 | * "status": 200, 196 | * "data": [ 197 | * { 198 | * "id": 2, 199 | * "receiver_name": "传智大法好", 200 | * "mobile": "13030303030", 201 | * "postcode": "430070", 202 | * "province": "湖北省", 203 | * "city": "武汉市", 204 | * "area": "东湖高新区", 205 | * "detailed_address": "金融港B15栋", 206 | * "common_used": 0 207 | * } 208 | * ], 209 | * "succMsg": "获取收货人列表成功!", 210 | * "errMsg": null 211 | * } 212 | * @apiSampleRequest /v1/users/getReceiverAddress 213 | * @apiVersion 1.0.0 214 | */ 215 | router.get('/getReceiverAddress', ctrl.users.getReceiverAddressAction) 216 | 217 | /** 218 | * @api {get} /v1/users/getReceiverAddress/:id 获取指定收货人信息 (需要token) 219 | * @apiDescription 获取指定收货人信息 220 | * @apiName getReceiverAddressById 221 | * @apiGroup 3.Users-Receiver 222 | * @apiHeader {string} Authorization token 223 | * @apiParam {number} id 收货信息id 224 | * @apiSuccess {number} status 状态码 225 | * @apiSuccess {json} data 指定收货人信息 226 | * @apiSuccess {string} succMsg 成功消息 227 | * @apiSuccess {string} succMsg 错误消息 228 | * @apiSuccessExample {json} Success-Response: 229 | * { 230 | * "status": 200, 231 | * "data": [ 232 | * { 233 | * "id": 2, 234 | * "receiver_name": "传智大法好", 235 | * "mobile": "13030303030", 236 | * "postcode": "430070", 237 | * "province": "湖北省", 238 | * "city": "武汉市", 239 | * "area": "东湖高新区", 240 | * "detailed_address": "金融港B15栋", 241 | * "common_used": 0 242 | * } 243 | * ], 244 | * "succMsg": "获取收货人列表成功!", 245 | * "errMsg": null 246 | * } 247 | * @apiSampleRequest /v1/users/getReceiverAddress/:id 248 | * @apiVersion 1.0.0 249 | */ 250 | router.get('/getReceiverAddress/:id', ctrl.users.getReceiverAddressByIdAction) 251 | 252 | /** 253 | * @api {get} /v1/users/deleteReceiverAddress/:id 删除收货人信息 (需要token) 254 | * @apiDescription 删除收货人信息 255 | * @apiName deleteReceiverAddress 256 | * @apiGroup 3.Users-Receiver 257 | * @apiHeader {string} Authorization token 258 | * @apiParam {number} id 收货人id 259 | * @apiSuccess {number} status 状态码 260 | * @apiSuccess {null} data 数据 261 | * @apiSuccess {string} succMsg 成功消息 262 | * @apiSuccess {string} succMsg 错误消息 263 | * @apiSuccessExample {json} Success-Response: 264 | * { 265 | * "status": 200, 266 | * "data": null, 267 | * "succMsg": "删除收货人成功!", 268 | * "errMsg": null 269 | * } 270 | * @apiSampleRequest /v1/users/deleteReceiverAddress/:id 271 | * @apiVersion 1.0.0 272 | */ 273 | router.get('/deleteReceiverAddress/:id', ctrl.users.deleteReceiverAddressAction) 274 | 275 | /** 276 | * @api {post} /v1/users/addReceiverAddress 添加收货人信息 (需要token) 277 | * @apiDescription 添加收货人信息 278 | * @apiName addReceiverAddress 279 | * @apiGroup 3.Users-Receiver 280 | * @apiHeader {string} Authorization token 281 | * @apiParam {string} receiver_name 收货人姓名 282 | * @apiParam {string} mobile 手机号 283 | * @apiParam {string} postcode 邮编 284 | * @apiParam {string} province 省 285 | * @apiParam {string} city 市 286 | * @apiParam {string} area 区 287 | * @apiParam {string} detailed_address 详细地址 288 | * @apiParam {number} common_used 是否为常用收货人, 1表示常用, 0表示不常用 289 | * @apiSuccess {number} status 状态码 290 | * @apiSuccess {json} data 添加的收货人信息 291 | * @apiSuccess {string} succMsg 成功消息 292 | * @apiSuccess {string} errMsg 错误消息 293 | * @apiSuccessExample {json} Success-Response: 294 | * { 295 | * "status": 200, 296 | * "data": { 297 | * "id": 1, 298 | * "receiver_name": "传智人", 299 | * "mobile": "13838383838", 300 | * "postcode": "430000", 301 | * "province": "湖北省", 302 | * "city": "武汉市", 303 | * "area": "洪山区", 304 | * "detailed_address": "汤逊湖北路长城科技园6栋知乐楼", 305 | * "user_id": 1, 306 | * "common_used": 0 307 | * }, 308 | * "succMsg": "添加收货人成功!", 309 | * "errMsg": null 310 | * } 311 | * @apiSampleRequest /v1/users/addReceiverAddress 312 | * @apiVersion 1.0.0 313 | */ 314 | router.post('/addReceiverAddress', ctrl.users.addReceiverAddressAction) 315 | 316 | /** 317 | * @api {post} /v1/users/updateReceiverAddress/:id 修改收货人信息 (需要token) 318 | * @apiDescription 修改收货人信息 319 | * @apiName updateReceiverAddress 320 | * @apiGroup 3.Users-Receiver 321 | * @apiHeader {string} Authorization token 322 | * @apiParam {string} [receiver_name] 收货人姓名 323 | * @apiParam {string} [mobile] 手机号 324 | * @apiParam {string} [postcode] 邮编 325 | * @apiParam {string} [province] 省 326 | * @apiParam {string} [city] 市 327 | * @apiParam {string} [area] 区 328 | * @apiParam {string} [detailed_address] 详细地址 329 | * @apiParam {number} [common_used] 是否为常用收货人, 1表示常用, 0表示不常用 330 | * @apiSuccess {number} status 状态码 331 | * @apiSuccess {json} data 修改的收货人信息 332 | * @apiSuccess {string} succMsg 成功消息 333 | * @apiSuccess {string} errMsg 错误消息 334 | * @apiSuccessExample {json} Success-Response: 335 | * { 336 | * "status": 200, 337 | * "data": { 338 | * "id": 1, 339 | * "receiver_name": "传智人", 340 | * "mobile": "13838383838", 341 | * "postcode": "430000", 342 | * "province": "湖北省", 343 | * "city": "武汉市", 344 | * "area": "洪山区", 345 | * "detailed_address": "汤逊湖北路长城科技园6栋知乐楼", 346 | * "user_id": 1, 347 | * "common_used": 0 348 | * }, 349 | * "succMsg": "修改收货人成功!", 350 | * "errMsg": null 351 | * } 352 | * @apiSampleRequest /v1/users/updateReceiverAddress/:id 353 | * @apiVersion 1.0.0 354 | */ 355 | router.post('/updateReceiverAddress/:id', ctrl.users.updateReceiverAddressAction) 356 | 357 | module.exports = router; 358 | --------------------------------------------------------------------------------