add episode list

This commit is contained in:
AceDataCloud committed 2022-02-08 00:03:09 +08:00
1 parent 344fd73833
commit 36a338b631
15 files changed
+326 -47

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
import { AxiosResponse } from 'axios';
import httpClient from '../../instance';
import { IWechatQRCodeResponse, IWechatLoginStatusResponse } from './types';
class WechatService {
key = 'wechat';
async createQRCode4Login(): Promise<AxiosResponse<IWechatQRCodeResponse>> {
return await httpClient.post(`/${this.key}/qrcode`, {
scene: 'login'
});
}
async getLoginStatus(ticket: string): Promise<AxiosResponse<IWechatLoginStatusResponse>> {
return httpClient.post(`/${this.key}/authenticate`, {
ticket: ticket
});
}
}
export default new WechatService();
-14
View File
@@ -1,14 +0,0 @@
import { IUser } from '../user/types';
export interface IWechatQRCode {
ticket: string;
url: string;
}
export interface IWechatQRCodeResponse extends IWechatQRCode {}
export interface IWechatLoginStatusResponse {
refreshToken: string;
accessToken: string;
user: IUser;
}
+37
View File
@@ -0,0 +1,37 @@
import { AxiosResponse } from 'axios';
import httpClient from '../instance';
import { IEpisode, IEpisodeDetailResponse, IEpisodeListResponse } from './types';
class EpisodeService {
key = 'episodes';
async getAll(): Promise<AxiosResponse<IEpisodeListResponse>> {
return await httpClient.get(`/${this.key}/`);
}
async get(id: number): Promise<AxiosResponse<IEpisodeDetailResponse>> {
return await httpClient.get(`/${this.key}/${id}`);
}
async create(data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
return await httpClient.post(`/${this.key}/`, data);
}
async update(id: number, data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
return await httpClient.put(`/${this.key}/${id}`, data);
}
async delete(id: number): Promise<AxiosResponse<null>> {
return await httpClient.delete(`/${this.key}/${id}`);
}
async createForCourse(courseId: number, data: IEpisode): Promise<AxiosResponse<IEpisodeDetailResponse>> {
return await httpClient.post(`/courses/${courseId}/${this.key}/`, data);
}
async getAllForCourse(courseId: number): Promise<AxiosResponse<IEpisodeListResponse>> {
return await httpClient.get(`/courses/${courseId}/${this.key}/`);
}
}
export const episodeService = new EpisodeService();
+25
View File
@@ -0,0 +1,25 @@
export interface IEpisode {
id: number;
tags?: string[];
title?: string;
cover?: string;
thumbnail?: string;
duration?: number;
introduction?: string;
state?: 'Pending' | 'Running' | 'Ready';
type?: 'Video' | 'Document';
isFree?: boolean;
index?: number;
viewCount?: number;
resourceUrl?: string;
createdAt?: string;
updatedAt?: string;
publisherId?: number;
}
export interface IEpisodeListResponse {
count: number;
items: IEpisode[];
}
export type IEpisodeDetailResponse = IEpisode;
-2
View File
@@ -13,7 +13,6 @@ const httpClient: AxiosInstance = axios.create({
httpClient.interceptors.request.use((config) => {
const accessToken = store.getters.accessToken;
console.log('accesstoken', accessToken);
if (accessToken) {
config.headers['Authorization'] = `Bearer ${accessToken}`;
}
@@ -31,7 +30,6 @@ httpClient.interceptors.response.use(
return response;
},
(error) => {
console.log('error', error);
if (error.response.status === 401) {
store.dispatch('resetAuth');
router.push('/');
@@ -1,5 +1,5 @@
import { AxiosResponse } from 'axios';
import httpClient from '../../instance';
import httpClient from '../instance';
import { IUserDetailResponse, IUser } from './types';
class UserService {
File renamed without changes.