Merge branch 'master' of github.com:luchenqun/my-bookmark
This commit is contained in:
commit
c55977e3c8
|
|
@ -1406,12 +1406,21 @@ api.post('/addNote', function(req, res) {
|
|||
|
||||
api.get('/notes', function(req, res) {
|
||||
console.log("getNotes username = ", req.session.username);
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Headers', 'Content-Type');
|
||||
res.header('Access-Control-Allow-Methods', '*');
|
||||
|
||||
var params = req.query;
|
||||
if (!params.shareNote && !req.session.user) {
|
||||
res.send(401);
|
||||
return;
|
||||
}
|
||||
if (params.shareNote) {
|
||||
if(params.json) {
|
||||
db.getNote(params.shareNote)
|
||||
.then((data) => res.json(data))
|
||||
.catch((err) => console.log('notes', err));
|
||||
} else {
|
||||
db.getNote(params.shareNote)
|
||||
.then((data) => res.send(`
|
||||
<body style="margin:0px;height:100%;">
|
||||
|
|
@ -1432,6 +1441,7 @@ api.get('/notes', function(req, res) {
|
|||
</div>
|
||||
</body>`))
|
||||
.catch((err) => console.log('notes', err));
|
||||
}
|
||||
} else {
|
||||
params.user_id = req.session.user.id;
|
||||
db.getNotes(params)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ drop table if exists notes;
|
|||
CREATE TABLE `notes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT, -- id
|
||||
`user_id` int(11) NOT NULL, -- 用户id
|
||||
`content` varchar(8092) DEFAULT NULL, -- 备忘内容
|
||||
`content` text DEFAULT NULL, -- 备忘内容
|
||||
`tag_id` int(11) DEFAULT NULL, -- 分类id
|
||||
`created_at` datetime DEFAULT now(), -- 创建时间
|
||||
`public` tinyint(4) DEFAULT '1', -- 是否公开 1 公开,0 不公开
|
||||
|
|
|
|||
Loading…
Reference in New Issue