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