share.js
719 Bytes
const shareModel = require('../models/share');
const shareController = {
collect(req, res, next) {
const {uid, fid} = req.query;
if (!uid || !fid) {
return res.status(200).end();
}
req.ctx(shareModel).collect({uid, fid});
return res.status(200).end();
},
async preshare(req, res, next) {
const {fid, eventName, shareUrl} = req.query;
if (!eventName || !shareUrl) {
return res.status(200).end();
}
try {
const id = await req.ctx(shareModel).preshare({fid, eventName, shareUrl, ip: req.yoho.clientIp});
return res.jsonp({
preid: id
});
} catch (error) {
return next(error);
}
}
};
module.exports = shareController;