mirror of
https://github.com/PlayEdu/backend
synced 2025-06-28 05:33:06 +08:00
数据结构重构优化
This commit is contained in:
parent
c2fb5c2243
commit
2a6e451417
@ -32,6 +32,12 @@ interface PropInterface {
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string | number;
|
||||
title: string;
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
export const CourseCreate: React.FC<PropInterface> = ({
|
||||
cateIds,
|
||||
depIds,
|
||||
@ -45,20 +51,20 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
const defaultThumb1 = courseDefaultThumbs[0];
|
||||
const defaultThumb2 = courseDefaultThumbs[1];
|
||||
const defaultThumb3 = courseDefaultThumbs[2];
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [departments, setDepartments] = useState<any>([]);
|
||||
const [categories, setCategories] = useState<any>([]);
|
||||
const [thumb, setThumb] = useState<string>("");
|
||||
const [type, setType] = useState<string>("open");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [departments, setDepartments] = useState<Option[]>([]);
|
||||
const [categories, setCategories] = useState<Option[]>([]);
|
||||
const [thumb, setThumb] = useState("");
|
||||
const [type, setType] = useState("open");
|
||||
const [chapterType, setChapterType] = useState(0);
|
||||
const [chapters, setChapters] = useState<any>([]);
|
||||
const [hours, setHours] = useState<any>([]);
|
||||
const [chapterHours, setChapterHours] = useState<any>([]);
|
||||
const [videoVisible, setVideoVisible] = useState<boolean>(false);
|
||||
const [videoVisible, setVideoVisible] = useState(false);
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [addvideoCurrent, setAddvideoCurrent] = useState(0);
|
||||
const [showDrop, setShowDrop] = useState<boolean>(false);
|
||||
const [attachmentVisible, setAttachmentVisible] = useState<boolean>(false);
|
||||
const [showDrop, setShowDrop] = useState(false);
|
||||
const [attachmentVisible, setAttachmentVisible] = useState(false);
|
||||
const [attachmentData, setAttachmentData] = useState<any>([]);
|
||||
const [attachments, setAttachments] = useState<any>([]);
|
||||
|
||||
@ -91,7 +97,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
const getParams = () => {
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments = res.data.departments;
|
||||
const departCount = res.data.dep_user_count;
|
||||
const departCount: DepIdsModel = res.data.dep_user_count;
|
||||
if (JSON.stringify(departments) !== "{}") {
|
||||
const new_arr: any = checkArr(departments, 0, departCount);
|
||||
setDepartments(new_arr);
|
||||
|
@ -22,6 +22,12 @@ interface PropInterface {
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string | number;
|
||||
title: string;
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
id,
|
||||
open,
|
||||
@ -36,10 +42,10 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
const defaultThumb2 = courseDefaultThumbs[1];
|
||||
const defaultThumb3 = courseDefaultThumbs[2];
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [departments, setDepartments] = useState<any>([]);
|
||||
const [categories, setCategories] = useState<any>([]);
|
||||
const [thumb, setThumb] = useState<string>("");
|
||||
const [type, setType] = useState<string>("open");
|
||||
const [departments, setDepartments] = useState<Option[]>([]);
|
||||
const [categories, setCategories] = useState<Option[]>([]);
|
||||
const [thumb, setThumb] = useState("");
|
||||
const [type, setType] = useState("open");
|
||||
|
||||
useEffect(() => {
|
||||
setInit(true);
|
||||
|
@ -23,13 +23,13 @@ const DepartmentPage = () => {
|
||||
const permissions = useSelector(
|
||||
(state: any) => state.loginUser.value.permissions
|
||||
);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [treeData, setTreeData] = useState<Option[]>([]);
|
||||
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||
|
||||
const [createVisible, setCreateVisible] = useState<boolean>(false);
|
||||
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||
const [createVisible, setCreateVisible] = useState(false);
|
||||
const [updateVisible, setUpdateVisible] = useState(false);
|
||||
const [did, setDid] = useState<number>(0);
|
||||
const [modal, contextHolder] = Modal.useModal();
|
||||
|
||||
|
@ -9,6 +9,12 @@ interface PropInterface {
|
||||
onSuccess: () => void;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string | number;
|
||||
title: string;
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
export const VideosUpdateDialog: React.FC<PropInterface> = ({
|
||||
id,
|
||||
open,
|
||||
@ -16,9 +22,9 @@ export const VideosUpdateDialog: React.FC<PropInterface> = ({
|
||||
onSuccess,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [init, setInit] = useState(true);
|
||||
const [categories, setCategories] = useState<any>([]);
|
||||
const [categories, setCategories] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setInit(true);
|
||||
@ -33,7 +39,7 @@ export const VideosUpdateDialog: React.FC<PropInterface> = ({
|
||||
|
||||
const getCategory = () => {
|
||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||
const categories = res.data.categories;
|
||||
const categories: CategoriesBoxModel = res.data.categories;
|
||||
if (JSON.stringify(categories) !== "{}") {
|
||||
const new_arr: any = checkArr(categories, 0, null);
|
||||
setCategories(new_arr);
|
||||
@ -52,7 +58,11 @@ export const VideosUpdateDialog: React.FC<PropInterface> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const checkArr = (departments: any[], id: number, counts: any) => {
|
||||
const checkArr = (
|
||||
departments: CategoriesBoxModel,
|
||||
id: number,
|
||||
counts: any
|
||||
) => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < departments[id].length; i++) {
|
||||
if (!departments[departments[id][i].id]) {
|
||||
|
@ -17,7 +17,7 @@ export const VideoPlayDialog: React.FC<PropInterface> = ({
|
||||
open,
|
||||
onCancel,
|
||||
}) => {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (open && url) {
|
||||
|
@ -10,6 +10,11 @@ interface PropInterface {
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
type selRoleModel = {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
|
||||
export const SystemAdministratorCreate: React.FC<PropInterface> = ({
|
||||
roleId,
|
||||
refresh,
|
||||
@ -17,8 +22,8 @@ export const SystemAdministratorCreate: React.FC<PropInterface> = ({
|
||||
onCancel,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [roles, setRoles] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [roles, setRoles] = useState<selRoleModel[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@ -43,7 +48,7 @@ export const SystemAdministratorCreate: React.FC<PropInterface> = ({
|
||||
const getParams = () => {
|
||||
adminUser.createAdminUser().then((res: any) => {
|
||||
const arr = [];
|
||||
let roles = res.data.roles;
|
||||
let roles: RoleModel[] = res.data.roles;
|
||||
for (let i = 0; i < roles.length; i++) {
|
||||
arr.push({
|
||||
label: roles[i].name,
|
||||
|
@ -10,6 +10,11 @@ interface PropInterface {
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
type selRoleModel = {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
|
||||
export const SystemAdministratorUpdate: React.FC<PropInterface> = ({
|
||||
id,
|
||||
refresh,
|
||||
@ -18,8 +23,8 @@ export const SystemAdministratorUpdate: React.FC<PropInterface> = ({
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [init, setInit] = useState(true);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [roles, setRoles] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [roles, setRoles] = useState<selRoleModel[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@ -40,7 +45,7 @@ export const SystemAdministratorUpdate: React.FC<PropInterface> = ({
|
||||
const getParams = () => {
|
||||
adminUser.createAdminUser().then((res: any) => {
|
||||
const arr = [];
|
||||
let roles = res.data.roles;
|
||||
let roles: RoleModel[] = res.data.roles;
|
||||
for (let i = 0; i < roles.length; i++) {
|
||||
arr.push({
|
||||
label: roles[i].name,
|
||||
@ -53,7 +58,7 @@ export const SystemAdministratorUpdate: React.FC<PropInterface> = ({
|
||||
|
||||
const getDetail = () => {
|
||||
adminUser.AdminUser(id).then((res: any) => {
|
||||
let user = res.data.user;
|
||||
let user: AdminUserDetailModel = res.data.user;
|
||||
form.setFieldsValue({
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
|
@ -25,22 +25,6 @@ interface DataType {
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
type RolesModel = {
|
||||
[key: number]: RoleModel[];
|
||||
};
|
||||
|
||||
type RoleModel = {
|
||||
created_at: string;
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
updated_at: string;
|
||||
};
|
||||
|
||||
type RoleIdsModel = {
|
||||
[key: number]: number[];
|
||||
};
|
||||
|
||||
const SystemAdministratorPage = () => {
|
||||
const navigate = useNavigate();
|
||||
const [loading, setLoading] = useState(true);
|
||||
@ -57,11 +41,10 @@ const SystemAdministratorPage = () => {
|
||||
const [updateRoleVisible, setUpdateRoleVisible] = useState(false);
|
||||
const [cid, setCid] = useState(0);
|
||||
const [role_ids, setRoleIds] = useState<number[]>([]);
|
||||
const [selLabel, setLabel] = useState<string>("全部管理员");
|
||||
const [selLabel, setLabel] = useState("全部管理员");
|
||||
const [roleDelSuccess, setRoleDelSuccess] = useState(false);
|
||||
const [isSuper, setIsSuper] = useState(false);
|
||||
|
||||
const [name, setName] = useState<string>("");
|
||||
const [name, setName] = useState("");
|
||||
|
||||
const columns: ColumnsType<DataType> = [
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Modal, Form } from "antd";
|
||||
|
||||
interface PropInterface {
|
||||
@ -15,7 +15,7 @@ export const AdminLogDetailDialog: React.FC<PropInterface> = ({
|
||||
result,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const onFinish = (values: any) => {};
|
||||
|
||||
|
@ -35,7 +35,7 @@ const SystemLogPage = () => {
|
||||
const [title, setTitle] = useState("");
|
||||
const [adminId, setAdminId] = useState("");
|
||||
const [adminName, setAdminName] = useState("");
|
||||
const [created_at, setCreatedAt] = useState<any>([]);
|
||||
const [created_at, setCreatedAt] = useState<string[]>([]);
|
||||
const [createdAts, setCreatedAts] = useState<any>([]);
|
||||
const [param, setParam] = useState("");
|
||||
const [result, setResult] = useState("");
|
||||
|
@ -19,9 +19,9 @@ export const SystemAdminrolesCreate: React.FC<PropInterface> = ({
|
||||
onCancel,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [permissions, setPermissions] = useState<any>([]);
|
||||
const [actions, setActions] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [permissions, setPermissions] = useState<Option[]>([]);
|
||||
const [actions, setActions] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
|
@ -31,9 +31,9 @@ export const SystemAdminrolesUpdate: React.FC<PropInterface> = ({
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [init, setInit] = useState(true);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [permissions, setPermissions] = useState<any>([]);
|
||||
const [actions, setActions] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [permissions, setPermissions] = useState<Option[]>([]);
|
||||
const [actions, setActions] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
|
@ -20,10 +20,10 @@ import type { CheckboxChangeEvent } from "antd/es/checkbox";
|
||||
|
||||
const SystemConfigPage = () => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [logo, setLogo] = useState<string>("");
|
||||
const [thumb, setThumb] = useState<string>("");
|
||||
const [avatar, setAvatar] = useState<string>("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [logo, setLogo] = useState("");
|
||||
const [thumb, setThumb] = useState("");
|
||||
const [avatar, setAvatar] = useState("");
|
||||
const [tabKey, setTabKey] = useState(1);
|
||||
const [nameChecked, setNameChecked] = useState(false);
|
||||
const [emailChecked, setEmailChecked] = useState(false);
|
||||
|
28
src/playedu.d.ts
vendored
28
src/playedu.d.ts
vendored
@ -35,6 +35,18 @@ declare global {
|
||||
verify_at?: string;
|
||||
}
|
||||
|
||||
interface AdminUserDetailModel {
|
||||
created_at: string;
|
||||
email: string;
|
||||
id: number;
|
||||
is_ban_login: number;
|
||||
login_at: string;
|
||||
login_ip: string;
|
||||
login_times: number;
|
||||
name: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
interface CourseModel {
|
||||
charge: number;
|
||||
class_hour: number;
|
||||
@ -88,6 +100,22 @@ declare global {
|
||||
sort: number;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
interface RolesModel {
|
||||
[key: number]: RoleModel[];
|
||||
}
|
||||
|
||||
interface RoleModel {
|
||||
created_at: string;
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
interface RoleIdsModel {
|
||||
[key: number]: number[];
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user