-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b44aa1a
commit 694147d
Showing
16 changed files
with
279 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ selenium-debug.log | |
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
个人博客原型.rp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var table = "article"; | ||
var Articlesql = { | ||
insert: "INSERT INTO " + table + "(title,content,publishTime) VALUES(?,?,?)", | ||
queryAll: | ||
"SELECT id,title,publishTime,modifyTime,commentNum,category FROM " + | ||
table + | ||
"", | ||
getUserById: "SELECT * FROM " + table + " WHERE title = ? ", | ||
update: "update " + table + " set name=? where name=?", | ||
delete: "delete from " + table + " where id=?" | ||
}; | ||
module.exports = Articlesql; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,75 @@ | ||
var express = require('express'); | ||
var express = require("express"); | ||
var router = express.Router(); | ||
var mysql = require('mysql'); | ||
var dbConfig = require('./DBconfig') | ||
var userSQL = require('./Usersql') | ||
var mysql = require("mysql"); | ||
var dbConfig = require("./DBconfig"); | ||
var Articlesql = require("./Articlesql"); | ||
var pageId = 0 | ||
|
||
// 使用DBConfig.js的配置信息创建一个MySQL连接池 | ||
var pool = mysql.createPool(dbConfig.mysql); | ||
// 响应一个JSON数据 | ||
var responseJSON = function (res, ret) { | ||
if (typeof ret === 'undefined') { | ||
var responseJSON = function(res, ret) { | ||
if (typeof ret === "undefined") { | ||
res.json({ | ||
code: '-200', msg: '操作失败' | ||
code: "-200", | ||
msg: "操作失败" | ||
}); | ||
} else { | ||
res.json(ret); | ||
} | ||
}; | ||
|
||
// 添加文章 | ||
router.get("/addArticle", function(req, res, next) { | ||
// 从连接池获取连接 | ||
pool.getConnection(function(err, connection) { | ||
// 获取前台页面传过来的参数 | ||
var param = req.query || req.params; | ||
// 建立连接 增加一个用户信息 | ||
console.log(param); | ||
console.log(err); | ||
var currentTime = new Date().getTime(); | ||
console.log(currentTime); | ||
connection.query( | ||
Articlesql.insert, | ||
[param.title, param.content, currentTime], | ||
function(err, result) { | ||
if (result) { | ||
result = { | ||
code: 0, | ||
msg: "新增文章成功", | ||
id: result.insertId | ||
}; | ||
} | ||
// console.log(res) | ||
|
||
// 以json形式,把操作结果返回给前台页面 | ||
responseJSON(res, result); | ||
|
||
// 添加用户 | ||
router.get('/addUser', function (req, res, next) { | ||
// 从连接池获取连接 | ||
pool.getConnection(function (err, connection) { | ||
// 获取前台页面传过来的参数 | ||
// 释放连接 | ||
connection.release(); | ||
} | ||
); | ||
}); | ||
}); | ||
// 查询文章标题列表 | ||
router.get("/queryTitlelist", function(req, res, next) { | ||
pool.getConnection((err, connection) => { | ||
var param = req.query || req.params; | ||
// 建立连接 增加一个用户信息 | ||
console.log(param) | ||
console.log(err) | ||
connection.query(userSQL.delete, [param.id], function (err, result) { | ||
console.log(err) | ||
connection.query(Articlesql.queryAll, function(err, result) { | ||
console.log(result); | ||
if (result) { | ||
result = { | ||
code: 200, | ||
msg: '新增成功' | ||
}; | ||
result = { code: 0, msg: "获取文章列表成功", data: pageId++ }; | ||
} | ||
// console.log(res) | ||
|
||
// 以json形式,把操作结果返回给前台页面 | ||
// 以json形式,把操作结果返回给前台页面 | ||
responseJSON(res, result); | ||
|
||
// 释放连接 | ||
// 释放连接 | ||
connection.release(); | ||
|
||
}); | ||
}); | ||
}); | ||
|
||
|
||
module.exports = router; | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<el-container> | ||
<el-main class="articleList"> | ||
123 | ||
<el-button @click="getTitlelist">默认按钮</el-button> | ||
</el-main> | ||
<el-footer> | ||
123 | ||
</el-footer> | ||
</el-container> | ||
</template> | ||
|
||
<script> | ||
import {request} from "../utils/request"; | ||
export default { | ||
name: "articleList", | ||
data() { | ||
return { | ||
}; | ||
}, | ||
methods: { | ||
getTitlelist(){ | ||
console.log(123) | ||
request.queryTitleList().then((res)=>{ | ||
console.log(res.data) | ||
}) | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped lang='less'> | ||
.articles{ | ||
background-color: #ccc; | ||
height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.