Commit c253b6ac authored by wty's avatar wty

更改后端代码所有接口字段

parent a85fb623
...@@ -26,22 +26,22 @@ const pkg = require('./package.json') ...@@ -26,22 +26,22 @@ const pkg = require('./package.json')
// 获取配置的端口号 // 获取配置的端口号
const port = 3000 const port = 3000
const dockerApp = new DockerApp({ // const dockerApp = new DockerApp({
app, // app,
appType: 'express', // appType: 'express',
port // port
}) // })
//
// 注册Eureka // // 注册Eureka
global.eureka = new Eureka({ // global.eureka = new Eureka({
port, // 应用端口号 // port, // 应用端口号
appName: pkg.name, // 应用名称 // appName: pkg.name, // 应用名称
services: ['KJY-WEB'] // 依赖服务名 // services: ['KJY-WEB'] // 依赖服务名
}) // })
//
global.eureka.start().then(() => { // global.eureka.start().then(() => {
dockerApp.startServer() // dockerApp.startServer()
}) // })
app.use((req, res, next) => { app.use((req, res, next) => {
const url = req.url const url = req.url
......
...@@ -4,10 +4,10 @@ const Mysql = require("../SQLPool"); ...@@ -4,10 +4,10 @@ const Mysql = require("../SQLPool");
const router = express.Router() const router = express.Router()
router.get('/addToolBox', (req, res) => { router.get('/addToolBox', (req, res) => {
const {toolBoxName, toolBoxIcon, toolBoxDesc, toolBoxUrl, typeId, childTypeId} = req.query const {toolbox_name, toolbox_icon, toolbox_desc, toolbox_url, type_id, child_type_id} = req.query
const SQL = 'INSERT INTO toolbox (toolBoxName, toolBoxIcon, toolBoxDesc, toolBoxUrl,sortId) VALUES (?,?,?,?,?)' const SQL = 'INSERT INTO toolbox (toolbox_name, toolbox_icon, toolbox_desc, toolbox_url,sortId) VALUES (?,?,?,?,?)'
Mysql.query(SQL, [toolBoxName, toolBoxDesc, toolBoxIcon, toolBoxUrl, 0], (err, result) => { Mysql.query(SQL, [toolbox_name, toolbox_desc, toolbox_icon, toolbox_url, 0], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -17,9 +17,9 @@ router.get('/addToolBox', (req, res) => { ...@@ -17,9 +17,9 @@ router.get('/addToolBox', (req, res) => {
} }
request(domain + '/query/queryToolBox', {}, (a, b, body) => { request(domain + '/query/queryToolBox', {}, (a, b, body) => {
const data = JSON.parse(body).data const data = JSON.parse(body).data
const lastToolBoxId = data[data.length - 1].toolBoxId const lastToolBoxId = data[data.length - 1].toolbox_id
const SQL = 'INSERT INTO type_childtype_toolbox (toolBoxId,typeId,childTypeId) VALUES (?,?,?)' const SQL = 'INSERT INTO type_childtype_toolbox (toolbox_id,type_id,child_type_id) VALUES (?,?,?)'
Mysql.query(SQL, [lastToolBoxId,typeId,childTypeId], (err, result) => { Mysql.query(SQL, [lastToolBoxId,type_id,child_type_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -36,16 +36,16 @@ router.get('/addToolBox', (req, res) => { ...@@ -36,16 +36,16 @@ router.get('/addToolBox', (req, res) => {
}) })
router.get('/addType', (req, res) => { router.get('/addType', (req, res) => {
const {typeName, childTypeName, typeId} = req.query const {type_name, child_type_name, type_id} = req.query
console.log(req.query) console.log(req.query)
let SQL = 'INSERT INTO type (typeName) VALUES (?)' let SQL = 'INSERT INTO type (type_name) VALUES (?)'
const values = [] const values = []
if (childTypeName && typeId) { if (child_type_name && type_id) {
SQL = 'INSERT INTO child_type (childTypeName, typeId) VALUES (?,?)' SQL = 'INSERT INTO child_type (child_type_name, type_id) VALUES (?,?)'
values.push(childTypeName) values.push(child_type_name)
values.push(typeId) values.push(type_id)
} else { } else {
values.push(typeName) values.push(type_name)
} }
console.log(values) console.log(values)
try { try {
......
...@@ -4,10 +4,10 @@ const Mysql = require("../SQLPool"); ...@@ -4,10 +4,10 @@ const Mysql = require("../SQLPool");
const router = express.Router() const router = express.Router()
router.get('/deleteToolBoxById', (req, res) => { router.get('/deleteToolBoxById', (req, res) => {
const {toolBoxId} = req.query const {toolbox_id} = req.query
const SQL = 'DELETE FROM toolbox WHERE toolBoxId = ?' const SQL = 'DELETE FROM toolbox WHERE toolbox_id = ?'
try { try {
Mysql.query(SQL, [toolBoxId], (err, result) => { Mysql.query(SQL, [toolbox_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
......
...@@ -7,11 +7,11 @@ const router = express.Router(); ...@@ -7,11 +7,11 @@ const router = express.Router();
router.post('/addPage', (req, res) => { router.post('/addPage', (req, res) => {
const {pageName, code} = req.body const {page_name, code} = req.body
const SQL = `INSERT INTO page (pageName) VALUES (?)` const SQL = `INSERT INTO page (page_name) VALUES (?)`
Mysql.query(SQL, [pageName], (err, result) => { Mysql.query(SQL, [page_name], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -24,7 +24,7 @@ router.post('/addPage', (req, res) => { ...@@ -24,7 +24,7 @@ router.post('/addPage', (req, res) => {
try { try {
request(domain + '/page/queryPage', {}, (a, b, body) => { request(domain + '/page/queryPage', {}, (a, b, body) => {
const data = JSON.parse(body).data const data = JSON.parse(body).data
const id = data[data.length - 1]['pageId'] const id = data[data.length - 1]['page_id']
const fileName = 'page' + id + '.html' const fileName = 'page' + id + '.html'
try { try {
console.log('path:', path.join(__dirname, '../static/' + fileName)) console.log('path:', path.join(__dirname, '../static/' + fileName))
...@@ -63,7 +63,7 @@ router.get('/queryPage', (req, res) => { ...@@ -63,7 +63,7 @@ router.get('/queryPage', (req, res) => {
} }
const _result = result.map(v => { const _result = result.map(v => {
const url = 'http://172.16.130.180:3001/static/' + 'page' + v['pageId'] + '.html' const url = 'http://172.16.130.180:3001/static/' + 'page' + v['page_id'] + '.html'
return { return {
...v, ...v,
pageUrl: url pageUrl: url
...@@ -78,9 +78,9 @@ router.get('/queryPage', (req, res) => { ...@@ -78,9 +78,9 @@ router.get('/queryPage', (req, res) => {
}) })
router.post('/updatePage', (req, res) => { router.post('/updatePage', (req, res) => {
const {pageId, pageName, code} = req.body const {page_id, page_name, code} = req.body
const SQL = 'UPDATE page SET pageName=? WHERE pageId = ?' const SQL = 'UPDATE page SET page_name=? WHERE page_id = ?'
Mysql.query(SQL, [pageName, pageId], (err, result) => { Mysql.query(SQL, [page_name, page_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -88,7 +88,7 @@ router.post('/updatePage', (req, res) => { ...@@ -88,7 +88,7 @@ router.post('/updatePage', (req, res) => {
}) })
} else { } else {
try{ try{
const fileName = 'page' + pageId + '.html' const fileName = 'page' + page_id + '.html'
fs.writeFileSync(path.join(__dirname, '../static/' + fileName), code) fs.writeFileSync(path.join(__dirname, '../static/' + fileName), code)
res.send({ res.send({
success: true success: true
......
...@@ -20,9 +20,9 @@ router.get('/queryType', (req, res) => { ...@@ -20,9 +20,9 @@ router.get('/queryType', (req, res) => {
}); });
router.get('/queryChildType', (req, res) => { router.get('/queryChildType', (req, res) => {
const {typeId} = req.query const {type_id} = req.query
const SQL = 'SELECT child_type.childTypeId, child_type.childTypeName, child_type.typeId FROM child_type INNER JOIN type ON child_type.typeId = type.typeId WHERE type.typeId = ?' const SQL = 'SELECT child_type.child_type_id, child_type.child_type_name, child_type.type_id FROM child_type INNER JOIN type ON child_type.type_id = type.type_id WHERE type.type_id = ?'
Mysql.query(SQL,[typeId], (err, result) => { Mysql.query(SQL,[type_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -38,16 +38,16 @@ router.get('/queryChildType', (req, res) => { ...@@ -38,16 +38,16 @@ router.get('/queryChildType', (req, res) => {
router.get('/queryToolBox', (req, res) => { router.get('/queryToolBox', (req, res) => {
let {isFollow, typeId} = req.query let {isFollow, type_id} = req.query
let SQL = `SELECT toolbox.*, type_childtype_toolbox.childTypeId FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolBoxId = toolbox.toolBoxId WHERE type_childtype_toolbox.typeId = ?` let SQL = `SELECT toolbox.*, type_childtype_toolbox.child_type_id FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolbox_id = toolbox.toolbox_id WHERE type_childtype_toolbox.type_id = ?`
if (!isFollow && !typeId){ if (!isFollow && !type_id){
SQL = `SELECT * FROM toolBox` SQL = `SELECT * FROM toolbox`
} }
if (isFollow) { if (isFollow) {
typeId = JSON.parse(typeId) type_id = JSON.parse(type_id)
SQL = 'SELECT * FROM toolbox WHERE toolboxId IN (?)' SQL = 'SELECT * FROM toolbox WHERE toolbox_id IN (?)'
} }
Mysql.query(SQL, [typeId], (err, result) => { Mysql.query(SQL, [type_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -64,7 +64,7 @@ router.get('/queryToolBox', (req, res) => { ...@@ -64,7 +64,7 @@ router.get('/queryToolBox', (req, res) => {
}); });
// router.get('/queryToolBoxSortId', (req, res) => { // router.get('/queryToolBoxSortId', (req, res) => {
// const SQL = 'SELECT sortId FROM toolBox' // const SQL = 'SELECT sortId FROM toolbox'
// Mysql.query(SQL, (err, result) => { // Mysql.query(SQL, (err, result) => {
// if (err) { // if (err) {
// res.send({ // res.send({
......
...@@ -38,18 +38,18 @@ router.get('/queryChildType', (req, res) => { ...@@ -38,18 +38,18 @@ router.get('/queryChildType', (req, res) => {
}) })
router.get('/queryTypeForManage', (req, res) => { router.get('/queryTypeForManage', (req, res) => {
const SQL = 'SELECT child_type.childTypeId, child_type.childTypeName, child_type.typeId, type.typeName FROM child_type INNER JOIN type ON child_type.typeId = type.typeId' const SQL = 'SELECT child_type.child_type_id, child_type.child_type_name, child_type.type_id, type.type_name FROM child_type INNER JOIN type ON child_type.type_id = type.type_id'
Mysql.query(SQL, [], (err, result) => { Mysql.query(SQL, [], (err, result) => {
const dataArr = [] const dataArr = []
const combineType = (value) => { const combineType = (value) => {
if (dataArr.filter(v => v.typeId === value.typeId).length) return if (dataArr.filter(v => v.type_id === value.type_id).length) return
const childType = result.filter(v => v.typeId === value.typeId).map(v => ({ const childType = result.filter(v => v.type_id === value.type_id).map(v => ({
childTypeId: v.childTypeId, child_type_id: v.child_type_id,
childTypeName: v.childTypeName child_type_name: v.child_type_name
})) }))
dataArr.push({ dataArr.push({
typeId: value.typeId, type_id: value.type_id,
typeName: value.typeName, type_name: value.type_name,
children: childType children: childType
}) })
} }
...@@ -65,12 +65,12 @@ router.get('/queryTypeForManage', (req, res) => { ...@@ -65,12 +65,12 @@ router.get('/queryTypeForManage', (req, res) => {
}) })
router.get('/deleteChildType', ((req, res) => { router.get('/deleteChildType', ((req, res) => {
const {childTypeId} = req.query const {child_type_id} = req.query
let SQL = 'DELETE FROM child_type WHERE childTypeId = ?;' let SQL = 'DELETE FROM child_type WHERE child_type_id = ?;'
let SQL2 = 'DELETE FROM type_childtype_toolbox WHERE childTypeId = ?;' let SQL2 = 'DELETE FROM type_childtype_toolbox WHERE child_type_id = ?;'
Mysql.query(SQL, [childTypeId], (err, result) => { Mysql.query(SQL, [child_type_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -78,7 +78,7 @@ router.get('/deleteChildType', ((req, res) => { ...@@ -78,7 +78,7 @@ router.get('/deleteChildType', ((req, res) => {
}) })
return return
} }
Mysql.query(SQL2, [childTypeId], (err, result) => { Mysql.query(SQL2, [child_type_id], (err, result) => {
res.send({ res.send({
success: true, success: true,
}) })
...@@ -88,17 +88,17 @@ router.get('/deleteChildType', ((req, res) => { ...@@ -88,17 +88,17 @@ router.get('/deleteChildType', ((req, res) => {
})) }))
router.get('/updateType', (req, res) => { router.get('/updateType', (req, res) => {
const {typeId, typeName, childTypeId, childTypeName} = req.query const {type_id, type_name, child_type_id, child_type_name} = req.query
let SQL let SQL
const values = [] const values = []
if (typeId) { if (type_id) {
SQL = 'UPDATE type SET typeName = ? WHERE typeId = ?' SQL = 'UPDATE type SET type_name = ? WHERE type_id = ?'
values.push(typeName) values.push(type_name)
values.push(typeId) values.push(type_id)
} else { } else {
SQL = 'UPDATE child_type SET childTypeName = ? WHERE childTypeId = ?' SQL = 'UPDATE child_type SET child_type_name = ? WHERE child_type_id = ?'
values.push(childTypeName) values.push(child_type_name)
values.push(childTypeId) values.push(child_type_id)
} }
Mysql.query(SQL, values, (err, result) => { Mysql.query(SQL, values, (err, result) => {
if (err) { if (err) {
......
...@@ -3,10 +3,10 @@ const router = express.Router() ...@@ -3,10 +3,10 @@ const router = express.Router()
const Mysql = require('../SQLPool') const Mysql = require('../SQLPool')
router.get('/updateToolBox', (req, res) => { router.get('/updateToolBox', (req, res) => {
const {toolBoxName, toolBoxIcon, toolBoxUrl, toolBoxDesc, toolBoxId} = req.query const {toolbox_name, toolbox_icon, toolbox_url, toolbox_desc, toolbox_id} = req.query
const SQL = 'UPDATE toolbox SET toolBoxName= ?, toolBoxIcon=?, toolBoxUrl=?, toolBoxDesc=? WHERE toolBoxId = ?' const SQL = 'UPDATE toolbox SET toolbox_name= ?, toolbox_icon=?, toolbox_url=?, toolbox_desc=? WHERE toolbox_id = ?'
Mysql.query(SQL, [toolBoxName, toolBoxIcon, toolBoxUrl, toolBoxDesc, toolBoxId], (err, result) => { Mysql.query(SQL, [toolbox_name, toolbox_icon, toolbox_url, toolbox_desc, toolbox_id], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -20,35 +20,13 @@ router.get('/updateToolBox', (req, res) => { ...@@ -20,35 +20,13 @@ router.get('/updateToolBox', (req, res) => {
}) })
}) })
router.get('/updateToolBoxSort',(req, res) => { // router.get('/updateToolBoxSort',(req, res) => {
const {sortArr} = req.query // const {sortArr} = req.query
console.log(sortArr) // console.log(sortArr)
res.send({ // res.send({
success: true, // success: true,
data: sortArr // data: sortArr
}) // })
}) // })
router.get('/updateChildType', (req, res) => {
const childrenTypeArr = [{id: 1, name: '运营'},{id: 2, name: '测试'},]
const SQL = 'UPDATE type SET typeContent = ? WHERE typeId = 2'
try {
Mysql.query(SQL, [JSON.stringify(childrenTypeArr)], (err, result) => {
if (err) {
res.send({
success: false,
err
})
throw err
}
res.send({
success: true,
data: result
})
})
} catch (e) {
console.error(e)
}
})
module.exports = router module.exports = router
...@@ -9,11 +9,11 @@ const ErrorCode = { ...@@ -9,11 +9,11 @@ const ErrorCode = {
/* GET users listing. */ /* GET users listing. */
router.get('/getUser', function (req, res, next) { router.get('/getUser', function (req, res, next) {
let {userId} = req.cookies let {uid} = req.cookies
if (!userId){ if (!uid){
userId = req.query.userId uid = req.query.uid
} }
// if (!userId) { // if (!uid) {
// res.send({ // res.send({
// success: false, // success: false,
// code: ErrorCode.USER_NOT_LOGIN, // code: ErrorCode.USER_NOT_LOGIN,
...@@ -22,7 +22,7 @@ router.get('/getUser', function (req, res, next) { ...@@ -22,7 +22,7 @@ router.get('/getUser', function (req, res, next) {
// return // return
// } // }
const SQL = 'SELECT * FROM `user` WHERE `user`.uid = ?' const SQL = 'SELECT * FROM `user` WHERE `user`.uid = ?'
Mysql.query(SQL, [userId], (err, result) => { Mysql.query(SQL, [uid], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -46,9 +46,9 @@ router.get('/getUser', function (req, res, next) { ...@@ -46,9 +46,9 @@ router.get('/getUser', function (req, res, next) {
}); });
router.get('/login', (req, res) => { router.get('/login', (req, res) => {
const {userId} = req.query const {uid} = req.query
const SQL = 'SELECT * FROM `user` WHERE `user`.uid = ?' const SQL = 'SELECT * FROM `user` WHERE `user`.uid = ?'
Mysql.query(SQL, [userId], (err, result) => { Mysql.query(SQL, [uid], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
...@@ -57,7 +57,7 @@ router.get('/login', (req, res) => { ...@@ -57,7 +57,7 @@ router.get('/login', (req, res) => {
throw err throw err
} }
if (result[0]?.uid) { if (result[0]?.uid) {
res.cookie('userId', result[0].uid) res.cookie('uid', result[0].uid)
res.send({ res.send({
success: true, success: true,
data: '登录成功!' data: '登录成功!'
...@@ -72,9 +72,9 @@ router.get('/login', (req, res) => { ...@@ -72,9 +72,9 @@ router.get('/login', (req, res) => {
}) })
router.get('/follow', (req, res) => { router.get('/follow', (req, res) => {
const {follow, userId} = req.query const {follow, uid} = req.query
const SQL = 'UPDATE user SET follow = ? WHERE uid = ?' const SQL = 'UPDATE user SET follow = ? WHERE uid = ?'
Mysql.query(SQL, [follow, userId], (err, result) => { Mysql.query(SQL, [follow, uid], (err, result) => {
if (err) { if (err) {
res.send({ res.send({
success: false, success: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment