Skip to content

Commit 2c29bad

Browse files
v2.1.10: api
1 parent b613610 commit 2c29bad

8 files changed

Lines changed: 228 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ccw-api/api",
3-
"version": "2.1.9",
3+
"version": "2.1.10",
44
"description": "ccw api collections",
55
"license": "MIT",
66
"author": "Meng Fuzi",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { request } from "src/request";
2+
import { ApiResponse } from "src/types/api";
3+
4+
export const url = "https://community-web.ccw.site/comment/like_record/delete";
5+
6+
export type Req = {
7+
commentId: number;
8+
};
9+
10+
export type Res = boolean;
11+
12+
/**
13+
* 取消点赞评论
14+
* @param {number} commentId 评论id
15+
* @returns {Promise<Res>} 操作是否成功
16+
*/
17+
export async function unlikeComment(commentId: number): Promise<Res> {
18+
const req: Req = { commentId };
19+
return await request
20+
.post<ApiResponse<Res>>(url, req)
21+
.then((res) => res.data.body);
22+
}

src/community-web/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import { getMyHashTagCreations } from "./hash_tag_creation/mine";
3030
import { getHashTagDetail } from "./hash_tag/detail";
3131
import { getManagedHashTags } from "./hash_tag/managed/list";
3232
import { getHashTagFavoriteDetail } from "./hash_tag_favorite/detail";
33+
import { getCloudProjectDetail } from "./study-cloud-database/cloud_project/detail";
34+
import { saveCloudProject } from "./study-cloud-database/cloud_project/save";
3335
import { getDonatedRecordRanking } from "./creation_donated_record/ranking_list";
3436
import { getCreationFavoriteDetail } from "./creation_favorite/detail";
3537
import { getCreationRecommendPositionList } from "./creation_recommend_position/list";
@@ -109,6 +111,8 @@ import { resetCommentWeight } from "./study-community/comment/reset_weight";
109111
import { deleteComment } from "./study-community/comment/delete";
110112
import { createComment } from "./comment/create";
111113
import { likeComment } from "./comment/like_record/create";
114+
import { unlikeComment } from "./comment/like_record/delete";
115+
import { createReportLog } from "./report_log/create";
112116
import { getStudentFollowingPage } from "./student/following/page";
113117
import { donateTrade } from "./study-trade/trade/donate";
114118
import { getUserProductsPage } from "./user_package/user_product";
@@ -150,6 +154,7 @@ export const communityWeb = {
150154
fetchObserverInviteToken,
151155
createCloudVariable,
152156
createComment,
157+
createReportLog,
153158
createShortUrl,
154159
createSmsCaptchaBySession,
155160
createSplitRule,
@@ -175,6 +180,7 @@ export const communityWeb = {
175180
getCreationDashboardMetricsDistribution,
176181
getCreationDashboardOverview,
177182
getCreationFavoriteDetail,
183+
getCloudProjectDetail,
178184
getCreationIntroduction,
179185
getConnectCommunityCreationLikeStatus,
180186
getCreationRecommendPositionList,
@@ -255,6 +261,7 @@ export const communityWeb = {
255261
insertCheckInRecord,
256262
investSmartContract,
257263
likeComment,
264+
unlikeComment,
258265
produceTeamMemberTicket,
259266
resetCommentWeight,
260267
resolveExternalIp,
@@ -264,6 +271,7 @@ export const communityWeb = {
264271
searchPosts,
265272
searchStudents,
266273
searchAll,
274+
saveCloudProject,
267275
sendEvent,
268276
setUserProductStatus,
269277
shareCreation,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { request } from "src/request";
2+
import { ApiResponse } from "src/types/api";
3+
4+
export const url = "https://community-web.ccw.site/report_log/create";
5+
6+
export type ReportSubjectType = "COMMENT" | "CREATION" | string;
7+
8+
export type Req = {
9+
description?: string;
10+
evidence: Array<string>;
11+
reason: string;
12+
reportedSubjectOid: string;
13+
reportedSubjectType: ReportSubjectType;
14+
version?: string;
15+
};
16+
17+
export type Res = boolean;
18+
19+
/**
20+
* 举报内容(评论/作品等)
21+
* @param {string} reason 上报理由,例如:"引战"
22+
* @param {string} reportedSubjectOid 被上报对象的 id(可为数字或字符串形式)
23+
* @param {string[]} evidence 证据列表(如截图链接)
24+
* @param {ReportSubjectType} reportedSubjectType 被上报对象类型,示例:"COMMENT"
25+
* @param {string} description 补充描述(可选)
26+
* @param {string} version 接口版本(可选)
27+
* @returns {Promise<Res>} 是否上报成功
28+
*/
29+
export async function createReportLog(
30+
reason: string,
31+
reportedSubjectOid: string,
32+
evidence: Array<string> = [],
33+
reportedSubjectType: ReportSubjectType = "COMMENT",
34+
description: string = "",
35+
version: string = "1.0",
36+
): Promise<Res> {
37+
const req: Req = {
38+
reason,
39+
reportedSubjectOid,
40+
evidence,
41+
reportedSubjectType,
42+
description,
43+
version,
44+
};
45+
46+
return await request
47+
.post<ApiResponse<Res>>(url, req)
48+
.then((res) => res.data.body);
49+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { request } from "src/request";
2+
import { ApiResponse, MongoDBId } from "src/types/api";
3+
4+
export const url =
5+
"https://community-web.ccw.site/study-cloud-database/cloud_project/detail";
6+
7+
export type Req = {
8+
creationOid: MongoDBId;
9+
};
10+
11+
export type CloudProjectMeta = {
12+
agent?: string;
13+
platform?: {
14+
name?: string;
15+
url?: string;
16+
};
17+
semver?: string;
18+
vm?: string;
19+
};
20+
21+
export type CloudProjectData = {
22+
cloudProject: {
23+
extensions: string[];
24+
gandi: null | Record<string, any>;
25+
meta: CloudProjectMeta;
26+
monitors: Record<string, any>;
27+
targets: string;
28+
};
29+
creationOid: MongoDBId;
30+
lastModified: number;
31+
};
32+
33+
export type Res = CloudProjectData;
34+
35+
/**
36+
* 获取云项目详情
37+
* @param {MongoDBId} creationOid 作品 oid
38+
* @returns {Promise<Res>} 云项目详情
39+
*/
40+
export async function getCloudProjectDetail(
41+
creationOid: MongoDBId,
42+
): Promise<Res> {
43+
const req: Req = { creationOid };
44+
return await request
45+
.post<ApiResponse<Res>>(url, req)
46+
.then((res) => res.data.body);
47+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { request } from "src/request";
2+
import { ApiResponse, MongoDBId } from "src/types/api";
3+
4+
export const url =
5+
"https://community-web.ccw.site/study-cloud-database/cloud_project/save";
6+
7+
export type CloudProjectMeta = {
8+
agent?: string;
9+
platform?: {
10+
name?: string;
11+
url?: string;
12+
};
13+
semver?: string;
14+
vm?: string;
15+
};
16+
17+
export type Req = {
18+
creationOid: MongoDBId;
19+
extensions?: string[];
20+
lastModified: number;
21+
meta?: CloudProjectMeta;
22+
monitors?: Record<string, any>;
23+
targets: Record<string, any>;
24+
};
25+
26+
export type Res = boolean;
27+
28+
/**
29+
* 保存云项目
30+
* @param {MongoDBId} creationOid 作品 oid
31+
* @param {number} lastModified 最后更新时间(毫秒)
32+
* @param {Record<string, unknown>} targets 项目目标对象
33+
* @param {CloudProjectMeta} meta 项目元信息(可选)
34+
* @param {Record<string, unknown>} monitors 监控对象(可选)
35+
* @param {string[]} extensions 扩展列表(可选)
36+
* @returns {Promise<boolean>} 是否保存成功
37+
*/
38+
export async function saveCloudProject(
39+
creationOid: MongoDBId,
40+
lastModified: number,
41+
targets: Record<string, unknown>,
42+
meta: CloudProjectMeta = {},
43+
monitors: Record<string, unknown> = {},
44+
extensions: string[] = [],
45+
): Promise<Res> {
46+
const req: Req = {
47+
creationOid,
48+
lastModified,
49+
targets,
50+
meta,
51+
monitors,
52+
extensions,
53+
};
54+
55+
return await request
56+
.post<ApiResponse<Res>>(url, req)
57+
.then((res) => res.data.body);
58+
}

src/sso/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createSmsCaptcha } from "./web/auth/assistant/captcha/v2/create";
55
import { loginByPhone } from "./web/auth/v3/login/by-phone";
66
import { oauthAuthorize } from "./oauth/authorize";
77
import { getOauthToken } from "./oauth/token";
8+
import { touchSession } from "./internal/auth/touch-session";
89

910
export const sso = {
1011
loginByPassword,
@@ -14,4 +15,5 @@ export const sso = {
1415
loginByPhone,
1516
oauthAuthorize,
1617
getOauthToken,
18+
touchSession,
1719
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { request } from "src/request";
2+
import { ApiResponse, MongoDBId } from "src/types/api";
3+
4+
export const url = "https://sso.ccw.site/internal/auth/touch-session";
5+
6+
export type Req = {
7+
token?: string;
8+
};
9+
10+
export type TouchSessionSuccess = {
11+
accountId: number;
12+
accountObjectId: MongoDBId;
13+
accountType: string;
14+
clientCode: string;
15+
createdAt: number;
16+
email: string | null;
17+
expireTime: number;
18+
extra: string; // JSON string
19+
id: number;
20+
lastAccessTime: number;
21+
orgId: string;
22+
scene: string | null;
23+
status: string;
24+
token: string;
25+
urlEncodedFullName: string | null;
26+
};
27+
28+
export type Res = TouchSessionSuccess | null;
29+
30+
/**
31+
* 刷新/校验会话(内部接口)
32+
* 当 token 为空时后端会返回 token 不能为空 的错误;成功时返回会话信息。
33+
* @param {string} token 会话 token(可选)
34+
* @returns {Promise<Res>} 成功返回会话信息,失败会抛出错误
35+
*/
36+
export async function touchSession(token?: string): Promise<Res> {
37+
const query = token ? `?token=${encodeURIComponent(token)}` : "";
38+
return await request
39+
.get<ApiResponse<TouchSessionSuccess | null>>(`${url}${query}`)
40+
.then((res) => res.data.body);
41+
}

0 commit comments

Comments
 (0)