This commit is contained in:
2025-06-13 20:46:10 +08:00
parent a3e6a6d8b8
commit 898b816655
52 changed files with 2250 additions and 3785 deletions
@@ -5,6 +5,177 @@ module.exports = {
_before: function () { // 通用预处理器
},
async del_cms_articles(query) {
try {
console.log(query)
let {
id
} = query;
await collection.doc(id).remove();
return {
code: 200,
}
} catch(e) {
return {
code: 500,
msg: e.message
}
}
},
async get_cms_articles_for_userId(query) {
try {
console.log(query)
let {
user_id
} = query;
const res = await collection.where({
user_id: user_id,
"edit_type": "mobile"
}).get();
console.log(res)
return {
code: 200,
data:res.data
}
} catch(e) {
console.error(e.message)
return {
code: 500,
msg: e.message
}
}
},
async update_cms_articles(query) {
try{
let {
id,
title,
user_id,
title_html,
title_delta,
thumbnail,
p_type,
category_id,
temp_id,
edit_type,
excerpt,
view_count,
cmsLst,
last_modify_ip,
article_status
} = query;
let last_modify_date = new Date();
let publish_date = new Date();
const r = await collection.doc(id).update({
title,
user_id,
title_html,
title_delta,
thumbnail,
p_type,
category_id,
temp_id,
edit_type,
excerpt,
view_count,
cmsLst,
publish_date,
last_modify_date,
last_modify_ip,
article_status
});
console.log(r.id)
let res = await collection.doc(r.id)
.get();
return {
code: 200,
res: {
data: res.data[0],
_id: r.id,
user_id: user_id
}
}
} catch(e) {
return {
code:500,
msg: e.message
}
}
},
async add_cms_articles(query) {
try {
let {
title,
user_id,
title_html,
title_delta,
thumbnail,
p_type,
category_id,
temp_id,
edit_type,
excerpt,
view_count,
cmsLst,
last_modify_ip,
article_status
} = query;
let last_modify_date = new Date();
let publish_date = new Date();
const r = await collection.add({
title,
user_id,
title_html,
title_delta,
thumbnail,
p_type,
category_id,
temp_id,
edit_type,
excerpt,
view_count,
cmsLst,
publish_date,
last_modify_date,
last_modify_ip,
article_status
});
console.log(r.id)
let res = await collection.doc(r.id)
.get();
return {
code: 200,
res: {
data: res.data[0],
_id: r.id,
user_id: user_id
}
}
} catch(e) {
return {
code:500,
msg: e.message
}
}
},
async getTemp(query) {
try{
const {
temp_id
} = query;
const res = await db.collection("cms-temp").doc(temp_id).get();
console.log(res)
return {
code: 200,
data: res.data[0]
}
}catch(e) {
return {
code: 500,
msg: e.message
}
}
},
async getTotal() {
try {