main
commit
7129e32d27
@ -0,0 +1,40 @@ |
||||
target/ |
||||
!.mvn/wrapper/maven-wrapper.jar |
||||
!**/src/main/**/target/ |
||||
!**/src/test/**/target/ |
||||
|
||||
### IntelliJ IDEA ### |
||||
.idea/modules.xml |
||||
.idea/jarRepositories.xml |
||||
.idea/compiler.xml |
||||
.idea/libraries/ |
||||
*.iws |
||||
*.iml |
||||
*.ipr |
||||
|
||||
### Eclipse ### |
||||
.apt_generated |
||||
.classpath |
||||
.factorypath |
||||
.project |
||||
.settings |
||||
.springBeans |
||||
.sts4-cache |
||||
|
||||
### NetBeans ### |
||||
/nbproject/private/ |
||||
/nbbuild/ |
||||
/dist/ |
||||
/nbdist/ |
||||
/.nb-gradle/ |
||||
build/ |
||||
!**/src/main/**/build/ |
||||
!**/src/test/**/build/ |
||||
|
||||
### VS Code ### |
||||
.vscode/ |
||||
|
||||
### Mac OS ### |
||||
.DS_Store |
||||
|
||||
.env |
@ -0,0 +1,456 @@ |
||||
/* |
||||
Navicat Premium Data Transfer |
||||
|
||||
Source Server : local_postgresql |
||||
Source Server Type : PostgreSQL |
||||
Source Server Version : 150003 (150003) |
||||
Source Host : localhost:5432 |
||||
Source Catalog : little_busters |
||||
Source Schema : public |
||||
|
||||
Target Server Type : PostgreSQL |
||||
Target Server Version : 150003 (150003) |
||||
File Encoding : 65001 |
||||
|
||||
Date: 21/08/2023 18:32:52 |
||||
*/ |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for activity |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."activity"; |
||||
CREATE TABLE "public"."activity" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL DEFAULT 0, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying, |
||||
"term" varchar(11) COLLATE "pg_catalog"."default" NOT NULL DEFAULT '2023-2024-1'::character varying, |
||||
"start_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"end_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."activity"."id" IS '选课活动id'; |
||||
COMMENT ON COLUMN "public"."activity"."name" IS '活动id'; |
||||
COMMENT ON COLUMN "public"."activity"."term" IS '学期,格式如2023-2024-1'; |
||||
COMMENT ON COLUMN "public"."activity"."start_time" IS '开始时间'; |
||||
COMMENT ON COLUMN "public"."activity"."end_time" IS '结束时间'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for class |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."class"; |
||||
CREATE TABLE "public"."class" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"course" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"start_week" int2 NOT NULL, |
||||
"end_week" int2 NOT NULL, |
||||
"time" int2 NOT NULL, |
||||
"academic_term" varchar(11) COLLATE "pg_catalog"."default" NOT NULL DEFAULT '2023-2024-1'::character varying, |
||||
"place" varchar(255) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying, |
||||
"ratio" float4 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false, |
||||
"distribution" jsonb NOT NULL DEFAULT '{}'::jsonb, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"week_day" int2 NOT NULL DEFAULT 1 |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."class"."id" IS '课堂id'; |
||||
COMMENT ON COLUMN "public"."class"."course" IS '课程id'; |
||||
COMMENT ON COLUMN "public"."class"."start_week" IS '开始周'; |
||||
COMMENT ON COLUMN "public"."class"."end_week" IS '结束周'; |
||||
COMMENT ON COLUMN "public"."class"."time" IS '节次时间,即第几节课'; |
||||
COMMENT ON COLUMN "public"."class"."academic_term" IS '学年学期,格式如2023-2024-2'; |
||||
COMMENT ON COLUMN "public"."class"."place" IS '上课地点'; |
||||
COMMENT ON COLUMN "public"."class"."ratio" IS '考试成绩占比'; |
||||
COMMENT ON COLUMN "public"."class"."distribution" IS '平时分成绩分布,usual_score参考依据'; |
||||
COMMENT ON COLUMN "public"."class"."name" IS '课堂名称'; |
||||
COMMENT ON COLUMN "public"."class"."week_day" IS '星期几'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for course |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."course"; |
||||
CREATE TABLE "public"."course" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"course_hours" int2 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false, |
||||
"spring_term" bool NOT NULL DEFAULT true, |
||||
"target_major" varchar[] COLLATE "pg_catalog"."default" NOT NULL DEFAULT ARRAY[''::text], |
||||
"target_grade" int2[] NOT NULL |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."course"."id" IS '课程id'; |
||||
COMMENT ON COLUMN "public"."course"."name" IS '课程名称'; |
||||
COMMENT ON COLUMN "public"."course"."course_hours" IS '课时'; |
||||
COMMENT ON COLUMN "public"."course"."spring_term" IS '是否春季期课程(false即是秋季期)'; |
||||
COMMENT ON COLUMN "public"."course"."target_major" IS '上课专业'; |
||||
COMMENT ON COLUMN "public"."course"."target_grade" IS '上课专业'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for course_selection |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."course_selection"; |
||||
CREATE TABLE "public"."course_selection" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"student" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"schedule" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false, |
||||
"activity" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."course_selection"."id" IS '选课记录id'; |
||||
COMMENT ON COLUMN "public"."course_selection"."student" IS '学生id'; |
||||
COMMENT ON COLUMN "public"."course_selection"."schedule" IS '课堂id'; |
||||
COMMENT ON COLUMN "public"."course_selection"."activity" IS '选课时候的活动id'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for experiment_item |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."experiment_item"; |
||||
CREATE TABLE "public"."experiment_item" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"course" int8 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."experiment_item"."id" IS '实验项目id'; |
||||
COMMENT ON COLUMN "public"."experiment_item"."name" IS '项目名称'; |
||||
COMMENT ON COLUMN "public"."experiment_item"."course" IS '课程id'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for experiment_score |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."experiment_score"; |
||||
CREATE TABLE "public"."experiment_score" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"student" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"experiment" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"score" int2 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."experiment_score"."id" IS '成绩id'; |
||||
COMMENT ON COLUMN "public"."experiment_score"."student" IS '学生id'; |
||||
COMMENT ON COLUMN "public"."experiment_score"."experiment" IS '实验id'; |
||||
COMMENT ON COLUMN "public"."experiment_score"."score" IS '实验分'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for major |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."major"; |
||||
CREATE TABLE "public"."major" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."major"."id" IS '专业id'; |
||||
COMMENT ON COLUMN "public"."major"."name" IS '专业名称'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for score |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."score"; |
||||
CREATE TABLE "public"."score" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"student" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"usual_score" float4 NOT NULL, |
||||
"exam_score" float4 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false, |
||||
"class" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."score"."id" IS '成绩id'; |
||||
COMMENT ON COLUMN "public"."score"."student" IS '学生id'; |
||||
COMMENT ON COLUMN "public"."score"."usual_score" IS '平时分'; |
||||
COMMENT ON COLUMN "public"."score"."exam_score" IS '考试分'; |
||||
COMMENT ON COLUMN "public"."score"."class" IS '课堂id'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for student_info |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."student_info"; |
||||
CREATE TABLE "public"."student_info" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"student_number" varchar(12) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"name" varchar(16) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"major" varchar(16) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"grade" int2 NOT NULL DEFAULT 2, |
||||
"class" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."student_info"."id" IS '学生id'; |
||||
COMMENT ON COLUMN "public"."student_info"."student_number" IS '学号'; |
||||
COMMENT ON COLUMN "public"."student_info"."name" IS '学生姓名'; |
||||
COMMENT ON COLUMN "public"."student_info"."major" IS '专业id'; |
||||
COMMENT ON COLUMN "public"."student_info"."grade" IS '年级,使用大x表示,如大二:2'; |
||||
COMMENT ON COLUMN "public"."student_info"."class" IS '班级'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for teacher_class |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."teacher_class"; |
||||
CREATE TABLE "public"."teacher_class" ( |
||||
"teacher" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"class" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."teacher_class"."teacher" IS '教师id'; |
||||
COMMENT ON COLUMN "public"."teacher_class"."class" IS '课程班级id'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for teacher_info |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."teacher_info"; |
||||
CREATE TABLE "public"."teacher_info" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."teacher_info"."id" IS '教师id'; |
||||
COMMENT ON COLUMN "public"."teacher_info"."name" IS '教师姓名'; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for user_basic |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS "public"."user_basic"; |
||||
CREATE TABLE "public"."user_basic" ( |
||||
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"username" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL, |
||||
"type" int2 NOT NULL, |
||||
"create_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"edit_time" timestamp(6) NOT NULL DEFAULT now(), |
||||
"deleted" bool NOT NULL DEFAULT false |
||||
) |
||||
; |
||||
COMMENT ON COLUMN "public"."user_basic"."id" IS '用户uuid'; |
||||
COMMENT ON COLUMN "public"."user_basic"."username" IS '用户名,登陆用'; |
||||
COMMENT ON COLUMN "public"."user_basic"."password" IS '密码'; |
||||
COMMENT ON COLUMN "public"."user_basic"."type" IS '用户类型,0:学生,1:教师,2:管理员'; |
||||
|
||||
-- ---------------------------- |
||||
-- Function structure for cs_timestamp |
||||
-- ---------------------------- |
||||
DROP FUNCTION IF EXISTS "public"."cs_timestamp"(); |
||||
CREATE OR REPLACE FUNCTION "public"."cs_timestamp"() |
||||
RETURNS "pg_catalog"."trigger" AS $BODY$ |
||||
begin |
||||
new.update_time= current_timestame; |
||||
return new; |
||||
end |
||||
$BODY$ |
||||
LANGUAGE plpgsql VOLATILE |
||||
COST 100; |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table activity |
||||
-- ---------------------------- |
||||
CREATE INDEX "act_idx_end" ON "public"."activity" USING brin ( |
||||
"end_time" "pg_catalog"."timestamp_minmax_ops" |
||||
); |
||||
CREATE INDEX "act_idx_id" ON "public"."activity" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
CREATE INDEX "act_idx_start" ON "public"."activity" USING brin ( |
||||
"start_time" "pg_catalog"."timestamp_minmax_ops" |
||||
); |
||||
CREATE INDEX "act_idx_term" ON "public"."activity" USING btree ( |
||||
"term" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table activity |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."activity" ADD CONSTRAINT "activity_pkey" PRIMARY KEY ("id"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table class |
||||
-- ---------------------------- |
||||
CREATE INDEX "cs_idx_course" ON "public"."class" USING btree ( |
||||
"course" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "cs_idx_id" ON "public"."class" USING btree ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "cs_idx_term" ON "public"."class" USING btree ( |
||||
"academic_term" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table class |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."class" ADD CONSTRAINT "class_pkey" PRIMARY KEY ("id", "course"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table course |
||||
-- ---------------------------- |
||||
CREATE INDEX "cours_idx_major" ON "public"."course" USING gin ( |
||||
"target_major" COLLATE "pg_catalog"."default" "pg_catalog"."array_ops" |
||||
) WITH (GIN_PENDING_LIST_LIMIT = 64); |
||||
CREATE INDEX "course_idx_grade" ON "public"."course" USING gin ( |
||||
"target_grade" "pg_catalog"."array_ops" |
||||
) WITH (GIN_PENDING_LIST_LIMIT = 64); |
||||
CREATE INDEX "course_idx_id" ON "public"."course" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
COMMENT ON INDEX "public"."course_idx_id" IS 'id索引'; |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table course |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."course" ADD CONSTRAINT "course_pkey" PRIMARY KEY ("id"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table course_selection |
||||
-- ---------------------------- |
||||
CREATE INDEX "csel_idex_student" ON "public"."course_selection" USING btree ( |
||||
"student" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "csel_idx_activity" ON "public"."course_selection" USING btree ( |
||||
"activity" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "csel_idx_course" ON "public"."course_selection" USING btree ( |
||||
"schedule" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "csel_idx_id" ON "public"."course_selection" USING btree ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table course_selection |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."course_selection" ADD CONSTRAINT "course_selection_pkey" PRIMARY KEY ("id", "student", "schedule"); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table experiment_item |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."experiment_item" ADD CONSTRAINT "course_experiment_pkey" PRIMARY KEY ("id", "course"); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table experiment_score |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."experiment_score" ADD CONSTRAINT "experiment_score_pkey" PRIMARY KEY ("id", "student", "experiment"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table major |
||||
-- ---------------------------- |
||||
CREATE INDEX "major_idx_id" ON "public"."major" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
CREATE INDEX "major_idx_name" ON "public"."major" USING btree ( |
||||
"name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table major |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."major" ADD CONSTRAINT "major_pkey" PRIMARY KEY ("id"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table score |
||||
-- ---------------------------- |
||||
CREATE INDEX "score_idx_class" ON "public"."score" USING btree ( |
||||
"class" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "score_idx_id" ON "public"."score" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
CREATE INDEX "score_idx_student" ON "public"."score" USING btree ( |
||||
"student" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table score |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."score" ADD CONSTRAINT "score_pkey" PRIMARY KEY ("id", "student", "class"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table student_info |
||||
-- ---------------------------- |
||||
CREATE INDEX "stu_dix_grade" ON "public"."student_info" USING btree ( |
||||
"grade" "pg_catalog"."int2_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "stu_idx_id" ON "public"."student_info" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
CREATE INDEX "stu_idx_major" ON "public"."student_info" USING btree ( |
||||
"major" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "stu_idx_num" ON "public"."student_info" USING btree ( |
||||
"student_number" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table student_info |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."student_info" ADD CONSTRAINT "student_info_pkey" PRIMARY KEY ("id", "student_number"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table teacher_class |
||||
-- ---------------------------- |
||||
CREATE INDEX "tc_idx_course" ON "public"."teacher_class" USING btree ( |
||||
"class" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
CREATE INDEX "tc_idx_teacher" ON "public"."teacher_class" USING btree ( |
||||
"teacher" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table teacher_class |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."teacher_class" ADD CONSTRAINT "teacher_course_pkey" PRIMARY KEY ("teacher", "class"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table teacher_info |
||||
-- ---------------------------- |
||||
CREATE INDEX "ti_idx_id" ON "public"."teacher_info" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table teacher_info |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."teacher_info" ADD CONSTRAINT "teacher_info_pkey" PRIMARY KEY ("id"); |
||||
|
||||
-- ---------------------------- |
||||
-- Indexes structure for table user_basic |
||||
-- ---------------------------- |
||||
CREATE INDEX "usr_idx_id" ON "public"."user_basic" USING hash ( |
||||
"id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" |
||||
); |
||||
CREATE INDEX "usr_idx_username" ON "public"."user_basic" USING btree ( |
||||
"username" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST |
||||
); |
||||
|
||||
-- ---------------------------- |
||||
-- Primary Key structure for table user_basic |
||||
-- ---------------------------- |
||||
ALTER TABLE "public"."user_basic" ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id", "username", "password"); |
@ -0,0 +1,240 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>net.lensfrex.service</groupId> |
||||
<artifactId>radical-dreamers</artifactId> |
||||
<version>${revision}</version> |
||||
|
||||
<properties> |
||||
<maven.compiler.source>17</maven.compiler.source> |
||||
<maven.compiler.target>17</maven.compiler.target> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
|
||||
<revision>0.0.1-SNAPSHOT</revision> |
||||
|
||||
<springboot.version>3.1.1</springboot.version> |
||||
|
||||
<caffeine.version>3.1.6</caffeine.version> |
||||
<snakeyaml.version>2.0</snakeyaml.version> |
||||
<junit.version>5.10.0-RC1</junit.version> |
||||
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version> |
||||
<mybatis.version>3.0.2</mybatis.version> |
||||
<lombok.version>1.18.26</lombok.version> |
||||
<hutool.version>5.8.20</hutool.version> |
||||
|
||||
<satoken.version>1.34.0</satoken.version> |
||||
|
||||
<druid.version>1.2.18</druid.version> |
||||
|
||||
<lettuce.bersion>6.2.5.RELEASE</lettuce.bersion> |
||||
|
||||
<idgen.version>1.0.6</idgen.version> |
||||
|
||||
<easyexcel.version>3.3.2</easyexcel.version> |
||||
</properties> |
||||
|
||||
<dependencyManagement> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-dependencies</artifactId> |
||||
<version>${springboot.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.hutool</groupId> |
||||
<artifactId>hutool-bom</artifactId> |
||||
<version>${hutool.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
</dependencyManagement> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>mybatis-plus-boot-starter-test</artifactId> |
||||
<version>3.5.3.2</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-devtools</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>${lombok.version}</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
|
||||
<!-- snakeyaml版本提升(烦人的漏洞警告) --> |
||||
<dependency> |
||||
<groupId>org.yaml</groupId> |
||||
<artifactId>snakeyaml</artifactId> |
||||
<version>${snakeyaml.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-validation</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-configuration-processor</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<!-- 数据库,mybatis和mybatis-plus --> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
<version>${mybatis-plus.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.mybatis.spring.boot</groupId> |
||||
<artifactId>mybatis-spring-boot-starter</artifactId> |
||||
<version>${mybatis.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.postgresql</groupId> |
||||
<artifactId>postgresql</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>druid-spring-boot-starter</artifactId> |
||||
<version>${druid.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- caffeine缓存 --> |
||||
<dependency> |
||||
<groupId>com.github.ben-manes.caffeine</groupId> |
||||
<artifactId>caffeine</artifactId> |
||||
<version>${caffeine.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- web框架 --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
|
||||
<!-- redis --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-data-redis</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-pool2</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.lettuce</groupId> |
||||
<artifactId>lettuce-core</artifactId> |
||||
<version>${lettuce.bersion}</version> |
||||
</dependency> |
||||
|
||||
<!-- id生成 --> |
||||
<dependency> |
||||
<groupId>com.github.yitter</groupId> |
||||
<artifactId>yitter-idgenerator</artifactId> |
||||
<version>${idgen.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- 权限认证 --> |
||||
<dependency> |
||||
<groupId>cn.dev33</groupId> |
||||
<artifactId>sa-token-spring-boot3-starter</artifactId> |
||||
<version>${satoken.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.dev33</groupId> |
||||
<artifactId>sa-token-dao-redis-jackson</artifactId> |
||||
<version>${satoken.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- 各种小工具 --> |
||||
<dependency> |
||||
<groupId>cn.hutool</groupId> |
||||
<artifactId>hutool-crypto</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.hutool</groupId> |
||||
<artifactId>hutool-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-core</artifactId> |
||||
<version>0.0.4-alpha</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-network-okhttp</artifactId> |
||||
<version>0.0.4-alpha</version> |
||||
</dependency> |
||||
|
||||
<!-- excel导出 --> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>easyexcel</artifactId> |
||||
<version>${easyexcel.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-compress</artifactId> |
||||
<version>1.23.0</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<configuration> |
||||
<source>${maven.compiler.source}</source> |
||||
<target>${maven.compiler.target}</target> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<configuration> |
||||
<addResources>true</addResources> |
||||
<!-- <fork>true</fork>--> |
||||
<excludes> |
||||
<exclude> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
</exclude> |
||||
</excludes> |
||||
</configuration> |
||||
<executions> |
||||
<execution> |
||||
<goals> |
||||
<goal>repackage</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -0,0 +1,29 @@ |
||||
package net.lensfrex.rd; |
||||
|
||||
import com.github.yitter.contract.IdGeneratorOptions; |
||||
import com.github.yitter.idgen.YitIdHelper; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.slf4j.MDC; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.scheduling.annotation.EnableAsync; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
import org.springframework.transaction.annotation.EnableTransactionManagement; |
||||
|
||||
import java.lang.management.ManagementFactory; |
||||
|
||||
@EnableAsync |
||||
@EnableScheduling |
||||
@SpringBootApplication |
||||
@EnableTransactionManagement |
||||
@MapperScan(basePackages = "net.lensfrex.rd.dao.mapper") |
||||
public class BackendMain { |
||||
public static void main(String[] args) { |
||||
IdGeneratorOptions options = new IdGeneratorOptions(); |
||||
options.WorkerIdBitLength = 4; |
||||
options.WorkerId = 0; |
||||
YitIdHelper.setIdGenerator(options); |
||||
|
||||
SpringApplication.run(BackendMain.class, args); |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
package net.lensfrex.rd.cache; |
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache; |
||||
import com.github.benmanes.caffeine.cache.Caffeine; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Component |
||||
public class CacheManager { |
||||
private static final Cache<String, Object> cache = Caffeine.newBuilder() |
||||
.expireAfterWrite(2, TimeUnit.DAYS) |
||||
.initialCapacity(256) |
||||
.maximumSize(2048) |
||||
.build(); |
||||
|
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
package net.lensfrex.rd.configure; |
||||
|
||||
import jakarta.servlet.*; |
||||
import jakarta.servlet.annotation.WebFilter; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
@Component |
||||
@WebFilter(filterName = "CorsFilter", urlPatterns = "/*") |
||||
public class CorsFilter implements Filter { |
||||
|
||||
@Override |
||||
public void init(FilterConfig filterConfig) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
||||
HttpServletResponse response = (HttpServletResponse) servletResponse; |
||||
|
||||
response.setHeader("Access-Control-Allow-Origin", "*"); |
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT"); |
||||
response.setHeader("Access-Control-Allow-Headers", "*"); |
||||
response.setHeader("Access-Control-Allow-Credentials", "true"); |
||||
|
||||
filterChain.doFilter(servletRequest, servletResponse); |
||||
} |
||||
|
||||
@Override |
||||
public void destroy() { |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
package net.lensfrex.rd.configure; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; |
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; |
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; |
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; |
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; |
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.time.LocalDateTime; |
||||
import java.time.LocalTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
|
||||
@Configuration |
||||
public class JacksonConfigure { |
||||
@Bean |
||||
public ObjectMapper objectMapper() { |
||||
ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
||||
// other serializer and deSerializer config ...
|
||||
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule(); |
||||
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ISO_DATE_TIME)); |
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ISO_DATE_TIME)); |
||||
|
||||
objectMapper.registerModule(javaTimeModule); |
||||
return objectMapper; |
||||
} |
||||
} |
@ -0,0 +1,17 @@ |
||||
package net.lensfrex.rd.configure; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType; |
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MybatisConfigure { |
||||
@Bean |
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); |
||||
return interceptor; |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
package net.lensfrex.rd.configure; |
||||
|
||||
import cn.wustlinghang.mywust.core.parser.undergraduate.UndergradCourseTableParser; |
||||
import cn.wustlinghang.mywust.core.parser.undergraduate.UndergradStudentInfoPageParser; |
||||
import cn.wustlinghang.mywust.core.request.service.auth.UndergraduateLogin; |
||||
import cn.wustlinghang.mywust.core.request.service.undergraduate.UndergradCourseTableApiService; |
||||
import cn.wustlinghang.mywust.core.request.service.undergraduate.UndergradStudentInfoApiService; |
||||
import cn.wustlinghang.mywust.network.RequestClientOption; |
||||
import cn.wustlinghang.mywust.network.Requester; |
||||
import cn.wustlinghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MywustConfigure { |
||||
@Bean |
||||
public RequestClientOption requestClientOption() { |
||||
return new RequestClientOption(); |
||||
} |
||||
|
||||
@Bean |
||||
public Requester requester() { |
||||
return new SimpleOkhttpRequester(requestClientOption()); |
||||
} |
||||
|
||||
@Bean |
||||
public UndergraduateLogin undergraduateLogin(Requester requester) { |
||||
return new UndergraduateLogin(requester); |
||||
} |
||||
|
||||
@Bean |
||||
public UndergradStudentInfoApiService undergradStudentInfoApiService(Requester requester) { |
||||
return new UndergradStudentInfoApiService(requester); |
||||
} |
||||
|
||||
@Bean |
||||
public UndergradStudentInfoPageParser undergradStudentInfoPageParser() { |
||||
return new UndergradStudentInfoPageParser(); |
||||
} |
||||
|
||||
@Bean |
||||
public UndergradCourseTableApiService undergradCourseTableApiService(Requester requester) { |
||||
return new UndergradCourseTableApiService(requester); |
||||
} |
||||
|
||||
@Bean |
||||
public UndergradCourseTableParser undergradCourseTableParser() { |
||||
return new UndergradCourseTableParser(); |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package net.lensfrex.rd.configure; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Data |
||||
@Component |
||||
@ConfigurationProperties("little-busters.password") |
||||
public class PasswordConfigure { |
||||
private String key; |
||||
private String iv; |
||||
} |
@ -0,0 +1,13 @@ |
||||
package net.lensfrex.rd.controller; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/health") |
||||
public class Health { |
||||
@RequestMapping("") |
||||
public String health() { |
||||
return ""; |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
package net.lensfrex.rd.controller.activity; |
||||
|
||||
import net.lensfrex.rd.data.entity.table.Activity; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.activity.ActivityService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/activity") |
||||
public class ActivityController { |
||||
|
||||
private final ActivityService activityService; |
||||
|
||||
public ActivityController(ActivityService activityService) { |
||||
this.activityService = activityService; |
||||
} |
||||
|
||||
@RequestMapping("/current") |
||||
public Response<List<Activity>> current() { |
||||
var result = activityService.getCurrentActivity(); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/list") |
||||
public Response<PaginationWrapper<List<Activity>>> list( |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize |
||||
) { |
||||
var result = activityService.list(page, pageSize); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/info") |
||||
public Response<Activity> info(@RequestParam(value = "id") String id) { |
||||
var result = activityService.getById(id); |
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
package net.lensfrex.rd.controller.activity; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.entity.table.Activity; |
||||
import net.lensfrex.rd.data.model.request.admin.ActivityInfoDto; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.exception.data.DataConflictException; |
||||
import net.lensfrex.rd.service.activity.ActivityService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/activity") |
||||
public class AdminActivityController { |
||||
|
||||
private final ActivityService activityService; |
||||
|
||||
public AdminActivityController(ActivityService activityService) { |
||||
this.activityService = activityService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<Activity> add(@RequestBody ActivityInfoDto request) { |
||||
try { |
||||
activityService.addActivity(request); |
||||
} catch (DataConflictException e) { |
||||
return Response.error(ResponseCode.PARAM_WRONG, "同一个学期内一个时间段内只能有一个选课活动"); |
||||
} |
||||
|
||||
return Response.success(); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/update") |
||||
public Response<Activity> update(@RequestParam("id") String id, @RequestBody ActivityInfoDto request) { |
||||
try { |
||||
var activity = activityService.update(id, request); |
||||
return Response.success(activity); |
||||
} catch (DataConflictException e) { |
||||
return Response.error(ResponseCode.PARAM_WRONG, "同一个学期内一个时间段内只能有一个选课活动"); |
||||
} |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<Activity> delete(@RequestParam("id") String id) { |
||||
activityService.delete(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.controller.admin; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/course-schedule") |
||||
public class AdminCourseScheduleController { |
||||
} |
@ -0,0 +1,57 @@ |
||||
package net.lensfrex.rd.controller.course; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.dto.course.CourseDTO; |
||||
import net.lensfrex.rd.data.model.request.course.CourseRequest; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.course.CourseService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/course") |
||||
public class AdminCourseController { |
||||
private final CourseService courseService; |
||||
|
||||
public AdminCourseController(CourseService courseService) { |
||||
this.courseService = courseService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<CourseDTO> add(@RequestBody CourseRequest request) { |
||||
CourseDTO dto = CourseDTO.builder() |
||||
.name(request.getName()) |
||||
.courseHours(request.getCourseHours()) |
||||
.targetMajor(request.getTargetMajor()) |
||||
.targetGrade(request.getTargetGrade()) |
||||
.springTerm(request.getSpringTerm()) |
||||
.build(); |
||||
|
||||
var newCourse = courseService.add(dto); |
||||
|
||||
return Response.success(newCourse); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/update") |
||||
public Response<CourseDTO> update(@RequestParam("id") String id, @RequestBody CourseRequest request) { |
||||
CourseDTO dto = CourseDTO.builder() |
||||
.name(request.getName()) |
||||
.courseHours(request.getCourseHours()) |
||||
.targetMajor(request.getTargetMajor()) |
||||
.targetGrade(request.getTargetGrade()) |
||||
.springTerm(request.getSpringTerm()) |
||||
.build(); |
||||
|
||||
var teacherInfo = courseService.update(id, dto); |
||||
|
||||
return Response.success(teacherInfo); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<Object> delete(@RequestParam("id") String id) { |
||||
courseService.delete(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
package net.lensfrex.rd.controller.course; |
||||
|
||||
import net.lensfrex.rd.data.dto.course.CourseDTO; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.course.CourseService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/course") |
||||
public class CourseController { |
||||
|
||||
private final CourseService courseService; |
||||
|
||||
public CourseController(CourseService courseService) { |
||||
this.courseService = courseService; |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public Response<PaginationWrapper<List<CourseDTO>>> list( |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize |
||||
) { |
||||
var result = courseService.list(page, pageSize); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@GetMapping("/info") |
||||
public Response<CourseDTO> info(@RequestParam(value = "id") String id) { |
||||
var result = courseService.getCourse(id); |
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
package net.lensfrex.rd.controller.course; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin; |
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import net.lensfrex.rd.data.dto.course.CourseDTO; |
||||
import net.lensfrex.rd.data.entity.table.Course; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.course.CourseResponse; |
||||
import net.lensfrex.rd.service.course.CourseService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/student/course") |
||||
public class StudentCourseController { |
||||
private final CourseService courseService; |
||||
|
||||
public StudentCourseController(CourseService courseService) { |
||||
this.courseService = courseService; |
||||
} |
||||
|
||||
@SaCheckLogin |
||||
@SaCheckRole("STUDENT") |
||||
@GetMapping("/candidate") |
||||
public Response<List<CourseDTO>> listCandidate() { |
||||
String uid = StpUtil.getLoginId().toString(); |
||||
var courses = courseService.getCandidateCourseForStudent(uid); |
||||
|
||||
return Response.success(courses); |
||||
} |
||||
} |
@ -0,0 +1,4 @@ |
||||
package net.lensfrex.rd.controller.course; |
||||
|
||||
public class TeacherCourseController { |
||||
} |
@ -0,0 +1,32 @@ |
||||
package net.lensfrex.rd.controller.major; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.entity.table.Major; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.major.MajorService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/major") |
||||
public class AdminMajorController { |
||||
|
||||
private final MajorService majorService; |
||||
|
||||
public AdminMajorController(MajorService majorService) { |
||||
this.majorService = majorService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<Major> add(@RequestParam("name") String name) { |
||||
Major major = majorService.addMajorIfNotExists(name); |
||||
return Response.success(major); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<Object> delete(@RequestParam("id") String id) { |
||||
majorService.deleteMajor(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
package net.lensfrex.rd.controller.major; |
||||
|
||||
import net.lensfrex.rd.data.entity.table.Major; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.major.MajorService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
@RestController |
||||
@RequestMapping("/major") |
||||
public class PublicMajor { |
||||
|
||||
private final MajorService majorService; |
||||
|
||||
public PublicMajor(MajorService majorService) { |
||||
this.majorService = majorService; |
||||
} |
||||
|
||||
@GetMapping("/info") |
||||
public Response<Major> get(@RequestParam("id") String id) { |
||||
Major major = majorService.getMajor(id); |
||||
return Response.success(major); |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public Response<Set<Major>> list() { |
||||
var majorList = majorService.listAllMajor(); |
||||
return Response.success(majorList); |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
package net.lensfrex.rd.controller.schedule; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.dto.schedule.CourseScheduleDTO; |
||||
import net.lensfrex.rd.data.entity.table.CourseSchedule; |
||||
import net.lensfrex.rd.data.model.request.schedule.ClassScheduleRequest; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.schedule.CourseScheduleService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/course-schedule") |
||||
public class AdminScheduleController { |
||||
|
||||
private final CourseScheduleService courseScheduleService; |
||||
|
||||
public AdminScheduleController(CourseScheduleService courseScheduleService) { |
||||
this.courseScheduleService = courseScheduleService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<CourseSchedule> add(@RequestBody ClassScheduleRequest request) { |
||||
var dto = convert(request); |
||||
|
||||
var newCourse = courseScheduleService.add(dto); |
||||
|
||||
return Response.success(newCourse); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@RequestMapping("/duplicate") |
||||
public Response<Object> info(@RequestParam("course") String course, |
||||
@RequestParam("from") String sourceTerm, |
||||
@RequestParam("to") String targetTerm) { |
||||
courseScheduleService.duplicate(course, sourceTerm, targetTerm); |
||||
return Response.success(); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/update") |
||||
public Response<CourseSchedule> update(@RequestParam("id") String id, @RequestBody ClassScheduleRequest request) { |
||||
var dto = convert(request); |
||||
|
||||
var newCourse = courseScheduleService.update(id, dto); |
||||
|
||||
return Response.success(newCourse); |
||||
} |
||||
|
||||
private CourseScheduleDTO convert(ClassScheduleRequest request) { |
||||
CourseScheduleDTO dto = new CourseScheduleDTO(); |
||||
dto.setName(request.getName()); |
||||
dto.setCourse(request.getCourse()); |
||||
dto.setStartWeek(request.getStartWeek()); |
||||
dto.setEndWeek(request.getEndWeek()); |
||||
dto.setTime(request.getEndWeek()); |
||||
dto.setWeekDay(request.getWeekDay()); |
||||
dto.setAcademicTerm(request.getTerm()); |
||||
dto.setPlace(request.getPlace()); |
||||
dto.setRatio(request.getRatio()); |
||||
dto.setDistribution(new HashMap<>()); |
||||
dto.setTime(request.getSection()); |
||||
dto.setTeacherIds(request.getTeachers()); |
||||
|
||||
return dto; |
||||
|
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<Object> delete(@RequestParam("id") String id) { |
||||
courseScheduleService.delete(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,105 @@ |
||||
package net.lensfrex.rd.controller.schedule; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import net.lensfrex.rd.data.dto.schedule.CourseScheduleDTO; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.schedule.CourseScheduleService; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/course-schedule") |
||||
public class ScheduleController { |
||||
|
||||
private final CourseScheduleService courseScheduleService; |
||||
private final ObjectMapper objectMapper; |
||||
|
||||
public ScheduleController(CourseScheduleService courseScheduleService, ObjectMapper objectMapper) { |
||||
this.courseScheduleService = courseScheduleService; |
||||
this.objectMapper = objectMapper; |
||||
} |
||||
|
||||
@RequestMapping("/list") |
||||
public Response<PaginationWrapper<List<CourseScheduleDTO>>> list( |
||||
@RequestParam(value = "course") String course, |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) { |
||||
|
||||
var result = courseScheduleService.getScheduleOfCourse(course, page, pageSize); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/list-term") |
||||
public Response<List<CourseScheduleDTO>> getAllForCourse( |
||||
@RequestParam(value = "course") String course, |
||||
@RequestParam(value = "term") String term |
||||
) { |
||||
|
||||
var result = courseScheduleService.getTermCourseSchedule(course, term); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/list-teachers") |
||||
public Response<List<TeacherInfo>> listTeachers(@RequestParam("id") String scheduleId) { |
||||
var result = courseScheduleService.getScheduleTeacherInfo(scheduleId); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/info") |
||||
public Response<CourseScheduleDTO> info(@RequestParam("id") String id) { |
||||
var result = courseScheduleService.getScheduleDTO(id); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@RequestMapping("/selected-count") |
||||
public Response<Integer> selectCount(@RequestParam("id") String id) { |
||||
var result = courseScheduleService.getSelectedCount(id); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
private class ASD { |
||||
|
||||
} |
||||
|
||||
protected class asdd { |
||||
|
||||
} |
||||
@SaCheckRole({"TEACHER", "ADMIN"}) |
||||
@RequestMapping("/list-student") |
||||
public void exportStudents(@RequestParam("id") String scheduleId, HttpServletResponse response) throws IOException { |
||||
if (scheduleId == null) { |
||||
Response<String> responseData = Response.error(ResponseCode.PARAM_WRONG); |
||||
response.setContentType("application/json"); |
||||
response.getWriter().write(objectMapper.writeValueAsString(responseData)); |
||||
return; |
||||
} |
||||
|
||||
var data = courseScheduleService.exportStudentExcel(scheduleId); |
||||
|
||||
if (data == null) { |
||||
Response<String> responseData = Response.success("数据是空的"); |
||||
response.setContentType("application/json"); |
||||
response.getWriter().write(objectMapper.writeValueAsString(responseData)); |
||||
return; |
||||
} |
||||
|
||||
response.setContentLength(data.length); |
||||
response.setContentType("application/octet-stream"); |
||||
response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", "export_students_" + scheduleId + ".xlsx")); |
||||
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
||||
response.setHeader("Pragma", "no-cache"); |
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
||||
|
||||
response.getOutputStream().write(data); |
||||
} |
||||
} |
@ -0,0 +1,104 @@ |
||||
package net.lensfrex.rd.controller.schedule; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import cn.wustlinghang.mywust.data.common.Course; |
||||
import cn.wustlinghang.mywust.exception.ApiException; |
||||
import cn.wustlinghang.mywust.exception.ParseException; |
||||
import cn.wustlinghang.mywust.util.StringUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import net.lensfrex.rd.data.dto.schedule.CourseScheduleDTO; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.official.OfficialUndergradScheduleService; |
||||
import net.lensfrex.rd.service.schedule.CourseScheduleService; |
||||
import net.lensfrex.rd.service.schedule.StudentCourseScheduleService; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
@RestController |
||||
@RequestMapping("/student/course-schedule") |
||||
public class StudentScheduleController { |
||||
|
||||
private final CourseScheduleService courseScheduleService; |
||||
private final OfficialUndergradScheduleService officialUndergradScheduleService; |
||||
private final StudentCourseScheduleService studentCourseScheduleService; |
||||
|
||||
public StudentScheduleController(CourseScheduleService courseScheduleService, |
||||
OfficialUndergradScheduleService officialUndergradScheduleService, |
||||
StudentCourseScheduleService studentCourseScheduleService) { |
||||
|
||||
this.courseScheduleService = courseScheduleService; |
||||
this.officialUndergradScheduleService = officialUndergradScheduleService; |
||||
this.studentCourseScheduleService = studentCourseScheduleService; |
||||
} |
||||
|
||||
@SaCheckRole("STUDENT") |
||||
@RequestMapping("/current") |
||||
public Response<List<CourseScheduleDTO>> list(@RequestParam(value = "term", required = false, defaultValue = "") String term) { |
||||
if (term == null || term.isEmpty()) { |
||||
term = StringUtil.getCurrentTermString(); |
||||
} |
||||
|
||||
String uid = StpUtil.getLoginId().toString(); |
||||
var result = courseScheduleService.getStudentTermSchedule(uid, term); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
|
||||
@SaCheckRole("STUDENT") |
||||
@RequestMapping("/official") |
||||
public Response<List<CourseScheduleDTO>> getOfficialCourse( |
||||
@RequestParam(value = "term", required = false, defaultValue = "") String term) |
||||
throws IOException, ParseException, ApiException { |
||||
|
||||
if (term == null || term.equals("")) { |
||||
term = StringUtil.getCurrentTermString(); |
||||
log.debug("默认的学期:" + term); |
||||
} |
||||
|
||||
String uid = StpUtil.getLoginId().toString(); |
||||
var schedules = officialUndergradScheduleService.getOfficialCourseSchedule(uid, term); |
||||
|
||||
var result = new ArrayList<CourseScheduleDTO>(schedules.size()); |
||||
for (var schedule : schedules) { |
||||
result.add(convert(schedule)); |
||||
} |
||||
|
||||
return Response.success(result); |
||||
} |
||||
|
||||
private CourseScheduleDTO convert(Course course) { |
||||
CourseScheduleDTO courseScheduleDTO = new CourseScheduleDTO(); |
||||
courseScheduleDTO.setName(course.getName()); |
||||
courseScheduleDTO.setCourse(course.getName()); |
||||
courseScheduleDTO.setStartWeek(course.getStartWeek()); |
||||
courseScheduleDTO.setEndWeek(course.getEndWeek()); |
||||
courseScheduleDTO.setTime(course.getStartSection() / 2); |
||||
courseScheduleDTO.setWeekDay(course.getWeekDay()); |
||||
courseScheduleDTO.setPlace(course.getClassroom()); |
||||
courseScheduleDTO.setDistribution(null); |
||||
|
||||
List<TeacherInfo> teachers = new ArrayList<>(); |
||||
teachers.add(TeacherInfo.builder().name(course.getTeacher()).build()); |
||||
courseScheduleDTO.setTeachers(teachers); |
||||
|
||||
return courseScheduleDTO; |
||||
} |
||||
|
||||
@SaCheckRole("STUDENT") |
||||
@RequestMapping("/select") |
||||
public Response<Object> select(@RequestParam("schedule") String schedule, @RequestParam("activity") String activity) { |
||||
String uid = StpUtil.getLoginId().toString(); |
||||
|
||||
studentCourseScheduleService.selectSchedule(uid, schedule, activity); |
||||
|
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
package net.lensfrex.rd.controller.schedule; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import net.lensfrex.rd.data.dto.schedule.CourseScheduleDTO; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.schedule.TeacherCourseScheduleService; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/teacher/course-schedule") |
||||
public class TeacherScheduleController { |
||||
private final TeacherCourseScheduleService teacherCourseScheduleService; |
||||
|
||||
public TeacherScheduleController(TeacherCourseScheduleService teacherCourseScheduleService) { |
||||
|
||||
this.teacherCourseScheduleService = teacherCourseScheduleService; |
||||
} |
||||
|
||||
@SaCheckRole("TEACHER") |
||||
@RequestMapping("/my-class") |
||||
public Response<List<CourseScheduleDTO>> list(@RequestParam("term") String term) { |
||||
String uid = StpUtil.getLoginId().toString(); |
||||
|
||||
var result = teacherCourseScheduleService.getTeacherSchedule(uid, term); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
package net.lensfrex.rd.controller.score; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.score.ScoreService; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
@RestController |
||||
@RequestMapping("/score") |
||||
public class ScoreController { |
||||
private final ScoreService scoreService; |
||||
|
||||
private final ObjectMapper objectMapper; |
||||
|
||||
public ScoreController(ScoreService scoreService, ObjectMapper objectMapper) { |
||||
this.scoreService = scoreService; |
||||
this.objectMapper = objectMapper; |
||||
} |
||||
|
||||
@SaCheckRole({"TEACHER", "ADMIN"}) |
||||
@RequestMapping("/export") |
||||
public void exportStudents(@RequestParam("id") String scheduleId, HttpServletResponse response) throws IOException { |
||||
if (scheduleId == null) { |
||||
Response<String> responseData = Response.error(ResponseCode.PARAM_WRONG); |
||||
response.setContentType("application/json"); |
||||
response.getWriter().write(objectMapper.writeValueAsString(responseData)); |
||||
return; |
||||
} |
||||
|
||||
var data = scoreService.exportScoreExcel(scheduleId); |
||||
|
||||
if (data == null) { |
||||
Response<String> responseData = Response.success("数据是空的"); |
||||
response.setContentType("application/json"); |
||||
response.getWriter().write(objectMapper.writeValueAsString(responseData)); |
||||
return; |
||||
} |
||||
|
||||
response.setContentLength(data.length); |
||||
response.setContentType("application/octet-stream"); |
||||
response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", "export_score_" + scheduleId + ".xlsx")); |
||||
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
||||
response.setHeader("Pragma", "no-cache"); |
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
||||
|
||||
response.getOutputStream().write(data); |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package net.lensfrex.rd.controller.score; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import net.lensfrex.rd.data.dto.score.StudentScore; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.score.ScoreService; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/student/score") |
||||
public class StudentScoreController { |
||||
|
||||
private final ScoreService scoreService; |
||||
|
||||
public StudentScoreController(ScoreService scoreService) { |
||||
this.scoreService = scoreService; |
||||
} |
||||
|
||||
@SaCheckRole("STUDENT") |
||||
@RequestMapping("/all") |
||||
public Response<List<StudentScore>> getAll() { |
||||
String uid = StpUtil.getLoginId().toString(); |
||||
var result = scoreService.getStudentScore(uid); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
package net.lensfrex.rd.controller.score; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import net.lensfrex.rd.data.dto.score.ScheduleScore; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.score.ScoreService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/teacher/score") |
||||
public class TeacherScoreController { |
||||
|
||||
private final ScoreService scoreService; |
||||
|
||||
public TeacherScoreController(ScoreService scoreService) { |
||||
this.scoreService = scoreService; |
||||
} |
||||
|
||||
@SaCheckRole("TEACHER") |
||||
@RequestMapping("/list-students") |
||||
public Response<List<ScheduleScore>> listStudents(@RequestParam("id") String schedule) { |
||||
var result = scoreService.getClassScore(schedule); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
|
||||
@SaCheckRole("TEACHER") |
||||
@PostMapping("/update") |
||||
public Response<Object> update(@RequestParam("schedule") String scheduleId, |
||||
@RequestParam(value = "scoreId", required = false) String scoreId, |
||||
@RequestBody ScheduleScore scheduleScore) { |
||||
|
||||
scoreService.insertOrUpdateScore(scheduleId, scoreId, scheduleScore); |
||||
|
||||
return Response.success(); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,67 @@ |
||||
package net.lensfrex.rd.controller.student; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.dto.user.student.BasicStudentInfoDto; |
||||
import net.lensfrex.rd.data.dto.user.student.NewStudentDTO; |
||||
import net.lensfrex.rd.data.dto.user.student.StudentUserBasicDTO; |
||||
import net.lensfrex.rd.data.dto.user.student.StudentUserInfoDTO; |
||||
import net.lensfrex.rd.data.dto.user.teacher.TeacherUserDTO; |
||||
import net.lensfrex.rd.data.entity.table.StudentInfo; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import net.lensfrex.rd.data.model.request.admin.StudentAddRequest; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.user.StudentUserService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/user/student") |
||||
public class AdminStudentController { |
||||
private final StudentUserService studentUserService; |
||||
|
||||
public AdminStudentController(StudentUserService studentUserService) { |
||||
this.studentUserService = studentUserService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<StudentInfo> add(@RequestBody StudentAddRequest request) { |
||||
var dto = new BasicStudentInfoDto(request.studentNumber(), request.studentName(), request.major()); |
||||
|
||||
var teacherInfo = studentUserService.add(dto); |
||||
return Response.success(teacherInfo); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add-with-auto-major") |
||||
public Response<StudentInfo> addWithAutoMajor(@RequestBody StudentAddRequest request) { |
||||
if (request.studentNumber() == null || request.studentName() == null || request.major() == null) { |
||||
return Response.error(ResponseCode.PARAM_WRONG); |
||||
} |
||||
var dto = new BasicStudentInfoDto(request.studentNumber(), request.studentName(), request.major()); |
||||
|
||||
var teacherInfo = studentUserService.addWithAutoMajor(dto); |
||||
return Response.success(teacherInfo); |
||||
} |
||||
//
|
||||
// @SaCheckRole("ADMIN")
|
||||
// @PostMapping("/update")
|
||||
// public Response<StudentInfo> update(@RequestParam("id") String id, @RequestBody StudentAddRequest request) {
|
||||
// String username = request.studentNumber();
|
||||
// String teacherName = request.studentName();
|
||||
// String initialPassword = request.initialPassword();
|
||||
//
|
||||
// var dto = new BasicStudentInfoDto(request.studentNumber(), request.studentName());
|
||||
//
|
||||
// var teacherInfo = studentUserService.update(id, dto);
|
||||
//
|
||||
// return Response.success(teacherInfo);
|
||||
// }
|
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<TeacherInfo> delete(@RequestParam("id") String id) { |
||||
studentUserService.delete(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
package net.lensfrex.rd.controller.student; |
||||
|
||||
import net.lensfrex.rd.data.dto.user.student.StudentUserInfoDTO; |
||||
import net.lensfrex.rd.data.entity.table.StudentInfo; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.user.StudentUserService; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/student") |
||||
public class StudentController { |
||||
private final StudentUserService studentUserService; |
||||
|
||||
public StudentController(StudentUserService studentUserService) { |
||||
this.studentUserService = studentUserService; |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public Response<PaginationWrapper<List<StudentInfo>>> list( |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize |
||||
) { |
||||
var result = studentUserService.list(page, pageSize); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@GetMapping("/info") |
||||
public Response<StudentUserInfoDTO> info(@RequestParam(value = "id") String id) { |
||||
var result = studentUserService.getInfoById(id); |
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
package net.lensfrex.rd.controller.teacher; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.dto.user.teacher.TeacherUserDTO; |
||||
import net.lensfrex.rd.data.dto.user.teacher.TeacherUserInfoDTO; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import net.lensfrex.rd.data.model.request.admin.TeacherAddRequest; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.user.TeacherUserService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/admin/user/teacher") |
||||
public class AdminTeacherController { |
||||
private final TeacherUserService teacherUserService; |
||||
|
||||
public AdminTeacherController(TeacherUserService teacherUserService) { |
||||
this.teacherUserService = teacherUserService; |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/add") |
||||
public Response<TeacherInfo> add(@RequestBody TeacherAddRequest request) { |
||||
String username = request.username(); |
||||
String teacherName = request.teacherName(); |
||||
String initialPassword = request.initialPassword(); |
||||
|
||||
TeacherUserDTO dto = new TeacherUserDTO(username, teacherName, initialPassword); |
||||
|
||||
var teacherInfo = teacherUserService.add(dto); |
||||
return Response.success(teacherInfo); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/update") |
||||
public Response<TeacherInfo> update(@RequestParam("id") String id, @RequestBody TeacherAddRequest request) { |
||||
String username = request.username(); |
||||
String teacherName = request.teacherName(); |
||||
String initialPassword = request.initialPassword(); |
||||
|
||||
TeacherUserDTO dto = new TeacherUserDTO(username, teacherName, initialPassword); |
||||
var teacherInfo = teacherUserService.update(id, dto); |
||||
|
||||
return Response.success(teacherInfo); |
||||
} |
||||
|
||||
@SaCheckRole("ADMIN") |
||||
@PostMapping("/delete") |
||||
public Response<TeacherInfo> delete(@RequestParam("id") String id) { |
||||
teacherUserService.delete(id); |
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
package net.lensfrex.rd.controller.teacher; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole; |
||||
import net.lensfrex.rd.data.dto.user.teacher.TeacherUserDTO; |
||||
import net.lensfrex.rd.data.dto.user.teacher.TeacherUserInfoDTO; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import net.lensfrex.rd.data.model.request.admin.TeacherAddRequest; |
||||
import net.lensfrex.rd.data.model.response.PaginationWrapper; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.service.user.TeacherUserService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("/teacher") |
||||
public class TeacherController { |
||||
private final TeacherUserService teacherUserService; |
||||
|
||||
public TeacherController(TeacherUserService teacherUserService) { |
||||
this.teacherUserService = teacherUserService; |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public Response<PaginationWrapper<List<TeacherInfo>>> list( |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize |
||||
) { |
||||
var result = teacherUserService.list(page, pageSize); |
||||
return Response.success(result); |
||||
} |
||||
|
||||
@GetMapping("/info") |
||||
public Response<TeacherUserInfoDTO> info(@RequestParam(value = "id") String id) { |
||||
var result = teacherUserService.getUserInfoById(id); |
||||
return Response.success(result); |
||||
} |
||||
} |
@ -0,0 +1,134 @@ |
||||
package net.lensfrex.rd.controller.user; |
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin; |
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import net.lensfrex.rd.configure.PasswordConfigure; |
||||
import net.lensfrex.rd.data.entity.table.UserBasic; |
||||
import net.lensfrex.rd.data.enums.UserType; |
||||
import net.lensfrex.rd.data.model.request.auth.UserLoginRequest; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.data.model.response.auth.UserLoginStatusResponse; |
||||
import net.lensfrex.rd.data.model.response.user.UserBasicInfo; |
||||
import net.lensfrex.rd.service.user.StudentUserService; |
||||
import net.lensfrex.rd.service.user.UserBasicService; |
||||
import net.lensfrex.rd.util.PasswordUtil; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* 登录认证Controller |
||||
*/ |
||||
@Slf4j |
||||
@RestController |
||||
@RequestMapping("/user/auth") |
||||
public class UserAuthController { |
||||
|
||||
private final UserBasicService userBasicService; |
||||
private final PasswordUtil passwordUtil; |
||||
|
||||
private final StudentUserService studentUserService; |
||||
|
||||
public UserAuthController(UserBasicService userBasicService, |
||||
PasswordConfigure passwordConfigure, |
||||
StudentUserService studentUserService) { |
||||
|
||||
this.userBasicService = userBasicService; |
||||
this.passwordUtil = new PasswordUtil(passwordConfigure.getKey(), passwordConfigure.getIv()); |
||||
this.studentUserService = studentUserService; |
||||
} |
||||
|
||||
@RequestMapping("/login") |
||||
public Response<UserBasicInfo> login(@RequestBody UserLoginRequest loginRequest) { |
||||
String username = loginRequest.username(); |
||||
String password = loginRequest.password(); |
||||
|
||||
UserBasic userBasic = userBasicService.getUserBasicByUsername(username); |
||||
if (userBasic == null || userBasic.getPassword() == null || "".equals(userBasic.getPassword())) { |
||||
// 用户不存在,尝试从教务处获取用户信息
|
||||
log.info("用户'{}'不存在,尝试从教务处获取用户信息", username); |
||||
try { |
||||
var newStudentDto = studentUserService.tryAddStudentFromOfficial(username, password); |
||||
userBasic = newStudentDto.userBasic(); |
||||
} catch (Exception e) { |
||||
return Response.error(ResponseCode.STUDENT_ID_DOES_NOT_EXISTS.getCode(), |
||||
"从教务处获取用户信息失败,\n" + |
||||
"如果是非学生学生用户,请检查用户名是否正确;\n" + |
||||
"如果是学生用户,请检查用户名和密码,或者再重试重试一下。\nException:" + e |
||||
); |
||||
} |
||||
} else { |
||||
// 用户已经存在,直接从数据库获取数据
|
||||
String encodedPassword = passwordUtil.encode(password); |
||||
if (!encodedPassword.equals(userBasic.getPassword())) { |
||||
log.info("用户'{}'不存在,尝试从教务处获取用户信息", username); |
||||
try { |
||||
var newStudentDto = studentUserService.tryAddStudentFromOfficial(username, password); |
||||
userBasic = newStudentDto.userBasic(); |
||||
} catch (Exception e) { |
||||
return Response.error(ResponseCode.PASSWORD_WRONG); |
||||
} |
||||
} |
||||
} |
||||
|
||||
StpUtil.login(userBasic.getId()); |
||||
|
||||
UserType userType = switch (userBasic.getType()) { |
||||
case 0 -> UserType.STUDENT; |
||||
case 1 -> UserType.TEACHER; |
||||
case 2 -> UserType.ADMIN; |
||||
default -> { |
||||
log.warn("未知的用户类型:{}", userBasic.getType()); |
||||
yield UserType.STUDENT; |
||||
} |
||||
}; |
||||
|
||||
var basicInfoResponse = UserBasicInfo.builder() |
||||
.id(userBasic.getId()) |
||||
.username(userBasic.getUsername()) |
||||
.userType(userType) |
||||
.build(); |
||||
|
||||
return Response.success(basicInfoResponse); |
||||
} |
||||
|
||||
@RequestMapping("/logout") |
||||
public Response<String> logout() { |
||||
StpUtil.logout(); |
||||
return Response.success(); |
||||
} |
||||
|
||||
@RequestMapping("/check") |
||||
public Response<UserLoginStatusResponse> checkLogin() { |
||||
boolean login = StpUtil.isLogin(); |
||||
if (!login) { |
||||
return Response.success(new UserLoginStatusResponse(null, null, false)); |
||||
} |
||||
|
||||
String uid = StpUtil.getLoginId().toString(); |
||||
String role = StpUtil.getRoleList().get(0); |
||||
|
||||
return Response.success(new UserLoginStatusResponse(uid, role, true)); |
||||
} |
||||
|
||||
@SaCheckLogin |
||||
@RequestMapping("/modify-password") |
||||
public Response<Object> modifyPassword(@RequestParam("old") String oldPassword, |
||||
@RequestParam("new") String newPassword) { |
||||
String uid = StpUtil.getLoginId().toString(); |
||||
var userBasic = userBasicService.getUserBasicById(uid); |
||||
String encodedPassword = passwordUtil.encode(oldPassword); |
||||
if (!encodedPassword.equals(userBasic.getPassword())) { |
||||
return Response.error(ResponseCode.PASSWORD_WRONG); |
||||
} |
||||
|
||||
userBasicService.updatePassword(uid, newPassword); |
||||
|
||||
StpUtil.logout(); |
||||
|
||||
return Response.success(); |
||||
} |
||||
} |
@ -0,0 +1,34 @@ |
||||
package net.lensfrex.rd.controller.user; |
||||
|
||||
import cn.dev33.satoken.stp.StpUtil; |
||||
import net.lensfrex.rd.data.enums.UserType; |
||||
import net.lensfrex.rd.data.model.response.Response; |
||||
import net.lensfrex.rd.data.model.response.ResponseCode; |
||||
import net.lensfrex.rd.service.user.UserInfoService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("/user/info") |
||||
public class UserInfoController { |
||||
private final UserInfoService userInfoService; |
||||
|
||||
public UserInfoController(UserInfoService userInfoService) { |
||||
this.userInfoService = userInfoService; |
||||
} |
||||
|
||||
@RequestMapping("") |
||||
public Object getUserInfo(@RequestParam("uid") String uid, @RequestParam("userType") String userType) { |
||||
// 如果不是自己的账号并且也不是管理员
|
||||
if (!StpUtil.getLoginId().equals(uid) && !StpUtil.hasRole(UserType.ADMIN.name())) { |
||||
return Response.error(ResponseCode.PERMISSION_DENIED); |
||||
} |
||||
|
||||
Object userInfo = switch (userType) { |
||||
case "STUDENT" -> userInfoService.getAsStudent(uid); |
||||
case "TEACHER" -> userInfoService.getAsTeacher(uid); |
||||
default -> null; |
||||
}; |
||||
|
||||
return Response.success(userInfo); |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
package net.lensfrex.rd.dao.mapper.activity; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import net.lensfrex.rd.data.entity.table.Activity; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public interface ActivityMapper extends BaseMapper<Activity> { |
||||
} |
@ -0,0 +1,18 @@ |
||||
package net.lensfrex.rd.dao.mapper.course; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.Course; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface CourseMapper extends BaseMapper<Course> { |
||||
List<Course> getCourseByMajorAndGrade(@Param("major") String major, |
||||
@Param("grade") Integer grade, |
||||
@Param("springTerm") Boolean sprintTerm |
||||
); |
||||
|
||||
Object getCourseDetail(String course); |
||||
} |
@ -0,0 +1,10 @@ |
||||
package net.lensfrex.rd.dao.mapper.experiment; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.ExperimentItem; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface ExperimentItemMapper extends BaseMapper<ExperimentItem> { |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.mapper.major; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.Major; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface MajorMapper extends BaseMapper<Major> { |
||||
} |
@ -0,0 +1,19 @@ |
||||
package net.lensfrex.rd.dao.mapper.schedule; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.CourseSchedule; |
||||
import net.lensfrex.rd.data.entity.table.StudentInfo; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface CourseScheduleMapper extends BaseMapper<CourseSchedule> { |
||||
Object getScheduleDetailFromCourseId(String course); |
||||
|
||||
Object getScheduleDetailFromScheduleId(String courseSchedule); |
||||
|
||||
Integer getScheduleTotalStudent(String courseSchedule); |
||||
|
||||
List<StudentInfo> getSelectedStudent(String courseSchedule); |
||||
} |
@ -0,0 +1,10 @@ |
||||
package net.lensfrex.rd.dao.mapper.schedule; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.CourseSelection; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
@Mapper |
||||
public interface CourseScheduleSelectionMapper extends BaseMapper<CourseSelection> { |
||||
} |
@ -0,0 +1,18 @@ |
||||
package net.lensfrex.rd.dao.mapper.schedule; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.CourseSchedule; |
||||
import net.lensfrex.rd.data.entity.table.TeacherClass; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface TeacherClassMapper extends BaseMapper<TeacherClass> { |
||||
Integer insetBatch(@Param("scheduleId") String scheduleId, |
||||
@Param("teachers") List<String> teachers |
||||
); |
||||
|
||||
List<CourseSchedule> getScheduleForTeacher(@Param("teacher") String teacher, @Param("term") String term); |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.mapper.schedule; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import net.lensfrex.rd.data.entity.table.TeacherClass; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class TeacherClassMapperService extends ServiceImpl<TeacherClassMapper, TeacherClass> { |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.mapper.score; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.ExperimentScore; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface ExperimentScoreMapper extends BaseMapper<ExperimentScore> { |
||||
} |
@ -0,0 +1,21 @@ |
||||
package net.lensfrex.rd.dao.mapper.score; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.dto.score.ScheduleScore; |
||||
import net.lensfrex.rd.data.dto.score.StudentScore; |
||||
import net.lensfrex.rd.data.entity.table.Score; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface ScoreMapper extends BaseMapper<Score> { |
||||
List<StudentScore> getStudentScore(@Param("student") String student); |
||||
|
||||
List<ScheduleScore> getScheduleAllStudentScore(@Param("scheduleId")String scheduleId); |
||||
|
||||
void insertOrUpdateScore(@Param("score") Score score); |
||||
|
||||
void insertOrUpdateScoreBatch(@Param("scores") List<Score> score); |
||||
} |
@ -0,0 +1,11 @@ |
||||
package net.lensfrex.rd.dao.mapper.user; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.StudentInfo; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
@Mapper |
||||
public interface StudentInfoMapper extends BaseMapper<StudentInfo> { |
||||
void insertOrUpdate(@Param("student") StudentInfo studentInfo); |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.mapper.user; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface TeacherInfoMapper extends BaseMapper<TeacherInfo> { |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.mapper.user; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import net.lensfrex.rd.data.entity.table.UserBasic; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
@Mapper |
||||
public interface UserBasicMapper extends BaseMapper<UserBasic> { |
||||
} |
@ -0,0 +1,77 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<Double>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class DoubleListTypeHandler extends BaseTypeHandler<List<Double>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<Double> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "Double"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<Double> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Double> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Double> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<Double> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var arr = array.getArray(); |
||||
var result = new ArrayList<Double>(); |
||||
|
||||
if (arr instanceof Double[] doubleArr) { |
||||
Collections.addAll(result, doubleArr); |
||||
} else if (arr instanceof Float[] floatArr) { |
||||
for (Float floatVal : floatArr) { |
||||
result.add(floatVal.doubleValue()); |
||||
} |
||||
} else if (arr instanceof Integer[] intArr) { |
||||
for (Integer intVal : intArr) { |
||||
result.add(intVal.doubleValue()); |
||||
} |
||||
} else if (arr instanceof Short[] shortArr) { |
||||
for (Short shortVal : shortArr) { |
||||
result.add(shortVal.doubleValue()); |
||||
} |
||||
} else if (arr instanceof Long[] longArr) { |
||||
for (Long longVal : longArr) { |
||||
result.add(longVal.doubleValue()); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<Float>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class FloatListTypeHandler extends BaseTypeHandler<List<Float>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<Float> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "double"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<Float> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Float> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Float> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<Float> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var arr = array.getArray(); |
||||
var result = new ArrayList<Float>(); |
||||
|
||||
if (arr instanceof Float[] doubleArr) { |
||||
Collections.addAll(result, doubleArr); |
||||
} else if (arr instanceof Double[] doublearr) { |
||||
for (Double intVal : doublearr) { |
||||
result.add(intVal.floatValue()); |
||||
} |
||||
} else if (arr instanceof Integer[] intArr) { |
||||
for (Integer intVal : intArr) { |
||||
result.add(intVal.floatValue()); |
||||
} |
||||
} else if (arr instanceof Short[] shortArr) { |
||||
for (Short shortVal : shortArr) { |
||||
result.add(shortVal.floatValue()); |
||||
} |
||||
} else if (arr instanceof Long[] longArr) { |
||||
for (Long longVal : longArr) { |
||||
result.add(longVal.floatValue()); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.*; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<Integer>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class IntegerListTypeHandler extends BaseTypeHandler<List<Integer>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<Integer> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "integer"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<Integer> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Integer> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Integer> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<Integer> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var arr = array.getArray(); |
||||
var result = new ArrayList<Integer>(); |
||||
|
||||
if (arr instanceof Integer[] intArr) { |
||||
Collections.addAll(result, intArr); |
||||
} else if (arr instanceof Short[] shortArr) { |
||||
for (Short shortVal : shortArr) { |
||||
result.add(shortVal.intValue()); |
||||
} |
||||
} else if (arr instanceof Long[] longArr) { |
||||
for (Long longVal : longArr) { |
||||
result.add(longVal.intValue()); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<Long>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class LongListTypeHandler extends BaseTypeHandler<List<Long>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<Long> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "numeric"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<Long> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Long> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Long> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<Long> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var arr = array.getArray(); |
||||
var result = new ArrayList<Long>(); |
||||
|
||||
if (arr instanceof Long[] longArr) { |
||||
Collections.addAll(result, longArr); |
||||
} else if (arr instanceof Integer[] intArr) { |
||||
for (Integer intVal : intArr) { |
||||
result.add(intVal.longValue()); |
||||
} |
||||
} else if (arr instanceof Short[] shortArr) { |
||||
for (Short shortVal : shortArr) { |
||||
result.add(shortVal.longValue()); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.BaseTypeHandler; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<Short>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class ShortListTypeHandler extends BaseTypeHandler<List<Short>> { |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<Short> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "integer"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<Short> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Short> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<Short> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<Short> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var arr = array.getArray(); |
||||
var result = new ArrayList<Short>(); |
||||
|
||||
if (arr instanceof Short[] shortArr) { |
||||
Collections.addAll(result, shortArr); |
||||
} else if (arr instanceof Integer[] intArr) { |
||||
for (Integer intVal : intArr) { |
||||
result.add(intVal.shortValue()); |
||||
} |
||||
} else if (arr instanceof Long[] longArr) { |
||||
for (Long longVal : longArr) { |
||||
result.add(longVal.shortValue()); |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,55 @@ |
||||
package net.lensfrex.rd.dao.type; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.*; |
||||
|
||||
import java.sql.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
//@MappedTypes(List<String>.class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY) |
||||
public class StringListTypeHandler extends BaseTypeHandler<List<String>> { |
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<String> parameter, JdbcType jdbcType) throws SQLException { |
||||
String typeName = "varchar"; |
||||
|
||||
Connection conn = ps.getConnection(); |
||||
Array array = conn.createArrayOf(typeName, parameter.toArray()); |
||||
ps.setArray(i, array); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
return getArray(rs.getArray(columnName)); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
return getArray(rs.getArray(columnIndex)); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
return getArray(cs.getArray(columnIndex)); |
||||
} |
||||
|
||||
private List<String> getArray(Array array) { |
||||
if (array == null) { |
||||
return null; |
||||
} |
||||
try { |
||||
var strArray = (String[]) array.getArray(); |
||||
var result = new ArrayList<String>(strArray.length); |
||||
Collections.addAll(result, strArray); |
||||
|
||||
return result; |
||||
} catch (Exception e) { |
||||
log.error("类型转换出错:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.type.json; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
public abstract class BaseJsonListTypeHandler<T> extends BaseJsonTypeHandler<ArrayList<T>> { |
||||
protected BaseJsonListTypeHandler(Class<T> clazz) { |
||||
super(objectMapper.getTypeFactory().constructParametricType(ArrayList.class, clazz)); |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
package net.lensfrex.rd.dao.type.json; |
||||
|
||||
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; |
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import com.fasterxml.jackson.databind.JavaType; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.postgresql.util.PGobject; |
||||
|
||||
import java.sql.PreparedStatement; |
||||
import java.sql.SQLException; |
||||
import java.sql.Types; |
||||
|
||||
@Slf4j |
||||
public abstract class BaseJsonTypeHandler<T> extends AbstractJsonTypeHandler<T> { |
||||
protected static final ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
||||
protected final JavaType javaType; |
||||
protected final Class<T> clazz; |
||||
|
||||
protected BaseJsonTypeHandler(JavaType javaType) { |
||||
this.javaType = javaType; |
||||
this.clazz = null; |
||||
} |
||||
|
||||
protected BaseJsonTypeHandler(Class<T> clazz) { |
||||
this.javaType = null; |
||||
this.clazz = clazz; |
||||
} |
||||
|
||||
@Override |
||||
protected T parse(String json) { |
||||
try { |
||||
if (clazz == null) { |
||||
return objectMapper.readValue(json, javaType); |
||||
} else { |
||||
return objectMapper.readValue(json, clazz); |
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException { |
||||
PGobject obj = new PGobject(); |
||||
obj.setType("jsonb"); |
||||
obj.setValue(toJson(parameter)); |
||||
|
||||
ps.setObject(i, obj); |
||||
} |
||||
|
||||
@Override |
||||
protected String toJson(T obj) { |
||||
try { |
||||
return objectMapper.writeValueAsString(obj); |
||||
} catch (JsonProcessingException e) { |
||||
log.warn("对象序列化异常:", e); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package net.lensfrex.rd.dao.type.json; |
||||
|
||||
import com.fasterxml.jackson.databind.JavaType; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class FloatMapTypeHandler extends BaseJsonTypeHandler<Map<String, String>> { |
||||
private static final JavaType FLOAT_MAP_TYPE = |
||||
objectMapper.getTypeFactory().constructMapType(HashMap.class, String.class, Float.class); |
||||
|
||||
public FloatMapTypeHandler() { |
||||
super(FLOAT_MAP_TYPE); |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.dao.type.json; |
||||
|
||||
import net.lensfrex.rd.data.entity.UsualScoreItem; |
||||
|
||||
public class UsualScoreItemListTypeHandler extends BaseJsonListTypeHandler<UsualScoreItem> { |
||||
public UsualScoreItemListTypeHandler() { |
||||
super(UsualScoreItem.class); |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
package net.lensfrex.rd.data.dto.course; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class CourseDTO { |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private Integer courseHours; |
||||
|
||||
/** |
||||
* 上课专业id |
||||
*/ |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级,使用大x表示,如大二:2 |
||||
*/ |
||||
private List<Integer> targetGrade; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
|
||||
} |
@ -0,0 +1,67 @@ |
||||
package net.lensfrex.rd.data.dto.schedule; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.data.entity.table.TeacherInfo; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class CourseScheduleDTO { |
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String course; |
||||
|
||||
/** |
||||
* 开始周 |
||||
*/ |
||||
private int startWeek; |
||||
|
||||
/** |
||||
* 结束周 |
||||
*/ |
||||
private int endWeek; |
||||
|
||||
/** |
||||
* 节次时间,即第几节课 |
||||
*/ |
||||
private int time; |
||||
|
||||
/** |
||||
* 节次时间,即第几节课 |
||||
*/ |
||||
private int weekDay; |
||||
|
||||
/** |
||||
* 学年学期,格式如2023-2024 |
||||
*/ |
||||
private String academicTerm; |
||||
|
||||
/** |
||||
* 上课地点 |
||||
*/ |
||||
private String place; |
||||
|
||||
/** |
||||
* 考试成绩占比 |
||||
*/ |
||||
private float ratio; |
||||
|
||||
/** |
||||
* 平时分组成描述 |
||||
*/ |
||||
private Map<String, Float> distribution; |
||||
|
||||
private List<TeacherInfo> teachers; |
||||
|
||||
@JsonIgnore |
||||
private List<String> teacherIds; |
||||
} |
@ -0,0 +1,11 @@ |
||||
package net.lensfrex.rd.data.dto.schedule; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class StudentExportDto { |
||||
private int id; |
||||
private String studentNumber; |
||||
private String name; |
||||
} |
@ -0,0 +1,23 @@ |
||||
package net.lensfrex.rd.data.dto.score; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class ScheduleScore { |
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private String number; |
||||
|
||||
private Float usualScore; |
||||
|
||||
private Float examScore; |
||||
} |
@ -0,0 +1,18 @@ |
||||
package net.lensfrex.rd.data.dto.score; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class ScoreExportDto { |
||||
private int id; |
||||
|
||||
private String name; |
||||
|
||||
private String number; |
||||
|
||||
private Float usualScore; |
||||
|
||||
private Float examScore; |
||||
|
||||
private Double finalScore; |
||||
} |
@ -0,0 +1,22 @@ |
||||
package net.lensfrex.rd.data.dto.score; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class StudentScore { |
||||
private String id; |
||||
|
||||
private String courseName; |
||||
|
||||
private String scheduleName; |
||||
|
||||
private String term; |
||||
|
||||
private String schedule; |
||||
|
||||
private Float ratio; |
||||
|
||||
private Float usualScore; |
||||
|
||||
private Float examScore; |
||||
} |
@ -0,0 +1,4 @@ |
||||
package net.lensfrex.rd.data.dto.user; |
||||
|
||||
public record UserBasicInfoDTO(String id, String username, String password, Short type) { |
||||
} |
@ -0,0 +1,4 @@ |
||||
package net.lensfrex.rd.data.dto.user.student; |
||||
|
||||
public record BasicStudentInfoDto(String studentNumber, String studentName, String major) { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.dto.user.student; |
||||
|
||||
import net.lensfrex.rd.data.entity.table.StudentInfo; |
||||
import net.lensfrex.rd.data.entity.table.UserBasic; |
||||
|
||||
public record NewStudentDTO(UserBasic userBasic, StudentInfo studentInfo) { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.dto.user.student; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record StudentUserBasicDTO(String id, String username, String number, String name, String major, int grade, String clazz, String password) { |
||||
} |
@ -0,0 +1,10 @@ |
||||
package net.lensfrex.rd.data.dto.user.student; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Builder; |
||||
|
||||
@Builder |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record StudentUserInfoDTO(String id, String username, String number, String name, String major, int grade, |
||||
String clazz, String password) { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.dto.user.teacher; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record TeacherUserDTO(String username, String teacherName, String password) { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.dto.user.teacher; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record TeacherUserInfoDTO(String id, String username, String teacherName) { |
||||
} |
@ -0,0 +1,49 @@ |
||||
package net.lensfrex.rd.data.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.dao.type.IntegerListTypeHandler; |
||||
import net.lensfrex.rd.dao.type.StringListTypeHandler; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class CourseDetail { |
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String courseName; |
||||
|
||||
/** |
||||
* 授课教师 |
||||
*/ |
||||
@TableField(typeHandler = StringListTypeHandler.class) |
||||
private List<String> teachers; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private Integer courseHours; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
|
||||
/** |
||||
* 上课专业 |
||||
*/ |
||||
@TableField(typeHandler = StringListTypeHandler.class) |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级 |
||||
*/ |
||||
@TableField(typeHandler = IntegerListTypeHandler.class) |
||||
private List<Integer> targetGrade; |
||||
} |
@ -0,0 +1,89 @@ |
||||
package net.lensfrex.rd.data.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.dao.type.IntegerListTypeHandler; |
||||
import net.lensfrex.rd.dao.type.StringListTypeHandler; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class CourseScheduleDetail { |
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String courseId; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String courseName; |
||||
|
||||
/** |
||||
* 授课教师 |
||||
*/ |
||||
@TableField(typeHandler = StringListTypeHandler.class) |
||||
private List<String> teachers; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private Integer courseHours; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
|
||||
/** |
||||
* 上课专业 |
||||
*/ |
||||
@TableField(typeHandler = StringListTypeHandler.class) |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级 |
||||
*/ |
||||
@TableField(typeHandler = IntegerListTypeHandler.class) |
||||
private List<Integer> targetGrade; |
||||
|
||||
/** |
||||
* 课堂id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String course; |
||||
|
||||
/** |
||||
* 开始周 |
||||
*/ |
||||
private String startWeek; |
||||
|
||||
/** |
||||
* 结束周 |
||||
*/ |
||||
private String endWeek; |
||||
|
||||
/** |
||||
* 节次时间,即第几节课 |
||||
*/ |
||||
private String time; |
||||
|
||||
/** |
||||
* 学年学期,格式如2023-2024 |
||||
*/ |
||||
private String academicTerm; |
||||
|
||||
/** |
||||
* 上课地点 |
||||
*/ |
||||
private String place; |
||||
|
||||
/** |
||||
* 考试成绩占比 |
||||
*/ |
||||
private String ratio; |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.entity; |
||||
|
||||
import lombok.Builder; |
||||
|
||||
@Builder |
||||
public record UsualScoreItem(String name, float score, float ratio) { |
||||
} |
@ -0,0 +1,68 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.google.common.base.Objects; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class Activity implements Serializable { |
||||
/** |
||||
* 选课活动id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 活动id |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 学期,格式如2023-2024-1 |
||||
*/ |
||||
private String term; |
||||
|
||||
/** |
||||
* 开始时间 |
||||
*/ |
||||
private LocalDateTime startTime; |
||||
|
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
private LocalDateTime endTime; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public Activity() { |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (o == null || getClass() != o.getClass()) return false; |
||||
Activity activity = (Activity) o; |
||||
return Objects.equal(id, activity.id); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(id); |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.dao.type.IntegerListTypeHandler; |
||||
import net.lensfrex.rd.dao.type.StringListTypeHandler; |
||||
//import org.apache.ibatis.type.ArrayTypeHandler;
|
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
@TableName(autoResultMap = true) |
||||
public class Course implements Serializable { |
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private Integer courseHours; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
|
||||
/** |
||||
* 上课专业 |
||||
*/ |
||||
@TableField(typeHandler = StringListTypeHandler.class) |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级 |
||||
*/ |
||||
@TableField(typeHandler = IntegerListTypeHandler.class) |
||||
private List<Integer> targetGrade; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
} |
@ -0,0 +1,101 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.google.common.base.Objects; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.dao.type.json.FloatMapTypeHandler; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import java.util.Map; |
||||
|
||||
@Data |
||||
@TableName(value = "class", autoResultMap = true) |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class CourseSchedule implements Serializable { |
||||
/** |
||||
* 课堂id |
||||
*/ |
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String course; |
||||
|
||||
/** |
||||
* 开始周 |
||||
*/ |
||||
private Integer startWeek; |
||||
|
||||
/** |
||||
* 结束周 |
||||
*/ |
||||
private Integer endWeek; |
||||
|
||||
/** |
||||
* 节次时间,即第几节课 |
||||
*/ |
||||
private Integer time; |
||||
|
||||
/** |
||||
* 节次时间,即第几节课 |
||||
*/ |
||||
private Integer weekDay; |
||||
|
||||
/** |
||||
* 学年学期,格式如2023-2024 |
||||
*/ |
||||
private String academicTerm; |
||||
|
||||
/** |
||||
* 上课地点 |
||||
*/ |
||||
private String place; |
||||
|
||||
/** |
||||
* 考试成绩占比 |
||||
*/ |
||||
private Float ratio; |
||||
|
||||
/** |
||||
* 平时分组成描述 |
||||
*/ |
||||
@TableField(typeHandler = FloatMapTypeHandler.class) |
||||
private Map<String, Float> distribution; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public CourseSchedule() { |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (o == null || getClass() != o.getClass()) return false; |
||||
CourseSchedule that = (CourseSchedule) o; |
||||
return Objects.equal(id, that.id); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(id); |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
public class CourseSelection implements Serializable { |
||||
/** |
||||
* 选课记录id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 学生id |
||||
*/ |
||||
private String student; |
||||
|
||||
/** |
||||
* 课堂id |
||||
*/ |
||||
private String schedule; |
||||
|
||||
/** |
||||
* 课堂id |
||||
*/ |
||||
private String activity; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public CourseSelection() { |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
public class ExperimentItem implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* 实验项目id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 项目名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String course; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public ExperimentItem() { |
||||
} |
||||
} |
@ -0,0 +1,17 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* @param id 成绩id |
||||
* @param student 学生id |
||||
* @param experiment 实验项目id |
||||
* @param score 实验分 |
||||
* @param createTime create_time |
||||
* @param editTime edit_time |
||||
* @param deleted delete |
||||
*/ |
||||
public record ExperimentScore(String id, String student, String experiment, Float score, LocalDateTime createTime, |
||||
LocalDateTime editTime, Boolean deleted) implements Serializable { |
||||
} |
@ -0,0 +1,58 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.google.common.base.Objects; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class Major implements Serializable { |
||||
/** |
||||
* 专业id |
||||
*/ |
||||
@TableId(type = IdType.INPUT) |
||||
private String id; |
||||
|
||||
/** |
||||
* 专业名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (o == null || getClass() != o.getClass()) return false; |
||||
Major major = (Major) o; |
||||
return Objects.equal(id, major.id) && Objects.equal(name, major.name); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hashCode(id, name); |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.io.Serial; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class Score implements Serializable { |
||||
private String id; |
||||
|
||||
private String student; |
||||
|
||||
@TableField("class") |
||||
private String schedule; |
||||
|
||||
private Float usualScore; |
||||
|
||||
private Float examScore; |
||||
|
||||
private LocalDateTime createTime; |
||||
|
||||
private LocalDateTime editTime; |
||||
|
||||
private Boolean deleted; |
||||
} |
@ -0,0 +1,64 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class StudentInfo implements Serializable { |
||||
/** |
||||
* 学生id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 学号 |
||||
*/ |
||||
private String studentNumber; |
||||
|
||||
/** |
||||
* 学生姓名 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 专业id |
||||
*/ |
||||
private String major; |
||||
|
||||
/** |
||||
* 年级,使用大x表示,如大二:2 |
||||
*/ |
||||
private Integer grade; |
||||
|
||||
/** |
||||
* 班级 |
||||
*/ |
||||
@TableField("class") |
||||
private String clazz; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
} |
@ -0,0 +1,43 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
public class TeacherClass implements Serializable { |
||||
|
||||
/** |
||||
* 教师id |
||||
*/ |
||||
@TableId(type = IdType.INPUT) |
||||
private String teacher; |
||||
|
||||
/** |
||||
* 课程班级id |
||||
*/ |
||||
@TableField("class") |
||||
private String clazz; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* deleted |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public TeacherClass() { |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@Builder |
||||
@AllArgsConstructor |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class TeacherInfo implements Serializable { |
||||
/** |
||||
* 教师id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 教师姓名 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public TeacherInfo() { |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
package net.lensfrex.rd.data.entity.table; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
public class UserBasic implements Serializable { |
||||
/** |
||||
* 用户uuid |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 用户名,登陆用 |
||||
*/ |
||||
private String username; |
||||
|
||||
/** |
||||
* 密码 |
||||
*/ |
||||
private String password; |
||||
|
||||
/** |
||||
* 用户类型 |
||||
*/ |
||||
private Short type; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private LocalDateTime createTime; |
||||
|
||||
/** |
||||
* edit_time |
||||
*/ |
||||
private LocalDateTime editTime; |
||||
|
||||
/** |
||||
* delete |
||||
*/ |
||||
private Boolean deleted; |
||||
|
||||
public UserBasic() { |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
package net.lensfrex.rd.data.enums; |
||||
|
||||
public enum UserType { |
||||
STUDENT(0, "student"), |
||||
TEACHER(1, "teacher"), |
||||
ADMIN(0, "admin"), |
||||
; |
||||
|
||||
public final int code; |
||||
private final String value; |
||||
|
||||
UserType(int code, String value) { |
||||
this.code = code; |
||||
this.value = value; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String value() { |
||||
return value; |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package net.lensfrex.rd.data.model.request.admin; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Builder; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
@Builder |
||||
public record ActivityInfoDto(String id, String name, String term, |
||||
@JsonFormat(locale = "zh", timezone = "GMT+8") |
||||
LocalDateTime start, |
||||
@JsonFormat(locale = "zh", timezone = "GMT+8") |
||||
LocalDateTime end) { |
||||
} |
@ -0,0 +1,9 @@ |
||||
package net.lensfrex.rd.data.model.request.admin; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Builder; |
||||
|
||||
@Builder |
||||
public record StudentAddRequest(String studentNumber, String studentName, String major) { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.model.request.admin; |
||||
|
||||
import lombok.Builder; |
||||
|
||||
@Builder |
||||
public record TeacherAddRequest(String username, String teacherName, String initialPassword) { |
||||
} |
@ -0,0 +1,5 @@ |
||||
package net.lensfrex.rd.data.model.request.auth; |
||||
|
||||
public record UserLoginRequest(String username, String password) { |
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
package net.lensfrex.rd.data.model.request.course; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class CourseRequest { |
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private Integer courseHours; |
||||
|
||||
/** |
||||
* 上课专业id |
||||
*/ |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级,使用大x表示,如大二:2 |
||||
*/ |
||||
private List<Integer> targetGrade; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
} |
@ -0,0 +1,28 @@ |
||||
package net.lensfrex.rd.data.model.request.schedule; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class ClassScheduleRequest { |
||||
private String name; |
||||
|
||||
private String course; |
||||
|
||||
private String term; |
||||
|
||||
private int section; |
||||
|
||||
private int weekDay; |
||||
|
||||
private int startWeek; |
||||
|
||||
private int endWeek; |
||||
|
||||
private String place; |
||||
|
||||
private int ratio; |
||||
|
||||
private List<String> teachers; |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.model.response; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record PaginationWrapper<T>(int current, int pageSize, int total, T result) { |
||||
} |
@ -0,0 +1,35 @@ |
||||
package net.lensfrex.rd.data.model.response; |
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
/** |
||||
* 通用的响应 |
||||
* |
||||
* @param code 响应码 |
||||
* @param msg 响应信息 |
||||
* @param data 响应数据 |
||||
* @param <T> data的类型 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record Response<T>(int code, String msg, T data) { |
||||
public static <T> Response<T> success(T data) { |
||||
return new Response<>(ResponseCode.SUCCESS.getCode(), "ok", data); |
||||
} |
||||
|
||||
public static <T> Response<T> success() { |
||||
return success(null); |
||||
} |
||||
|
||||
public static <T> Response<T> error(int code, String message) { |
||||
return new Response<>(code, message, null); |
||||
} |
||||
|
||||
public static <T> Response<T> error(ResponseCode code) { |
||||
return error(code.getCode(), code.getMessage()); |
||||
} |
||||
|
||||
public static <T> Response<T> error(ResponseCode code, String message) { |
||||
return error(code.getCode(), message); |
||||
} |
||||
} |
@ -0,0 +1,43 @@ |
||||
/* |
||||
* Class created by lensfrex. |
||||
*/ |
||||
|
||||
package net.lensfrex.rd.data.model.response; |
||||
|
||||
public enum ResponseCode { |
||||
SUCCESS(20000, "成功"), |
||||
REQUEST_TOO_FAST(20001, "技能冷却中..."), |
||||
INVALID_REQUEST(30000, "非法请求"), |
||||
PARAM_WRONG(30001, "参数错误"), |
||||
PERMISSION_DENIED(40000, "权限不足"), |
||||
TOKEN_EXPIRED(40001, "token过期"), |
||||
TOKEN_INVALID(40002, "token无效"), |
||||
SERVER_INTERNAL_ERROR(50000, "服务器内部错误"), |
||||
API_NOT_IMPLEMENT(0, "接口未实现"), |
||||
|
||||
STUDENT_ID_DOES_NOT_EXISTS(60001,"学生学号不存在"), |
||||
PASSWORD_WRONG(60002, "密码错误"), |
||||
IMAGE_FORMAT_WORN(60202, ""), |
||||
NOTICE_WAS_INTERCEPT(60203, "消息被系统拦截发布"), |
||||
|
||||
USER_DOES_NOT_MATCH_PUBLISHER(60301, "请求用户与告示发表者不匹配"), |
||||
|
||||
REQUEST_FILE_DOES_NOT_EXIST(60701, "请求的文件不存在"); |
||||
|
||||
private final int code; |
||||
|
||||
private final String message; |
||||
|
||||
ResponseCode(int code, String message) { |
||||
this.code = code; |
||||
this.message = message; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.model.response.auth; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public record UserLoginStatusResponse(String id, String role, boolean status) { |
||||
} |
@ -0,0 +1,41 @@ |
||||
package net.lensfrex.rd.data.model.response.course; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 待选课程响应 |
||||
*/ |
||||
@Data |
||||
public class CandidateCourseResponse { |
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private String courseHours; |
||||
|
||||
/** |
||||
* 上课专业id |
||||
*/ |
||||
private List<String> targetMajor; |
||||
|
||||
/** |
||||
* 上课年级,使用大x表示,如大二:2 |
||||
*/ |
||||
private List<Integer> targetGrade; |
||||
|
||||
/** |
||||
* 是否春季期课程(false即是秋季期) |
||||
*/ |
||||
private Boolean springTerm; |
||||
} |
@ -0,0 +1,31 @@ |
||||
package net.lensfrex.rd.data.model.response.course; |
||||
|
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 课程信息响应 |
||||
*/ |
||||
@Data |
||||
@Builder |
||||
public class CourseResponse { |
||||
/** |
||||
* 课程id |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 课时 |
||||
*/ |
||||
private int courseHours; |
||||
|
||||
/** |
||||
* 春季期课程 |
||||
*/ |
||||
private String term; |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.data.model.response.score; |
||||
|
||||
import lombok.Builder; |
||||
|
||||
@Builder |
||||
public record StudentScoreSummary(String courseName, int usualScore, int finalScore) { |
||||
} |
@ -0,0 +1,15 @@ |
||||
package net.lensfrex.rd.data.model.response.user; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import net.lensfrex.rd.data.enums.UserType; |
||||
|
||||
@Data |
||||
@Builder |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class UserBasicInfo { |
||||
private String id; |
||||
private String username; |
||||
private UserType userType; |
||||
} |
@ -0,0 +1,7 @@ |
||||
package net.lensfrex.rd.exception; |
||||
|
||||
public class BaseException extends RuntimeException { |
||||
public BaseException(String message) { |
||||
super(message); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue