mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 01:46:44 +08:00
139 lines
3.5 KiB
JavaScript
139 lines
3.5 KiB
JavaScript
/**文章模块的相关处理*/
|
||
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
|
||
}
|