目录
1. 环境搭建
1.1 前端环境
1.2 后端环境
1.2.1 父项目
1.2.2 domain项目
1.2.3 gateway项目
1.3 数据库环境
1.3.1 用户数据库
1.3.2 班级数据库
1.3.3 门生数据库
1.3.4 课程数据库
1. 环境搭建
1.1 前端环境
- 项目名:nacos-nuxt-student-fore
- 创建项目(整合Element ui、整合axios)
- 修改axios baseURL
- 修改Element UI 整合文件
1.2 后端环境
1.2.1 父项目
1.2.2 domain项目
- 项目名:nacos-nuxt-student-domain
- pom文件
- 拷贝JavaBean
1.2.3 gateway项目
- 项目名:nacos-nuxt-student-gateway
- pom文件
- <dependencies>
- <!--lombok , @Data 等-->
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>1.5.13</version>
- </dependency>
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- <!--jackson , @JsonFormat-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-json</artifactId>
- </dependency>
- <!--mybatis-plus , @TableName @TableId 等 -->
- <dependency>
- <groupId>com.baomidou</groupId>
- <artifactId>mybatis-plus-annotation</artifactId>
- </dependency>
- </dependencies>
复制代码 - yml文件
-
- <dependencies>
- <!-- 网关 -->
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-gateway</artifactId>
- </dependency>
-
- <!-- nacos 服务发现 -->
- <dependency>
- <groupId>com.alibaba.cloud</groupId>
- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
- </dependency>
-
- <!--自定义项目-->
- <dependency>
- <groupId>com.czxy</groupId>
- <artifactId>nacos-nuxt-student-domain</artifactId>
- </dependency>
-
- <!--jwt工具-->
- <dependency>
- <groupId>io.jsonwebtoken</groupId>
- <artifactId>jjwt</artifactId>
- </dependency>
- <!--joda 时间工具类 -->
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- </dependency>
- <!--JavaBean工具类,用于JavaBean数据封装-->
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
-
- </dependencies>
-
复制代码
- 启动类
- #端口号
- server:
- port: 10010
- spring:
- application:
- name: gateway
- servlet:
- multipart:
- max-file-size: 2MB #上传文件的大小
- cloud:
- nacos:
- discovery:
- server-addr: 127.0.0.1:8848 #nacos服务地址
- gateway:
- discovery:
- locator:
- enabled: true #开启服务注册和发现的功能,自动创建router以服务名开头的请求路径转发到对应的服务
- lowerCaseServiceId: true #将请求路径上的服务名配置为小写
-
复制代码 - 拷贝跨域配置类
1.3 数据库环境
1.3.1 用户数据库
- package com.czxy;
-
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-
- /**
- * @author 桐叔
- * @email liangtong@itcast.cn
- * @description
- */
- @SpringBootApplication
- @EnableDiscoveryClient //服务发现
- public class GatewayApplication {
- public static void main(String[] args) {
- SpringApplication.run(GatewayApplication.class, args);
- }
- }
-
复制代码
1.3.2 班级数据库
- # 用户数据库
- CREATE DATABASE cloud_es_user;
- USE cloud_es_user;
-
- CREATE TABLE `tb_user` (
- `u_id` VARCHAR(32) PRIMARY KEY NOT NULL COMMENT '用户编号',
- `user_name` VARCHAR(50) UNIQUE DEFAULT NULL COMMENT '用户名',
- `password` VARCHAR(32) DEFAULT NULL COMMENT '密码',
- `gender` BIT(1) DEFAULT NULL COMMENT '性别,1表示男,0表示女',
- `image` VARCHAR(50) UNIQUE DEFAULT NULL COMMENT '头像图片'
- );
-
- INSERT INTO `tb_user`(`u_id`,`user_name`,`password`,`gender`,`image`) VALUES ('u001','jack','1234',1,'1.jpg');
- INSERT INTO `tb_user`(`u_id`,`user_name`,`password`,`gender`,`image`) VALUES ('u002','rose','1234',0,'2.jpg');
- INSERT INTO `tb_user`(`u_id`,`user_name`,`password`,`gender`,`image`) VALUES ('u003','tom','1234',1,'3.jpg');
-
复制代码
1.3.3 门生数据库
- # 班级数据库
- CREATE DATABASE cloud_es_classes;
- USE cloud_es_classes;
-
- CREATE TABLE `tb_teacher` (
- `tid` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
- `tname` VARCHAR(50) DEFAULT NULL COMMENT '老师姓名',
- `type` INT(11) DEFAULT NULL COMMENT '老师类型:1.授课老师、2.助理老师、3.辅导员老师'
- );
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (1,'梁桐老师',1);
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (2,'马坤老师',2);
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (3,'仲燕老师',3);
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (4,'袁新奇老师',1);
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (5,'任林达老师',2);
- INSERT INTO `tb_teacher`(`tid`,`tname`,`type`) VALUES (6,'王珊珊老师',3);
-
-
- CREATE TABLE `tb_class` (
- `cid` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
- `cname` VARCHAR(50) DEFAULT NULL COMMENT '班级名称',
- `teacher1_id` INT(11) DEFAULT NULL COMMENT '授课老师',
- `teacher2_id` INT(11) DEFAULT NULL COMMENT '助理老师',
- `teacher3_id` INT(11) DEFAULT NULL COMMENT '辅导员老师'
- );
-
- INSERT INTO `tb_class`(`cid`,`cname`,`teacher1_id`,`teacher2_id`,`teacher3_id`) VALUES (1,'Java56',1,2,3);
- INSERT INTO `tb_class`(`cid`,`cname`,`teacher1_id`,`teacher2_id`,`teacher3_id`) VALUES (2,'Java78',1,2,3);
- INSERT INTO `tb_class`(`cid`,`cname`,`teacher1_id`,`teacher2_id`,`teacher3_id`) VALUES (3,'Java12',4,5,6);
- INSERT INTO `tb_class`(`cid`,`cname`,`teacher1_id`,`teacher2_id`,`teacher3_id`) VALUES (4,'Java34',4,5,6);
-
复制代码
1.3.4 课程数据库
- #学生数据库
- CREATE DATABASE cloud_es_student;
- USE cloud_es_student;
-
- CREATE TABLE tb_city(
- c_id VARCHAR(32) PRIMARY KEY COMMENT '城市ID',
- city_name VARCHAR(20) COMMENT '城市名称' ,
- parent_id VARCHAR(32) COMMENT '父ID'
- );
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('320000','江苏省','0');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140000','山西省','0');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('130000','河北省','0');
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('320100','南京市','320000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('320102','玄武区','320100');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('320103','白下区','320100');
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('321300','宿迁市','320000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('321322','沭阳县','321300');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('321323','泗阳县','321300');
-
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140100','太原市','140000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140106','迎泽区','140100');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140108','尖草坪区','140100');
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140800','运城市','140000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140823','闻喜县','140800');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('140828','夏 县','140800');
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('130100','石家庄市','130000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('130127','高邑县','130100');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('130185','鹿泉市','130100');
-
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('131000','廊坊市','130000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('131003','广阳区','131000');
- INSERT INTO tb_city(c_id,city_name,parent_id) VALUES('131022','固安县','131000');
-
-
- CREATE TABLE `tb_student` (
- `s_id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '学生ID',
- `sname` VARCHAR(50) DEFAULT NULL COMMENT '姓名',
- `age` INT(11) DEFAULT NULL COMMENT '年龄',
- `birthday` DATETIME DEFAULT NULL COMMENT '生日',
- `gender` CHAR(1) DEFAULT NULL COMMENT '性别',
- `c_id` INT DEFAULT NULL,
- `city_ids` VARCHAR(32) DEFAULT NULL COMMENT '城市:320000,321300,321322'
- );
-
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (1,'赵三33',21,'2001-01-17 00:00:00','1',1,'320000,321300,321322');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (2,'钱四444',1900,'2001-05-16 00:00:00','1',2,'320000,321300,321322');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (3,'孙五56',189,'2022-03-15 00:00:00','0',1,'320000,321300,321322');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (4,'张三',20,'2020-12-21 00:00:00','0',2,'320000,321300,321322');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (5,'xxx',18,'2020-12-21 00:00:00','0',2,'140000,140800,140823');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (6,'123',18,'2020-11-01 00:00:00','0',3,'130000,130100,130127');
- INSERT INTO `tb_student`(`s_id`,`sname`,`age`,`birthday`,`gender`,`c_id`,`city_ids`) VALUES (7,'xx',18,'2020-11-02 00:00:00','0',1,'130000,131000,131003');
-
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |