总结
这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家
全套下载
环境准备
框架架构
登录页面
首页展示
业务模块
数据库后台展示
管理员密码为:admin
学生密码为:123456
教师密码为:123456
部分代码
package com.org.myzhxy.controller;
import com.org.myzhxy.pojo.Admin;
import com.org.myzhxy.pojo.LoginForm;
import com.org.myzhxy.pojo.Student;
import com.org.myzhxy.pojo.Teacher;
import com.org.myzhxy.service.AdminService;
import com.org.myzhxy.service.StudentService;
import com.org.myzhxy.service.TeacherService;
import com.org.myzhxy.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
@Api(tags = "系统控制器")
@RestController
@RequestMapping("/sms/system")
public class SystemController {
@Autowired
private AdminService adminService;
@Autowired
private StudentService studentService;
@Autowired
private TeacherService teacherService;
/*
* 修改密码的处理器
* POST /sms/system/updatePwd/123456/admin
* /sms/system/updatePwd/{oldPwd}/{newPwd}
* 请求参数
oldpwd
newPwd
token 头
响应的数据
Result OK data= null
* */
@ApiOperation("更新用户密码的处理器")
@PostMapping("/updatePwd/{oldPwd}/{newPwd}")
public Result updatePwd(
@ApiParam("token口令") @RequestHeader("token") String token,
@ApiParam("旧密码") @PathVariable("oldPwd") String oldPwd,
@ApiParam("新密码") @PathVariable("newPwd") String newPwd
){
boolean expiration = JwtHelper.isExpiration(token);
if (expiration) {
// token过期
return Result.fail().message("token失效,请重新登录后修改密码");
}
// 获取用户ID和用类型
Long userId = JwtHelper.getUserId(token);
Integer userType = JwtHelper.getUserType(token);
oldPwd= MD5.encrypt(oldPwd);
newPwd= MD5.encrypt(newPwd);
switch (userType) {
case 1:
QueryWrapper<Admin> queryWrapper1=new QueryWrapper<>();
queryWrapper1.eq("id",userId.intValue());
queryWrapper1.eq("password",oldPwd);
Admin admin =adminService.getOne(queryWrapper1);
if (admin != null){
// 修改
admin.setPassword(newPwd);
adminService.saveOrUpdate(admin);
}else{
return Result.fail().message("原密码有误!");
}
break;
case 2:
QueryWrapper<Student> queryWrapper2=new QueryWrapper<>();
queryWrapper2.eq("id",userId.intValue());
queryWrapper2.eq("password",oldPwd);
Student student =studentService.getOne(queryWrapper2);
if (student != null){
// 修改
student.setPassword(newPwd);
studentService.saveOrUpdate(student);
}else{
return Result.fail().message("原密码有误!");
}
break;
case 3:
QueryWrapper<Teacher> queryWrapper3=new QueryWrapper<>();
queryWrapper3.eq("id",userId.intValue());
queryWrapper3.eq("password",oldPwd);
Teacher teacher =teacherService.getOne(queryWrapper3);
if (teacher != null){
// 修改
teacher.setPassword(newPwd);
teacherService.saveOrUpdate(teacher);
}else{
return Result.fail().message("原密码有误!");
}
break;
}
return Result.ok();
}
// POST /sms/system/headerImgUpload
@ApiOperation("文件上传统一入口")
@PostMapping("/headerImgUpload")
public Result headerImgUpload(
@ApiParam("头像文件") @RequestPart("multipartFile") MultipartFile multipartFile
,
HttpServletRequest request
){
String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
String originalFilename = multipartFile.getOriginalFilename();
int i = originalFilename.lastIndexOf(".");
String newFileName =uuid.concat(originalFilename.substring(i));
// 保存文件 将文件发送到第三方/独立的图片服务器上,
String portraitPath="C:/code/myzhxy/target/classes/public/upload/".concat(newFileName);
try {
multipartFile.transferTo(new File(portraitPath));
} catch (IOException e) {
e.printStackTrace();
}
// 响应图片的路径
String path="upload/".concat(newFileName);
return Result.ok(path);
}
@ApiOperation("通过token口令获取当前登录的用户信息的方法")
@GetMapping("/getInfo")
public Result getInfoByToken(
@ApiParam("token口令")@RequestHeader("token") String token){
boolean expiration = JwtHelper.isExpiration(token);
if (expiration) {
return Result.build(null,ResultCodeEnum.TOKEN_ERROR);
}
//从token中解析出 用户id 和用户的类型
Long userId = JwtHelper.getUserId(token);
Integer userType = JwtHelper.getUserType(token);
Map<String,Object> map =new LinkedHashMap<>();
switch (userType){
case 1:
Admin admin =adminService.getAdminById(userId);
map.put("userType",1);
map.put("user",admin);
break;
case 2:
Student student =studentService.getStudentById(userId);
map.put("userType",2);
map.put("user",student);
break;
case 3:
Teacher teacher= teacherService.getByTeacherById(userId);
map.put("userType",3);
map.put("user",teacher);
# 最后
本人也收藏了一份Java面试核心知识点来应付面试,借着这次机会可以送给我的读者朋友们:
**目录:**
![二面蚂蚁金服(交叉面),已拿offer,Java岗定级阿里P6](https://img-blog.csdnimg.cn/img_convert/be8ceda0c09612982c14ca91bd174fb8.webp?x-oss-process=image/format,png)
Java面试核心知识点
**一共有30个专题,足够读者朋友们应付面试啦,也节省朋友们去到处搜刮资料自己整理的时间!**
![二面蚂蚁金服(交叉面),已拿offer,Java岗定级阿里P6](https://img-blog.csdnimg.cn/img_convert/a578811b8854d708f3d814a222da4fbc.webp?x-oss-process=image/format,png)
Java面试核心知识点
> **本文已被[CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)收录**
**[需要这份系统化的资料的朋友,可以点击这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**
map.put("user",teacher);
# 最后
本人也收藏了一份Java面试核心知识点来应付面试,借着这次机会可以送给我的读者朋友们:
**目录:**
[外链图片转存中...(img-rLSWpSxu-1715606486765)]
Java面试核心知识点
**一共有30个专题,足够读者朋友们应付面试啦,也节省朋友们去到处搜刮资料自己整理的时间!**
[外链图片转存中...(img-CnnD9LLH-1715606486766)]
Java面试核心知识点
> **本文已被[CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)收录**
**[需要这份系统化的资料的朋友,可以点击这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**