【发布时间】:2020-05-14 04:11:00
【问题描述】:
我遇到了节点 js 的问题。我在 node js 上没有做太多的工作。问题是我创建了一个用于注册的注册表单和一个用于获取 PAN 卡详细信息的 PAN 卡表。我的 PAN 卡的数据已被所有用户显示。而且我还能够通过 PAN 卡 ID 正确显示 PAN 卡数据。但我想显示一个用户的所有 PAN 卡。这样每个用户都可以看到他们所有的 PAN 卡。该用户已申请。下面给出一些细节
请帮帮我。我怎样才能做到这一点 Gate方法可以应用什么逻辑,才能正确显示用户申请的所有PAN卡。
泛卡申请码贴法
// @route POST pan/newpan
// @desc Create a post
// @access Private
router.post(
'/newpan',
[
auth,
[
check('areaoffice', 'Area Office is required')
.not()
.isEmpty(),
check('aocode', 'aocode is required')
.not()
.isEmpty(),
check('ao', 'Ao is required')
.not()
.isEmpty(),
check('range', 'Range is required')
.not()
.isEmpty(),
check('aonumber', 'AO number is required')
.not()
.isEmpty(),
check('application', 'Application Type is required')
.not()
.isEmpty(),
check('old_pan', 'Old Pan Type is required')
.not()
.isEmpty(),
check('category', 'Category Type is required')
.not()
.isEmpty(),
check('applicant', 'Applicant Type is required')
.not()
.isEmpty(),
check('firstname', 'First name is required')
.not()
.isEmpty(),
check('middlename', 'Middle Name is required')
.not()
.isEmpty(),
check('lastname', 'Last Name is required')
.not()
.isEmpty(),
check('ffirstname', 'Father first Name is required')
.not()
.isEmpty(),
check('fmiddlename', 'Father Middle Name is required')
.not()
.isEmpty(),
check('flastname', 'Father Last Name is required')
.not()
.isEmpty(),
check('mfirstname', 'Mother First Name is required')
.not()
.isEmpty(),
check('mmiddlename', 'Mother Middle Name is required')
.not()
.isEmpty(),
check('mlastname', 'Mother Last Name is required')
.not()
.isEmpty(),
check('cardHolder', 'Card Holder Name is required')
.not()
.isEmpty(),
check('dob', 'Date of Birth is required')
.not()
.isEmpty(),
check('contect_number', 'Contact Number is required')
.not()
.isEmpty(),
check('email', 'Email is required')
.not()
.isEmpty(),
check('proofid', 'Id Proof is required')
.not()
.isEmpty(),
check('proofadd', 'Id Address is required')
.not()
.isEmpty(),
check('proofdob', 'Id Date of Birth is required')
.not()
.isEmpty(),
check('gender', 'Gender is required')
.not()
.isEmpty(),
check('adhar_number', 'Adhar Number is required')
.not()
.isEmpty(),
check('address_f', 'Address is required')
.not()
.isEmpty(),
check('address_v', 'Address is required')
.not()
.isEmpty(),
check('address_p', 'Post office Address is required')
.not()
.isEmpty(),
check('address_divi', 'Address of Division is required')
.not()
.isEmpty(),
check('address_d', 'Address of Dist. is required')
.not()
.isEmpty(),
check('state', 'State is required')
.not()
.isEmpty(),
check('pin_code', 'Pin Code is required')
.not()
.isEmpty()
]
],
async (req, res, next) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ msg: errors.array() });
}
try {
const user = await users.findById(req.user.id).select('-password');
let image = req.files.image;
let pdf = req.files.pdf;
let sig = req.files.sig;
const newPan = new Pan({
areaoffice: req.body.areaoffice,
aocode: req.body.aocode,
ao: req.body.ao,
range: req.body.range,
aonumber: req.body.aonumber,
application: req.body.application,
old_pan: req.body.old_pan,
category: req.body.category,
applicant: req.body.applicant,
firstname: req.body.firstname,
middlename: req.body.middlename,
lastname: req.body.lastname,
ffirstname: req.body.ffirstname,
fmiddlename: req.body.fmiddlename,
flastname: req.body.flastname,
mfirstname: req.body.mfirstname,
mmiddlename: req.body.mmiddlename,
mlastname: req.body.mlastname,
cardHolder: req.body.cardHolder,
dob: req.body.dob,
contect_number: req.body.contect_number,
email: req.body.email,
proofid: req.body.proofid,
proofadd: req.body.proofadd,
proofdob: req.body.proofdob,
gender: req.body.gender,
adhar_number: req.body.adhar_number,
address_f: req.body.address_f,
address_v: req.body.address_v,
address_p: req.body.address_p,
address_divi: req.body.address_divi,
address_d: req.body.address_d,
state: req.body.state,
pin_code: req.body.pin_code,
image: image.name,
pdf: pdf.name,
sig: sig.name,
imagepath: image.tempFilePath,
username: user.username,
avatar: user.avatar,
user: req.user.id
});
image.mv(`./client/public/panImages/${image.name}`, function (err) {
if (err) {
return res.status(500).json({ msg: 'something Error' });
}
})
sig.mv(`./client/public/panImages/${sig.name}`, function (err) {
if (err) {
return res.status(500).json({ msg: 'something Error' });
}
})
pdf.mv(`./client/public/panImages/${pdf.name}`, function (err) {
if (err) {
return res.status(500).json({ msg: 'something Error' });
}
})
const pan = await newPan.save();
res.json(pan);
} catch (err) {
console.error(err.message);
res.status(500).send('Server Error');
}
}
);
mongoDB中的pan卡结果
{
"_id": "5eb81c00265d1a2404b2d5e6",
"areaoffice": "JKHJHKJ",
"aocode": "FADSF",
"ao": "FDAFDF",
"range": "ADSFAS",
"aonumber": "JLK",
"application": "KJLKJ",
"old_pan": "KJLKJ",
"category": "KJLKJ",
"applicant": "KJLKJ",
"firstname": "KJLJ",
"middlename": "JJKHJK",
"lastname": "JHJKHK",
"ffirstname": "JHKJH",
"fmiddlename": "JHJH",
"flastname": "JHJHK",
"mfirstname": "JHJKHK",
"mmiddlename": "HKJHKJ",
"mlastname": "KJKJHJKLH",
"cardHolder": "SATENDRA SINGH",
"dob": "HJKJHKJH",
"contect_number": "HJKHLKJ",
"email": "JHKJHK",
"proofid": "JKHJHK",
"proofadd": "JHJKHJ",
"proofdob": "JHKJ",
"gender": "HJKHJ",
"adhar_number": "JHJKLH",
"address_f": "JKHKJH",
"address_v": "JKHKJH",
"address_p": "JKHJK",
"address_divi": "FG",
"address_d": "HUHUJK",
"state": "UIGHBJKJK",
"pin_code": "JKHKJHJKJ",
"image": "Festivals-and-Occasions.jpg",
"pdf": "sample.pdf",
"sig": "showcase.jpg",
"username": "s",
"user": "5eb2fa29d37d9a08741621c8",
"date": "2020-05-10T15:21:36.675Z",
"__v": 0
}
获取所有平底锅数据方法
// @route GET pan/pans
// @desc Get all pans
// @access Private
router.get('/pans', adminAuth, async (req, res) => {
try {
const pans = await Pan.find().sort({ data: -1 });
res.json(pans)
} catch (error) {
console.error(error.message)
res.status(500).send('Server Error')
}
});
获取用户配置文件数据
{
"_id": "5eb2fa29d37d9a08741621c8",
"username": "s",
"name": "s",
"email": "s@s.com",
"mobile": "s",
"address": "s",
"city": "s",
"state": "s",
"zipCode": "s",
"date": "2020-05-06T17:55:53.001Z",
"__v": 0
}
【问题讨论】:
-
如果以下答案之一回答了您的问题,本网站的运作方式,您将“接受”答案,更多信息请点击此处:What should I do when someone answers my question?。但前提是你的问题真的得到了回答。如果没有,请考虑在问题中添加更多详细信息。
标签: node.js mongodb express redux react-redux