Compare commits
No commits in common. 'ea5a1152fd400ce99deb7fe98a0fe7cdf45a8cb7' and '3acbc3a9b92f84be14a070c1a54a800cec4cbf1f' have entirely different histories.
ea5a1152fd
...
3acbc3a9b9
@ -1,20 +0,0 @@
|
|||||||
const {
|
|
||||||
handleArrayDaoData
|
|
||||||
} = require("../utils/tools")
|
|
||||||
const expressModel = require("./model/expressModel")
|
|
||||||
module.exports.getExpressDao = async function () {
|
|
||||||
return handleArrayDaoData(await expressModel.findAll())
|
|
||||||
}
|
|
||||||
module.exports.addExpressDao = async function (expData) {
|
|
||||||
await expressModel.create(expData)
|
|
||||||
return handleArrayDaoData(await expressModel.findAll())
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.updateExpressDao = async function (expData) {
|
|
||||||
await expressModel.update(expData, {
|
|
||||||
where: {
|
|
||||||
id: expData.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return handleArrayDaoData(await expressModel.findAll())
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
const sequelize = require("../dbConnect")
|
|
||||||
const {
|
|
||||||
DataTypes
|
|
||||||
} = require("sequelize")
|
|
||||||
|
|
||||||
module.exports = sequelize.define("express", {
|
|
||||||
expressId: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
senderName: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
senderCity: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
receiverName: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
receiverCity: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
isSigned: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
signedTime: DataTypes.STRING
|
|
||||||
|
|
||||||
}, {
|
|
||||||
freezeTableName: true,
|
|
||||||
createdAt: false,
|
|
||||||
updatedAt: false,
|
|
||||||
})
|
|
@ -1,27 +1,6 @@
|
|||||||
const express = require("express")
|
const express = require("express")
|
||||||
const router = express.Router()
|
const router = express.router
|
||||||
const {
|
|
||||||
getExpressServices,
|
|
||||||
addExpressServices,
|
|
||||||
updateExpressServices
|
|
||||||
} = require("../services/expressService")
|
|
||||||
const {
|
|
||||||
formatResponse
|
|
||||||
} = require("../utils/tools")
|
|
||||||
|
|
||||||
router.get("/", async function (req, res, next) {
|
router.
|
||||||
const data = await getExpressServices()
|
|
||||||
res.send(formatResponse(0, "", data))
|
|
||||||
})
|
|
||||||
|
|
||||||
router.post("/", async function (req, res, next) {
|
|
||||||
const data = await addExpressServices(req.body)
|
|
||||||
res.send(formatResponse(0, "", data))
|
|
||||||
})
|
|
||||||
|
|
||||||
router.put("/", async function (req, res, next) {
|
|
||||||
const data = await updateExpressServices(req.body)
|
|
||||||
res.send(formatResponse(0, "", data))
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
@ -1,26 +0,0 @@
|
|||||||
const {
|
|
||||||
getExpressDao,
|
|
||||||
addExpressDao,
|
|
||||||
updateExpressDao
|
|
||||||
} = require("../dao/expressDao")
|
|
||||||
const {
|
|
||||||
getRandomExpressId
|
|
||||||
} = require("../utils/tools")
|
|
||||||
module.exports.getExpressServices = async function () {
|
|
||||||
return await getExpressDao()
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.addExpressServices = async function (expData) {
|
|
||||||
//获取的对象需要补充"expressId", "isSigned"
|
|
||||||
const data = {
|
|
||||||
expressId: getRandomExpressId(),
|
|
||||||
isSigned: 0,
|
|
||||||
...expData,
|
|
||||||
}
|
|
||||||
return await addExpressDao(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.updateExpressServices = async function (expData) {
|
|
||||||
//这里需要提供id
|
|
||||||
return await updateExpressDao(expData)
|
|
||||||
}
|
|
Loading…
Reference in new issue