Refactor code structure and remove redundant changes
This commit is contained in:
202
api/channel/index.ts
Normal file
202
api/channel/index.ts
Normal file
@ -0,0 +1,202 @@
|
||||
import { get, post, Delete, put } from '@/utils/axios'
|
||||
import {
|
||||
TpageReq,
|
||||
TpageRes,
|
||||
TcreateReq,
|
||||
TlistRes,
|
||||
TGetChannelPostsRes,
|
||||
PageResultPostsCommentRespVO,
|
||||
sendSingleChatReq,
|
||||
PageResultSessionRespVO,
|
||||
PageResultMessageRespVO,
|
||||
ChannelRespVO,
|
||||
MemberUserRespDTO,
|
||||
SingleMessageVo,
|
||||
} from './types'
|
||||
|
||||
/**
|
||||
* 获得频道帖子分页
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const page = (params: TpageReq) => {
|
||||
return get<IResponse<TpageRes>>({
|
||||
url: '/prod-api/app-api/business/posts/page',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建帖子
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const create = (params: TcreateReq) => {
|
||||
return post<IResponse<number>>({
|
||||
url: '/prod-api/app-api/business/posts/create',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获得论坛频道列表
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const list = () => {
|
||||
return get<IResponse<TlistRes[]>>({
|
||||
url: '/prod-api/app-api/business/channel/list',
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获得论坛频道列表
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const getChannelPosts = (params: { id: number }) => {
|
||||
return get<IResponse<TGetChannelPostsRes[]>>({
|
||||
url: '/prod-api/app-api/business/posts/get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 删除频道帖子
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const postsDelete = (params: { id: number }) => {
|
||||
return Delete<IResponse<boolean>>({
|
||||
url: '/prod-api/app-api/business/posts/delete',
|
||||
params,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取帖子详情
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const getChannelDetail = (params: { id: string }) => {
|
||||
return get<IResponse<TGetChannelPostsRes>>({
|
||||
url: '/prod-api/app-api/business/posts/get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子评论列表
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const postscommentpage = (params: { postsId: string; pageNo: number; pageSize: number }) => {
|
||||
return get<IResponse<PageResultPostsCommentRespVO>>({
|
||||
url: '/prod-api/app-api/business/posts-comment/page',
|
||||
params,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 创建帖子评论
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const createPostsComment = (params: { postsId: string; content: string; commentId?: string }) => {
|
||||
return post<IResponse<number>>({
|
||||
url: '/prod-api/app-api/business/posts-comment/create',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送单聊信息
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const sendSingleChat = (params: sendSingleChatReq) => {
|
||||
return post<IResponse<any>>({
|
||||
url: '/prod-api/app-api/mqtt/message/send/single',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送客服消息
|
||||
*/
|
||||
export const sendKefuMessage = (params: SingleMessageVo) => {
|
||||
return post<IResponse<any>>({
|
||||
url: '/prod-api/app-api/mqtt/message/send/kefu',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得消息记录分页
|
||||
*/
|
||||
export const getMessagePage = (params: { pageNo: number; pageSize: number; fromId?: number; msgType?: number; topic: string }) => {
|
||||
return get<IResponse<PageResultMessageRespVO>>({
|
||||
url: '/prod-api/app-api/mqtt/message/page',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话列表
|
||||
*/
|
||||
export const conversationList = () => {
|
||||
return get<IResponse<PageResultSessionRespVO[]>>({
|
||||
url: '/prod-api/app-api/mqtt/session/list',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天记录
|
||||
*/
|
||||
export const getChatDetail = (params: { sessionId: number; pageNo: number; pageSize: number }) => {
|
||||
return get<IResponse<PageResultMessageRespVO>>({
|
||||
url: '/prod-api/app-api/mqtt/message/pageBySession',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空未读信息
|
||||
*/
|
||||
export const clearUnreadMessage = (params: { id: number }) => {
|
||||
return put<IResponse<boolean>>({
|
||||
url: '/prod-api/app-api/mqtt/session/clear',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得论坛频道
|
||||
*/
|
||||
export const getChannelLunTanDetail = (params: { id: string }) => {
|
||||
return get<IResponse<ChannelRespVO>>({
|
||||
url: '/prod-api/app-api/business/channel/get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建论坛关注
|
||||
*/
|
||||
export const createChannelFollow = (params: { channelId: string }) => {
|
||||
return post<IResponse<boolean>>({
|
||||
url: '/prod-api/app-api/business/channel-follow/create',
|
||||
data: params,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除论坛关注
|
||||
*/
|
||||
export const deleteChannelFollow = (params: { channelId: string }) => {
|
||||
return Delete<IResponse<boolean>>({
|
||||
url: '/prod-api/app-api/business/channel-follow/delete',
|
||||
params,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据群组ID获取群组成员
|
||||
*/
|
||||
export const getGroupMembers = (params: { channelId: string }) => {
|
||||
return get<IResponse<MemberUserRespDTO[]>>({
|
||||
url: `/prod-api/app-api/mqtt/session/users/${params.channelId}`,
|
||||
})
|
||||
}
|
||||
223
api/channel/types.ts
Normal file
223
api/channel/types.ts
Normal file
@ -0,0 +1,223 @@
|
||||
export interface TpageReq {
|
||||
pageNo: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TpageRes {
|
||||
total: number
|
||||
list: {
|
||||
postsId: number
|
||||
channelId: number
|
||||
postsTitle: string
|
||||
postsCover: string
|
||||
postsContent: string
|
||||
postsTags: string
|
||||
projectDicId: number
|
||||
browseNum: number
|
||||
likeNum: number
|
||||
createTime: string
|
||||
creator: string
|
||||
creatorName: string
|
||||
creatorAvatar: string
|
||||
commentNum: number
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface TcreateReq {
|
||||
// channelId: number | undefined
|
||||
postsTitle: string
|
||||
postsCover?: string
|
||||
postsContent: string
|
||||
postsTags: string
|
||||
projectDicId: number | undefined
|
||||
channelId?: string
|
||||
}
|
||||
|
||||
export interface TlistRes {
|
||||
createTime: string
|
||||
updateTime: string
|
||||
creator: string
|
||||
updater: string
|
||||
deleted: boolean
|
||||
channelId: number
|
||||
channelTitle: string
|
||||
channelTopic: string
|
||||
channelIcon: string
|
||||
status: number
|
||||
chinnelProfile: string
|
||||
projectDicId: number
|
||||
}
|
||||
|
||||
export interface TGetChannelPostsRes {
|
||||
postsId: number
|
||||
channelId: number
|
||||
postsTitle: string
|
||||
postsCover: string
|
||||
postsContent: string
|
||||
postsTags: string
|
||||
projectDicId: number
|
||||
browseNum: number
|
||||
likeNum: number
|
||||
createTime: string
|
||||
creator: string
|
||||
creatorName: string
|
||||
creatorAvatar: string
|
||||
commentNum: number
|
||||
}
|
||||
|
||||
export interface PageResultPostsCommentRespVO {
|
||||
list: {
|
||||
commentId: number
|
||||
postsId: number
|
||||
content: string
|
||||
quoteUser: string
|
||||
quoteContent: string
|
||||
createTime: string
|
||||
creator: string
|
||||
creatorName: string
|
||||
creatorAvatar: string
|
||||
}[]
|
||||
total: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天消息
|
||||
*/
|
||||
export interface chatMessagesReq {
|
||||
msgType: number
|
||||
content: string
|
||||
toId: number
|
||||
userId: number
|
||||
createTime: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息类型 消息类型 0:文本 1:图片 2:视频 3:文件
|
||||
*/
|
||||
export type msgType = 0 | 1 | 2 | 3
|
||||
|
||||
/**
|
||||
* 发送单聊信息
|
||||
*/
|
||||
export interface sendSingleChatReq {
|
||||
/** 消息类型 0:文本 1:图片 2:视频 3:文件,示例值(11854) */
|
||||
msgType: msgType
|
||||
/** 内容,示例值(11854) */
|
||||
content: string
|
||||
/** 对方userId,示例值(11854) */
|
||||
toId: number
|
||||
/** 客户端ID,示例值(11854) */
|
||||
userId: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话列表
|
||||
*/
|
||||
export interface PageResultSessionRespVO {
|
||||
sessionId: number
|
||||
sessionCode: string
|
||||
sessionType: string
|
||||
fromId: number
|
||||
fromTitle: string
|
||||
name: string
|
||||
fromUser: {
|
||||
id: number
|
||||
nickname: string
|
||||
status: number
|
||||
avatar: string
|
||||
mobile: string
|
||||
createTime: string
|
||||
levelId: number
|
||||
point: number
|
||||
}
|
||||
toId: number
|
||||
toTitle: string
|
||||
toUser: {
|
||||
id: number
|
||||
nickname: string
|
||||
status: number
|
||||
avatar: string
|
||||
mobile: string
|
||||
createTime: string
|
||||
levelId: number
|
||||
point: number
|
||||
}
|
||||
lastMsg: any
|
||||
unreadCount: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天记录
|
||||
*/
|
||||
export interface PageResultMessageRespVO {
|
||||
list: {
|
||||
msgId?: number
|
||||
sessionId?: number
|
||||
fromId?: number
|
||||
fromUser?: {
|
||||
id: number
|
||||
nickname: string
|
||||
status: number
|
||||
avatar: string
|
||||
mobile: string
|
||||
createTime: string
|
||||
levelId: number
|
||||
point: number
|
||||
}
|
||||
toId?: number | string
|
||||
toUser?: {
|
||||
id: number
|
||||
nickname: string
|
||||
status: number
|
||||
avatar: string
|
||||
mobile: string
|
||||
createTime: string
|
||||
levelId: number
|
||||
point: number
|
||||
}
|
||||
msgType: number
|
||||
content: string
|
||||
ext?: string
|
||||
createTime: string
|
||||
}[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface ChannelRespVO {
|
||||
channelId: string
|
||||
channelTitle: string
|
||||
channelIcon: string
|
||||
status: number
|
||||
channelProfile: string
|
||||
followCount: number
|
||||
hotTags: any[]
|
||||
projectDicId: number
|
||||
createTime: string
|
||||
isFollow: boolean
|
||||
chatUserCount: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 群组成员
|
||||
*/
|
||||
export interface MemberUserRespDTO {
|
||||
id: number
|
||||
nickname: string
|
||||
status: number
|
||||
avatar: string
|
||||
mobile: string
|
||||
createTime: string
|
||||
levelId: number
|
||||
point: number
|
||||
}
|
||||
|
||||
export interface SingleMessageVo {
|
||||
userId: number
|
||||
toId?: number
|
||||
content: string
|
||||
msgType: number
|
||||
sessionId?: string
|
||||
createTime?: string
|
||||
}
|
||||
Reference in New Issue
Block a user