diff --git a/pom.xml b/pom.xml
index f1ab8f5f17aed61e4034bfe157ef69b178295585..d2072e4e7734f9e505e4d3558284d35ba3e07f62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,18 @@
17
+
+ com.alipay.sdk
+ alipay-easysdk
+ 2.2.3
+
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
org.springframework.boot
spring-boot-starter-data-redis
diff --git a/sql/init.sql b/sql/init.sql
new file mode 100644
index 0000000000000000000000000000000000000000..9123f46873ba9b3881ee3dfb2322662cda7aa8a9
--- /dev/null
+++ b/sql/init.sql
@@ -0,0 +1,101 @@
+INSERT INTO role_info (id, name)
+VALUES (1, '教师');
+INSERT INTO role_info (id, name)
+VALUES (2, '助教');
+INSERT INTO role_info (id, name)
+VALUES (3, '学生');
+INSERT INTO role_info (id, name)
+VALUES (4, '管理员');
+
+
+INSERT INTO permission (id, name, url)
+VALUES (1, '课程管理', '/course/info');
+INSERT INTO permission (id, name, url)
+VALUES (2, '课程审核', '/course/info/status');
+INSERT INTO permission (id, name, url)
+VALUES (3, '课程编辑', '/course/info/edit');
+INSERT INTO permission (id, name, url)
+VALUES (4, '添加课程章节', '/course/section');
+INSERT INTO permission (id, name, url)
+VALUES (5, '添加课程资源', '/course/resource');
+INSERT INTO permission (id, name, url)
+VALUES (6, '上传图片', '/file/upload/picture');
+INSERT INTO permission (id, name, url)
+VALUES (7, '上传大文件', '/file/add');
+INSERT INTO permission (id, name, url)
+VALUES (8, '文件管理', '/file');
+INSERT INTO permission (id, name, url)
+VALUES (9, '添加选课', '/course/election');
+INSERT INTO permission (id, name, url)
+VALUES (10, '添加订单', '/course/order/topay');
+INSERT INTO permission (id, name, url)
+VALUES (11, '查看个人订单', '/course/order/selectbyid');
+INSERT INTO permission (id, name, url)
+VALUES (12, '查看所有订单', '/course/order/list');
+INSERT INTO permission (id, name, url)
+VALUES (13, '评论管理', '/comment');
+INSERT INTO permission (id, name, url)
+VALUES (14, 'banner管理', '/api/admin/banner');
+INSERT INTO permission (id, name, url)
+VALUES (15, '讲师管理', '/api/teacher');
+INSERT INTO permission (id, name, url)
+VALUES (16, '用户管理', '/rbac');
+INSERT INTO permission (id, name, url)
+VALUES (17, '查看教师统计', '/api/stat/teacher');
+INSERT INTO permission (id, name, url)
+VALUES (18, '查看管理员统计', '/api/stat/admin');
+
+
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 3);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 4);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 5);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 6);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 7);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 13);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (1, 17);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (3, 6);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (3, 9);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (3, 10);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (3, 11);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 1);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 2);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 3);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 4);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 6);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 7);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 8);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 12);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 14);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 15);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 16);
+INSERT INTO role_permission_relation (role_id, permission_id)
+VALUES (4, 18);
+
+
+INSERT INTO user_info (id, username, password, status, display_name, avatar, phone, email, is_deleted)
+VALUES (1, 'test_admin', '$2a$10$8tFZIY2vgSsu3kgu/13WUOrbSkVABzkwQDwlEwNYBZVmyZ3Z.kImy', 1, '管理员', '', '11111111111',
+ 'aaaa@a.com', 0);
+INSERT INTO user_role_relation (user_id, role_id)
+VALUES (1, 4);
diff --git a/sql/online_edu/OSSFile.sql b/sql/online_edu/OSSFile.sql
index 0fba37af34f49d0593dd61efb1152a1e8e9d6bb4..a2470518e128d257e4bbf8e2c5f68b239820f627 100644
--- a/sql/online_edu/OSSFile.sql
+++ b/sql/online_edu/OSSFile.sql
@@ -2,8 +2,8 @@ create table OSSFile
(
id bigint not null comment 'id'
primary key,
- name char(50) null comment '文件名',
- path varchar(50) null comment '访问路径',
+ name char(255) null comment '文件名',
+ path varchar(500) null comment '访问路径',
type varchar(50) null comment '类型',
size int null comment '大小',
uploader_id bigint null comment '上传者id',
diff --git a/sql/online_edu/banner.sql b/sql/online_edu/banner.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a2b07af0d8bc166a47f8ba4a6bd50cc24a8b770c
--- /dev/null
+++ b/sql/online_edu/banner.sql
@@ -0,0 +1,14 @@
+create table banner
+(
+ id int unsigned auto_increment comment 'ID'
+ primary key,
+ title varchar(63) default '' null comment '标题',
+ image_url varchar(1023) default '' not null comment '图片地址',
+ link_url varchar(1023) default '' null comment '链接地址',
+ sort int unsigned default 0 not null comment '排序',
+ enable tinyint unsigned default 0 not null comment '是否启用',
+ update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
+ create_time datetime default CURRENT_TIMESTAMP null comment '创建时间'
+)
+ comment 'banner表';
+
diff --git a/sql/online_edu/comment.sql b/sql/online_edu/comment.sql
index ac4f0e81700ab5a85049303cdf96f8713a5bda81..45778f26bee7e9240094905e1eae99022cb36136 100644
--- a/sql/online_edu/comment.sql
+++ b/sql/online_edu/comment.sql
@@ -1,13 +1,20 @@
create table comment
(
- id bigint not null comment '评论id'
+ id bigint not null comment '评论id'
primary key,
- course_id bigint null comment '课程id',
- student_id bigint null comment '学生id',
- content text null comment '内容',
- is_deleted tinyint(1) null comment '是否删除',
- created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
+ course_id bigint null comment '课程id',
+ student_id bigint null comment '学生id',
+ member_avatar varchar(1000) null comment '用户头像',
+ member_name char(50) null comment '用户显示名',
+ mark int default 5 null comment '评分 0-5 分',
+ content text null comment '内容',
+ is_deleted tinyint(1) null comment '是否删除',
+ created_at datetime default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
+ constraint comment_course_info_id_fk
+ foreign key (course_id) references course_info (id),
+ constraint comment_user_info_id_fk
+ foreign key (student_id) references user_info (id)
)
comment '评论';
diff --git a/sql/online_edu/course_election.sql b/sql/online_edu/course_election.sql
index 21e08689307b15e01528cc85820c400a1e9f9e2f..e72c2b35b0f8d2e54f9a97ec8530bf06cc7cb6dd 100644
--- a/sql/online_edu/course_election.sql
+++ b/sql/online_edu/course_election.sql
@@ -1,20 +1,24 @@
create table course_election
(
- id bigint not null
+ id bigint not null
primary key,
- serial_number varchar(20) default '' not null comment '订单号',
- course_id bigint not null comment '课程id',
- course_name varchar(100) null comment '课程名称',
- teacher_name varchar(20) null comment '教师名称',
- student_id bigint null comment '学生id',
- student_name varchar(50) null comment '学生昵称',
- price decimal(10, 2) default 0.01 null comment '订单金额(分)',
- status tinyint(3) null comment '订单状态(0:未支付 1:已支付)',
- is_deleted tinyint(1) unsigned default 0 not null comment '逻辑删除 1(true)已删除, 0(false)未删除',
- created_at timestamp not null comment '创建时间',
- updated_at timestamp not null comment '更新时间',
+ serial_number varchar(20) default '' not null comment '订单号',
+ course_id bigint not null comment '课程id',
+ course_name varchar(100) null comment '课程名称',
+ teacher_name varchar(20) null comment '教师名称',
+ student_id bigint null comment '学生id',
+ student_name varchar(50) null comment '学生昵称',
+ price decimal(10, 2) default 0.01 null comment '订单金额(分)',
+ status tinyint(3) null comment '订单状态(0:未支付 1:已支付)',
+ is_deleted tinyint(1) unsigned default 0 not null comment '逻辑删除 1(true)已删除, 0(false)未删除',
+ created_at datetime default CURRENT_TIMESTAMP not null comment '创建时间',
+ updated_at datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
constraint ux_serial_number
- unique (serial_number)
+ unique (serial_number),
+ constraint course_election_course_info_id_fk
+ foreign key (course_id) references course_info (id),
+ constraint course_election_user_info_id_fk
+ foreign key (student_id) references user_info (id)
)
comment '选课';
diff --git a/sql/online_edu/course_info.sql b/sql/online_edu/course_info.sql
index 71eb7d4ae849d5566fbfa49fc9b96b5abc29294d..9e5b6fb244e0111b0e6c1f41ab6a01add20c6198 100644
--- a/sql/online_edu/course_info.sql
+++ b/sql/online_edu/course_info.sql
@@ -1,16 +1,22 @@
create table course_info
(
- id bigint not null comment '课程id'
+ id bigint not null comment '课程id'
primary key,
- teacher_id bigint null comment '教师id',
- type_id int default 0 not null comment '课程类型',
- title varchar(50) null comment '标题',
- cover varchar(500) null comment '封面链接',
- price decimal(10, 2) default 0.01 not null comment '价格',
- status int default 0 not null comment '课程状态 0:未上线,1:私有开课中,2:公开开课中,3:结课',
- is_deleted tinyint(1) null comment '是否删除',
- created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
+ teacher_id bigint null comment '教师id',
+ type_id int default 0 not null comment '课程类型',
+ title varchar(50) null comment '标题',
+ cover varchar(500) null comment '封面链接',
+ description text null comment '课程描述',
+ price decimal(10, 2) default 0.01 not null comment '价格',
+ status int default 0 not null comment '课程状态 -1:草稿,0:审核中,1:未上线,2:公开开课中,3:结课',
+ is_deleted tinyint(1) null comment '是否删除',
+ created_at datetime default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
+ constraint course_info_teacher_info_teacher_id_fk
+ foreign key (teacher_id) references teacher_info (teacher_id)
)
comment '课程信息';
+create index course_info_course_type_id_fk
+ on course_info (type_id);
+
diff --git a/sql/online_edu/course_order.sql b/sql/online_edu/course_order.sql
index bb15d1a1a32b5d7c9e5a6c529c0b52eb8b131b6c..a0f3540391168e7b89c796906998e5d39ec946f1 100644
--- a/sql/online_edu/course_order.sql
+++ b/sql/online_edu/course_order.sql
@@ -1,16 +1,16 @@
create table course_order
(
- id char(19) default '' not null
+ id bigint not null
primary key,
- serial_number varchar(20) default '' not null comment '订单号',
- payedAt timestamp null comment '支付完成时间',
- price decimal(10, 2) default 0.01 null comment '支付金额(分)',
- transaction_id varchar(30) null comment '交易流水号',
- trade_state char(20) null comment '交易状态',
- attr text null comment '其他属性',
- is_deleted tinyint(1) unsigned default 0 not null comment '逻辑删除 1(true)已删除, 0(false)未删除',
- created_at timestamp not null comment '创建时间',
- updated_at timestamp not null comment '更新时间',
+ serial_number varchar(20) default '' not null comment '订单号',
+ payedAt timestamp null comment '支付完成时间',
+ price decimal(10, 2) default 0.01 null comment '支付金额(分)',
+ transaction_id varchar(30) null comment '交易流水号',
+ trade_state char(20) null comment '交易状态',
+ attr text null comment '其他属性',
+ is_deleted tinyint(1) unsigned default 0 not null comment '逻辑删除 1(true)已删除, 0(false)未删除',
+ created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
constraint uk_serial_number
unique (serial_number)
)
diff --git a/sql/online_edu/course_section.sql b/sql/online_edu/course_section.sql
index 62b741f9e930298cefd036f1f49940bb66a3bc17..38739124f8a5c8d144c2a4c3f08b04a82827f187 100644
--- a/sql/online_edu/course_section.sql
+++ b/sql/online_edu/course_section.sql
@@ -1,10 +1,15 @@
create table course_section
(
- id bigint not null comment '章节id'
+ id bigint not null comment '章节id'
primary key,
- section_name varchar(20) null comment '章节名',
- `order` int null comment '排序',
- course_id bigint null comment '内容id'
+ section_name varchar(20) null comment '章节名',
+ sort int null comment '排序',
+ course_id bigint null comment '内容id',
+ status tinyint null comment '状态: 0,未使用;1,使用中',
+ created_at datetime default CURRENT_TIMESTAMP null comment '创建时间',
+ update_at datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
+ constraint course_section_course_info_id_fk
+ foreign key (course_id) references course_info (id)
)
comment '课程章节';
diff --git a/sql/online_edu/course_type.sql b/sql/online_edu/course_type.sql
new file mode 100644
index 0000000000000000000000000000000000000000..04971fd872444e29492a3cba6617457cf5270b24
--- /dev/null
+++ b/sql/online_edu/course_type.sql
@@ -0,0 +1,9 @@
+create table course_type
+(
+ id int auto_increment comment '类型ID'
+ primary key,
+ course_type char(20) null comment '课程类型',
+ is_deleted tinyint default 0 null comment '已删除'
+)
+ comment '课程类型';
+
diff --git a/sql/online_edu/feedback.sql b/sql/online_edu/feedback.sql
index 062f6b7715af5480c2896ef3b063fa69b048bccf..0ad21f603b2029a1a7875889e734933a7a4f8473 100644
--- a/sql/online_edu/feedback.sql
+++ b/sql/online_edu/feedback.sql
@@ -3,7 +3,11 @@ create table feedback
id bigint not null comment '反馈id'
primary key,
student_id bigint null comment '学生id',
- resource_id bigint null comment '资源id'
+ resource_id bigint null comment '资源id',
+ constraint feedback_homework_resource_id_fk
+ foreign key (resource_id) references homework_resource (id),
+ constraint feedback_user_info_id_fk
+ foreign key (student_id) references user_info (id)
)
comment '反馈';
diff --git a/sql/online_edu/homework.sql b/sql/online_edu/homework.sql
index 01aaf9f8bc54076f36eaf5df87b34fce46c56f76..d2dbcd0a74d82464e880fe694ac807ca776f6a8c 100644
--- a/sql/online_edu/homework.sql
+++ b/sql/online_edu/homework.sql
@@ -2,9 +2,14 @@ create table homework
(
id bigint not null comment '作业id'
primary key,
- feedback_id bigint null comment '反馈id',
+ feedback_id bigint not null comment '反馈id',
+ file_id bigint null comment '文件ID',
created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
+ updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
+ constraint homework_OSSFile_id_fk
+ foreign key (file_id) references OSSFile (id),
+ constraint homework_feedback_id_fk
+ foreign key (feedback_id) references feedback (id)
)
comment '作业';
diff --git a/sql/online_edu/homework_resource.sql b/sql/online_edu/homework_resource.sql
index 0bd70ebfd4d216f35fb2819a0b475e5bb12cee55..bdc0b5f1b8b407714df70a83f5954d62386d3cbd 100644
--- a/sql/online_edu/homework_resource.sql
+++ b/sql/online_edu/homework_resource.sql
@@ -2,13 +2,15 @@ create table homework_resource
(
id bigint not null comment 'id'
primary key,
+ section_id bigint null comment '对应章节',
name varchar(20) null comment '作业名',
cover varchar(50) null comment '封面',
deadline timestamp null comment '截止日期',
- `order` int null comment '顺序',
+ sort int null comment '顺序',
description char(200) null comment '描述',
avalible_types varchar(100) null comment '可用类型',
- section_id bigint null comment '对应章节'
+ constraint homework_resource_course_section_id_fk
+ foreign key (section_id) references course_section (id)
)
comment '作业资源';
diff --git a/sql/online_edu/live_resource.sql b/sql/online_edu/live_resource.sql
index f599d55ee36f17a373ea55461d053a183b5daeff..85aa95064827eab73c5dfd2cb7284dfc2e1226c8 100644
--- a/sql/online_edu/live_resource.sql
+++ b/sql/online_edu/live_resource.sql
@@ -2,6 +2,7 @@ create table live_resource
(
id bigint not null comment 'id'
primary key,
+ section_id bigint null comment '对应章节',
name varchar(20) null comment '直播名',
cover varchar(50) null comment '封面',
roomId varchar(20) null comment '房间id',
@@ -9,8 +10,9 @@ create table live_resource
endTime timestamp null comment '结束时间',
status smallint default 0 null comment '直播状态',
is_deleted tinyint default 0 null comment '是否删除',
- `order` int default 0 null comment '顺序',
- section_id bigint null comment '对应章节'
+ sort int default 0 null comment '顺序',
+ constraint live_resource_course_section_id_fk
+ foreign key (section_id) references course_section (id)
)
comment '直播资源';
diff --git a/sql/online_edu/message.sql b/sql/online_edu/message.sql
index d63c26bb95f3f72322c16145a6c36b6d474afae0..35c0ac492dd86ee02012a607b4b971e7a4b6b956 100644
--- a/sql/online_edu/message.sql
+++ b/sql/online_edu/message.sql
@@ -1,16 +1,16 @@
create table message
(
- id bigint auto_increment comment '消息ID'
+ id bigint not null comment '消息ID'
primary key,
- created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
message_title char(50) not null comment '消息标题',
message_body char(200) null comment '消息内容',
sender_id bigint not null comment '发送者id',
receiver_id bigint not null comment '接收者ID',
- sent tinyint(1) default 1 null comment '是否发送{0:未发送,1:已发送}',
- received tinyint(1) default 0 null comment '是否已读{0:未读,1:已读}',
+ send_status tinyint(1) default 1 null comment '是否发送{0:未发送,1:已发送}',
+ read_status tinyint(1) default 0 null comment '是否已读{0:未读,1:已读}',
deleted tinyint(1) null comment '是否删除{0:未删除,1:已删除}',
+ created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
constraint message_user_info_id_fk
foreign key (sender_id) references user_info (id),
constraint message_user_info_id_fk2
diff --git a/sql/online_edu/message_template.sql b/sql/online_edu/message_template.sql
deleted file mode 100644
index 75cfba8455ea16aa91a2417e56eefc4a34003257..0000000000000000000000000000000000000000
--- a/sql/online_edu/message_template.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-create table message_template
-(
- id bigint auto_increment comment '主键'
- primary key,
- name varchar(63) not null comment '模板名称',
- code varchar(64) not null comment '模版编码',
- nickname varchar(255) not null comment '发送人名称',
- content varchar(1024) not null comment '模版内容',
- type tinyint not null comment '类型',
- params varchar(255) null comment '参数数组',
- status tinyint not null comment '状态',
- remark varchar(255) null comment '备注',
- creator varchar(64) default '' null comment '创建者',
- create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
- updater varchar(64) default '' null comment '更新者',
- update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
- deleted bit default b'0' not null comment '是否删除'
-)
- comment '站内信模板表' collate = utf8mb4_unicode_ci;
-
diff --git a/sql/online_edu/permission.sql b/sql/online_edu/permission.sql
index ea83afb737471abe20638306d1c842072717952b..decb2f9cb632a706af3c6d1f7d07ca59e49ddb43 100644
--- a/sql/online_edu/permission.sql
+++ b/sql/online_edu/permission.sql
@@ -1,16 +1,16 @@
create table permission
(
- id bigint auto_increment
+ id bigint not null
primary key,
- created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
name char(20) not null comment '权限名称',
url varchar(200) not null comment '操作对应的URL',
menu_title varchar(20) null comment '菜单名',
type smallint(2) null comment '权限类型 0:仅后端, 1: 前端菜单,2:前端按钮',
router_name varchar(20) null comment '路由名',
router_path varchar(50) null comment '前端路径名',
- component_path varchar(50) null comment '前端组件路径'
+ component_path varchar(50) null comment '前端组件路径',
+ created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
)
comment '可操作对象';
diff --git a/sql/online_edu/social_user.sql b/sql/online_edu/social_user.sql
deleted file mode 100644
index 6727161d7938a1d50500872697ac61049ae1abe9..0000000000000000000000000000000000000000
--- a/sql/online_edu/social_user.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-create table social_user
-(
- id bigint auto_increment comment '登录用户id'
- primary key,
- user_id bigint null comment '用户id',
- open_id varchar(100) null comment '对应的授权id',
- created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
-)
- comment '第三方登录用户';
-
diff --git a/sql/online_edu/static_resource.sql b/sql/online_edu/static_resource.sql
index 8daf129996bd5158f303dc1545568c8f84d150e6..5fd53c89883e25fc11babf70a11e27fe63d10906 100644
--- a/sql/online_edu/static_resource.sql
+++ b/sql/online_edu/static_resource.sql
@@ -2,13 +2,16 @@ create table static_resource
(
id bigint not null comment '资源id'
primary key,
- name char(20) null comment '资源名',
- cover varchar(50) null comment '封面',
+ section_id bigint null comment '章节id',
+ name char(255) null comment '资源名',
fileId bigint null comment 'oss文件Id',
- `order` int default 0 null comment '显示顺序',
+ sort int default 0 null comment '显示顺序',
type int default 0 null comment '类型',
- is_accessable tinyint(1) default 0 not null comment '可以在线访问',
- section_id bigint null comment '章节id'
+ is_accessible tinyint(1) default 0 not null comment '可以在线访问',
+ constraint static_resource_OSSFile_id_fk
+ foreign key (fileId) references OSSFile (id),
+ constraint static_resource_course_section_id_fk
+ foreign key (section_id) references course_section (id)
)
comment '静态资源';
diff --git a/sql/online_edu/system_notify_message.sql b/sql/online_edu/system_notify_message.sql
deleted file mode 100644
index e9178605d441023d067970fb40f205e747ce11cd..0000000000000000000000000000000000000000
--- a/sql/online_edu/system_notify_message.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-create table system_notify_message
-(
- id bigint auto_increment comment '用户ID'
- primary key,
- user_id bigint not null comment '用户id',
- user_type tinyint not null comment '用户类型',
- template_id bigint not null comment '模版编号',
- template_code varchar(64) not null comment '模板编码',
- template_nickname varchar(63) not null comment '模版发送人名称',
- template_content varchar(1024) not null comment '模版内容',
- template_type int not null comment '模版类型',
- template_params varchar(255) not null comment '模版参数',
- read_status bit not null comment '是否已读',
- read_time datetime null comment '阅读时间',
- creator varchar(64) default '' null comment '创建者',
- create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
- updater varchar(64) default '' null comment '更新者',
- update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
- deleted bit default b'0' not null comment '是否删除',
- tenant_id bigint default 0 not null comment '租户编号'
-)
- comment '站内信消息表' collate = utf8mb4_unicode_ci;
-
diff --git a/sql/online_edu/teacher_info.sql b/sql/online_edu/teacher_info.sql
index fcacb22e7984dfdf704996d01b4ed4b9caaf0fac..5f5d6bed5d8bc3123bdf89f67bf8ec417bd92632 100644
--- a/sql/online_edu/teacher_info.sql
+++ b/sql/online_edu/teacher_info.sql
@@ -1,12 +1,15 @@
create table teacher_info
(
- teacher_id bigint not null comment '教师id'
+ teacher_id bigint not null comment '教师id'
primary key,
- teacher_name varchar(20) null comment '教师姓名',
- teacher_description varchar(200) null comment '教师描述',
- constraint teacher_info_user_info_id_fk
- foreign key (teacher_id) references user_info (id)
- on update cascade on delete cascade
+ teacher_avatar varchar(500) null comment '教师头像',
+ teacher_name varchar(20) null comment '教师姓名',
+ teacher_description varchar(200) null comment '教师描述',
+ teacher_email varchar(50) null comment '教师邮箱',
+ status smallint default 2 null comment '教师状态:0禁用,1已审核,2待审核',
+ is_deleted tinyint(1) default 0 null comment '已删除',
+ created_at timestamp default CURRENT_TIMESTAMP null comment '创建时间',
+ updated_at timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间'
)
comment '教师信息';
diff --git a/sql/online_edu/user_info.sql b/sql/online_edu/user_info.sql
index 9bbaee2b4d5d3df4747f8ef79bd79bedb408222d..61fee18083f5b48de7e9934326684857136c8818 100644
--- a/sql/online_edu/user_info.sql
+++ b/sql/online_edu/user_info.sql
@@ -1,17 +1,17 @@
create table user_info
(
- id bigint auto_increment comment '用户ID'
+ id bigint not null comment '用户ID'
primary key,
- username varchar(20) not null,
- password varchar(100) not null,
- status enum ('正常', '未使用', '禁用') default '正常' not null comment '用户状态',
- display_name char(20) not null comment '姓名',
- avatar varchar(512) null comment '头像路径',
- phone char(20) null comment '电话号码',
- email char(40) null comment '电子邮箱',
- created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
- updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
- is_deleted tinyint(1) null comment '是否删除',
+ username varchar(20) not null,
+ password varchar(100) not null,
+ status tinyint default 1 not null comment '0:''禁用'',1:''正常''',
+ display_name char(20) not null comment '姓名',
+ avatar varchar(512) null comment '头像路径',
+ phone char(20) null comment '电话号码',
+ email char(40) null comment '电子邮箱',
+ created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
+ updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
+ is_deleted tinyint(1) null comment '是否删除',
constraint user_info_pk
unique (phone),
constraint user_info_pk2
diff --git a/sql/online_edu/video.sql b/sql/online_edu/video.sql
deleted file mode 100644
index 3ca2816b53a6b9e81bf9932e72f38f5f3e72b197..0000000000000000000000000000000000000000
--- a/sql/online_edu/video.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-create table video
-(
- id bigint not null comment '视频id'
- primary key,
- resource_id bigint null comment '资源id',
- name varchar(20) null comment '分辨率名',
- fileId bigint null comment '文件id'
-)
- comment '视频';
-
diff --git a/src/main/java/com/online/edu/common/PageParam.java b/src/main/java/com/online/edu/common/PageParam.java
index 34cc0cc50b36876e8a89006f05414e080017cfa5..e906ecab34e4bbd70bec1b9d7308284797040df8 100644
--- a/src/main/java/com/online/edu/common/PageParam.java
+++ b/src/main/java/com/online/edu/common/PageParam.java
@@ -23,7 +23,7 @@ public class PageParam implements Serializable {
@Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "页码不能为空")
@Min(value = 1, message = "页码最小值为 1")
- private Integer pageNo = PAGE_NO;
+ private Integer current = PAGE_NO;
@Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@NotNull(message = "每页条数不能为空")
@@ -38,7 +38,7 @@ public class PageParam implements Serializable {
public static Page buildPage(PageParam pageParam, Collection sortingFields) {
// 页码 + 数量
- Page page = new Page<>(pageParam.getPageNo(), pageParam.getPageSize());
+ Page page = new Page<>(pageParam.getCurrent(), pageParam.getPageSize());
// 排序字段
if (!CollectionUtil.isEmpty(sortingFields)) {
page.addOrder(sortingFields.stream().map(sortingField -> SortingField.ORDER_ASC.equals(sortingField.getOrder()) ?
diff --git a/src/main/java/com/online/edu/common/VerifyCodeException.java b/src/main/java/com/online/edu/common/VerifyCodeException.java
deleted file mode 100644
index 39666fb8d073695f41ae8026422fe932083c2e03..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/common/VerifyCodeException.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.online.edu.common;
-
-
-import org.springframework.security.core.AuthenticationException;
-
-public class VerifyCodeException extends AuthenticationException {
-
- public VerifyCodeException(String detail) {
- super(detail);
- }
-}
diff --git a/src/main/java/com/online/edu/config/AlipayConfig.java b/src/main/java/com/online/edu/config/AlipayConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..3df33c0956b4c5e07f69477dd212cd72b43e5f5e
--- /dev/null
+++ b/src/main/java/com/online/edu/config/AlipayConfig.java
@@ -0,0 +1,37 @@
+package com.online.edu.config;
+
+import com.alipay.easysdk.factory.Factory;
+import com.alipay.easysdk.kernel.Config;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AlipayConfig {
+
+ public static final String RETURN_URL = "http://localhost:9530/#/";
+
+ static {
+ Factory.setOptions(getOptions());
+ }
+
+ private static Config getOptions() {
+ Config config = new Config();
+
+ config.protocol = "https";
+
+ // 沙箱环境修改为 openapi.alipaydev.com
+ config.gatewayHost = "openapi-sandbox.dl.alipaydev.com";
+
+ config.signType = "RSA2";
+
+ config.appId = "2021000122667727";
+
+ // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
+ config.merchantPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC328PNsJULeV9L5P1vjgDPW3y9PgkDIXddDMgYbBWAu3GK40SZnmN+GAzGuobuAU6Um28aq4v4j4kLdilb6IdkLj/dEjhXSfJL9RmKOFyV2AevpFAcqhKG4z01DQhJ+KFTxFTxi5SlzfP/N3iXiu98Ju+1jHZK7CnX1AKo4GQeCVpGM7fEU3idhRIfMIJVEphNXxyCY2HU6P8QHKVzSTfYgttR+Snugup+mPk/BzNgkwu7BwnqBdRDA7qoc+4c43/knMZ3M/0y59DSZas1fYxYhzgOUbKfgL/LzvrJRxGMrCQMD4QW0LYNd/qgAMC9wDNsP8azjBp2v7iWSpMoA0GhAgMBAAECggEAaiVKadnkcndj+SD+4ASPmycqYOcLtO8BRos2ikL8NxIAfzquRDIZJpcj6SeO9qFyiIEkJ7WaXaogaKmTPyiD4eaBoFQAiwR6Cjg6wn2/lhLefRzT03issYtHrvUTMAGGwiG7GKiI7SB2GYYg7PydPoQMKDgrox2tGpmf33eM1Xl85/ncU3ri1BY4Zqd+jXOWkog5PhLVfeljxPkZ8J2CbmJXqfuZpfTavQHO7C5gdN7XMP1r6UzBtw7318Tv4lSBjp4LiosNDhtCUxEBSx/+rjELE7PZCMBsq/ZxR8gfpcTvCsKA0VBiJn67Yh4q+2XJA9VVecUbSTVSO3xs3mbhAQKBgQDxKwPk5mpbFyeRSXI2rpzEm1kZQNgdeYjegrsghA2CVm9R0QvJN8dmn2wG8rYRiKzva4btsKr0JOfXx6itf4qW6rwVfqUOMmOtlHxe8VxUUgRrBhSX1kyTdQhVzN4m/AC4ah2aFHzrlY3Fe6Uxf5bCJDHooeRUvQdOYXztmifE2QKBgQDDKnWX1K/i1GJYLbrLyu2jzfY8X3n52B8wV32Cz9evsKYFiVlktXGLRlcqxIAHtFdfrKaymepZa6SmIKj900Gppt/kTsRqRYAoBDcNBCscs/ClUvFtoBVdUo9YDfcIupaMaM1Tgaf2zp9cyQhbWadleHTBr0lkd95/eSZAnNpGCQKBgQDBUoEJoacKJBKExYJ30Rs8A2e19aQIZJ9R9yv4EcMegxkzVccD4uHGIu+e1jsa7RvrxJ9htCgmE9uBvrw5cC7xcXOaK242ZjA/OfNEzGf988002afyW0gBQGSRGuvOBl6xdecK13eYBcei0c4HUsbQE+GqIPR+9RSBQWa6tMNCaQKBgFGD8XvKJPCb/ruP1h56kslBJGDRDBRTtasuT8kMYK0MHjvfw0uyEUu3xH6jdkpBg+D9Lt8YNG7G7A1LROpHi3x9q7QjRhyRDNcp84hnPk6Nxax3uUktfN7utdp0csLdlDXvLBt94xbN9Hf/q5LkHmveZP3k5cWl33PkuRpxqSVpAoGACFT9q+i2M7kjZzw26JN5XOMwsSdp6hH11vN7zRr8WbZPqm0mq5toPsNPZIsJFN6UsR6NQk8iBBBj6vWJLWv6vGiQICr0/OiBF5P1GwMnshMM9iodH63aWYMNc9BuMkdAA0AG4nGxVZzlbLXlPSXl93q4U6psQJ7UOJLM48qWmRM=";
+ //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
+ config.alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2+PaztqivMGAAEm3+tDyVkfJEwQV2Sf7E9nzBvx2dUOgBxJzN/jjoGNyXvMqyC0AW9sUdAWEWgbZ4ktGgp+l05KdoochkWdirXqipoevWrv5n84OmT3R8YxtcoO3AZivJ3jRTLQPLMLAf9BUDBCO1zYaoNwzka1AfXJTIAzIiCYmbiBHlLJWtk/r69Niv61FloCcLk40IZlE6SdVkQZXaRzmRrYn00A/bBS6qmTJCjadnSce4DR+n1XJZhCK1eGB4cBVgP4pxDAAW5hHfU+5YloOfyPb1oP7L3vL/NiyAisC1Uy86kB+t4lVcrlJKdln+eV3ctQmCuLQLEMUctbVoQIDAQAB";
+ //可设置异步通知接收服务地址(可选)
+ config.notifyUrl = "";
+
+ return config;
+ }
+}
diff --git a/src/main/java/com/online/edu/config/MySecurityConfig.java b/src/main/java/com/online/edu/config/MySecurityConfig.java
index 33068eff1bf16eb4fe98906e4adceacc6a440a52..eb08e06bb465dcf6f62cc1af18a6bec6069a1029 100644
--- a/src/main/java/com/online/edu/config/MySecurityConfig.java
+++ b/src/main/java/com/online/edu/config/MySecurityConfig.java
@@ -77,13 +77,13 @@ public class MySecurityConfig extends SecurityConfigurerAdapter {
//先获取用户
UserInfoDAO user = userService.getUserByUsername(username);
- if (user != null && user.getStatus().equals("正常")) {
+ if (user != null && "1".equals(user.getStatus())) {
List permissionList = userService.getUserPermission(user.getId());
return new MyUserDetails(user, permissionList);
}
diff --git a/src/main/java/com/online/edu/utils/S3FileClientConfig.java b/src/main/java/com/online/edu/config/S3FileClientConfig.java
similarity index 98%
rename from src/main/java/com/online/edu/utils/S3FileClientConfig.java
rename to src/main/java/com/online/edu/config/S3FileClientConfig.java
index 7dd632b30176944b898ff2783ac676d7026ce881..945e2bc6c3aa90686e2660cb170b1e6a7a7cfb25 100644
--- a/src/main/java/com/online/edu/utils/S3FileClientConfig.java
+++ b/src/main/java/com/online/edu/config/S3FileClientConfig.java
@@ -1,4 +1,4 @@
-package com.online.edu.utils;
+package com.online.edu.config;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
diff --git a/src/main/java/com/online/edu/controller/banner/BannerController.java b/src/main/java/com/online/edu/controller/banner/BannerController.java
new file mode 100644
index 0000000000000000000000000000000000000000..ac5a9d78199b4a7903a0dcba3c289be6b63e2a80
--- /dev/null
+++ b/src/main/java/com/online/edu/controller/banner/BannerController.java
@@ -0,0 +1,111 @@
+package com.online.edu.controller.banner;
+
+import com.online.edu.common.CommonResult;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.banner.Banner;
+import com.online.edu.entity.banner.vo.BannerQueryVO;
+import com.online.edu.entity.banner.vo.BannerVO;
+import com.online.edu.service.banner.BannerService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.security.PermitAll;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.Min;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Banner控制器
+ */
+@RestController("AdminHmBannerController")
+@RequestMapping("/api/admin/banner")
+@Tag(name = "Banner控制器")
+@CrossOrigin(value = "*")
+
+public class BannerController {
+
+ @Autowired
+ private BannerService bannerService;
+
+ @PostMapping("/list")
+ @Operation(description = "搜索Banner")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+ public CommonResult> query(@RequestBody @Valid BannerQueryVO queryVO) {
+ PageResult result = bannerService.query(queryVO);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "搜索失败");
+ }
+ }
+
+ @PostMapping("/create")
+ @Operation(description = "创建Banner")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+ public CommonResult create(@RequestBody @Valid BannerVO vo) throws IOException {
+ Banner banner = vo.build();
+ boolean result = bannerService.save(banner);
+ if (result) {
+ return CommonResult.success(banner);
+ } else {
+ return CommonResult.error(400, "创建Banner失败");
+ }
+ }
+
+ @PostMapping("/update")
+ @Operation(description = "修改Banner信息")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+ public CommonResult updateProfile(@RequestBody @Valid BannerVO vo) throws IOException {
+ Banner banner = vo.build();
+ boolean result = bannerService.updateById(banner);
+ if (result) {
+ return CommonResult.success(banner);
+ } else {
+ return CommonResult.error(400, "创建Banner失败");
+ }
+ }
+
+
+ @PostMapping("/disable/{bannerId}")
+ @Operation(description = "禁用Banner")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+ public CommonResult disable(@PathVariable("bannerId") @Min(1) Integer bannerId) {
+ return CommonResult.success(bannerService.disable(bannerId));
+
+ }
+
+ @PostMapping("/enable/{bannerId}")
+ @Operation(description = "启用Banner")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+
+ public CommonResult enable(@PathVariable("bannerId") @Min(1) Integer bannerId) {
+ return CommonResult.success(bannerService.enable(bannerId));
+
+ }
+
+ @PostMapping("/delete/{bannerId}")
+ @Operation(description = "删除Banner")
+ @PreAuthorize("hasAuthority('/api/admin/banner')")
+
+ public CommonResult delete(@PathVariable("bannerId") @Min(1) Integer bannerId) {
+ return CommonResult.success(bannerService.delete(bannerId));
+
+ }
+
+ @GetMapping("/get")
+ @Operation(description = "获取所有banner")
+ @PermitAll
+ public CommonResult> getBanners() {
+ return CommonResult.success(bannerService.get());
+ }
+
+}
diff --git a/src/main/java/com/online/edu/controller/course/CommentController.java b/src/main/java/com/online/edu/controller/course/CommentController.java
index 59b63162484bec47ba494d665d119cdae8ceacee..9052ff5641868e292353cf723c933469861a70e3 100644
--- a/src/main/java/com/online/edu/controller/course/CommentController.java
+++ b/src/main/java/com/online/edu/controller/course/CommentController.java
@@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@Tag(name = "评论控制")
@@ -35,6 +36,7 @@ public class CommentController {
@Operation(description = "查询评论")
@PostMapping("/query")
+
public CommonResult> queryComment(@RequestBody @Valid CommentQueryVO commentQueryVO) {
PageResult result = commentService.query(commentQueryVO);
if (result != null) {
@@ -46,7 +48,9 @@ public class CommentController {
@Operation(description = "删除评论")
@DeleteMapping("/delete")
- public CommonResult deleteComment(@RequestParam @Valid @Schema(description = "课程ID") String commentId) {
+ @PreAuthorize("hasAuthority('/comment')")
+
+ public CommonResult deleteComment(@RequestParam @Valid @Schema(description = "评论ID") String commentId) {
boolean result = commentService.setIsDeleted(commentId,1);
if (result) {
@@ -59,13 +63,15 @@ public class CommentController {
@Operation(description = "更新评论")
@PostMapping("/update")
+ @PreAuthorize("hasAuthority('/comment')")
+
public CommonResult updateComment(@RequestBody @Valid Comment comment) {
Comment result = commentService.updateComment(comment);
if (result != null) {
return CommonResult.success(result);
} else {
- return CommonResult.error(400, "删除失败");
+ return CommonResult.error(400, "更新评论失败");
}
}
}
diff --git a/src/main/java/com/online/edu/controller/course/CourseInfoController.java b/src/main/java/com/online/edu/controller/course/CourseInfoController.java
index 28f1bdc62924f85c527ecaf8ef815b6961df8bce..e95b1c57d909a832c15b3b888f60ae2b1bfca64e 100644
--- a/src/main/java/com/online/edu/controller/course/CourseInfoController.java
+++ b/src/main/java/com/online/edu/controller/course/CourseInfoController.java
@@ -4,18 +4,24 @@ package com.online.edu.controller.course;
import com.online.edu.common.CommonResult;
import com.online.edu.common.PageResult;
import com.online.edu.entity.course.CourseInfo;
-import com.online.edu.entity.course.vo.CourseQueryVO;
-import com.online.edu.entity.course.vo.CourseUpdateVO;
-import com.online.edu.entity.course.vo.NewCourseVO;
+import com.online.edu.entity.course.CourseType;
+import com.online.edu.entity.course.vo.*;
import com.online.edu.service.course.CourseInfoService;
+import com.online.edu.service.course.CourseTypeService;
import com.online.edu.service.order.CourseElectionService;
+import com.online.edu.service.rbac.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
@Tag(name = "课程信息控制")
@RestController
@RequestMapping("/course/info")
@@ -23,11 +29,19 @@ import org.springframework.web.bind.annotation.*;
public class CourseInfoController {
@Autowired
private CourseInfoService courseInfoService;
+
+ @Autowired
+ private CourseTypeService typeService;
+
@Autowired
private CourseElectionService courseElectionService;
+ @Autowired
+ private UserService userService;
+
@Operation(description = "添加课程")
@PostMapping("/add")
+ @PreAuthorize("hasAuthority('/course/info/edit')")
public CommonResult addCourse(@RequestBody @Valid NewCourseVO newCourseVO) {
CourseInfo result = courseInfoService.addCourse(newCourseVO);
if (result != null) {
@@ -36,12 +50,14 @@ public class CourseInfoController {
return CommonResult.error(400, "添加失败");
}
}
+
@Operation(description = "获取课程信息")
@GetMapping("/get")
- public CommonResult getCourse(@RequestParam @Valid @Schema(description = "课程ID") String courseId) {
- CourseInfo courseInfo= courseInfoService.getById(courseId);
+ public CommonResult getCourse(@RequestParam @Valid @Schema(description = "课程ID") String courseId) {
+ CourseInfo courseInfo = courseInfoService.getById(courseId);
+
if (courseInfo != null) {
- return CommonResult.success(courseInfo);
+ return CommonResult.success(courseInfoService.convertToVO(courseInfo));
} else {
return CommonResult.error(400, "查询失败");
}
@@ -49,8 +65,31 @@ public class CourseInfoController {
@Operation(description = "获取课程信息")
@PostMapping("/query")
- public CommonResult > queryCourse(@RequestBody @Valid CourseQueryVO courseQueryVO) {
- PageResult courseInfo= courseInfoService.query(courseQueryVO);
+ @PermitAll
+ public CommonResult> queryCourse(@RequestBody @Valid CourseQueryVO courseQueryVO,
+ Authentication authentication) {
+ if (authentication == null) {
+ return CommonResult.success(new PageResult<>(0L));
+ }
+ PageResult courseInfo = courseInfoService.query(courseQueryVO);
+ if (courseInfo != null) {
+ return CommonResult.success(courseInfoService.convertToVO(courseInfo));
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+ @Operation(description = "获取课程基本信息")
+ @GetMapping("/list/base")
+ @PreAuthorize("hasAuthority('/course/info/edit')")
+
+ public CommonResult > listBase(Authentication authentication) {
+ String username = authentication.getName();
+ if(username == null){
+ return CommonResult.error(401, "未登录");
+ }
+ String teacherId = userService.getUserByUsername(username).getId();
+ List courseInfo= courseInfoService.listAll(teacherId);
if (courseInfo != null) {
return CommonResult.success(courseInfo);
} else {
@@ -58,20 +97,25 @@ public class CourseInfoController {
}
}
+
@Operation(description = "更新课程信息")
@PostMapping("/update")
+ @PreAuthorize("hasAuthority('/course/info/edit')")
+
public CommonResult updateCourse(@RequestBody @Valid CourseUpdateVO courseUpdateVO) {
CourseInfo result = courseInfoService.updateCourse(courseUpdateVO);
if (result != null) {
return CommonResult.success(result);
} else {
- return CommonResult.error(400, "更新失败");
+ return CommonResult.error(400, "课程信息没有更新");
}
}
@Operation(description = "删除课程")
@DeleteMapping("/delete")
+ @PreAuthorize("hasAuthority('/course/info/edit')")
+
public CommonResult deleteCourse(@RequestParam @Valid @Schema(description = "课程ID") String courseId) {
boolean result = courseInfoService.setIsDeleted(courseId,1);
@@ -84,6 +128,8 @@ public class CourseInfoController {
@Operation(description = "修改课程状态")
@PostMapping("/status")
+ @PreAuthorize("hasAuthority('/course/info/status')")
+
public CommonResult updateCourseStatus(@RequestParam @Valid @Schema(description = "课程ID") String courseId,
@RequestParam @Valid @Schema(description = "课程状态") Integer status) {
@@ -95,6 +141,70 @@ public class CourseInfoController {
}
}
+ @Operation(description = "获取课程类型列表")
+ @GetMapping("/type")
+ @PermitAll
+ public CommonResult> getCourseType() {
+ List types = typeService.list();
+ if (types != null) {
+ return CommonResult.success(types);
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+ @Operation(description = "查询课程类型列表")
+ @PostMapping("/type/query")
+ public CommonResult> queryCourseType(@RequestBody @Valid CourseTypeQueryVO queryVO) {
+ PageResult types = typeService.query(queryVO);
+ if (types != null) {
+ return CommonResult.success(types);
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+ @Operation(description = "新增课程类型")
+ @PostMapping("/type/add")
+ @PreAuthorize("hasAuthority('/course/info')")
+
+ public CommonResult addCourseType(@RequestBody @Valid CourseType courseType) {
+ boolean result = typeService.addCourseType(courseType);
+ if (result) {
+ return CommonResult.success(courseType);
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+ @Operation(description = "更新课程类型")
+ @PostMapping("/type/update")
+ @PreAuthorize("hasAuthority('/course/info')")
+
+ public CommonResult updateCourseType(@RequestBody @Valid CourseType courseType) {
+ boolean result = typeService.updateCourseType(courseType);
+
+ if (result) {
+ return CommonResult.success(courseType);
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+ @Operation(description = "删除课程类型")
+ @DeleteMapping("/type/delete")
+ @PreAuthorize("hasAuthority('/course/info')")
+
+ public CommonResult deleteCourseType(@RequestParam @Valid @Schema(name = "类型ID") String id) {
+ boolean result = typeService.removeById(id);
+ if (result) {
+ return CommonResult.success(id + "已删除");
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+ }
+
+
}
diff --git a/src/main/java/com/online/edu/controller/message/MessageController.java b/src/main/java/com/online/edu/controller/message/MessageController.java
index 88513e7d3220b1b272533e580791cf7cff1e3ea4..345b83dfa1b34d3971a8faebc1deaa720871d163 100644
--- a/src/main/java/com/online/edu/controller/message/MessageController.java
+++ b/src/main/java/com/online/edu/controller/message/MessageController.java
@@ -2,15 +2,18 @@ package com.online.edu.controller.message;
import com.online.edu.common.CommonResult;
-import com.online.edu.entity.message.Message;
+import com.online.edu.entity.message.vo.MessageVO;
import com.online.edu.service.message.MessageService;
-import com.online.edu.service.order.CourseElectionService;
+import com.online.edu.service.rbac.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
+import java.util.HashMap;
+import java.util.List;
+
@Tag(name = "消息控制")
@RestController
@RequestMapping("/message")
@@ -18,19 +21,77 @@ import org.springframework.web.bind.annotation.*;
public class MessageController {
@Autowired
private MessageService messageService;
+
@Autowired
- private CourseElectionService courseElectionService;
+ private UserService userService;
- @Operation(description = "添加消息")
- @PostMapping("/add")
- public CommonResult addCourse(@RequestBody @Valid Message message) {
- //TODO:建立VO
- boolean success = messageService.save(message);
+ @Operation(description = "查看消息")
+ @GetMapping("/list")
+ public CommonResult> list(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String userId = userService.getUserByUsername(username).getId();
+ List messages = messageService.listRecieved(userId);
+ if (messages != null) {
+ return CommonResult.success(messages);
+ }
+ return CommonResult.error(400, "查看消息失败");
+ }
+
+ @Operation(description = "检查是否有未读消息")
+ @GetMapping("/check")
+ public CommonResult> checkCount(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String userId = userService.getUserByUsername(username).getId();
+ Long messages = messageService.countUnread(userId);
+ if (messages != null) {
+ return CommonResult.success("count", messages);
+ }
+ return CommonResult.error(400, "查看消息失败");
+ }
+
+ @Operation(description = "标记消息为已读")
+ @GetMapping("/read")
+ public CommonResult markAsRead(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String userId = userService.getUserByUsername(username).getId();
+ Long messages = messageService.markAsRead(userId);
+ return CommonResult.success("标记为已读");
+ }
+
+ @Operation(description = "删除单条消息")
+ @DeleteMapping("/delete/{id}")
+ public CommonResult delete(@PathVariable("id") String id, Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String userId = userService.getUserByUsername(username).getId();
+ boolean success = messageService.delete(id, userId);
if (success) {
- return CommonResult.success(message);
- } else {
- return CommonResult.error(400, "添加失败");
+ return CommonResult.success("已移除" + id);
+ }
+ return CommonResult.error(400, "移除失败");
+ }
+
+ @Operation(description = "清空所有消息")
+ @DeleteMapping("/clear")
+ public CommonResult clear(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
}
+ String userId = userService.getUserByUsername(username).getId();
+ boolean messages = messageService.clear(userId);
+ return CommonResult.success("标记为已读");
}
}
diff --git a/src/main/java/com/online/edu/controller/message/MessageTemplateController.java b/src/main/java/com/online/edu/controller/message/MessageTemplateController.java
deleted file mode 100644
index 01ce006afcb911c732e607cb4524288f1014cd8c..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/controller/message/MessageTemplateController.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.online.edu.controller.message;
-
-
-import com.online.edu.common.CommonResult;
-import com.online.edu.entity.message.MessageTemplate;
-import com.online.edu.service.message.MessageTemplateService;
-import com.online.edu.service.order.CourseElectionService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.validation.Valid;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-@Tag(name = "消息模板控制")
-@RestController
-@RequestMapping("/admin/messageTemplate")
-@CrossOrigin(value = "*")
-public class MessageTemplateController {
- @Autowired
- private MessageTemplateService messageTemplateService;
- @Autowired
- private CourseElectionService courseElectionService;
-
- @Operation(description = "添加消息模板")
- @PostMapping("/add")
- public CommonResult addCourse(@RequestBody @Valid MessageTemplate messageTemplate) {
- //TODO:建立VO
- boolean success = messageTemplateService.save(messageTemplate);
- if (success) {
- return CommonResult.success(messageTemplate);
- } else {
- return CommonResult.error(400, "添加失败");
- }
- }
-
-}
-
-
diff --git a/src/main/java/com/online/edu/controller/order/CourseElectionController.java b/src/main/java/com/online/edu/controller/order/CourseElectionController.java
index 71242d5743a07b4881fb4dd47d04651b9053414d..c54ad048775d666427941c8b21d0f4b741d1f153 100644
--- a/src/main/java/com/online/edu/controller/order/CourseElectionController.java
+++ b/src/main/java/com/online/edu/controller/order/CourseElectionController.java
@@ -3,11 +3,18 @@ package com.online.edu.controller.order;
import com.online.edu.common.CommonResult;
import com.online.edu.entity.order.CourseElection;
+import com.online.edu.entity.order.CourseOrder;
import com.online.edu.service.order.CourseElectionService;
+import com.online.edu.service.order.CourseOrderService;
+import com.online.edu.service.order.impl.AlipayService;
+import com.online.edu.service.rbac.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
@Tag(name = "选课控制")
@@ -19,18 +26,67 @@ public class CourseElectionController {
@Autowired
private CourseElectionService courseElectionService;
+ @Autowired
+ private AlipayService alipayService;
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private CourseOrderService courseOrderService;
+
@Operation(description = "添加选课记录")
- @PostMapping("/add")
- public CommonResult addCourse(@RequestBody @Valid CourseElection courseElection) {
- //TODO:建立VO
- boolean success = courseElectionService.save(courseElection);
- if (success) {
- return CommonResult.success(courseElection);
+ @PostMapping("/election")
+ @PreAuthorize("hasAuthority('/course/election')")
+ public CommonResult electCourse(@RequestParam @NotEmpty String courseId, Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String studentId = userService.getUserByUsername(username).getId();
+
+ CourseElection courseElection = courseElectionService.lambdaQuery().eq(CourseElection::getCourseId, courseId)
+ .eq(CourseElection::getStudentId, studentId).one();
+ if (courseElection != null) {
+ if (courseElection.getStatus() == 0) {
+ return CommonResult.success(courseOrderService.lambdaQuery()
+ .eq(CourseOrder::getSerialNumber, courseElection.getSerialNumber()).one());
+ } else {
+ return CommonResult.error(400, "已经完成支付");
+ }
+ }
+
+ CourseOrder result = courseElectionService.electCourse(courseId, studentId);
+ if (result != null) {
+ return CommonResult.success(result);
} else {
return CommonResult.error(400, "添加失败");
}
}
+
+ /**
+ * 根据课程id与学生id查询选课结果
+ */
+
+ @GetMapping("/inCourse")
+ public CommonResult check(@RequestParam @Valid String courseId, Authentication authentication) throws Exception {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String studentId = userService.getUserByUsername(username).getId();
+ CourseElection election = courseElectionService.lambdaQuery().eq(CourseElection::getCourseId, courseId)
+ .eq(CourseElection::getStudentId, studentId).one();
+ if (election == null) {
+ return CommonResult.success(false);
+ }
+ alipayService.queryTradeStatus(election.getSerialNumber());
+
+ return CommonResult.success(election.getStatus() == 1);
+ }
+
+
}
diff --git a/src/main/java/com/online/edu/controller/order/CourseOrderController.java b/src/main/java/com/online/edu/controller/order/CourseOrderController.java
index c3d6a1ae19fdb8e5d92c4b2d1251a61658b6278e..4991d0882a7d1683548e29c78d0bb131d10d4aa0 100644
--- a/src/main/java/com/online/edu/controller/order/CourseOrderController.java
+++ b/src/main/java/com/online/edu/controller/order/CourseOrderController.java
@@ -2,40 +2,118 @@ package com.online.edu.controller.order;
import com.online.edu.common.CommonResult;
+import com.online.edu.common.PageResult;
import com.online.edu.entity.order.CourseElection;
import com.online.edu.entity.order.CourseOrder;
+import com.online.edu.entity.order.vo.CourseElectionQueryVO;
+import com.online.edu.entity.order.vo.CourseOrderListVO;
+import com.online.edu.entity.order.vo.CourseOrderVO;
import com.online.edu.service.order.CourseElectionService;
import com.online.edu.service.order.CourseOrderService;
+import com.online.edu.service.order.impl.AlipayService;
+import com.online.edu.service.rbac.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
+import java.util.List;
+
@Tag(name = "订单控制")
@RestController
@RequestMapping("/course/order")
@CrossOrigin(value = "*")
public class CourseOrderController {
+
@Autowired
private CourseElectionService courseElectionService;
+ @Autowired
+ private AlipayService alipayService;
+
+ @Autowired
+ private UserService userService;
+
+
@Autowired
private CourseOrderService courseOrderService;
- @Operation(description = "添加订单")
- @PostMapping("/add")
- public CommonResult add(@RequestBody @Valid CourseOrder courseOrder) {
- //TODO:建立VO
- boolean success = courseOrderService.save(courseOrder);
- if (success) {
- return CommonResult.success(courseOrder);
+ /**
+ * 支付
+ */
+
+ @Operation(description = "支付")
+ @PostMapping("/topay")
+ @PreAuthorize("hasAuthority('/course/order/topay')")
+ public CommonResult toPay(@RequestBody @Valid CourseOrderVO courseOrderVO) throws Exception {
+ String subject = "course";
+ String serialNumber = courseOrderVO.getSerialNumber();
+ BigDecimal money = courseOrderService.lambdaQuery()
+ .eq(CourseOrder::getSerialNumber, courseOrderVO.getSerialNumber()).one().getPrice();
+ String form = alipayService.toPay(subject, serialNumber, money);
+ return CommonResult.success(form);
+ }
+
+
+ /**
+ * 根据id查询结果
+ */
+ @GetMapping("/selectbyid")
+ @PreAuthorize("hasAuthority('/course/order/selectbyid')")
+ public CommonResult> selectCoursebyid(Authentication authentication) {
+
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String studentId = userService.getUserByUsername(username).getId();
+
+ List elections = courseElectionService.lambdaQuery()
+ .eq(CourseElection::getStudentId, studentId).list();
+ if (elections != null) {
+
+
+ return CommonResult.success(courseOrderService.buildVO(elections));
} else {
- return CommonResult.error(400, "添加失败");
+ return CommonResult.error(400, "查询失败");
}
}
+ /**
+ * 查询全部结果
+ */
+
+ @PostMapping("/list")
+ @PreAuthorize("hasAuthority('/course/order/list')")
+ public CommonResult> query(@RequestBody @Valid CourseElectionQueryVO queryVO) {
+ PageResult courses = courseOrderService.query(queryVO);
+ List elections = courses.getList();
+ if (elections != null) {
+ List result = courseOrderService.buildVO(elections);
+
+ return CommonResult.success(new PageResult<>(result, courses.getTotal()));
+ } else {
+ return CommonResult.error(400, "查询失败");
+ }
+
+ }
+
+
+ /**
+ * 根据订单号查询支付结果
+ */
+
+ @PostMapping("/query")
+ @Operation(description = "根据订单号查询支付结果")
+ public Object queryTradeStatus(@NotNull String serialNumber) throws Exception {
+ return alipayService.queryTradeStatus(serialNumber);
+ }
}
diff --git a/src/main/java/com/online/edu/controller/rbac/PermissionController.java b/src/main/java/com/online/edu/controller/rbac/PermissionController.java
index 29ba1ceb11e5f01291c9347a675ed6955c8a523f..cf6a970db4298abf8003f565ac806e5f043d2775 100644
--- a/src/main/java/com/online/edu/controller/rbac/PermissionController.java
+++ b/src/main/java/com/online/edu/controller/rbac/PermissionController.java
@@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -25,6 +26,7 @@ public class PermissionController {
@Operation(description = "新建权限")
@RequestMapping(method = RequestMethod.POST, value = "/add", produces = "application/json")
+ @PreAuthorize("hasAuthority('/rbac')")
public CommonResult addPermission(@RequestBody @Valid PermissionVO permissionVO) {
boolean success = permissionService.addPermission(permissionVO);
@@ -38,6 +40,8 @@ public class PermissionController {
@Operation(description = "查询所有权限")
@GetMapping("/list")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult> listPermission() {
List result = permissionService.getAll();
@@ -50,6 +54,8 @@ public class PermissionController {
@Operation(description = "更新权限")
@PostMapping("/updateURL")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult updatePermission(@RequestBody @Valid PermissionVO permissionVO) {
boolean result = permissionService.updateUrl(permissionVO);
@@ -62,6 +68,8 @@ public class PermissionController {
@Operation(description = "查询特定权限")
@GetMapping("/get")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult getPermission(@NotNull String id) {
List result = permissionService.getById(id);
@@ -74,6 +82,8 @@ public class PermissionController {
@Operation(description = "删除特定权限")
@GetMapping("/delete")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult deletePermission(@NotNull @Schema(description = "权限名",
defaultValue = "test") String name) {
boolean result = permissionService.deletePermission(name);
@@ -87,6 +97,8 @@ public class PermissionController {
@Operation(description = "查询所有具有该权限的角色")
@GetMapping("/getPermissions")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult> getRoleNameByPermission(@NotNull @Schema(description = "权限Id",
defaultValue = "1") String permissionId) {
List result = permissionService.getRoleNameByPermission(permissionId);
diff --git a/src/main/java/com/online/edu/controller/rbac/RoleController.java b/src/main/java/com/online/edu/controller/rbac/RoleController.java
index 0ecfc4534dace29173bad5155204fa613dfe72b2..6cb584998b40f92f82a56a49e1c81cb73803b4e6 100644
--- a/src/main/java/com/online/edu/controller/rbac/RoleController.java
+++ b/src/main/java/com/online/edu/controller/rbac/RoleController.java
@@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -27,6 +28,8 @@ public class RoleController {
@Operation(description = "新建角色")
@PostMapping("/add")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult addRole(@RequestBody @Valid NewRoleVO newRoleVO) {
boolean success = roleInfoService.addRole(newRoleVO);
@@ -39,6 +42,8 @@ public class RoleController {
@Operation(description = "查询所有角色")
@GetMapping("/list")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult> listRole() {
List result = roleInfoService.listRole();
@@ -51,6 +56,8 @@ public class RoleController {
@Operation(description = "重命名")
@PostMapping("/rename")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult rename(@RequestParam @NotNull @Schema(description = "新角色名",
defaultValue = "new") String newName, @RequestParam @NotNull @Schema(description = "旧角色名",
defaultValue = "old") String oldName) {
@@ -65,6 +72,8 @@ public class RoleController {
@Operation(description = "查询特定角色")
@GetMapping("/get")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult getRole(@NotNull String id) {
String result = roleInfoService.getNameById(id);
@@ -77,6 +86,8 @@ public class RoleController {
@Operation(description = "删除特定角色")
@GetMapping("/delete")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult deleteRole(@NotNull @Schema(description = "角色id",
defaultValue = "1") String id) {
boolean result = roleInfoService.deleteRole(id);
@@ -90,6 +101,8 @@ public class RoleController {
@Operation(description = "为特定角色提供权限")
@PostMapping("/addPermission")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult addPermission(@RequestParam @NotNull @Schema(description = "角色id",
defaultValue = "1") String roleId, @RequestParam @NotNull @Schema(description = "权限id",
defaultValue = "1") String permissionId) {
@@ -103,6 +116,8 @@ public class RoleController {
@Operation(description = "获取特定角色权限")
@PostMapping("/getPermission")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult> getPermission(@RequestParam @NotNull @Schema(description = "角色id",
defaultValue = "1") String roleId) {
List result = roleInfoService.getPermissions(roleId);
@@ -115,6 +130,8 @@ public class RoleController {
@Operation(description = "获取特定角色权限")
@PostMapping("/delPermission")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult delPermission(@RequestParam @NotNull @Schema(description = "角色id",
defaultValue = "1") String roleId, @RequestParam @NotNull @Schema(description = "权限id",
defaultValue = "1") String permissionId) {
diff --git a/src/main/java/com/online/edu/controller/rbac/UserController.java b/src/main/java/com/online/edu/controller/rbac/UserController.java
index d376b4327fb1ff90164bc1dde95557a205572146..b95e983e44d13b395ad47c7548769f83168f6722 100644
--- a/src/main/java/com/online/edu/controller/rbac/UserController.java
+++ b/src/main/java/com/online/edu/controller/rbac/UserController.java
@@ -2,18 +2,22 @@ package com.online.edu.controller.rbac;
import com.online.edu.common.CommonResult;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.rbac.UserInfo;
import com.online.edu.entity.rbac.UserInfoDAO;
-import com.online.edu.entity.rbac.vo.NewUserVO;
-import com.online.edu.entity.rbac.vo.PermissionMenuVO;
-import com.online.edu.entity.rbac.vo.UserInfoVO;
-import com.online.edu.entity.rbac.vo.UserLoginVO;
+import com.online.edu.entity.rbac.vo.*;
+import com.online.edu.entity.userInfo.vo.RegisterVO;
import com.online.edu.service.rbac.AuthService;
+import com.online.edu.service.rbac.RoleInfoService;
import com.online.edu.service.rbac.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.security.PermitAll;
+import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
+import org.hibernate.validator.constraints.Length;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
@@ -21,7 +25,6 @@ import org.springframework.security.core.annotation.CurrentSecurityContext;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
-import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Set;
@@ -35,8 +38,13 @@ public class UserController {
@Autowired
private AuthService authService;
- @Operation(description = "新建用户")
+ @Autowired
+ private RoleInfoService roleInfoService;
+
+ @Operation(description = "管理员新建用户")
@PostMapping("/add")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult addUser(@RequestBody @Valid NewUserVO newUserVO) {
boolean success = authService.addUser(newUserVO);
@@ -47,9 +55,24 @@ public class UserController {
}
}
+
+ @Operation(description = "注册用户")
+ @PostMapping("/register")
+ @PermitAll
+ public CommonResult register(@RequestBody @Valid RegisterVO registerVO) {
+
+ boolean success = authService.addUser(registerVO);
+ if (success) {
+ return CommonResult.success(registerVO);
+ } else {
+ return CommonResult.error(400, "添加失败");
+ }
+ }
+
@Operation(description = "查看用户列表")
@GetMapping("/list")
- @PreAuthorize("hasAuthority('test')")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult> list(@RequestParam(required = false) @Valid
@Schema(description = "待查看状态id") List targetStatus) {
List result;
@@ -67,15 +90,32 @@ public class UserController {
}
+ @Operation(description = "查看用户信息")
+ @GetMapping("/getById")
+
+ public CommonResult getById(@RequestParam @Valid
+ @Schema(description = "待查看用户Id") String userId) {
+
+ UserInfo result = userService.getById(userId);
+ if (result != null) {
+ result.setPassword(null);
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "查看用户信息失败");
+ }
+ }
+
@Operation(description = "查看用户信息")
@GetMapping("/get")
- @PreAuthorize("hasAuthority('test')")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult get(@RequestParam(required = false) @Valid
@Schema(description = "待查看用户名") String username) {
-
UserInfoDAO result = userService.getUserByUsername(username);
if (result != null) {
+ result.setPassword(null);
+ result.setRoles(roleInfoService.getRoleIdByUser(result.getId()));
return CommonResult.success(result);
} else {
return CommonResult.error(400, "查看用户信息失败");
@@ -84,11 +124,31 @@ public class UserController {
@Operation(description = "查看自身信息")
@GetMapping("/get/self")
-
+ @PermitAll
public CommonResult getSelf(@CurrentSecurityContext(expression = "authentication")
Authentication authentication) {
+ if (authentication == null || authentication.getName() == null) {
+ return CommonResult.success(null);
+ }
+ UserInfoDAO result = userService.getUserByUsername(authentication.getName());
+
+ if (result != null) {
+ result.setPassword(null);
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "查看自身信息失败");
+ }
+ }
+
+ @Operation(description = "查看自身信息")
+ @GetMapping("/info")
+
+ public CommonResult info(@CurrentSecurityContext(expression = "authentication")
+ Authentication authentication) {
UserInfoDAO result = userService.getUserByUsername(authentication.getName());
+
if (result != null) {
+ result.setPassword(null);
return CommonResult.success(result);
} else {
return CommonResult.error(400, "查看自身信息失败");
@@ -96,7 +156,9 @@ public class UserController {
}
@Operation(description = "删除用户")
- @GetMapping("/delete")
+ @PostMapping("/delete")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult delete(@RequestParam @Valid
@Schema(description = "待删除用户名") String username) {
boolean result = userService.delUser(username);
@@ -108,47 +170,122 @@ public class UserController {
}
}
+ @Operation(description = "恢复用户")
+ @PostMapping("/recover")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult recover(@RequestParam @Valid
+ @Schema(description = "待恢复用户名") String username) {
+ boolean result = userService.recoverUser(username);
+
+ if (result) {
+ return CommonResult.success(username + "已经恢复用户");
+ } else {
+ return CommonResult.error(400, username + "恢复用户失败");
+ }
+ }
+
@Operation(description = "登录")
@PostMapping("/login")
- public CommonResult login(@RequestBody @Valid UserLoginVO userLoginVO, @RequestParam("code") String code, HttpSession session, Model model) {
- return CommonResult.success(authService.login(userLoginVO, code, session, model));
+ @PermitAll
+ public CommonResult login(@RequestBody @Valid UserLoginVO userLoginVO, HttpSession session, Model model) {
+ if (!authService.checkStatus(userLoginVO.getUsername())) {
+ return CommonResult.error(403, "当前用户被禁用");
+ }
+ String token = authService.login(userLoginVO, session, model);
+ if (token != null) {
+ return CommonResult.success(token);
+ } else {
+ return CommonResult.error(401, "登录失败");
+ }
}
- @Operation(description = "更新用户显示名")
- @PostMapping("/update/display")
- public CommonResult updateDisplayName(@RequestParam @NotNull
- @Schema(description = "新显示名") String displayName,
- @RequestParam @NotNull
- @Schema(description = "用户名") String username) {
- boolean result = userService.updateDisplayName(displayName, username);
+
+ @Operation(description = "管理员登录")
+ @PostMapping("/admin/login")
+ @PermitAll
+ public CommonResult adminLogin(@RequestBody @Valid UserLoginVO userLoginVO, HttpSession session, Model model) {
+ if (!authService.checkStatus(userLoginVO.getUsername())) {
+ return CommonResult.error(403, "当前用户被禁用");
+ }
+ String token = authService.adminLogin(userLoginVO, session, model);
+ if (token != null) {
+ return CommonResult.success(token);
+ } else {
+ return CommonResult.error(401, "登录失败");
+ }
+ }
+
+
+ @Operation(description = "更新用户")
+ @PostMapping("/update")
+ public CommonResult update(@RequestBody @Valid
+ @Schema(description = "更新数据") UserUpdateVO userUpdateVO,
+ Authentication authentication) {
+ if (!authentication.getName().equals(userUpdateVO.getUsername())) {
+ return CommonResult.error(403, "更新失败");
+ }
+ UserInfoDAO result = userService.update(userUpdateVO);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "更新失败");
+ }
+ }
+
+ @Operation(description = "管理员更新用户")
+ @PostMapping("/update/admin")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult update(@RequestBody @Valid
+ @Schema(description = "更新数据") UserUpdateVO userUpdateVO) {
+
+ UserInfoDAO result = userService.update(userUpdateVO);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "更新失败");
+ }
+ }
+
+ @Operation(description = "更新用户状态: 启用")
+ @PostMapping("/enable")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult enable(@RequestParam @NotNull
+ @Schema(description = "用户名") String username) {
+ boolean result = userService.updateStatus(1, username);
if (result) {
- return CommonResult.success(username + "更新为" + displayName);
+ return CommonResult.success(username + "更新为" + 1);
} else {
return CommonResult.error(400, "更新失败");
}
}
- @Operation(description = "更新用户状态")
- @PostMapping("/update/status")
- public CommonResult updateStatus(@RequestParam @NotNull
- @Schema(description = "新状态", allowableValues = {"1", "2", "3"}) int newStatus,
- @RequestParam @NotNull
- @Schema(description = "用户名") String username) {
- boolean result = userService.updateStatus(newStatus, username);
+ @Operation(description = "更新用户状态: 禁用")
+ @PostMapping("/disable")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult disable(@RequestParam @NotNull
+ @Schema(description = "用户名") String username) {
+ boolean result = userService.updateStatus(0, username);
if (result) {
- return CommonResult.success(username + "更新为" + newStatus);
+ return CommonResult.success(username + "更新为" + 0);
} else {
return CommonResult.error(400, "更新失败");
}
}
- @Operation(description = "更新用户状态")
+
+ @Operation(description = "更新用户密码")
@PostMapping("/update/password")
public CommonResult updatePassword(@RequestParam @NotNull
- @Schema(description = "新密码") String newPassword,
+ @Schema(description = "新密码") @Length(min = 6) String newPassword,
@RequestParam @NotNull
- @Schema(description = "用户名") String username) {
- boolean result = authService.updatePassword(newPassword, username);
+ @Schema(description = "原密码") String oldPassword,
+ Authentication authentication) {
+ String username = authentication.getName();
+ boolean result = authService.updatePassword(newPassword, oldPassword, username);
if (result) {
return CommonResult.success(username + "的密码已经更新");
} else {
@@ -157,8 +294,26 @@ public class UserController {
}
+ @Operation(description = "强制更新用户密码")
+ @PostMapping("/update/password/admin")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult forceUpdatePassword(@RequestParam @NotNull
+ @Schema(description = "新密码") @Length(min = 6) String newPassword,
+ @RequestParam @NotNull
+ @Schema(description = "用户名") String username) {
+ boolean result = authService.updatePassword(newPassword, username);
+ if (result) {
+ return CommonResult.success(username + "的密码已经更新");
+ } else {
+ return CommonResult.error(400, "更新失败");
+ }
+ }
+
@Operation(description = "添加用户角色")
@PostMapping("/addRole")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult addUserRole(@RequestParam @NotNull
@Schema(description = "用户Id") String userId,
@RequestParam @NotNull
@@ -174,6 +329,8 @@ public class UserController {
@Operation(description = "删除用户角色")
@PostMapping("/delRole")
+ @PreAuthorize("hasAuthority('/rbac')")
+
public CommonResult delUserRole(@RequestParam @NotNull
@Schema(description = "用户Id") String userId,
@RequestParam @NotNull
@@ -186,6 +343,19 @@ public class UserController {
}
}
+ @Operation(description = "查询用户信息")
+ @PostMapping("/query")
+ @PreAuthorize("hasAuthority('/rbac')")
+
+ public CommonResult> queryUser(@RequestBody @Valid UserQueryVO userQueryVO) {
+ PageResult result = userService.query(userQueryVO);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "删除失败");
+ }
+ }
+
@Operation(description = "获取当前用户菜单")
@PostMapping("/getMenu")
@@ -203,6 +373,14 @@ public class UserController {
}
}
+ @Operation(description = "登出")
+ @PostMapping("/logout")
+ @PermitAll
+ public CommonResult logout(@CurrentSecurityContext(expression = "authentication")
+ Authentication authentication) {
+ return CommonResult.success(authentication.getName());
+ }
+
}
diff --git a/src/main/java/com/online/edu/controller/resource/CourseSectionController.java b/src/main/java/com/online/edu/controller/resource/CourseSectionController.java
index 013ffe94cb0ad4fb1d5e5120c9f7b3c617345500..1e11016adf4cd6f67a2054e41ef503f644ca1447 100644
--- a/src/main/java/com/online/edu/controller/resource/CourseSectionController.java
+++ b/src/main/java/com/online/edu/controller/resource/CourseSectionController.java
@@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@@ -29,8 +30,9 @@ public class CourseSectionController {
@Operation(description = "添加课程章节")
@PostMapping("/add")
+ @PreAuthorize("hasAuthority('/course/section')")
+
public CommonResult> addCourseSection(@RequestBody @Valid CourseSection section) {
- //TODO:建立VO
boolean success = courseSectionService.save(section);
if (success) {
return CommonResult.success(courseSectionService.listByCourseId(section.getCourseId(),null));
@@ -42,9 +44,15 @@ public class CourseSectionController {
@Operation(description = "删除课程章节")
@DeleteMapping("/delete")
+ @PreAuthorize("hasAuthority('/course/section')")
public CommonResult delCourseSection(@RequestParam @Schema(description = "待删除id")
@NotNull String sectionId) {
- boolean success = courseSectionService.removeById(sectionId);
+ boolean success;
+ try {
+ success = courseSectionService.removeById(sectionId);
+ } catch (Exception e) {
+ return CommonResult.error(200, "删除失败,请先删除本节所有资源");
+ }
if (success) {
return CommonResult.success(sectionId);
} else {
@@ -54,6 +62,7 @@ public class CourseSectionController {
@Operation(description = "修改可用章节")
@PostMapping("/set")
+ @PreAuthorize("hasAuthority('/course/section')")
public CommonResult> setCourseSection(@RequestBody @Valid CourseSectionSetVO sectionSetVO) {
boolean success = courseSectionService.updateOrder(sectionSetVO.getInUse(),sectionSetVO.getCourseId());
if (success) {
@@ -65,6 +74,7 @@ public class CourseSectionController {
@Operation(description = "修改章节信息")
@PostMapping("/update")
+ @PreAuthorize("hasAuthority('/course/section')")
public CommonResult update(@RequestBody @Valid CourseSection section) {
boolean success = courseSectionService.updateById(section);
if (success) {
@@ -79,12 +89,13 @@ public class CourseSectionController {
public CommonResult> list(@RequestParam @Schema(description = "对应课程",requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull String courseId) {
List list = new ArrayList<>();
- list.add(1);
+
return CommonResult.success(courseSectionService.listByCourseId(String.valueOf(courseId),list));
}
@Operation(description = "显示所有章节")
@GetMapping("/list/all")
+
public CommonResult> listAll(@RequestParam @Schema(description = "对应课程",requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull String courseId) {
return CommonResult.success(courseSectionService.listByCourseId(courseId,null));
diff --git a/src/main/java/com/online/edu/controller/resource/FileController.java b/src/main/java/com/online/edu/controller/resource/FileController.java
index 6aaa0fcfd9cb8b2453e2c035ee96da4bde424aaf..f001f70599b2eee51a52101bca4698698fd5c7ec 100644
--- a/src/main/java/com/online/edu/controller/resource/FileController.java
+++ b/src/main/java/com/online/edu/controller/resource/FileController.java
@@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -36,6 +37,7 @@ public class FileController {
@Operation(description = "直接上传文件")
@PostMapping("/add")
+ @PreAuthorize("hasAuthority('/file/add')")
public CommonResult addDirect(@RequestParam("file") MultipartFile file, Authentication authentication) throws Exception {
String userId = userService.getUserByUsername(authentication.getName()).getId();
if(file == null){
@@ -49,13 +51,52 @@ public class FileController {
}
}
+ @Operation(description = "上传图片文件")
+ @PostMapping("/upload/picture")
+ @PreAuthorize("hasAuthority('/file/upload/picture')")
+
+ public CommonResult uploadPicture(@RequestParam("file") MultipartFile file, Authentication authentication) throws Exception {
+ String userId = userService.getUserByUsername(authentication.getName()).getId();
+ if(file == null){
+ return CommonResult.error(400, "添加失败");
+ }
+ OSSFile result = ossFileService.uploadPicture(file, userId);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "添加失败");
+ }
+ }
+
+ @Operation(description = "更新用户头像")
+ @PostMapping("/update/avatar")
+ @PreAuthorize("hasAuthority('/file/upload/picture')")
+
+ public CommonResult updateAvatar(@RequestParam("file") MultipartFile file, Authentication authentication) throws Exception {
+ String userId = userService.getUserByUsername(authentication.getName()).getId();
+ if (file == null) {
+ return CommonResult.error(400, "添加失败");
+ }
+ OSSFile result = ossFileService.uploadPicture(file, userId);
+ if (result != null) {
+ String url = "http://" + result.getPath();
+ url = userService.updateAvatarUrl(url, userId);
+ return CommonResult.success(url);
+ } else {
+ return CommonResult.error(400, "添加失败");
+ }
+
+ }
+
@Operation(description = "获取上传凭证")
@PostMapping("/get/token")
- public CommonResult> getToken(@RequestParam("file") MultipartFile file) {
+ @PreAuthorize("hasAuthority('/file/add')")
+
+ public CommonResult> getToken(@RequestParam("file") MultipartFile file) {
String fileName = file.getOriginalFilename();
String token = ossFileService.getToken(fileName);
if (token != null) {
- return CommonResult.success("token",token);
+ return CommonResult.success("token", token);
} else {
return CommonResult.error(400, "添加失败");
}
@@ -63,6 +104,8 @@ public class FileController {
@Operation(description = "保存文件信息")
@PostMapping("/add/file")
+ @PreAuthorize("hasAuthority('/file/add')")
+
public CommonResult addFile(@RequestBody @Valid OSSFile file) {
boolean success = ossFileService.save(file);
if (success) {
@@ -75,6 +118,8 @@ public class FileController {
@Operation(description = "删除文件")
@DeleteMapping("/delete")
+ @PreAuthorize("hasAuthority('/file')")
+
public CommonResult> delById(@RequestParam @Schema(description = "待删除id")
@NotNull String fileId,
@RequestParam @Schema(description = "仅修改数据库记录")
@@ -86,6 +131,8 @@ public class FileController {
@Operation(description = "恢复文件")
@GetMapping("/recovery")
+ @PreAuthorize("hasAuthority('/file')")
+
public CommonResult recovery(@RequestParam @Schema(description = "待恢复id")
@NotNull String fileId) throws Exception {
OSSFile file = ossFileService.recovery(fileId);
@@ -94,6 +141,8 @@ public class FileController {
@Operation(description = "通过id获取")
@GetMapping("/get")
+ @PreAuthorize("hasAuthority('/file')")
+
public CommonResult getById(@RequestParam @Schema(description = "待获取id")
@NotNull String fileId) {
OSSFile success = ossFileService.getById(fileId);
@@ -106,6 +155,8 @@ public class FileController {
@Operation(description = "通过用户id获取")
@GetMapping("/list")
+ @PreAuthorize("hasAuthority('/file')")
+
public CommonResult> listByUploader(@RequestParam @Schema(description = "上传者id")
@NotNull String uploaderId) {
List success = ossFileService.listByUploader(uploaderId);
@@ -118,6 +169,8 @@ public class FileController {
@Operation(description = "分页查询")
@PostMapping("/list/query")
+ @PreAuthorize("hasAuthority('/file')")
+
public CommonResult> listQuery(@RequestBody @Valid FileQueryVO query) {
PageResult result = ossFileService.query(query);
if (result != null) {
diff --git a/src/main/java/com/online/edu/controller/resource/ResourceController.java b/src/main/java/com/online/edu/controller/resource/ResourceController.java
index 38d6eb3ae15159aac5575aa5b3ee77cbc7b28b38..85631402cd6a167b539ff2ffb50fb43d29a1df21 100644
--- a/src/main/java/com/online/edu/controller/resource/ResourceController.java
+++ b/src/main/java/com/online/edu/controller/resource/ResourceController.java
@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -35,8 +36,10 @@ public class ResourceController {
@Operation(description = "添加静态资源")
@PostMapping("/add/static")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
+
public CommonResult addStatic(@RequestBody @Valid StaticResource resource) {
- //TODO:建立VO
boolean success = resourceService.addStatic(resource);
if (success) {
return CommonResult.success(resource);
@@ -45,11 +48,40 @@ public class ResourceController {
}
}
+ @Operation(description = "更新静态资源")
+ @PostMapping("/update/static")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
+ public CommonResult updateStatic(@RequestBody @Valid StaticResource resource) {
+ boolean success = resourceService.updateStatic(resource);
+ if (success) {
+ return CommonResult.success(resource);
+ } else {
+ return CommonResult.error(400, "更新失败");
+ }
+ }
+
+
+ @Operation(description = "删除静态资源")
+ @DeleteMapping("/del/static")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
+
+ public CommonResult delStatic(@RequestParam @Valid String resourceId) {
+ boolean success = resourceService.delStatic(resourceId);
+ if (success) {
+ return CommonResult.success(resourceId);
+ } else {
+ return CommonResult.error(400, "删除失败");
+ }
+ }
+
@Operation(description = "添加直播资源")
@PostMapping("/add/live")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
public CommonResult addLive(@RequestBody @Valid LiveResource resource) {
- //TODO:建立VO
boolean success = resourceService.addLive(resource);
if (success) {
return CommonResult.success(resource);
@@ -60,8 +92,9 @@ public class ResourceController {
@Operation(description = "添加作业资源")
@PostMapping("/add/homework")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
public CommonResult addHomework(@RequestBody @Valid HomeworkResource resource) {
- //TODO:建立VO
boolean success = resourceService.addHomework(resource);
if (success) {
return CommonResult.success(resource);
@@ -73,9 +106,21 @@ public class ResourceController {
@Operation(description = "显示章节资源")
@GetMapping("/list")
- public CommonResult> list(@RequestParam @Schema(description = "对应课程章节",requiredMode = Schema.RequiredMode.REQUIRED)
- @NotNull String sectionId) {
+
+ public CommonResult> list(@RequestParam @Schema(description = "对应课程章节", requiredMode = Schema.RequiredMode.REQUIRED)
+ @NotNull String sectionId) {
return CommonResult.success(resourceService.getResourcesBySectionId(sectionId));
}
+
+ @Operation(description = "删除静态资源")
+ @GetMapping("/delete/static")
+ @PreAuthorize("hasAuthority('/course/resource')")
+
+ public CommonResult> deleteStatic(@RequestParam @Schema(description = "资源Id", requiredMode = Schema.RequiredMode.REQUIRED)
+ @NotNull String sectionId) {
+ return CommonResult.success(resourceService.getResourcesBySectionId(sectionId));
+ }
+
+
}
diff --git a/src/main/java/com/online/edu/controller/stat/StatController.java b/src/main/java/com/online/edu/controller/stat/StatController.java
new file mode 100644
index 0000000000000000000000000000000000000000..dbbac617ab622955ed507b299a67c7b7efc0b96b
--- /dev/null
+++ b/src/main/java/com/online/edu/controller/stat/StatController.java
@@ -0,0 +1,56 @@
+package com.online.edu.controller.stat;
+
+import com.online.edu.common.CommonResult;
+import com.online.edu.entity.stat.vo.AdminStatVO;
+import com.online.edu.entity.stat.vo.TeacherStatVO;
+import com.online.edu.service.rbac.UserService;
+import com.online.edu.service.stat.StatService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Tag(name = "统计数据")
+@RestController
+@RequestMapping("/api/stat")
+@CrossOrigin(value = "*")
+public class StatController {
+
+ @Autowired
+ StatService statService;
+ @Autowired
+ UserService userService;
+
+ @Operation(description = "获取教师统计数据")
+ @GetMapping("/teacher")
+ @PreAuthorize("hasAuthority('/api/stat/teacher')")
+ public CommonResult getTeacher(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String teacherId = userService.getUserByUsername(username).getId();
+ return CommonResult.success(statService.getTeacherStat(teacherId));
+ }
+
+
+ @Operation(description = "获取管理员统计数据")
+ @GetMapping("/admin")
+ @PreAuthorize("hasAuthority('/api/stat/admin')")
+
+ public CommonResult getAdmin(Authentication authentication) {
+ String username = authentication.getName();
+ if (username == null) {
+ return CommonResult.error(401, "未登录");
+ }
+ String userId = userService.getUserByUsername(username).getId();
+ return CommonResult.success(statService.getAdminStat(userId));
+ }
+
+
+}
diff --git a/src/main/java/com/online/edu/controller/userInfo/SocialUserController.java b/src/main/java/com/online/edu/controller/userInfo/SocialUserController.java
deleted file mode 100644
index 7c451c43c17752435f2b85e52137289c4bb22094..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/controller/userInfo/SocialUserController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.online.edu.controller.userInfo;
-
-
-import com.online.edu.common.CommonResult;
-import com.online.edu.entity.rbac.UserInfoDAO;
-import com.online.edu.entity.rbac.vo.NewUserVO;
-import com.online.edu.entity.rbac.vo.UserInfoVO;
-import com.online.edu.service.rbac.AuthService;
-import com.online.edu.service.rbac.UserService;
-import com.online.edu.service.userInfo.SocialUserService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.validation.Valid;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Tag(name = "社交用户")
-@RestController
-@RequestMapping("/rbac/social")
-@CrossOrigin(value = "*")
-public class SocialUserController {
- @Autowired
- private UserService userService;
- @Autowired
- private AuthService authService;
-
- @Autowired
- private SocialUserService socialUserService;
-
- @Operation(description = "新建社交用户")
- @PostMapping("/add")
- public CommonResult addSocialUser(@RequestBody @Valid NewUserVO newUserVO) {
-
- boolean success = authService.addUser(newUserVO);
- if (success) {
- return CommonResult.success(newUserVO);
- } else {
- return CommonResult.error(400, "添加失败");
- }
- }
-
- @Operation(description = "查看用户列表")
- @GetMapping("/list")
- @PreAuthorize("hasAuthority('test')")
- public CommonResult> list(@RequestParam(required = false) @Valid
- @Schema(description = "待查看状态id") List targetStatus) {
- List result;
- if (targetStatus != null) {
- result = userService.getAllByStatusIn(targetStatus);
- } else {
- result = userService.getAllUnionRole();
- }
-
- if (result != null) {
- return CommonResult.success(result);
- } else {
- return CommonResult.error(400, "查看用户列表失败");
- }
- }
-
-
- @Operation(description = "查看用户信息")
- @GetMapping("/get")
- @PreAuthorize("hasAuthority('test')")
- public CommonResult get(@RequestParam(required = false) @Valid
- @Schema(description = "待查看用户名") String username) {
-
-
- UserInfoDAO result = userService.getUserByUsername(username);
- if (result != null) {
- return CommonResult.success(result);
- } else {
- return CommonResult.error(400, "查看用户信息失败");
- }
- }
-
-
-}
-
-
diff --git a/src/main/java/com/online/edu/controller/userInfo/TeacherController.java b/src/main/java/com/online/edu/controller/userInfo/TeacherController.java
new file mode 100644
index 0000000000000000000000000000000000000000..16faf0dd361d8ee30a04af98e320f2f2828c7124
--- /dev/null
+++ b/src/main/java/com/online/edu/controller/userInfo/TeacherController.java
@@ -0,0 +1,175 @@
+package com.online.edu.controller.userInfo;
+
+
+import com.online.edu.common.CommonResult;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.rbac.vo.UserLoginVO;
+import com.online.edu.entity.userInfo.TeacherInfo;
+import com.online.edu.entity.userInfo.vo.NewTeacherInfo;
+import com.online.edu.entity.userInfo.vo.TeacherQueryVO;
+import com.online.edu.service.rbac.AuthService;
+import com.online.edu.service.rbac.UserService;
+import com.online.edu.service.userInfo.TeacherInfoService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.security.PermitAll;
+import jakarta.servlet.http.HttpSession;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+@Tag(name = "教师用户")
+@RestController
+@RequestMapping("/api/teacher")
+@CrossOrigin(value = "*")
+public class TeacherController {
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private AuthService authService;
+
+ @Autowired
+ private TeacherInfoService teacherInfoService;
+
+ @Operation(description = "申请教师用户")
+ @PostMapping("/user/apply")
+
+ public CommonResult addTeacher(@RequestBody @Valid NewTeacherInfo newTeacherInfo,
+ Authentication authentication) {
+ String username = authentication.getName();
+ if(username == null){
+ return CommonResult.error(401, "未登录");
+ }
+ String id = userService.getUserByUsername(username).getId();
+ if (teacherInfoService.getById(id) != null) {
+ return CommonResult.error(400, "当前用户已经是教师");
+ }
+ TeacherInfo info = newTeacherInfo.bulidTeacherInfo(id);
+ boolean result = teacherInfoService.save(info);
+ if (result) {
+ return CommonResult.success(info);
+ } else {
+ return CommonResult.error(400, "添加失败");
+ }
+ }
+
+ @Operation(description = "更新教师用户")
+ @PostMapping("/update")
+ @PreAuthorize("hasAuthority('/api/teacher')")
+ public CommonResult updateTeacher(@RequestBody @Valid TeacherInfo teacherInfo) {
+ boolean result = teacherInfoService.updateById(teacherInfo);
+ if (result) {
+ return CommonResult.success(teacherInfo);
+ } else {
+ return CommonResult.error(400, "添加失败");
+ }
+ }
+
+ @Operation(description = "审核教师用户")
+ @PostMapping("/audit")
+ @PreAuthorize("hasAuthority('/api/teacher')")
+ public CommonResult auditTeacher(@RequestParam @NotNull @Schema(description = "教师ID") String teacherId,
+ @RequestParam @NotNull @Schema(description = "教师状态") Integer status) {
+
+
+ if(status < 0 || status > 2){
+ return CommonResult.error(400, "状态错误");
+ }
+ else if(status == 1){
+ userService.addUserRole(teacherId,"1");
+ }
+ else {
+ userService.delUserRole(teacherId,"1");
+ }
+ boolean result = teacherInfoService.updateTeacherStatus(teacherId,status);
+ if (result) {
+ return CommonResult.success(teacherInfoService.getById(teacherId));
+ } else {
+ return CommonResult.error(400, "审核失败");
+ }
+ }
+
+
+ @Operation(description = "删除教师用户")
+ @PostMapping("/delete")
+ @PreAuthorize("hasAuthority('/api/teacher')")
+ public CommonResult deleteTeacher(@RequestParam @NotNull @Schema(description = "教师ID") String teacherId,
+ @RequestParam @NotNull @Schema(description = "删除状态") Integer isDeleted) {
+ if(isDeleted == 1){
+ userService.delUserRole(teacherId,"1");
+ }
+ boolean result = teacherInfoService.updateIsDeleted(teacherId,isDeleted);
+ if (result) {
+ return CommonResult.success(teacherInfoService.getById(teacherId));
+ } else {
+ return CommonResult.error(400, "删除失败");
+ }
+ }
+
+
+ @Operation(description = "获取教师信息")
+ @GetMapping("/user/get")
+
+ public CommonResult getTeacher(@RequestParam @NotNull @Schema(description = "教师ID") String teacherId) {
+ TeacherInfo result = teacherInfoService.getById(teacherId);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "删除失败");
+ }
+ }
+
+ @Operation(description = "获取教师信息")
+ @GetMapping("/user/get/self")
+ public CommonResult getTeacher(Authentication authentication) {
+ String username = authentication.getName();
+ if(username == null){
+ return CommonResult.error(401, "未登录");
+ }
+ String teacherId = userService.getUserByUsername(username).getId();
+ TeacherInfo result = teacherInfoService.getById(teacherId);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "获取教师信息失败");
+ }
+ }
+
+ @Operation(description = "查询教师信息")
+ @PostMapping("/query")
+ @PreAuthorize("hasAuthority('/api/teacher')")
+ public CommonResult> queryTeacher(@RequestBody @Valid TeacherQueryVO teacherQueryVO) {
+ PageResult result = teacherInfoService.query(teacherQueryVO);
+ if (result != null) {
+ return CommonResult.success(result);
+ } else {
+ return CommonResult.error(400, "删除失败");
+ }
+ }
+
+ @Operation(description = "教师登录")
+ @PostMapping("/user/login")
+ @PermitAll
+ public CommonResult teacherLogin(@RequestBody @Valid UserLoginVO userLoginVO, HttpSession session, Model model) {
+ if (!authService.checkStatus(userLoginVO.getUsername())) {
+ return CommonResult.error(403, "当前用户被禁用");
+ }
+
+ String token = authService.teacherLogin(userLoginVO, session, model);
+ if (token != null) {
+ return CommonResult.success(token);
+ } else {
+ return CommonResult.error(401, "登录失败");
+ }
+ }
+
+
+}
+
+
diff --git a/src/main/java/com/online/edu/controller/verification/KaptchaController.java b/src/main/java/com/online/edu/controller/verification/KaptchaController.java
index 261b6a84dc135f50861935cab850c46f6f092912..5dba0500eacc45219e9bca61001d1924788535e2 100644
--- a/src/main/java/com/online/edu/controller/verification/KaptchaController.java
+++ b/src/main/java/com/online/edu/controller/verification/KaptchaController.java
@@ -2,6 +2,8 @@ package com.online.edu.controller.verification;
import com.google.code.kaptcha.Producer;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/src/main/java/com/online/edu/entity/message/SystemNotifyMessage.java b/src/main/java/com/online/edu/entity/banner/Banner.java
similarity index 44%
rename from src/main/java/com/online/edu/entity/message/SystemNotifyMessage.java
rename to src/main/java/com/online/edu/entity/banner/Banner.java
index fce048d3c00d3ec32a3cecaccef4316b930a5992..a4d2c5e03f9a980b863b2afe581a31046e1ec783 100644
--- a/src/main/java/com/online/edu/entity/message/SystemNotifyMessage.java
+++ b/src/main/java/com/online/edu/entity/banner/Banner.java
@@ -1,76 +1,65 @@
-package com.online.edu.entity.message;
+package com.online.edu.entity.banner;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
import java.io.Serializable;
import java.util.Date;
-import lombok.Data;
/**
- * 站内信消息表
- * @TableName system_notify_message
+ * banner表
+ *
+ * @TableName banner
*/
-@TableName(value ="system_notify_message")
+@TableName(value = "banner")
+@Accessors(chain = true)
@Data
-public class SystemNotifyMessage implements Serializable {
- /**
- * 用户ID
- */
- @TableId
- private Long id;
-
- /**
- * 用户id
- */
- private Long userId;
-
- /**
- * 模版编号
- */
- private Long templateId;
-
+public class Banner implements Serializable {
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
/**
- * 模版发送人名称
+ * ID
*/
- private String templateNickname;
-
+ @TableId(type = IdType.AUTO)
+ @Min(1)
+ private Integer id;
/**
- * 模版内容
+ * 标题
*/
- private String templateContent;
-
+ @Length(max = 63, message = "标题长度不能超过63个字符")
+ @NotEmpty
+ private String title;
/**
- * 模版类型
+ * 图片地址
*/
- private Integer templateType;
-
+ @NotEmpty
+ private String imageUrl;
/**
- * 模版参数
+ * 链接地址
*/
- private String templateParams;
-
+ private String linkUrl;
/**
- * 是否已读
+ * 排序
*/
- private Integer readStatus;
-
+ @Min(0)
+ private Integer sort;
/**
- * 创建时间
+ * 是否可用
*/
- private Date createTime;
-
+ private Boolean enable;
/**
* 更新时间
*/
private Date updateTime;
-
/**
- * 是否删除
+ * 创建时间
*/
- private Integer deleted;
-
- @TableField(exist = false)
- private static final long serialVersionUID = 1L;
+ private Date createTime;
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/banner/vo/BannerQueryVO.java b/src/main/java/com/online/edu/entity/banner/vo/BannerQueryVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2f6bbe3e40ec0ac4b0535fe099631dba7fc7427
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/banner/vo/BannerQueryVO.java
@@ -0,0 +1,25 @@
+package com.online.edu.entity.banner.vo;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.online.edu.common.PageParam;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@TableName(value = "banner")
+@Data
+public class BannerQueryVO extends PageParam {
+
+ /**
+ * 标题
+ */
+ private String title;
+
+ /**
+ * 是否可用
+ */
+ private Boolean enable;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/message/MessageTemplate.java b/src/main/java/com/online/edu/entity/banner/vo/BannerVO.java
similarity index 35%
rename from src/main/java/com/online/edu/entity/message/MessageTemplate.java
rename to src/main/java/com/online/edu/entity/banner/vo/BannerVO.java
index cbedfe0165956ea644e1fa0cecf22a1b7fd03eb6..adad62fd060d237234245c5b9aa903ffdfa36aee 100644
--- a/src/main/java/com/online/edu/entity/message/MessageTemplate.java
+++ b/src/main/java/com/online/edu/entity/banner/vo/BannerVO.java
@@ -1,76 +1,54 @@
-package com.online.edu.entity.message;
+package com.online.edu.entity.banner.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-import java.util.Date;
+import com.online.edu.entity.banner.Banner;
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
-/**
- * 站内信模板表
- * @TableName message_template
- */
-@TableName(value ="message_template")
-@Data
-public class MessageTemplate implements Serializable {
- /**
- * 主键
- */
- @TableId
- private Long id;
-
- /**
- * 模板名称
- */
- private String name;
-
- /**
- * 发送人名称
- */
- private String nickname;
-
- /**
- * 模版内容
- */
- private String content;
+import java.io.Serializable;
+@TableName(value = "banner")
+@Data
+public class BannerVO implements Serializable {
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
/**
- * 类型
+ * ID
*/
- private Integer type;
-
+ @TableId(type = IdType.AUTO)
+ @Min(1)
+ private Integer id;
/**
- * 参数数组
+ * 标题
*/
- private String params;
-
+ @NotEmpty
+ private String title;
/**
- * 状态
+ * 图片地址
*/
- private Integer status;
-
+ @NotEmpty
+ private String imageUrl;
/**
- * 备注
+ * 链接地址
*/
- private String remark;
-
+ private String linkUrl;
/**
- * 创建时间
+ * 排序
*/
- private Date createdAt;
-
+ @Min(0)
+ private Integer sort;
/**
- * 更新时间
+ * 是否可用
*/
- private Date updatedAt;
- /**
- * 是否删除
- */
- private Integer deleted;
+ private Boolean enable;
- @TableField(exist = false)
- private static final long serialVersionUID = 1L;
+ public Banner build() {
+ return new Banner().setId(id).setTitle(title).setImageUrl(imageUrl)
+ .setLinkUrl(linkUrl).setSort(sort).setEnable(enable);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/Comment.java b/src/main/java/com/online/edu/entity/course/Comment.java
index 91266cafe0c8061b4bddeee6e12ba7d24428be3f..08c5aca940dc9c4810c698ef3dc875bf329aef8e 100644
--- a/src/main/java/com/online/edu/entity/course/Comment.java
+++ b/src/main/java/com/online/edu/entity/course/Comment.java
@@ -30,6 +30,22 @@ public class Comment implements Serializable {
* 学生id
*/
private String studentId;
+ /**
+ * 学生头像
+ */
+ private String memberAvatar;
+
+ /**
+ * 学生姓名
+ */
+ private String memberName;
+
+
+ /**
+ * 评分
+ */
+ private Integer mark;
+
/**
* 内容
*/
@@ -46,4 +62,5 @@ public class Comment implements Serializable {
* 更新时间
*/
private Date updatedAt;
+
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/CourseInfo.java b/src/main/java/com/online/edu/entity/course/CourseInfo.java
index 58ab4b16bb289197e924a62b9e5ddd6ba12b92a7..cbc2d06c33f92d93f1152b31e170522ddf4d8fd0 100644
--- a/src/main/java/com/online/edu/entity/course/CourseInfo.java
+++ b/src/main/java/com/online/edu/entity/course/CourseInfo.java
@@ -41,12 +41,18 @@ public class CourseInfo implements Serializable {
* 封面链接
*/
private String cover;
+
+ /**
+ * 描述
+ */
+ private String description;
+
/**
* 价格
*/
private BigDecimal price;
/**
- * 课程状态 0:未上线,1:私有开课中,2:公开开课中,3:结课
+ * 课程状态
*/
private Integer status;
/**
diff --git a/src/main/java/com/online/edu/entity/course/CourseType.java b/src/main/java/com/online/edu/entity/course/CourseType.java
new file mode 100644
index 0000000000000000000000000000000000000000..a8f6f9fe0818663697ada8778eee9065ffaab848
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/course/CourseType.java
@@ -0,0 +1,33 @@
+package com.online.edu.entity.course;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 课程类型
+ * @TableName course_type
+ */
+@TableName(value ="course_type")
+@Data
+public class CourseType implements Serializable {
+ /**
+ * 类型ID
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 课程类型
+ */
+ private String courseType;
+
+ /**
+ * 已删除
+ */
+ private Integer isDeleted;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/CommentQueryVO.java b/src/main/java/com/online/edu/entity/course/vo/CommentQueryVO.java
index e8a7be0092037352161d2b3bd5083d4a0b9ed6a7..9c3c70aafbf87017574e821953c3a789cf1b9e11 100644
--- a/src/main/java/com/online/edu/entity/course/vo/CommentQueryVO.java
+++ b/src/main/java/com/online/edu/entity/course/vo/CommentQueryVO.java
@@ -8,6 +8,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
+import java.util.List;
/**
* 评论
@@ -20,10 +21,21 @@ import java.util.Date;
@ToString(callSuper = true)
public class CommentQueryVO extends PageParam implements Serializable {
+ /**
+ * 教师id
+ */
+ private String teacherId;
+
/**
* 课程id
*/
private String courseId;
+
+ /**
+ * 课程id
+ */
+ private List courses;
+
/**
* 学生id
*/
diff --git a/src/main/java/com/online/edu/entity/userInfo/SocialUser.java b/src/main/java/com/online/edu/entity/course/vo/CourseBasicInfo.java
similarity index 44%
rename from src/main/java/com/online/edu/entity/userInfo/SocialUser.java
rename to src/main/java/com/online/edu/entity/course/vo/CourseBasicInfo.java
index fa5426b56715142b8c1cdaede0ab856d4ab164ad..5463815ee7c8ad12829e600eadb487f7699202bf 100644
--- a/src/main/java/com/online/edu/entity/userInfo/SocialUser.java
+++ b/src/main/java/com/online/edu/entity/course/vo/CourseBasicInfo.java
@@ -1,41 +1,34 @@
-package com.online.edu.entity.userInfo;
+package com.online.edu.entity.course.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serial;
import java.io.Serializable;
-import java.util.Date;
/**
- * 第三方登录用户
+ * 课程信息
*
- * @TableName social_user
+ * @TableName course_info
*/
@Data
-public class SocialUser implements Serializable {
+@Accessors(chain = true)
+public class CourseBasicInfo implements Serializable {
+ @Serial
private static final long serialVersionUID = 1L;
/**
- * 登录用户id
+ * 课程id
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
-
+ @Schema(nullable = true,defaultValue = "")
private String id;
- /**
- * 用户id
- */
- private String userId;
- /**
- * 对应的授权id
- */
- private String openId;
- /**
- * 创建时间
- */
- private Date createdAt;
/**
- * 更新时间
+ * 标题
*/
- private Date updatedAt;
+ private String title;
+
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/CourseInfoVO.java b/src/main/java/com/online/edu/entity/course/vo/CourseInfoVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a9824c58ae4b8c7fc162775f26d02d85b70665f
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/course/vo/CourseInfoVO.java
@@ -0,0 +1,106 @@
+package com.online.edu.entity.course.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.online.edu.entity.course.CourseInfo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 课程信息
+ *
+ * @TableName course_info
+ */
+@Data
+@Accessors(chain = true)
+public class CourseInfoVO implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 1L;
+ /**
+ * 课程id
+ */
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @Schema(nullable = true,defaultValue = "")
+ private String id;
+ /**
+ * 教师id
+ */
+ private String teacherId;
+ /**
+ * 教师姓名
+ */
+ private String teacherName;
+
+ /**
+ * 教师描述
+ */
+ private String teacherDescription;
+
+ /**
+ * 教师头像
+ */
+ private String teacherAvatar;
+ /**
+ * 课程类型
+ */
+ private Integer typeId;
+
+ /**
+ * 课程类型名称
+ */
+ private String typeName;
+ /**
+ * 标题
+ */
+ private String title;
+ /**
+ * 封面链接
+ */
+ private String cover;
+ /**
+ * 描述
+ */
+ private String description;
+
+ /**
+ * 课程状态 0:未上线,1:私有开课中,2:公开开课中,3:结课
+ */
+ private Integer resourceCount;
+
+ /**
+ * 价格
+ */
+ private BigDecimal price;
+ /**
+ * 课程状态
+ */
+ private Integer status;
+ /**
+ * 是否删除
+ */
+ private Integer isDeleted;
+ /**
+ * 创建时间
+ */
+ private Date createdAt;
+ /**
+ * 更新时间
+ */
+ private Date updatedAt;
+
+ public static CourseInfoVO build(CourseInfo courseInfo, String teacherName, String teacherDescription,
+ String teacherAvatar, String typeName, Integer resourceCount) {
+ return new CourseInfoVO().setId(courseInfo.getId()).setTeacherId(courseInfo.getTeacherId())
+ .setTeacherName(teacherName).setTeacherDescription(teacherDescription).setTeacherAvatar(teacherAvatar)
+ .setTitle(courseInfo.getTitle()).setTypeId(courseInfo.getTypeId()).setTypeName(typeName)
+ .setPrice(courseInfo.getPrice()).setCover(courseInfo.getCover()).setPrice(courseInfo.getPrice())
+ .setCreatedAt(courseInfo.getCreatedAt()).setUpdatedAt(courseInfo.getUpdatedAt()).setStatus(courseInfo.getStatus())
+ .setDescription(courseInfo.getDescription()).setIsDeleted(courseInfo.getIsDeleted()).setResourceCount(resourceCount == null ? 0 : resourceCount);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/CourseTypeQueryVO.java b/src/main/java/com/online/edu/entity/course/vo/CourseTypeQueryVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..a88d109ccdf9a007ba77c93ecfd0d666f0e6de68
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/course/vo/CourseTypeQueryVO.java
@@ -0,0 +1,21 @@
+package com.online.edu.entity.course.vo;
+
+import com.online.edu.common.PageParam;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@ToString(callSuper = true)
+public class CourseTypeQueryVO extends PageParam implements Serializable {
+ /**
+ * 课程类型
+ */
+ private String courseType;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/CourseUpdateVO.java b/src/main/java/com/online/edu/entity/course/vo/CourseUpdateVO.java
index e0f024f800a776172216375be5a08672b8eded92..b3025e370c8a1656b980ed7eee8720e984f99217 100644
--- a/src/main/java/com/online/edu/entity/course/vo/CourseUpdateVO.java
+++ b/src/main/java/com/online/edu/entity/course/vo/CourseUpdateVO.java
@@ -37,6 +37,10 @@ public class CourseUpdateVO implements Serializable {
* 封面链接
*/
private String cover;
+ /**
+ * 描述
+ */
+ private String description;
/**
* 价格
*/
@@ -51,6 +55,6 @@ public class CourseUpdateVO implements Serializable {
private Integer isDeleted;
public CourseInfo buildCourseInfo(){
return new CourseInfo().setId(id).setTypeId(typeId).setTitle(title)
- .setCover(cover).setPrice(price).setStatus(status).setIsDeleted(isDeleted);
+ .setCover(cover).setDescription(description).setPrice(price).setStatus(status).setIsDeleted(isDeleted);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/NewCommentVO.java b/src/main/java/com/online/edu/entity/course/vo/NewCommentVO.java
index ec5fad0e8e0f3aee0512e53103d6559a5c10949f..3742bc5a9444501bedd2fbd47d4d5f3caaacc82a 100644
--- a/src/main/java/com/online/edu/entity/course/vo/NewCommentVO.java
+++ b/src/main/java/com/online/edu/entity/course/vo/NewCommentVO.java
@@ -1,6 +1,7 @@
package com.online.edu.entity.course.vo;
import com.online.edu.entity.course.Comment;
+import com.online.edu.entity.rbac.UserInfo;
import lombok.Data;
import java.io.Serializable;
@@ -20,12 +21,19 @@ public class NewCommentVO implements Serializable {
* 学生id
*/
private String studentId;
+
+ /**
+ * 评分
+ */
+ private Integer mark;
+
/**
* 内容
*/
private String content;
- public Comment buildComment(){
- return new Comment().setContent(content).setStudentId(studentId).setCourseId(courseId).setIsDeleted(0);
+ public Comment buildComment(UserInfo userInfo) {
+ return new Comment().setContent(content).setStudentId(studentId).setCourseId(courseId).setMark(mark).setIsDeleted(0)
+ .setMemberAvatar(userInfo.getAvatar()).setMemberName(userInfo.getDisplayName());
}
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/course/vo/NewCourseVO.java b/src/main/java/com/online/edu/entity/course/vo/NewCourseVO.java
index 0303f20bdde390632d4365744b7b5fb6057acf6b..55efd43a1d5e90752c6851865824bd9913b07f29 100644
--- a/src/main/java/com/online/edu/entity/course/vo/NewCourseVO.java
+++ b/src/main/java/com/online/edu/entity/course/vo/NewCourseVO.java
@@ -28,6 +28,10 @@ public class NewCourseVO implements Serializable {
* 封面链接
*/
private String cover;
+ /**
+ * 描述
+ */
+ private String description;
/**
* 价格
*/
@@ -35,6 +39,6 @@ public class NewCourseVO implements Serializable {
public CourseInfo buildCourseInfo(){
return new CourseInfo().setTeacherId(teacherId).setTypeId(typeId).setTitle(title)
- .setCover(cover).setPrice(price).setStatus(0).setIsDeleted(0);
+ .setCover(cover).setPrice(price).setDescription(description).setStatus(0).setIsDeleted(0);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/message/Message.java b/src/main/java/com/online/edu/entity/message/Message.java
index adf4d9c530449f8244fc29c54a121769a7a0c784..7b910e14c38a3862085f0a209d894aa48ed5de0a 100644
--- a/src/main/java/com/online/edu/entity/message/Message.java
+++ b/src/main/java/com/online/edu/entity/message/Message.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@@ -14,12 +15,13 @@ import java.util.Date;
*/
@TableName(value ="message")
@Data
+@Accessors(chain = true)
public class Message implements Serializable {
/**
* 消息ID
*/
@TableId
- private Long id;
+ private String id;
/**
* 消息标题
@@ -34,12 +36,12 @@ public class Message implements Serializable {
/**
* 发送者id
*/
- private Long senderId;
+ private String senderId;
/**
* 接收者ID
*/
- private Long receiverId;
+ private String receiverId;
/**
* 是否发送{0:未发送,1:已发送}
diff --git a/src/main/java/com/online/edu/entity/message/vo/MessageSendVO.java b/src/main/java/com/online/edu/entity/message/vo/MessageSendVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..e0e9e921bdc7dae44e3e832e3234eabf03dbc6e7
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/message/vo/MessageSendVO.java
@@ -0,0 +1,50 @@
+package com.online.edu.entity.message.vo;
+
+import com.online.edu.entity.message.Message;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 消息表
+ *
+ */
+@Data
+@Accessors(chain = true)
+public class MessageSendVO implements Serializable {
+
+
+ /**
+ * 消息标题
+ */
+ private String messageTitle;
+
+ /**
+ * 消息内容
+ */
+ private String messageBody;
+
+ /**
+ * 发送者id
+ */
+ private String senderId;
+
+ /**
+ * 接收者用户名
+ */
+ private List receivers;
+
+ public List build() {
+ List result = new ArrayList<>();
+ receivers.forEach(receiver -> {
+ result.add(new Message().setSenderId(senderId).setReceiverId(receiver).setMessageBody(messageBody)
+ .setMessageTitle(messageTitle).setDeleted(0).setSendStatus(1).setReadStatus(0)
+ .setUpdatedAt(new Date()).setCreatedAt(new Date()));
+ });
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/message/vo/MessageVO.java b/src/main/java/com/online/edu/entity/message/vo/MessageVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..95fc720b2624ae7c61b5e557ecdb8bd0a1ce7aa3
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/message/vo/MessageVO.java
@@ -0,0 +1,96 @@
+package com.online.edu.entity.message.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.online.edu.entity.message.Message;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 消息
+ */
+@TableName(value = "message")
+@Data
+@Accessors(chain = true)
+public class MessageVO implements Serializable {
+ /**
+ * 消息ID
+ */
+ @TableId
+ private String id;
+
+ /**
+ * 消息标题
+ */
+ private String messageTitle;
+
+ /**
+ * 消息内容
+ */
+ private String messageBody;
+
+ /**
+ * 发送者id
+ */
+ private String senderId;
+
+ /**
+ * 发送者id
+ */
+ private String senderName;
+
+ /**
+ * 接收者ID
+ */
+ private String receiverId;
+
+ /**
+ * 是否发送{0:未发送,1:已发送}
+ */
+ private Integer sendStatus;
+
+ /**
+ * 是否已读{0:未读,1:已读}
+ */
+ private Integer readStatus;
+
+ /**
+ * 是否删除{0:未删除,1:已删除}
+ */
+ private Integer deleted;
+
+ /**
+ * 创建时间
+ */
+ private Date createdAt;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedAt;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ public MessageVO(Message message, String senderName) {
+ id = message.getId();
+
+ messageTitle = message.getMessageTitle();
+ messageBody = message.getMessageBody();
+
+ senderId = message.getSenderId();
+ this.senderName = senderName;
+ receiverId = message.getReceiverId();
+
+ sendStatus = message.getSendStatus();
+ readStatus = message.getReadStatus();
+ deleted = message.getDeleted();
+ createdAt = message.getCreatedAt();
+ updatedAt = message.getUpdatedAt();
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/order/CourseElection.java b/src/main/java/com/online/edu/entity/order/CourseElection.java
index 32776f0d807a63c845b82c21d651b39a6e90eaae..395badfe5752b7f933a81e3285be16ec4c447f33 100644
--- a/src/main/java/com/online/edu/entity/order/CourseElection.java
+++ b/src/main/java/com/online/edu/entity/order/CourseElection.java
@@ -2,7 +2,10 @@ package com.online.edu.entity.order;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -14,6 +17,9 @@ import java.util.Date;
* @TableName course_election
*/
@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
public class CourseElection implements Serializable {
private static final long serialVersionUID = 1L;
/**
@@ -65,4 +71,5 @@ public class CourseElection implements Serializable {
* 更新时间
*/
private Date updatedAt;
+
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/order/CourseOrder.java b/src/main/java/com/online/edu/entity/order/CourseOrder.java
index 01aeba612f9f8cc1cb0c691b1f05b55dacd2e759..86d51a1fa23c111e6c811708d12371069e244b1d 100644
--- a/src/main/java/com/online/edu/entity/order/CourseOrder.java
+++ b/src/main/java/com/online/edu/entity/order/CourseOrder.java
@@ -2,7 +2,10 @@ package com.online.edu.entity.order;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -14,6 +17,9 @@ import java.util.Date;
* @TableName course_order
*/
@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
public class CourseOrder implements Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git a/src/main/java/com/online/edu/entity/order/vo/CourseElectionQueryVO.java b/src/main/java/com/online/edu/entity/order/vo/CourseElectionQueryVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd5e1eec9e93a05dfcb2e0bc9b781f730d2d1323
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/order/vo/CourseElectionQueryVO.java
@@ -0,0 +1,45 @@
+package com.online.edu.entity.order.vo;
+
+import com.online.edu.common.PageParam;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
+public class CourseElectionQueryVO extends PageParam {
+
+ /**
+ * 订单号
+ */
+ private String serialNumber;
+
+
+ /**
+ * 学生昵称
+ */
+ private String studentName;
+
+ /**
+ * 订单状态(0:未支付 1:已支付)
+ */
+ private Integer status;
+ /**
+ * 逻辑删除 1(true)已删除, 0(false)未删除
+ */
+ private Integer isDeleted;
+ /**
+ * 最早创建时间
+ */
+ private Date oldDate;
+ /**
+ * 最晚创建时间
+ */
+ private Date newDate;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/order/vo/CourseOrderListVO.java b/src/main/java/com/online/edu/entity/order/vo/CourseOrderListVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..23d2af3add9d1665c9a0e423879a41a157cacf6a
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/order/vo/CourseOrderListVO.java
@@ -0,0 +1,86 @@
+package com.online.edu.entity.order.vo;
+
+import com.online.edu.entity.order.CourseElection;
+import com.online.edu.entity.order.CourseOrder;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class CourseOrderListVO {
+ /**
+ * 订单号
+ */
+ private String serialNumber;
+
+ /**
+ * 课程id
+ */
+ private String courseId;
+ /**
+ * 课程名称
+ */
+ private String courseName;
+ /**
+ * 教师名称
+ */
+ private String teacherName;
+ /**
+ * 学生id
+ */
+ private String studentId;
+ /**
+ * 学生昵称
+ */
+ private String studentName;
+
+ /**
+ * 支付完成时间
+ */
+ private Date payedat;
+ /**
+ * 支付金额(分)
+ */
+ private BigDecimal price;
+ /**
+ * 交易流水号
+ */
+ private String transactionId;
+ /**
+ * 交易状态
+ */
+ private String tradeState;
+
+ /**
+ * 逻辑删除 1(true)已删除, 0(false)未删除
+ */
+ private Integer isDeleted;
+ /**
+ * 创建时间
+ */
+ private Date createdAt;
+ /**
+ * 更新时间
+ */
+ private Date updatedAt;
+
+ public CourseOrderListVO(CourseOrder order, CourseElection election) {
+ serialNumber = order.getSerialNumber();
+ courseId = election.getCourseId();
+ courseName = election.getCourseName();
+ teacherName = election.getTeacherName();
+ studentId = election.getStudentId();
+ studentName = election.getStudentName();
+ payedat = order.getPayedat();
+ price = order.getPrice();
+
+ transactionId = order.getTransactionId();
+ tradeState = order.getTradeState();
+ isDeleted = order.getIsDeleted();
+
+ createdAt = order.getCreatedAt();
+ updatedAt = order.getUpdatedAt();
+
+ }
+}
diff --git a/src/main/java/com/online/edu/entity/order/vo/CourseOrderVO.java b/src/main/java/com/online/edu/entity/order/vo/CourseOrderVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a0fae95dbd6cf37870171b896e0bd2b40d8e812
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/order/vo/CourseOrderVO.java
@@ -0,0 +1,22 @@
+package com.online.edu.entity.order.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class CourseOrderVO {
+ /**
+ * 订单号
+ */
+ private String serialNumber;
+ /**
+ * 支付金额(分)
+ */
+ private BigDecimal price;
+ /**
+ * 其他属性
+ */
+ private String attr;
+
+}
diff --git a/src/main/java/com/online/edu/entity/rbac/UserInfo.java b/src/main/java/com/online/edu/entity/rbac/UserInfo.java
index e3fc23e3bfe753235013f8d1eb08b63f69425173..df9be36f92de84c0e2f7aed371761e3114cb2d1c 100644
--- a/src/main/java/com/online/edu/entity/rbac/UserInfo.java
+++ b/src/main/java/com/online/edu/entity/rbac/UserInfo.java
@@ -30,8 +30,7 @@ public class UserInfo implements Serializable {
*/
@NotNull(message = "[用户ID]不能为空")
@Schema(description = "用户ID")
- @TableId(value = "id", type = IdType.ASSIGN_ID)
-
+ @TableId(type = IdType.INPUT)
private String id;
/**
* 创建时间
@@ -74,9 +73,6 @@ public class UserInfo implements Serializable {
@Schema(description = "姓名")
private String displayName;
-
- private String openid;
-
private String phone;
private String email;
diff --git a/src/main/java/com/online/edu/entity/rbac/UserInfoDAO.java b/src/main/java/com/online/edu/entity/rbac/UserInfoDAO.java
index 066b6a9642ff6a0e115c87c1241374869c83ecfb..23c1f831836755fcc5438c8264c3adb2373afbb5 100644
--- a/src/main/java/com/online/edu/entity/rbac/UserInfoDAO.java
+++ b/src/main/java/com/online/edu/entity/rbac/UserInfoDAO.java
@@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
+import java.util.List;
+
@Data
@AllArgsConstructor
@NoArgsConstructor
@@ -55,4 +57,14 @@ public class UserInfoDAO {
@NotNull(message = "[用户状态]不能为空")
@Schema(description = "用户状态")
private String status;
+
+ private String phone;
+
+ private String email;
+
+ private String avatar;
+
+ private List roles;
+
+
}
diff --git a/src/main/java/com/online/edu/entity/rbac/UserRoleRelation.java b/src/main/java/com/online/edu/entity/rbac/UserRoleRelation.java
index 539f9b2c94eeba3336745970f016d275dce51773..8cc35e324aa6cd34f69a593d7e594f2b2d6fbb64 100644
--- a/src/main/java/com/online/edu/entity/rbac/UserRoleRelation.java
+++ b/src/main/java/com/online/edu/entity/rbac/UserRoleRelation.java
@@ -28,7 +28,6 @@ public class UserRoleRelation implements Serializable {
@NotNull(message = "[关联ID]不能为空")
@Schema(description = "关联ID")
@TableId(value = "id", type = IdType.ASSIGN_ID)
-
private String id;
/**
* 用户ID
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/NewUserVO.java b/src/main/java/com/online/edu/entity/rbac/vo/NewUserVO.java
index e2bf234b797e009266ad655f0567f2ab438030cf..819366cef01ae05648f19b85147d39e2f5d4e4d6 100644
--- a/src/main/java/com/online/edu/entity/rbac/vo/NewUserVO.java
+++ b/src/main/java/com/online/edu/entity/rbac/vo/NewUserVO.java
@@ -18,11 +18,11 @@ import java.util.List;
public class NewUserVO {
/**
- * 用户名,为学/工号
+ * 用户名
*/
@NotBlank(message = "[用户名]不能为空")
@Size(max = 50, message = "编码长度不能超过50")
- @Schema(description = "用户名,默认为学/工号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2200000000")
+ @Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "2200000000")
private String username;
/**
@@ -47,12 +47,26 @@ public class NewUserVO {
@NotNull(message = "[角色]不能为空")
@Size(max = 10)
@Schema(description = "角色", requiredMode = Schema.RequiredMode.REQUIRED, example = "['1']")
- private List role;
+ private List roles;
/**
- * 用户状态
+ * 头像
*/
- @NotNull(message = "[用户状态]不能为空")
- @Schema(description = "用户状态", example = "1")
- private Integer status;
+ @NotNull(message = "[头像]不能为空")
+ @Schema(description = "头像")
+ private String avatar;
+
+ /**
+ * 电话
+ */
+ @NotNull(message = "[电话]不能为空")
+ @Schema(description = "电话")
+ private String phone;
+
+ /**
+ * 邮箱
+ */
+ @Schema(description = "邮箱")
+ private String email;
+
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/UserBasicInfoVO.java b/src/main/java/com/online/edu/entity/rbac/vo/UserBasicInfoVO.java
index 5cd82dc4125543bc48393d7ea4b23e6de1a8d3e8..4aeee9acd4cb7ee7a16fa845cf758005822c8bbb 100644
--- a/src/main/java/com/online/edu/entity/rbac/vo/UserBasicInfoVO.java
+++ b/src/main/java/com/online/edu/entity/rbac/vo/UserBasicInfoVO.java
@@ -27,6 +27,7 @@ public class UserBasicInfoVO {
@Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
private String displayName;
+ private String avatar;
private String phone;
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/UserInfoVO.java b/src/main/java/com/online/edu/entity/rbac/vo/UserInfoVO.java
index 48ba8a3b4c0803489d4d091413992399db7dd6e1..a20ac0cc3efb49231f1aa39a087b2cf075eafe48 100644
--- a/src/main/java/com/online/edu/entity/rbac/vo/UserInfoVO.java
+++ b/src/main/java/com/online/edu/entity/rbac/vo/UserInfoVO.java
@@ -61,6 +61,7 @@ public class UserInfoVO {
private String email;
+ private String avatar;
public UserInfoVO(UserInfoDAO userInfoDAO, List roles) {
this.id = userInfoDAO.getId();
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/UserLoginVO.java b/src/main/java/com/online/edu/entity/rbac/vo/UserLoginVO.java
index 7574fdfe8885a6bd8dde1e3d499959f8512ef5dc..c1fcc096d93dffc9b1efe73fca521e7442f2a204 100644
--- a/src/main/java/com/online/edu/entity/rbac/vo/UserLoginVO.java
+++ b/src/main/java/com/online/edu/entity/rbac/vo/UserLoginVO.java
@@ -28,6 +28,12 @@ public class UserLoginVO {
*/
@NotBlank(message = "[密码]不能为空")
@Size(max = 100, message = "编码长度不能超过100")
- @Schema(description = "密码,为加密格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "password")
+ @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "password")
private String password;
+
+ /**
+ * 验证码
+ */
+ @Schema(description = "验证码", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1234")
+ private String code;
}
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/UserQueryVO.java b/src/main/java/com/online/edu/entity/rbac/vo/UserQueryVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..70b378ba57856e9640ecaa857a51d3f5359caf0a
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/rbac/vo/UserQueryVO.java
@@ -0,0 +1,61 @@
+package com.online.edu.entity.rbac.vo;
+
+import com.online.edu.common.PageParam;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.hibernate.validator.constraints.Range;
+
+import java.util.Date;
+
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class UserQueryVO extends PageParam {
+
+
+ /**
+ * 用户名
+ */
+ private String username;
+
+ /**
+ * 显示名
+ */
+ private String displayName;
+
+
+ /**
+ * 电话号
+ */
+ private String phone;
+
+ /**
+ * 邮箱
+ */
+ private String email;
+
+ /**
+ * 已删除
+ */
+ @Range(min = 0, max = 1)
+ private Integer isDeleted;
+
+ /**
+ * 状态
+ */
+ @Range(min = 0, max = 1)
+ private Integer status;
+
+ /**
+ * 创建时间
+ */
+ private Date oldDate;
+
+ /**
+ * 更新时间
+ */
+ private Date newDate;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/rbac/vo/UserUpdateVO.java b/src/main/java/com/online/edu/entity/rbac/vo/UserUpdateVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2427a24f5ed118fa2963ecdceb4c6d3e99d5614
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/rbac/vo/UserUpdateVO.java
@@ -0,0 +1,42 @@
+package com.online.edu.entity.rbac.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
+public class UserUpdateVO {
+
+ /**
+ * 用户ID
+ */
+ @NotNull(message = "[用户ID]不能为空")
+ @Schema(description = "用户ID")
+ private String id;
+
+ /**
+ * 用户ID
+ */
+ @NotNull(message = "[用户名]不能为空")
+ @Schema(description = "用户名")
+ private String username;
+
+ /**
+ * 姓名
+ */
+ @NotNull(message = "[姓名]不能为空")
+ @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
+ private String displayName;
+
+ private String phone;
+
+ private String email;
+
+
+}
diff --git a/src/main/java/com/online/edu/entity/resource/LiveResourceVO.java b/src/main/java/com/online/edu/entity/resource/LiveResourceVO.java
index 8b2640c645655a1b667a1b728a3bebb57d47a23b..705134daffd006683ba51e8e6f2bf455a99a7cc0 100644
--- a/src/main/java/com/online/edu/entity/resource/LiveResourceVO.java
+++ b/src/main/java/com/online/edu/entity/resource/LiveResourceVO.java
@@ -35,10 +35,13 @@ public class LiveResourceVO implements Resource {
@Override
public String getAccess() {
- return roomId;
+ Date now = new Date();
+ if (now.after(getStartTime()) && now.before(getEndTime())) {
+ return roomId;
+ }
+ return null;
}
- @Override
public String getCover() {
return cover;
}
diff --git a/src/main/java/com/online/edu/entity/resource/Resource.java b/src/main/java/com/online/edu/entity/resource/Resource.java
index f13b28a65433c6b4b655c5e76ab292d83460b1c5..641c0b4bdaa84d0c0ec34782cd350951e2c47e04 100644
--- a/src/main/java/com/online/edu/entity/resource/Resource.java
+++ b/src/main/java/com/online/edu/entity/resource/Resource.java
@@ -5,7 +5,6 @@ public interface Resource {
public String getAccess();
- public String getCover();
public Integer getSort();
diff --git a/src/main/java/com/online/edu/entity/resource/StaticResource.java b/src/main/java/com/online/edu/entity/resource/StaticResource.java
index 91aafd623f77f00f42f734c41b118cf74076178c..ea219c52da0ba6bbb9c4b439debd1e9b2cb06376 100644
--- a/src/main/java/com/online/edu/entity/resource/StaticResource.java
+++ b/src/main/java/com/online/edu/entity/resource/StaticResource.java
@@ -32,11 +32,6 @@ public class StaticResource implements Serializable {
*/
private String name;
- /**
- * 封面
- */
- private String cover;
-
/**
* oss文件Id
*/
@@ -56,7 +51,7 @@ public class StaticResource implements Serializable {
/**
* 可以在线访问
*/
- private Integer isAccessable;
+ private Integer isAccessible;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/online/edu/entity/resource/StaticResourceVO.java b/src/main/java/com/online/edu/entity/resource/StaticResourceVO.java
index 4160c6e509a28d211f3d26ad3cf52d6da7893dcd..2d5a7ba82e7f05d1c571f413e3ca11f52c50aae9 100644
--- a/src/main/java/com/online/edu/entity/resource/StaticResourceVO.java
+++ b/src/main/java/com/online/edu/entity/resource/StaticResourceVO.java
@@ -1,5 +1,6 @@
package com.online.edu.entity.resource;
+import com.online.edu.service.resource.VideoService;
import lombok.*;
import lombok.experimental.Accessors;
@@ -14,28 +15,28 @@ public class StaticResourceVO implements Resource {
private String name;
- private String cover;
-
@Getter(AccessLevel.PROTECTED)
private OSSFile file;
private Integer sort;
- private Boolean isAccessible;
+ private Integer isAccessible;
- public OSSFile getDownload() {
- return file;
+ public static StaticResourceVO convert(StaticResource staticResource, OSSFile file) {
+ return new StaticResourceVO(staticResource.getId(), staticResource.getName(), file, staticResource.getSort(), staticResource.getIsAccessible());
}
- public static StaticResourceVO convert(StaticResource staticResource,OSSFile file){
- return new StaticResourceVO(staticResource.getId(), staticResource.getName(),
- staticResource.getCover(),file,staticResource.getSort(),staticResource.getIsAccessable()==1);
+ public String getDownload() {
+ return file.getPath();
}
@Override
public String getAccess() {
- return getIsAccessible() ? file.getName() : "";
+ if (getIsAccessible() == 0) {
+ return "";
+ }
+ return getFile().getType().startsWith("video") ? VideoService.getVideoPath(getFile()) : getFile().getPath();
}
@Override
diff --git a/src/main/java/com/online/edu/entity/resource/VideoResourceVO.java b/src/main/java/com/online/edu/entity/resource/VideoResourceVO.java
index ad19a77d78d3ca1e059191efac3afe9a98978493..c55751094bb8d9c1037a7499e280d294a422ca52 100644
--- a/src/main/java/com/online/edu/entity/resource/VideoResourceVO.java
+++ b/src/main/java/com/online/edu/entity/resource/VideoResourceVO.java
@@ -1,5 +1,6 @@
package com.online.edu.entity.resource;
+import com.online.edu.service.resource.VideoService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,7 +19,7 @@ public class VideoResourceVO extends StaticResourceVO {
@Override
public String getAccess() {
- return getFile().getName();
+ return VideoService.getVideoPath(getFile());
}
public LinkedHashMap generateResolutionUrls() {
diff --git a/src/main/java/com/online/edu/entity/stat/vo/AdminStatVO.java b/src/main/java/com/online/edu/entity/stat/vo/AdminStatVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..a4c71982e9fbefc40f071345794b749488e166df
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/stat/vo/AdminStatVO.java
@@ -0,0 +1,52 @@
+package com.online.edu.entity.stat.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class AdminStatVO implements Serializable {
+ @Schema(description = "管理员数目")
+ private Integer adminCount;
+
+ @Schema(description = "已禁用管理员数目")
+ private Integer disabledAdminCount;
+
+ @Schema(description = "教师数目")
+ private Integer teacherCount;
+
+
+ @Schema(description = "已禁用教师数目")
+ private Integer disabledTeacherCount;
+
+
+ private Integer disabledStudentCount;
+
+ @Schema(description = "课程数目")
+ private Integer courseCount;
+
+
+ @Schema(description = "公开开课课程数目")
+ private Integer enabledCourseCount;
+
+ @Schema(description = "已禁用课程数目")
+ private Integer disabledCourseCount;
+
+ @Schema(description = "未上架课程数目")
+ private Integer editingCourseCount;
+
+ @Schema(description = "审核中课程数目")
+ private Integer auditingCourseCount;
+
+ @Schema(description = "已驳回课程数目")
+ private Integer rejectedCourseCount;
+
+
+ @Schema(description = "资源总数")
+ private Integer resourceCount;
+
+ @Schema(description = "订单总数")
+ private Integer orderCount;
+
+}
diff --git a/src/main/java/com/online/edu/entity/stat/vo/TeacherStatVO.java b/src/main/java/com/online/edu/entity/stat/vo/TeacherStatVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d8bc641b995aa1170a82e4fb822e306401ebb26
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/stat/vo/TeacherStatVO.java
@@ -0,0 +1,27 @@
+package com.online.edu.entity.stat.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class TeacherStatVO implements Serializable {
+ @Schema(description = "已上架课程数量")
+ private Integer courseCount;
+
+ @Schema(description = "已上架课程章节数量")
+ private Integer sectionCount;
+
+ @Schema(description = "评论数量")
+ private Integer commentCount;
+
+
+ @Schema(description = "加入时间")
+ private Date joinDateTime;
+
+ @Schema(description = "加入时长")
+ private Integer joinDaysCount;
+
+}
diff --git a/src/main/java/com/online/edu/entity/userInfo/TeacherInfo.java b/src/main/java/com/online/edu/entity/userInfo/TeacherInfo.java
index 3792fa2089f6847a79185871d0eb88750a74f3af..9c55a6ebfcc81750a4a27c8ae7e605e1c05982eb 100644
--- a/src/main/java/com/online/edu/entity/userInfo/TeacherInfo.java
+++ b/src/main/java/com/online/edu/entity/userInfo/TeacherInfo.java
@@ -1,33 +1,68 @@
package com.online.edu.entity.userInfo;
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import lombok.experimental.Accessors;
-import java.io.Serial;
import java.io.Serializable;
+import java.util.Date;
/**
* 教师信息
- *
* @TableName teacher_info
*/
+@TableName(value ="teacher_info")
@Data
+@Accessors(chain = true)
public class TeacherInfo implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
/**
* 教师id
*/
- @TableId(value = "id", type = IdType.ASSIGN_ID)
-
+ @TableId
private String teacherId;
+
+ /**
+ * 教师头像
+ */
+ private String teacherAvatar;
+
/**
* 教师姓名
*/
private String teacherName;
+
/**
* 教师描述
*/
private String teacherDescription;
+
+ /**
+ * 教师邮箱
+ */
+ private String teacherEmail;
+
+ /**
+ * 教师状态:0禁用,1已审核,2待审核
+ */
+ private Integer status;
+
+ /**
+ * 已删除
+ */
+ private Integer isDeleted;
+
+ /**
+ * 创建时间
+ */
+ private Date createdAt;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedAt;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/userInfo/vo/NewTeacherInfo.java b/src/main/java/com/online/edu/entity/userInfo/vo/NewTeacherInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbf43433f688bc2732c9a8835efedf02790ce817
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/userInfo/vo/NewTeacherInfo.java
@@ -0,0 +1,52 @@
+package com.online.edu.entity.userInfo.vo;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.online.edu.entity.userInfo.TeacherInfo;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 教师信息
+ * @TableName teacher_info
+ */
+@TableName(value ="teacher_info")
+@Data
+public class NewTeacherInfo implements Serializable {
+
+
+ /**
+ * 教师头像
+ */
+ private String teacherAvatar;
+
+ /**
+ * 教师姓名
+ */
+ private String teacherName;
+
+ /**
+ * 教师描述
+ */
+ private String teacherDescription;
+
+ /**
+ * 教师邮箱
+ */
+ private String teacherEmail;
+
+ public TeacherInfo bulidTeacherInfo(String userId){
+ if(userId == null){
+ return null;
+ }
+ TeacherInfo result = new TeacherInfo();
+ result.setTeacherId(userId);
+ result.setTeacherEmail(teacherEmail);
+ result.setTeacherAvatar(teacherAvatar);
+ result.setTeacherDescription(teacherDescription);
+ result.setTeacherName(teacherName);
+ result.setIsDeleted(0);
+ result.setStatus(2);
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/userInfo/vo/RegisterVO.java b/src/main/java/com/online/edu/entity/userInfo/vo/RegisterVO.java
index 8bb75d9b5861c8e6cae5e2a5f3ea9d8439afa0b1..774af7e70355c542478488f480801364e19a4d8b 100644
--- a/src/main/java/com/online/edu/entity/userInfo/vo/RegisterVO.java
+++ b/src/main/java/com/online/edu/entity/userInfo/vo/RegisterVO.java
@@ -1,23 +1,26 @@
package com.online.edu.entity.userInfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
@Data
public class RegisterVO { //注册对象
@Schema(description = "用户名")
+ @NotEmpty
private String username;
@Schema(description = "显示名")
+ @NotEmpty
private String displayName;
@Schema(description = "手机号")
+ @NotEmpty
private String mobile;
@Schema(description = "密码")
+ @NotEmpty
private String password;
- @Schema(description = "验证码")
- private String code;
}
diff --git a/src/main/java/com/online/edu/entity/userInfo/vo/TeacherQueryVO.java b/src/main/java/com/online/edu/entity/userInfo/vo/TeacherQueryVO.java
new file mode 100644
index 0000000000000000000000000000000000000000..72161e23dfe5c4cf513ed889171056f52239de16
--- /dev/null
+++ b/src/main/java/com/online/edu/entity/userInfo/vo/TeacherQueryVO.java
@@ -0,0 +1,47 @@
+package com.online.edu.entity.userInfo.vo;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.online.edu.common.PageParam;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+/**
+ * 教师信息
+ * @TableName teacher_info
+ */
+@TableName(value ="teacher_info")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class TeacherQueryVO extends PageParam {
+
+ /**
+ * 教师姓名
+ */
+ private String teacherName;
+
+
+ /**
+ * 教师状态:0禁用,1已审核,2待审核
+ */
+ private Integer status;
+
+ /**
+ * 已删除
+ */
+ private Integer isDeleted;
+
+ /**
+ * 创建时间
+ */
+ private Date oldDate;
+
+ /**
+ * 更新时间
+ */
+ private Date newDate;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/online/edu/entity/verification/BaseVerifyCode.java b/src/main/java/com/online/edu/entity/verification/BaseVerifyCode.java
deleted file mode 100644
index 5eb9ef34ba0f2dbab88f25638dbbcd59bdd3d9dd..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/entity/verification/BaseVerifyCode.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.online.edu.entity.verification;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-
-@Data
-public class BaseVerifyCode implements Serializable {
-
- private String verifyCode;
-
- private LocalDateTime expireTime;
-
- public BaseVerifyCode(String verifyCode, int expireSecond) {
- this.verifyCode = verifyCode;
- this.expireTime = LocalDateTime.now().plusSeconds(expireSecond);
- }
-
- public BaseVerifyCode(String verifyCode, LocalDateTime expireTime) {
- this.verifyCode = verifyCode;
- this.expireTime = expireTime;
- }
-
- //判断是否过期
- public boolean isExpire() {
- return LocalDateTime.now().isAfter(expireTime);
- }
-}
diff --git a/src/main/java/com/online/edu/entity/verification/ImageVerifyCode.java b/src/main/java/com/online/edu/entity/verification/ImageVerifyCode.java
deleted file mode 100644
index 2d6dc949a1185cd52090d99cc0ad54f79d294ede..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/entity/verification/ImageVerifyCode.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.online.edu.entity.verification;
-
-import java.awt.image.BufferedImage;
-import java.time.LocalDateTime;
-
-
-public class ImageVerifyCode extends BaseVerifyCode {
-
- private BufferedImage image;
-
-
- public ImageVerifyCode(BufferedImage image, String verifyCode, int expireSecond) {
- super(verifyCode, expireSecond);
- this.image = image;
- }
-
- public ImageVerifyCode(BufferedImage image, String verifyCode, LocalDateTime expireTime) {
- super(verifyCode, expireTime);
- this.image = image;
- }
-
- public BufferedImage getImage() {
- return image;
- }
-
- public ImageVerifyCode setImage(BufferedImage image) {
- this.image = image;
- return this;
- }
-}
diff --git a/src/main/java/com/online/edu/mapper/banner/BannerMapper.java b/src/main/java/com/online/edu/mapper/banner/BannerMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..c62b701ffc1e1beec785ec613186c9fbbd3c1ea8
--- /dev/null
+++ b/src/main/java/com/online/edu/mapper/banner/BannerMapper.java
@@ -0,0 +1,35 @@
+package com.online.edu.mapper.banner;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.online.edu.common.PageParam;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.banner.Banner;
+import com.online.edu.entity.banner.vo.BannerQueryVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author Nvnqs
+ * @description 针对表【banner(banner表)】的数据库操作Mapper
+ */
+public interface BannerMapper extends BaseMapper {
+
+ default PageResult selectPage(BannerQueryVO queryVO) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
+ .like(queryVO.getTitle() != null, Banner::getTitle, queryVO.getTitle())
+ .eq(queryVO.getEnable() != null, Banner::getEnable, Boolean.TRUE.equals(queryVO.getEnable()) ? 1 : 0)
+ .orderByDesc(Banner::getSort);
+ IPage mpPage = PageParam.buildPage(queryVO);
+ selectPage(mpPage, wrapper);
+ // 转换返回
+ return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
+ }
+
+ int updateEnableById(@Param("enable") Integer enable, @Param("id") Integer id);
+
+}
+
+
+
+
diff --git a/src/main/java/com/online/edu/mapper/course/CommentMapper.java b/src/main/java/com/online/edu/mapper/course/CommentMapper.java
index 681dfc28cf82c154752852b5a9dd77e5f331cd2a..aab819c626dd0e7ed6741ce4ea76104b5cf090c6 100644
--- a/src/main/java/com/online/edu/mapper/course/CommentMapper.java
+++ b/src/main/java/com/online/edu/mapper/course/CommentMapper.java
@@ -1,5 +1,4 @@
package com.online.edu.mapper.course;
-import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -8,6 +7,7 @@ import com.online.edu.common.PageParam;
import com.online.edu.common.PageResult;
import com.online.edu.entity.course.Comment;
import com.online.edu.entity.course.vo.CommentQueryVO;
+import org.apache.ibatis.annotations.Param;
/**
* @author Nvnqs
@@ -19,6 +19,7 @@ public interface CommentMapper extends BaseMapper {
default PageResult selectPage(CommentQueryVO queryVO) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
.eq(queryVO.getCourseId() != null, Comment::getCourseId, queryVO.getCourseId())
+ .in(queryVO.getCourses() != null && queryVO.getCourses().size() != 0, Comment::getCourseId, queryVO.getCourses())
.eq(queryVO.getStudentId() != null, Comment::getStudentId, queryVO.getStudentId())
.between(queryVO.getNewTime() != null && queryVO.getOldTime() != null, Comment::getCreatedAt, queryVO.getOldTime(), queryVO.getNewTime())
.eq(queryVO.getIsDeleted() != null, Comment::getIsDeleted, queryVO.getIsDeleted())
diff --git a/src/main/java/com/online/edu/mapper/course/CourseInfoMapper.java b/src/main/java/com/online/edu/mapper/course/CourseInfoMapper.java
index 2d60bde3c703d6b7f7d619c9968ea634489b31e4..01723a4a13d102508cd816a5d2a4997bf3e9411a 100644
--- a/src/main/java/com/online/edu/mapper/course/CourseInfoMapper.java
+++ b/src/main/java/com/online/edu/mapper/course/CourseInfoMapper.java
@@ -1,5 +1,4 @@
package com.online.edu.mapper.course;
-import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -7,7 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.online.edu.common.PageParam;
import com.online.edu.common.PageResult;
import com.online.edu.entity.course.CourseInfo;
+import com.online.edu.entity.course.vo.CourseBasicInfo;
import com.online.edu.entity.course.vo.CourseQueryVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* @author Nvnqs
@@ -22,6 +25,7 @@ public interface CourseInfoMapper extends BaseMapper {
.eq(queryVO.getTeacherId() != null, CourseInfo::getTeacherId, queryVO.getTeacherId())
.eq(queryVO.getTypeId() != null, CourseInfo::getTypeId, queryVO.getTypeId())
.eq(queryVO.getStatus() != null, CourseInfo::getStatus, queryVO.getStatus())
+ .ge(queryVO.getStatus() == null, CourseInfo::getStatus, 2)
.between(queryVO.getMinPrice() != null && queryVO.getMaxPrice() != null, CourseInfo::getPrice, queryVO.getMinPrice(), queryVO.getMaxPrice())
.eq(queryVO.getIsDeleted() != null, CourseInfo::getIsDeleted, queryVO.getIsDeleted())
.eq(queryVO.getIsDeleted() == null, CourseInfo::getIsDeleted, 0)
@@ -33,6 +37,10 @@ public interface CourseInfoMapper extends BaseMapper {
}
int updateIsDeletedById(@Param("isDeleted") Integer isDeleted, @Param("id") String id);
+
+ List listAll(@Param("teacherId") String teacherId);
+
+ List listAllId(@Param("teacherId") String teacherId);
}
diff --git a/src/main/java/com/online/edu/mapper/course/CourseTypeMapper.java b/src/main/java/com/online/edu/mapper/course/CourseTypeMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..5664fbbb5f68d2af60d5f712ba7d28ba9485a56f
--- /dev/null
+++ b/src/main/java/com/online/edu/mapper/course/CourseTypeMapper.java
@@ -0,0 +1,37 @@
+package com.online.edu.mapper.course;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.online.edu.common.PageParam;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.course.CourseType;
+import com.online.edu.entity.course.vo.CourseTypeQueryVO;
+
+/**
+ * @author Nvnqs
+ * @description 针对表【course_type(课程类型)】的数据库操作Mapper
+ * @createDate 2023-06-17 19:44:29
+ * @Entity com.online.edu.entity.course.CourseType
+ */
+public interface CourseTypeMapper extends BaseMapper {
+
+ default PageResult selectPage(CourseTypeQueryVO queryVO) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
+ .like(queryVO.getCourseType() != null, CourseType::getCourseType, queryVO.getCourseType())
+ .orderByDesc(CourseType::getId);
+ IPage mpPage = PageParam.buildPage(queryVO);
+ selectPage(mpPage, wrapper);
+ // 转换返回
+ return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
+ }
+
+
+ int addAll(CourseType courseType);
+
+ int updateCourseType(CourseType courseType);
+}
+
+
+
+
diff --git a/src/main/java/com/online/edu/mapper/message/MessageMapper.java b/src/main/java/com/online/edu/mapper/message/MessageMapper.java
index 5620999fef176dd78847252764961a53f29627fe..03472fa11bcd4c219f656c783f3800fe3d787c4c 100644
--- a/src/main/java/com/online/edu/mapper/message/MessageMapper.java
+++ b/src/main/java/com/online/edu/mapper/message/MessageMapper.java
@@ -1,16 +1,22 @@
package com.online.edu.mapper.message;
-import com.online.edu.entity.message.Message;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.online.edu.entity.message.Message;
+import org.apache.ibatis.annotations.Param;
/**
-* @author Nvnqs
-* @description 针对表【message(消息表)】的数据库操作Mapper
-* @createDate 2023-06-17 14:32:31
-* @Entity com.online.edu.entity.message.Message
-*/
+ * @author Nvnqs
+ * @description 针对表【message(消息表)】的数据库操作Mapper
+ * @createDate 2023-06-17 14:32:31
+ * @Entity com.online.edu.entity.message.Message
+ */
public interface MessageMapper extends BaseMapper {
+ int updateReadStatusByReceiverId(@Param("readStatus") Integer readStatus, @Param("receiverId") String receiverId);
+
+ int updateDeletedByReceiverId(@Param("deleted") Integer deleted, @Param("receiverId") String receiverId);
+
+ int updateDeletedByReceiverIdAndId(@Param("deleted") Integer deleted, @Param("receiverId") String receiverId, @Param("id") String id);
}
diff --git a/src/main/java/com/online/edu/mapper/message/MessageTemplateMapper.java b/src/main/java/com/online/edu/mapper/message/MessageTemplateMapper.java
deleted file mode 100644
index 0f4e77d8b0329134848a08b8b79b7bfc64a74cab..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/mapper/message/MessageTemplateMapper.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.online.edu.mapper.message;
-
-import com.online.edu.entity.message.MessageTemplate;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
-* @author Nvnqs
-* @description 针对表【message_template(站内信模板表)】的数据库操作Mapper
-* @createDate 2023-06-17 14:32:31
-* @Entity com.online.edu.entity.message.MessageTemplate
-*/
-public interface MessageTemplateMapper extends BaseMapper {
-
-}
-
-
-
-
diff --git a/src/main/java/com/online/edu/mapper/message/SystemNotifyMessageMapper.java b/src/main/java/com/online/edu/mapper/message/SystemNotifyMessageMapper.java
deleted file mode 100644
index e3b24f0c755a830c2b1d858c1e6dfca47c061e29..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/mapper/message/SystemNotifyMessageMapper.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.online.edu.mapper.message;
-
-import com.online.edu.entity.message.SystemNotifyMessage;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
-* @author Nvnqs
-* @description 针对表【system_notify_message(站内信消息表)】的数据库操作Mapper
-* @createDate 2023-06-17 14:32:31
-* @Entity com.online.edu.entity.message.SystemNotifyMessage
-*/
-public interface SystemNotifyMessageMapper extends BaseMapper {
-
-}
-
-
-
-
diff --git a/src/main/java/com/online/edu/mapper/order/CourseElectionMapper.java b/src/main/java/com/online/edu/mapper/order/CourseElectionMapper.java
index e576ff2d68cd413fdf02147f408484943d62cf89..55bab45ac726558591ee9e75655a19db9a421e37 100644
--- a/src/main/java/com/online/edu/mapper/order/CourseElectionMapper.java
+++ b/src/main/java/com/online/edu/mapper/order/CourseElectionMapper.java
@@ -1,7 +1,16 @@
package com.online.edu.mapper.order;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.online.edu.common.PageParam;
+import com.online.edu.common.PageResult;
import com.online.edu.entity.order.CourseElection;
+import com.online.edu.entity.order.vo.CourseElectionQueryVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* @author Nvnqs
@@ -9,8 +18,33 @@ import com.online.edu.entity.order.CourseElection;
* @createDate 2023-06-04 17:20:56
* @Entity com.online.edu.entity.order.CourseElection
*/
+@Mapper
public interface CourseElectionMapper extends BaseMapper {
+ int insertAll(CourseElection courseElection);
+
+ List getById(@Param("studentId") Long studentId);
+
+ List getByCourse(@Param("courseId") Long courseId);
+
+ int updateById(@Param("serialNumber") String serialNumber, @Param("status") Integer status);
+
+
+ default PageResult selectPage(CourseElectionQueryVO queryVO) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
+ .like(queryVO.getSerialNumber() != null, CourseElection::getSerialNumber, queryVO.getSerialNumber())
+ .like(queryVO.getStudentName() != null, CourseElection::getStudentName, queryVO.getStudentName())
+ .eq(queryVO.getStatus() != null, CourseElection::getStatus, queryVO.getStatus())
+ .between(queryVO.getNewDate() != null && queryVO.getOldDate() != null, CourseElection::getCreatedAt,
+ queryVO.getOldDate(), queryVO.getNewDate())
+ .eq(queryVO.getIsDeleted() != null, CourseElection::getIsDeleted, queryVO.getIsDeleted())
+ .eq(queryVO.getIsDeleted() == null, CourseElection::getIsDeleted, 0)
+ .orderByDesc(CourseElection::getId);
+ IPage mpPage = PageParam.buildPage(queryVO);
+ selectPage(mpPage, wrapper);
+ // 转换返回
+ return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
+ }
}
diff --git a/src/main/java/com/online/edu/mapper/order/CourseOrderMapper.java b/src/main/java/com/online/edu/mapper/order/CourseOrderMapper.java
index 1398bcf053ca95f82add0efa686ab53316196055..f2c991c7849f092a70aaf9cc094c821b4d3889b7 100644
--- a/src/main/java/com/online/edu/mapper/order/CourseOrderMapper.java
+++ b/src/main/java/com/online/edu/mapper/order/CourseOrderMapper.java
@@ -2,6 +2,9 @@ package com.online.edu.mapper.order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.online.edu.entity.order.CourseOrder;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
/**
* @author Nvnqs
@@ -10,6 +13,13 @@ import com.online.edu.entity.order.CourseOrder;
* @Entity com.online.edu.entity.order.CourseOrder
*/
public interface CourseOrderMapper extends BaseMapper {
+ int insertAll(CourseOrder courseOrder);
+
+ int updateById(@Param("serialNumber") String serialNumber, @Param("tradeState") String tradeState,
+ @Param("payedAt") Date payedAt, @Param("transactionId") String transactionId);
+
+ int updateWaitPayById(@Param("serialNumber") String serialNumber, @Param("tradeState") String tradeState);
+
}
diff --git a/src/main/java/com/online/edu/mapper/rbac/UserMapper.java b/src/main/java/com/online/edu/mapper/rbac/UserMapper.java
index 907d58e44a7d91cff7ba84aae583cdd872303012..1e0b0e775c6281ed04678738afd4064b793c8d11 100644
--- a/src/main/java/com/online/edu/mapper/rbac/UserMapper.java
+++ b/src/main/java/com/online/edu/mapper/rbac/UserMapper.java
@@ -1,12 +1,17 @@
package com.online.edu.mapper.rbac;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.online.edu.common.PageParam;
+import com.online.edu.common.PageResult;
import com.online.edu.entity.rbac.UserInfo;
import com.online.edu.entity.rbac.UserInfoDAO;
import com.online.edu.entity.rbac.vo.PermissionMenuVO;
import com.online.edu.entity.rbac.vo.PermissionVO;
-import com.online.edu.entity.rbac.vo.UserInfoVO;
-import jakarta.validation.constraints.NotNull;
+import com.online.edu.entity.rbac.vo.UserQueryVO;
+import com.online.edu.entity.rbac.vo.UserUpdateVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -15,7 +20,7 @@ import java.util.List;
import java.util.Set;
@Mapper
-public interface UserMapper {
+public interface UserMapper extends BaseMapper {
UserInfoDAO getUserByUsername(String username);
List getAllByStatusInWithoutPassword(@Param("statusList") Collection statusList);
@@ -30,16 +35,49 @@ public interface UserMapper {
int updateDisplayNameByUsername(@Param("displayName") String displayName, @Param("username") String username);
+ int updateEmailAndPhoneAndDisplayNameById(UserUpdateVO userUpdateVO);
+
int updatePasswordByUsername(@Param("password") String password, @Param("username") String username);
int updateStatusByUsername(@Param("status") Integer status, @Param("username") String username);
- List getAllByRole(@Param("role_id") String roleId);
+ List getAllByRole(@Param("role_id") String roleId);
- @NotNull(message = "[用户ID]不能为空") String getIdByUsername(@Param("username") String username);
+ String getIdByUsername(@Param("username") String username);
int delById(@Param("id") String id);
+
+ int delLogicById(@Param("id") String id);
+
+ int recoverById(@Param("id") String id);
+
Set getMenu(@Param("username") String username);
+
+ String getAvatarById(@Param("id") String id);
+
+ int updateAvatarById(@Param("avatar") String avatar, @Param("id") String id);
+
+ default PageResult selectPage(UserQueryVO queryVO) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
+ .like(queryVO.getUsername() != null, UserInfo::getUsername, queryVO.getUsername())
+ .like(queryVO.getDisplayName() != null, UserInfo::getDisplayName, queryVO.getDisplayName())
+ .like(queryVO.getPhone() != null, UserInfo::getPhone, queryVO.getPhone())
+ .like(queryVO.getEmail() != null, UserInfo::getEmail, queryVO.getEmail())
+ .between(queryVO.getOldDate() != null && queryVO.getNewDate() != null, UserInfo::getCreatedAt, queryVO.getOldDate(), queryVO.getNewDate())
+ .eq(queryVO.getStatus() != null, UserInfo::getStatus, queryVO.getStatus())
+ .eq(queryVO.getStatus() == null, UserInfo::getStatus, 1)
+ .eq(queryVO.getIsDeleted() != null, UserInfo::getIsDeleted, queryVO.getIsDeleted())
+ .eq(queryVO.getIsDeleted() == null, UserInfo::getIsDeleted, 0)
+
+ .orderByDesc(UserInfo::getId);
+ IPage mpPage = PageParam.buildPage(queryVO);
+ selectPage(mpPage, wrapper);
+ // 转换返回
+ return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
+ }
+
+
+ int countByUsernameAndStatusAndIsDeleted(@Param("username") String username, @Param("status") Integer status, @Param("isDeleted") Integer isDeleted);
}
diff --git a/src/main/java/com/online/edu/mapper/rbac/UserRoleRelationMapper.java b/src/main/java/com/online/edu/mapper/rbac/UserRoleRelationMapper.java
index e41ac3850afa1e1399fed81fb2aeca7c1b099842..36a12ceffbdfb017fd1651854f08be796f862369 100644
--- a/src/main/java/com/online/edu/mapper/rbac/UserRoleRelationMapper.java
+++ b/src/main/java/com/online/edu/mapper/rbac/UserRoleRelationMapper.java
@@ -24,6 +24,9 @@ public interface UserRoleRelationMapper {
List getUserNameByRoleId(@Param("roleId") String roleId);
int getByUserIdAndRoleId(@Param("userId") String userId, @Param("roleId") String roleId);
+
+
+ List getByRoleId(@Param("roleId") String roleId);
}
diff --git a/src/main/java/com/online/edu/mapper/stat/StatMapper.java b/src/main/java/com/online/edu/mapper/stat/StatMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..da83bbab2cc8a17fa588f5513658bdc7dd380b44
--- /dev/null
+++ b/src/main/java/com/online/edu/mapper/stat/StatMapper.java
@@ -0,0 +1,7 @@
+package com.online.edu.mapper.stat;
+
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface StatMapper {
+}
diff --git a/src/main/java/com/online/edu/mapper/userInfo/SocialUserMapper.java b/src/main/java/com/online/edu/mapper/userInfo/SocialUserMapper.java
deleted file mode 100644
index 5d4b0a79b0845006f5a0130688c4198b6ecffcf2..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/mapper/userInfo/SocialUserMapper.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.online.edu.mapper.userInfo;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.online.edu.entity.userInfo.SocialUser;
-
-/**
- * @author Nvnqs
- * @description 针对表【social_user(第三方登录用户)】的数据库操作Mapper
- * @createDate 2023-06-04 17:20:56
- * @Entity com.online.edu.entity.userInfo.SocialUser
- */
-public interface SocialUserMapper extends BaseMapper {
-
-
-}
-
-
-
-
diff --git a/src/main/java/com/online/edu/mapper/userInfo/TeacherInfoMapper.java b/src/main/java/com/online/edu/mapper/userInfo/TeacherInfoMapper.java
index f81c4efac68631c8d8fd548fd8d396fcebd55f61..8d787bbe1c045d6c3e16534b30e1300e894f117b 100644
--- a/src/main/java/com/online/edu/mapper/userInfo/TeacherInfoMapper.java
+++ b/src/main/java/com/online/edu/mapper/userInfo/TeacherInfoMapper.java
@@ -1,7 +1,12 @@
package com.online.edu.mapper.userInfo;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.online.edu.common.PageParam;
+import com.online.edu.common.PageResult;
import com.online.edu.entity.userInfo.TeacherInfo;
+import com.online.edu.entity.userInfo.vo.TeacherQueryVO;
import org.apache.ibatis.annotations.Param;
/**
@@ -12,6 +17,25 @@ import org.apache.ibatis.annotations.Param;
*/
public interface TeacherInfoMapper extends BaseMapper {
int countByTeacherId(@Param("teacherId") String teacherId);
+
+ int updateStatusByTeacherId(@Param("status") Integer status, @Param("teacherId") String teacherId);
+
+ int updateIsDeletedByTeacherId(@Param("isDeleted") Integer isDeleted, @Param("teacherId") String teacherId);
+
+ default PageResult selectPage(TeacherQueryVO queryVO) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper()
+ .like(queryVO.getTeacherName() != null, TeacherInfo::getTeacherName, queryVO.getTeacherName())
+ .between(queryVO.getOldDate() != null && queryVO.getNewDate() != null, TeacherInfo::getCreatedAt, queryVO.getOldDate(), queryVO.getNewDate())
+ .eq(queryVO.getIsDeleted() != null, TeacherInfo::getIsDeleted, queryVO.getIsDeleted())
+ .eq(queryVO.getIsDeleted() == null, TeacherInfo::getIsDeleted, 0)
+ .eq(queryVO.getStatus() != null, TeacherInfo::getStatus, queryVO.getStatus())
+ .eq(queryVO.getStatus() == null, TeacherInfo::getStatus, 1)
+ .orderByDesc(TeacherInfo::getTeacherId);
+ IPage mpPage = PageParam.buildPage(queryVO);
+ selectPage(mpPage, wrapper);
+ // 转换返回
+ return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
+ }
}
diff --git a/src/main/java/com/online/edu/service/banner/BannerService.java b/src/main/java/com/online/edu/service/banner/BannerService.java
new file mode 100644
index 0000000000000000000000000000000000000000..75301ff1a7fe6e0b11f505a58e82bf30dcaeaf10
--- /dev/null
+++ b/src/main/java/com/online/edu/service/banner/BannerService.java
@@ -0,0 +1,24 @@
+package com.online.edu.service.banner;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.banner.Banner;
+import com.online.edu.entity.banner.vo.BannerQueryVO;
+
+import java.util.List;
+
+
+/**
+ * @author Nvnqs
+ */
+public interface BannerService extends IService {
+ PageResult query(BannerQueryVO bannerQuery);
+
+ Banner enable(Integer bannerId);
+
+ Banner disable(Integer bannerId);
+
+ Banner delete(Integer bannerId);
+
+ List get();
+}
diff --git a/src/main/java/com/online/edu/service/banner/impl/BannerServiceImpl.java b/src/main/java/com/online/edu/service/banner/impl/BannerServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..51a4e31ef52ecd177b3ec0dd9f35f85f735195b5
--- /dev/null
+++ b/src/main/java/com/online/edu/service/banner/impl/BannerServiceImpl.java
@@ -0,0 +1,60 @@
+package com.online.edu.service.banner.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.banner.Banner;
+import com.online.edu.entity.banner.vo.BannerQueryVO;
+import com.online.edu.mapper.banner.BannerMapper;
+import com.online.edu.service.banner.BannerService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Nvnqs
+ */
+@Service
+public class BannerServiceImpl extends ServiceImpl
+ implements BannerService {
+
+
+ @Override
+ public PageResult query(BannerQueryVO bannerQuery) {
+ return baseMapper.selectPage(bannerQuery);
+ }
+
+ @Override
+ public Banner enable(Integer bannerId) {
+ Banner banner = getById(bannerId);
+ banner.setEnable(true);
+ baseMapper.updateEnableById(1, bannerId);
+ return banner;
+ }
+
+ @Override
+ public Banner disable(Integer bannerId) {
+ Banner banner = getById(bannerId);
+ banner.setEnable(false);
+ baseMapper.updateEnableById(0, bannerId);
+ return banner;
+ }
+
+ @Override
+ public Banner delete(Integer bannerId) {
+ Banner banner = getById(bannerId);
+ removeById(bannerId);
+ return banner;
+ }
+
+ @Override
+ public List get() {
+ BannerQueryVO bannerQuery = new BannerQueryVO();
+ bannerQuery.setEnable(true);
+ bannerQuery.setPageSize(1000);
+ return query(bannerQuery).getList();
+ }
+}
+
+
+
+
diff --git a/src/main/java/com/online/edu/service/course/CourseInfoService.java b/src/main/java/com/online/edu/service/course/CourseInfoService.java
index 26426aa845f944857eb84b21782ce422eb2e1413..595e539a198d7868489cfbf66830f52e941af9da 100644
--- a/src/main/java/com/online/edu/service/course/CourseInfoService.java
+++ b/src/main/java/com/online/edu/service/course/CourseInfoService.java
@@ -3,9 +3,9 @@ package com.online.edu.service.course;
import com.baomidou.mybatisplus.extension.service.IService;
import com.online.edu.common.PageResult;
import com.online.edu.entity.course.CourseInfo;
-import com.online.edu.entity.course.vo.CourseQueryVO;
-import com.online.edu.entity.course.vo.CourseUpdateVO;
-import com.online.edu.entity.course.vo.NewCourseVO;
+import com.online.edu.entity.course.vo.*;
+
+import java.util.List;
/**
* @author Nvnqs
@@ -22,6 +22,17 @@ public interface CourseInfoService extends IService {
PageResult query(CourseQueryVO courseQueryVO);
+
+ PageResult convertToVO(PageResult courseInfoPageResult);
+
+ CourseInfoVO convertToVO(CourseInfo courseInfoPageResult);
+
+
boolean setIsDeleted(String courseId, Integer isDeleted);
+ List listAll(String teacherId);
+
+
+ List listAllId(String teacherId);
+
}
diff --git a/src/main/java/com/online/edu/service/course/CourseTypeService.java b/src/main/java/com/online/edu/service/course/CourseTypeService.java
new file mode 100644
index 0000000000000000000000000000000000000000..6aef84ff1d08a3532f461d7ca04382bce8fb75e6
--- /dev/null
+++ b/src/main/java/com/online/edu/service/course/CourseTypeService.java
@@ -0,0 +1,22 @@
+package com.online.edu.service.course;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.course.CourseType;
+import com.online.edu.entity.course.vo.CourseTypeQueryVO;
+
+/**
+ * @author Nvnqs
+ * @description 针对表【course_type(课程类型)】的数据库操作Service
+ * @createDate 2023-06-17 19:44:29
+ */
+public interface CourseTypeService extends IService {
+
+
+ boolean addCourseType(CourseType courseType);
+
+ boolean updateCourseType(CourseType courseType);
+
+ PageResult query(CourseTypeQueryVO query);
+
+}
diff --git a/src/main/java/com/online/edu/service/course/impl/CommentServiceImpl.java b/src/main/java/com/online/edu/service/course/impl/CommentServiceImpl.java
index af38410e68dd377efbbc97dc9e6a0b3f28bd67e3..5dbea3fdf7c0a969e52c8b3fce730a19e62e09e4 100644
--- a/src/main/java/com/online/edu/service/course/impl/CommentServiceImpl.java
+++ b/src/main/java/com/online/edu/service/course/impl/CommentServiceImpl.java
@@ -5,10 +5,16 @@ import com.online.edu.common.PageResult;
import com.online.edu.entity.course.Comment;
import com.online.edu.entity.course.vo.CommentQueryVO;
import com.online.edu.entity.course.vo.NewCommentVO;
+import com.online.edu.entity.rbac.UserInfo;
import com.online.edu.mapper.course.CommentMapper;
import com.online.edu.service.course.CommentService;
+import com.online.edu.service.course.CourseInfoService;
+import com.online.edu.service.rbac.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
* @author Nvnqs
* @description 针对表【comment(评论)】的数据库操作Service实现
@@ -18,6 +24,12 @@ import org.springframework.stereotype.Service;
public class CommentServiceImpl extends ServiceImpl
implements CommentService {
+ @Autowired
+ UserService userService;
+
+ @Autowired
+ CourseInfoService courseInfoService;
+
@Override
public boolean checkCommented(String courseId, String studentId) {
return baseMapper.countByCourseIdAndStudentIdAndIsDeleted(courseId, studentId) > 0;
@@ -25,11 +37,12 @@ public class CommentServiceImpl extends ServiceImpl
@Override
public Comment addComment(NewCommentVO newCommentVO) {
- if(newCommentVO == null || checkCommented(newCommentVO.getCourseId(), newCommentVO.getStudentId())) {
+ if (newCommentVO == null) {
return null;
}
- Comment comment = newCommentVO.buildComment();
- if(save(comment)){
+ UserInfo userInfo = userService.getById(newCommentVO.getStudentId());
+ Comment comment = newCommentVO.buildComment(userInfo);
+ if (save(comment)) {
return comment;
}
return null;
@@ -47,6 +60,13 @@ public class CommentServiceImpl extends ServiceImpl
@Override
public PageResult query(CommentQueryVO query) {
+ if (query.getTeacherId() != null) {
+ List courses = courseInfoService.listAllId(query.getTeacherId());
+ if (courses.size() == 0) {
+ courses.add("-1");
+ }
+ query.setCourses(courses);
+ }
return baseMapper.selectPage(query);
}
@@ -54,6 +74,7 @@ public class CommentServiceImpl extends ServiceImpl
public boolean setIsDeleted(String commentId, Integer isDeleted) {
return baseMapper.updateIsDeletedById(isDeleted,commentId) > 0;
}
+
}
diff --git a/src/main/java/com/online/edu/service/course/impl/CourseInfoServiceImpl.java b/src/main/java/com/online/edu/service/course/impl/CourseInfoServiceImpl.java
index 984b72462d155ed86b0fbf31b23519d0df2d9224..21c6eda6887e8c04701eb21eb1f160d3cd7f4156 100644
--- a/src/main/java/com/online/edu/service/course/impl/CourseInfoServiceImpl.java
+++ b/src/main/java/com/online/edu/service/course/impl/CourseInfoServiceImpl.java
@@ -1,34 +1,56 @@
package com.online.edu.service.course.impl;
+import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.online.edu.common.PageResult;
import com.online.edu.entity.course.CourseInfo;
-import com.online.edu.entity.course.vo.CourseQueryVO;
-import com.online.edu.entity.course.vo.CourseUpdateVO;
-import com.online.edu.entity.course.vo.NewCourseVO;
+import com.online.edu.entity.course.CourseType;
+import com.online.edu.entity.course.vo.*;
+import com.online.edu.entity.message.vo.MessageSendVO;
+import com.online.edu.entity.rbac.UserInfoDAO;
+import com.online.edu.entity.resource.CourseSection;
+import com.online.edu.entity.userInfo.TeacherInfo;
import com.online.edu.mapper.course.CourseInfoMapper;
import com.online.edu.service.course.CourseInfoService;
+import com.online.edu.service.course.CourseTypeService;
+import com.online.edu.service.message.MessageService;
+import com.online.edu.service.rbac.UserService;
+import com.online.edu.service.resource.CourseSectionService;
import com.online.edu.service.userInfo.TeacherInfoService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Nvnqs
- * @description 针对表【course_info(课程信息)】的数据库操作Service实现
- * @createDate 2023-06-04 17:20:56
+
*/
@Service
public class CourseInfoServiceImpl extends ServiceImpl
implements CourseInfoService {
@Autowired
TeacherInfoService teacherInfoService;
+
+
+ @Autowired
+ UserService userService;
+ @Autowired
+ CourseTypeService courseTypeService;
+
+ @Autowired
+ CourseSectionService courseSectionService;
+ @Autowired
+ MessageService messageService;
+
@Override
public CourseInfo addCourse(NewCourseVO newCourseVO) {
- CourseInfo courseInfo= newCourseVO.buildCourseInfo();
- if(!teacherInfoService.checkTeacher(newCourseVO.getTeacherId())) {
+ CourseInfo courseInfo = newCourseVO.buildCourseInfo();
+ if (!teacherInfoService.checkTeacher(newCourseVO.getTeacherId())) {
return null;
- }
- else{
+ } else {
save(courseInfo);
}
return courseInfo;
@@ -48,18 +70,74 @@ public class CourseInfoServiceImpl extends ServiceImpl receivers = new ArrayList<>();
+ receivers.add(teacherId);
+ sendVO.setReceivers(receivers);
+
+ if (status < 0) {
+ sendVO.setMessageTitle("课程被驳回");
+ sendVO.setMessageBody(StrUtil.format("您的课程《{}》被驳回,请进行修改。", currentCourse.getTitle()));
+ } else if (status > 0) {
+ sendVO.setMessageTitle("课程通过审核");
+ sendVO.setMessageBody(StrUtil.format("您的课程《{}》已通过审核。", currentCourse.getTitle()));
+ }
+ messageService.sendSystemMessage(sendVO);
+
+ }
return updateCourse(new CourseUpdateVO().setId(courseId).setStatus(status));
}
@Override
public PageResult query(CourseQueryVO courseQueryVO) {
+
return baseMapper.selectPage(courseQueryVO);
}
+ @Override
+ public PageResult convertToVO(PageResult courseInfoPageResult) {
+ List courses = new ArrayList<>();
+ for (CourseInfo info : courseInfoPageResult.getList()) {
+ TeacherInfo teacherInfo = teacherInfoService.lambdaQuery().eq(TeacherInfo::getTeacherId, info.getTeacherId()).one();
+ CourseType type = courseTypeService.getById(info.getTypeId());
+ Long count = courseSectionService.lambdaQuery().eq(CourseSection::getCourseId, info.getId()).count();
+ courses.add(CourseInfoVO.build(info, teacherInfo.getTeacherName(), teacherInfo.getTeacherDescription(),
+ teacherInfo.getTeacherAvatar(), type == null ? "0" : type.getCourseType(), Math.toIntExact(count)));
+ }
+ return new PageResult<>(courses, courseInfoPageResult.getTotal());
+ }
+
+ @Override
+ public CourseInfoVO convertToVO(CourseInfo courseInfo) {
+ TeacherInfo teacherInfo = teacherInfoService.lambdaQuery().eq(TeacherInfo::getTeacherId, courseInfo.getTeacherId()).one();
+ CourseType type = courseTypeService.getById(courseInfo.getTypeId());
+ Long count = courseSectionService.lambdaQuery().eq(CourseSection::getCourseId, courseInfo.getId()).count();
+ return CourseInfoVO.build(courseInfo, teacherInfo.getTeacherName(), teacherInfo.getTeacherDescription(),
+ teacherInfo.getTeacherAvatar(), type == null ? "0" : type.getCourseType(), Math.toIntExact(count));
+ }
+
@Override
public boolean setIsDeleted(String courseId, Integer isDeleted) {
- return baseMapper.updateIsDeletedById(isDeleted,courseId) > 0;
+ return baseMapper.updateIsDeletedById(isDeleted, courseId) > 0;
+ }
+
+ @Override
+ public List listAll(String teacherId) {
+ return baseMapper.listAll(teacherId);
+ }
+
+ @Override
+ public List listAllId(String teacherId) {
+ return baseMapper.listAllId(teacherId);
}
}
diff --git a/src/main/java/com/online/edu/service/course/impl/CourseTypeServiceImpl.java b/src/main/java/com/online/edu/service/course/impl/CourseTypeServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..280240b9372f24d12dbbbda352efc41f53489a3d
--- /dev/null
+++ b/src/main/java/com/online/edu/service/course/impl/CourseTypeServiceImpl.java
@@ -0,0 +1,38 @@
+package com.online.edu.service.course.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.course.CourseType;
+import com.online.edu.entity.course.vo.CourseTypeQueryVO;
+import com.online.edu.mapper.course.CourseTypeMapper;
+import com.online.edu.service.course.CourseTypeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Nvnqs
+ * @description 针对表【course_type(课程类型)】的数据库操作Service实现
+ * @createDate 2023-06-17 19:44:29
+ */
+@Service
+public class CourseTypeServiceImpl extends ServiceImpl
+ implements CourseTypeService {
+
+ @Override
+ public boolean addCourseType(CourseType courseType) {
+ return baseMapper.addAll(courseType) > 0;
+ }
+
+ @Override
+ public boolean updateCourseType(CourseType courseType) {
+ return baseMapper.updateCourseType(courseType) > 0;
+ }
+
+ @Override
+ public PageResult query(CourseTypeQueryVO query) {
+ return baseMapper.selectPage(query);
+ }
+}
+
+
+
+
diff --git a/src/main/java/com/online/edu/service/message/MessageService.java b/src/main/java/com/online/edu/service/message/MessageService.java
index 382612234278a18ce8684833c39c9a9d32418e30..3aecc8403d51b8e407de2274a33bb3075f7c613e 100644
--- a/src/main/java/com/online/edu/service/message/MessageService.java
+++ b/src/main/java/com/online/edu/service/message/MessageService.java
@@ -2,6 +2,10 @@ package com.online.edu.service.message;
import com.baomidou.mybatisplus.extension.service.IService;
import com.online.edu.entity.message.Message;
+import com.online.edu.entity.message.vo.MessageSendVO;
+import com.online.edu.entity.message.vo.MessageVO;
+
+import java.util.List;
/**
* @author Nvnqs
@@ -10,4 +14,15 @@ import com.online.edu.entity.message.Message;
*/
public interface MessageService extends IService {
+ void sendSystemMessage(MessageSendVO sendVO);
+
+ List listRecieved(String userId);
+
+ Long countUnread(String userId);
+
+ Long markAsRead(String userId);
+
+ boolean clear(String userId);
+
+ boolean delete(String id, String userId);
}
diff --git a/src/main/java/com/online/edu/service/message/MessageTemplateService.java b/src/main/java/com/online/edu/service/message/MessageTemplateService.java
deleted file mode 100644
index be0556f8394d859dc363ff6d58f52b8e2b990581..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/service/message/MessageTemplateService.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.online.edu.service.message;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.online.edu.entity.message.MessageTemplate;
-
-/**
- * @author Nvnqs
- * @description 针对表【message_template(站内信模板表)】的数据库操作Service
- * @createDate 2023-06-04 17:20:56
- */
-public interface MessageTemplateService extends IService {
-
-}
diff --git a/src/main/java/com/online/edu/service/message/SystemNotifyMessageService.java b/src/main/java/com/online/edu/service/message/SystemNotifyMessageService.java
deleted file mode 100644
index 9f0d7ca22bbde6a32067f08ec7d881a988270893..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/service/message/SystemNotifyMessageService.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.online.edu.service.message;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.online.edu.entity.message.SystemNotifyMessage;
-
-/**
- * @author Nvnqs
- * @description 针对表【system_notify_message(站内信消息表)】的数据库操作Service
- * @createDate 2023-06-04 17:20:56
- */
-public interface SystemNotifyMessageService extends IService {
-
-}
diff --git a/src/main/java/com/online/edu/service/message/impl/MessageServiceImpl.java b/src/main/java/com/online/edu/service/message/impl/MessageServiceImpl.java
index 012e63d2a469b93c86b70853c75e9c163275dc02..7ec163a7b337739e2d0239312f4388be23fe87d6 100644
--- a/src/main/java/com/online/edu/service/message/impl/MessageServiceImpl.java
+++ b/src/main/java/com/online/edu/service/message/impl/MessageServiceImpl.java
@@ -2,10 +2,17 @@ package com.online.edu.service.message.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.online.edu.entity.message.Message;
+import com.online.edu.entity.message.vo.MessageSendVO;
+import com.online.edu.entity.message.vo.MessageVO;
import com.online.edu.mapper.message.MessageMapper;
import com.online.edu.service.message.MessageService;
+import com.online.edu.service.rbac.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Nvnqs
* @description 针对表【message(消息表)】的数据库操作Service实现
@@ -15,6 +22,49 @@ import org.springframework.stereotype.Service;
public class MessageServiceImpl extends ServiceImpl
implements MessageService {
+ @Autowired
+ UserService userService;
+
+ @Override
+ public void sendSystemMessage(MessageSendVO sendVO) {
+ List messages = sendVO.build();
+ saveBatch(messages);
+ }
+
+ @Override
+ public List listRecieved(String userId) {
+ List messages = lambdaQuery().eq(Message::getReceiverId, userId)
+ .eq(Message::getDeleted, 0).list();
+ List result = new ArrayList<>();
+ for (Message message : messages) {
+ String displayName = userService.getById(message.getSenderId()).getDisplayName();
+ result.add(new MessageVO(message, displayName));
+ }
+ return result;
+ }
+
+ @Override
+ public Long countUnread(String userId) {
+ return lambdaQuery().eq(Message::getReceiverId, userId)
+ .eq(Message::getDeleted, 0).ne(Message::getReadStatus, 1).count();
+ }
+
+ @Override
+ public Long markAsRead(String userId) {
+
+ return (long) baseMapper.updateReadStatusByReceiverId(1, userId);
+ }
+
+ @Override
+ public boolean clear(String userId) {
+ return baseMapper.updateDeletedByReceiverId(1, userId) > 0;
+ }
+
+ @Override
+ public boolean delete(String id, String userId) {
+ baseMapper.updateDeletedByReceiverIdAndId(1, userId, id);
+ return lambdaQuery().eq(Message::getReceiverId, userId).eq(Message::getId, id).count() > 0;
+ }
}
diff --git a/src/main/java/com/online/edu/service/message/impl/MessageTemplateServiceImpl.java b/src/main/java/com/online/edu/service/message/impl/MessageTemplateServiceImpl.java
deleted file mode 100644
index 826583251a840d0a61681be385a8cfd991b20534..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/service/message/impl/MessageTemplateServiceImpl.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.online.edu.service.message.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.online.edu.entity.message.MessageTemplate;
-import com.online.edu.mapper.message.MessageTemplateMapper;
-import com.online.edu.service.message.MessageTemplateService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author Nvnqs
- * @description 针对表【message_template(站内信模板表)】的数据库操作Service实现
- * @createDate 2023-06-04 17:20:56
- */
-@Service
-public class MessageTemplateServiceImpl extends ServiceImpl
- implements MessageTemplateService {
-
-}
-
-
-
-
diff --git a/src/main/java/com/online/edu/service/message/impl/SystemNotifyMessageServiceImpl.java b/src/main/java/com/online/edu/service/message/impl/SystemNotifyMessageServiceImpl.java
deleted file mode 100644
index c245a9b4b1a47500a5fe7447f629fd856718f323..0000000000000000000000000000000000000000
--- a/src/main/java/com/online/edu/service/message/impl/SystemNotifyMessageServiceImpl.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.online.edu.service.message.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.online.edu.entity.message.SystemNotifyMessage;
-import com.online.edu.mapper.message.SystemNotifyMessageMapper;
-import com.online.edu.service.message.SystemNotifyMessageService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author Nvnqs
- * @description 针对表【system_notify_message(站内信消息表)】的数据库操作Service实现
- * @createDate 2023-06-04 17:20:56
- */
-@Service
-public class SystemNotifyMessageServiceImpl extends ServiceImpl
- implements SystemNotifyMessageService {
-
-}
-
-
-
-
diff --git a/src/main/java/com/online/edu/service/order/CourseElectionService.java b/src/main/java/com/online/edu/service/order/CourseElectionService.java
index 7de1108b46f1557d8652dbc5813dcfbea6479d39..934b3c117059c310b55e16919cb8fd79fc92d664 100644
--- a/src/main/java/com/online/edu/service/order/CourseElectionService.java
+++ b/src/main/java/com/online/edu/service/order/CourseElectionService.java
@@ -2,6 +2,7 @@ package com.online.edu.service.order;
import com.baomidou.mybatisplus.extension.service.IService;
import com.online.edu.entity.order.CourseElection;
+import com.online.edu.entity.order.CourseOrder;
/**
* @author Nvnqs
@@ -10,4 +11,6 @@ import com.online.edu.entity.order.CourseElection;
*/
public interface CourseElectionService extends IService {
+ CourseOrder electCourse(String courseId, String studentId);
+
}
diff --git a/src/main/java/com/online/edu/service/order/CourseOrderService.java b/src/main/java/com/online/edu/service/order/CourseOrderService.java
index 68d18d05fd6c575b9bfb7d013a8948a1742f7a86..6ac9d719acd0ffe6008f4c5966387b7dfe2ac346 100644
--- a/src/main/java/com/online/edu/service/order/CourseOrderService.java
+++ b/src/main/java/com/online/edu/service/order/CourseOrderService.java
@@ -1,7 +1,13 @@
package com.online.edu.service.order;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.order.CourseElection;
import com.online.edu.entity.order.CourseOrder;
+import com.online.edu.entity.order.vo.CourseElectionQueryVO;
+import com.online.edu.entity.order.vo.CourseOrderListVO;
+
+import java.util.List;
/**
* @author Nvnqs
@@ -9,5 +15,9 @@ import com.online.edu.entity.order.CourseOrder;
* @createDate 2023-06-04 17:20:56
*/
public interface CourseOrderService extends IService {
+ boolean save(CourseOrder courseOrder);
+
+ PageResult query(CourseElectionQueryVO queryVO);
+ List buildVO(List elections);
}
diff --git a/src/main/java/com/online/edu/service/order/impl/AlipayService.java b/src/main/java/com/online/edu/service/order/impl/AlipayService.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ac56918dd08c946fde7e82d3b7250aa5a589f24
--- /dev/null
+++ b/src/main/java/com/online/edu/service/order/impl/AlipayService.java
@@ -0,0 +1,81 @@
+package com.online.edu.service.order.impl;
+
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.alipay.easysdk.factory.Factory;
+import com.alipay.easysdk.kernel.util.ResponseChecker;
+import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
+import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
+import com.online.edu.common.CommonResult;
+import com.online.edu.config.AlipayConfig;
+import com.online.edu.mapper.order.CourseElectionMapper;
+import com.online.edu.mapper.order.CourseOrderMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 支付服务
+ */
+
+@Service
+public class AlipayService {
+ @Autowired
+ CourseOrderMapper courseOrderMapper;
+
+
+ @Autowired
+ CourseElectionMapper courseElectionMapper;
+
+ /**
+ * 生成支付表单
+ * @param subject
+ * @param money
+ * @return
+ * @throws Exception
+ */
+ public String toPay(String subject,String serialNumber, BigDecimal money) throws Exception {
+ AlipayTradePagePayResponse pay = Factory.Payment.Page().pay(subject, serialNumber,
+ String.valueOf(money), AlipayConfig.RETURN_URL);
+ String payForm = null;
+ if (ResponseChecker.success(pay)) {
+ courseOrderMapper.updateWaitPayById(serialNumber, "WAIT_BUYER_PAY");
+ payForm = pay.getBody();
+ }
+ return payForm;
+ }
+
+
+ /**
+ * 查询交易状态
+ * @param outTradeNo 订单号 out_trade_no
+ * @return
+ * @throws Exception
+ */
+
+ public Object queryTradeStatus(String outTradeNo) throws Exception {
+ AlipayTradeQueryResponse query = Factory.Payment.Common().query(outTradeNo);
+ JSONObject map = JSON.parseObject(query.getHttpBody());
+ JSONObject resultMap = JSON.parseObject(map.get("alipay_trade_query_response").toString());
+ Object trade_status = resultMap.get("trade_status");
+ String trade_no = (String) resultMap.get("trade_no");
+ if ("TRADE_SUCCESS".equals(trade_status) || "TRADE_FINISHED".equals(trade_status)) {
+ courseOrderMapper.updateById(outTradeNo, "TRADE_FINISHED", new Date(), trade_no);
+ courseElectionMapper.updateById(outTradeNo, 1);
+ } else {
+ return CommonResult.error(400, "支付失败");
+ }
+ // 返回交易结果, 是否交易成功需要根据该对象中的 trade_status 来确定
+ // trade_status 的枚举值如下, 请见 https://opendocs.alipay.com/apis/api_1/alipay.trade.query
+ // WAIT_BUYER_PAY(交易创建,等待买家付款)
+ // TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)
+ // TRADE_SUCCESS(交易支付成功)
+ // TRADE_FINISHED(交易结束,不可退款)
+ // 当 trade_status 等于 TRADE_SUCCESS 或 TRADE_FINISHED 时, 表示支付成功
+ return map.get("alipay_trade_query_response");
+ }
+
+}
diff --git a/src/main/java/com/online/edu/service/order/impl/CourseElectionServiceImpl.java b/src/main/java/com/online/edu/service/order/impl/CourseElectionServiceImpl.java
index d9c4dbc2119db06e7885be50751425d413447f98..37273a2ee1ba46c00b8796ee20cf3681bf970be1 100644
--- a/src/main/java/com/online/edu/service/order/impl/CourseElectionServiceImpl.java
+++ b/src/main/java/com/online/edu/service/order/impl/CourseElectionServiceImpl.java
@@ -1,11 +1,22 @@
package com.online.edu.service.order.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.online.edu.entity.course.CourseInfo;
import com.online.edu.entity.order.CourseElection;
+import com.online.edu.entity.order.CourseOrder;
import com.online.edu.mapper.order.CourseElectionMapper;
+import com.online.edu.service.course.CourseInfoService;
import com.online.edu.service.order.CourseElectionService;
+import com.online.edu.service.order.CourseOrderService;
+import com.online.edu.service.rbac.UserService;
+import com.online.edu.service.userInfo.TeacherInfoService;
+import com.online.edu.utils.OrderSerialNumberUtil;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
+import java.util.Date;
+
/**
* @author Nvnqs
* @description 针对表【course_election(选课)】的数据库操作Service实现
@@ -14,6 +25,51 @@ import org.springframework.stereotype.Service;
@Service
public class CourseElectionServiceImpl extends ServiceImpl
implements CourseElectionService {
+ @Autowired
+ CourseElectionMapper courseElectionMapper;
+
+ @Autowired
+ private CourseInfoService courseInfoService;
+
+ @Autowired
+ private CourseOrderService courseOrderService;
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private TeacherInfoService teacherInfoService;
+
+
+ @Override
+ public CourseOrder electCourse(String courseId, String studentId) {
+ CourseInfo info = courseInfoService.getById(courseId);
+ if (info == null) {
+ return null;
+ }
+ CourseElection courseElection = new CourseElection().setCourseId(courseId)
+ .setCourseName(info.getTitle()).setPrice(info.getPrice()).setIsDeleted(0);
+ String teacherId = info.getTeacherId();
+ courseElection.setTeacherName(teacherInfoService.getById(teacherId).getTeacherName());
+ courseElection.setStudentId(studentId).setStudentName(userService.getById(studentId).getDisplayName());
+ courseElection.setSerialNumber(OrderSerialNumberUtil.getSerialNumber());
+
+ CourseOrder order;
+ if (BigDecimal.ZERO.equals(info.getPrice())) {
+ courseElection.setStatus(1);
+ order = new CourseOrder().setSerialNumber(courseElection.getSerialNumber())
+ .setPayedat(new Date()).setPrice(BigDecimal.ZERO).setIsDeleted(0).setTradeState("TRADE_FINISHED")
+ .setCreatedAt(new Date()).setUpdatedAt(new Date());
+ }
+ courseElection.setStatus(0).setPrice(info.getPrice());
+ save(courseElection);
+ order = new CourseOrder().setSerialNumber(courseElection.getSerialNumber())
+ .setPrice(courseElection.getPrice()).setIsDeleted(0).setTradeState("INITIAL")
+ .setCreatedAt(new Date()).setUpdatedAt(new Date());
+ courseOrderService.save(order);
+ return order;
+ }
+
}
diff --git a/src/main/java/com/online/edu/service/order/impl/CourseOrderServiceImpl.java b/src/main/java/com/online/edu/service/order/impl/CourseOrderServiceImpl.java
index ceaa2aa54bc1297c8fef5594f87f0fb63b18cfa6..256e9b5eb26647aa48459368f9fc69e5c1764ae5 100644
--- a/src/main/java/com/online/edu/service/order/impl/CourseOrderServiceImpl.java
+++ b/src/main/java/com/online/edu/service/order/impl/CourseOrderServiceImpl.java
@@ -1,11 +1,20 @@
package com.online.edu.service.order.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.online.edu.common.PageResult;
+import com.online.edu.entity.order.CourseElection;
import com.online.edu.entity.order.CourseOrder;
+import com.online.edu.entity.order.vo.CourseElectionQueryVO;
+import com.online.edu.entity.order.vo.CourseOrderListVO;
+import com.online.edu.mapper.order.CourseElectionMapper;
import com.online.edu.mapper.order.CourseOrderMapper;
import com.online.edu.service.order.CourseOrderService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Nvnqs
* @description 针对表【course_order(订单)】的数据库操作Service实现
@@ -15,6 +24,32 @@ import org.springframework.stereotype.Service;
public class CourseOrderServiceImpl extends ServiceImpl
implements CourseOrderService {
+ @Autowired
+ CourseElectionMapper courseElectionMapper;
+
+ @Override
+ public boolean save(CourseOrder courseOrder) {
+ return baseMapper.insertAll(courseOrder) != 0;
+ }
+
+ @Override
+ public PageResult