mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
complete item editing
This commit is contained in:
parent
7513f79b93
commit
0cbbc0ce8a
12 changed files with 94 additions and 34 deletions
|
@ -12,7 +12,7 @@ module.exports = async (req, res) => {
|
|||
if (!exists) return res.send({ success: false, mode: 'not_exists' });
|
||||
if (exists && exists.owner._id !== id) return res.send({ success: false, mode: 'not_yours' });
|
||||
|
||||
exists.delete();
|
||||
await exists.set({ is_deleted: true }).save();
|
||||
|
||||
return res.send({ success: true, address });
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = async (req, res) => {
|
|||
|
||||
if (!name) return res.send({ success: false, mode: 'not_found_1' });
|
||||
|
||||
const exists = await Route.findOne({ _id: name }).populate('owner', '_id');
|
||||
const exists = await Route.findOne({ _id: name, is_deleted: false }).populate('owner', '_id');
|
||||
|
||||
if (!exists) return res.send({ success: false, mode: 'not_found_2' });
|
||||
const data = exists.toObject();
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = async (req, res) => {
|
|||
|
||||
const user = await User.findOne({ _id: id, token });
|
||||
|
||||
let criteria = {};
|
||||
let criteria = { is_deleted: false };
|
||||
|
||||
if (title) {
|
||||
criteria = {
|
||||
|
@ -32,16 +32,14 @@ module.exports = async (req, res) => {
|
|||
{
|
||||
...criteria,
|
||||
},
|
||||
'_id title distance owner updated_at is_public',
|
||||
'_id title distance owner updated_at is_public is_deleted',
|
||||
{
|
||||
limit: 9000,
|
||||
sort: { updated_at: -1 },
|
||||
}
|
||||
).populate('owner', '_id');
|
||||
|
||||
list = list.filter(item => (
|
||||
!author || item.owner._id === author
|
||||
));
|
||||
list = list.filter(item => !author || (item.owner && item.owner._id === author));
|
||||
|
||||
let limits = list.reduce(({ min, max }, { distance: dist }) => ({
|
||||
min: Math.ceil(Math.min(dist, min) / 25) * 25,
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = async (req, res) => {
|
|||
const title = parseString(body.title, 32);
|
||||
const is_public = !!body.is_public;
|
||||
|
||||
const exists = await Route.findOne({ _id: address }).populate('owner', '_id');
|
||||
const exists = await Route.findOne({ _id: address, is_deleted: false }).populate('owner', '_id');
|
||||
|
||||
if (!exists) return res.send({ success: false, mode: 'not_exists' });
|
||||
if (exists && exists.owner._id !== id) return res.send({ success: false, mode: 'not_yours' });
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = async (req, res) => {
|
|||
return res.send({ success: false, mode: 'empty' });
|
||||
}
|
||||
|
||||
const exists = await Route.findOne({ _id: address }).populate('owner', '_id');
|
||||
const exists = await Route.findOne({ _id: address, is_deleted: false }).populate('owner', '_id');
|
||||
|
||||
if (exists && exists.owner._id !== id) return res.send({ success: false, mode: 'exists' });
|
||||
if (exists && !force) return res.send({ success: false, mode: 'overwriting' });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue