Files
learning-system-mobile/api/modules/article.js
2022-05-29 18:59:24 +08:00

139 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**文章模块的相关处理*/
import ajax from '@/utils/xajax.js'
/**
* 文章列表,不分页查询,门户查询
* @param {Object} num
* @param {Object} type 1表最新2表最热3表推荐
*/
const portalList = function(num, type) {
return ajax.get(`/xboe/m/article/list?num=${num}&type=${type}`);
}
/*
文章列表,门户页面
@param{Objece} query 查询的json{pageIndex:1,pageSize:20,keyword:'',}
*/
const findPortal=function(query){
return ajax.post('/xboe/m/article/findPortal',query);
}
/**
* 分页查询 个人中心页面
* @param {Object} query 查询的json {pageIndex:1,pageSize:20,keyword:'',status:
enabled ture或者false 代表上架下架/
* **状态 1 表草稿2表已提交待审核3表审核不通过9表已发布}
*/
const portalPageList = function(query) {
return ajax.post('/xboe/m/article/page', query);
}
/**
* 分页查询我的文章
* {status,keyword,sysCreateAid
enabled ture或者false 代表上架下架
} 状态,关键词,用户id
*/
const myPageList = function(query) {
return ajax.post('/xboe/m/article/userlist', query);
}
/*
*文章排行榜
@param pageSize
*/
const usernameList=function(pageSize){
return ajax.get(`/xboe/m/article/article-username?pageSize=${pageSize}`);
}
/**
* 推荐设置
* @param {Array} ids
* @param {Boolean} flag
*/
const recommend = function(ids, flag) {
if (flag) {
return ajax.postJson('/xboe/m/article/recommend', ids);
} else {
return ajax.postJson('/xboe/m/article/recommend/cancel', ids);
}
}
/**
* 保存
* @param {Object} data
* title标题必填
* content内容必填
* coverurl封面图的地址上传后返回的存储地址 ,可以为空
* summary摘要 非必填
* keyword关键字 非必填
* source来源非必填
* status:1表草稿2表提交
*/
const save = function(data) {
return ajax.postJson('/xboe/m/article/save', data);
}
/**
* 更新
* @param {Object} data
* title标题必填
* content内容必填
* coverurl封面图的地址上传后返回的存储地址 ,可以为空
* summary摘要 非必填
* keyword关键字 非必填
*/
const update = function(data) {
return ajax.postJson('/xboe/m/article/update', data);
}
/**
* 得到文章的详细信息,
* @param {String} id
* @param {String} addView 是否增加浏览数
*/
const detail = function(id, addView) {
return ajax.get(`/xboe/m/article/detail?id=${id}&addView=${addView}`);
}
/**
* 删除文章,注意只能自己删除自己的文章
* @param {Object} id addView
*/
const del = function(id) {
return ajax.post('/xboe/m/article/delete?id='+id);
}
// 审核 id 文章id auditRemark审核意见 auditState审核状态
const savaAudit = function(id,auditRemark,auditState) {
return ajax.get(`/xboe/m/article/savaAudit?id=${id}&auditRemark=${auditRemark}&auditState=${auditState}`);
}
// 上架下架 id 文章id enabled 上级或下架 true 或false
const isEnabled = function(id,enabled) {
return ajax.get(`/xboe/m/article/isEnabled?id=${id}&enabled=${enabled}`);
}
/*
贡献排行榜
pageSize 你需要的条数
*/
const countsUsername=function(pageSize){
return ajax.get('/xboe/m/article/counts-username?pageSize='+pageSize);
}
export default {
portalList,
portalPageList,
// userPageList,
myPageList,
save,
update,
detail,
recommend,
del,
savaAudit,
isEnabled,
findPortal,
usernameList,
countsUsername
}