springboot+vue前后端分离实现宿舍管理系统,前端开发大佬的百度美团快手等大厂Offer收割之旅

文章详细描述了三个SpringMVC控制器(BackLateController,BuildingController,DepartApplicationController)中的CRUD操作,涉及@Autowired注解、权限控制(@RequirePermission)、分页查询(PageHelper)以及使用RedisUtil进行数据缓存。展示了如何处理HTTP请求和权限验证。
摘要由CSDN通过智能技术生成

public class BackLateController {

@Autowired

private BackLateService backLateService;

@Autowired

private RedisUtil redisUtil;

@PostMapping(“/saveOrUpdate”)

@RequirePermission(permissions = {“back:save”,“back:update”})

@Log

public Result<?> saveOrUpdate(@RequestBody @Validated BackLate backLate) {

backLateService.saveOrUpdate(backLate);

return Result.ok(“操作成功”);

}

@GetMapping(“delete/{id}”)

@RequirePermission(permissions = {“back:delete”})

@Log

public Result<?> delete(@PathVariable Long id) {

backLateService.delete(id);

return Result.ok(“删除成功”);

}

@PostMapping(“/list”)

@RequirePermission(permissions = {“back:list”})

public Result<PageInfo> list(@RequestBody ListQuery listQuery,

@RequestHeader(Constant.HEADER_TOKEN) String token) {

SystemUser systemUser = redisUtil.exchange(token).get();

PageInfo pageInfo = backLateService.list(listQuery, systemUser.getBuildingId());

return Result.<PageInfo>ok().add(pageInfo);

}

@GetMapping(“/query/{id}”)

@RequirePermission(permissions = {“back:query”})

public Result query(@PathVariable Long id) {

BackLate backLate = backLateService.query(id);

return Result.ok().add(backLate);

}

}

package com.hzvtc.myproject.controller;

import com.github.pagehelper.PageHelper;

import com.github.pagehelper.PageInfo;

import com.hzvtc.myproject.annotation.Log;

import com.hzvtc.myproject.annotation.RequirePermission;

import com.hzvtc.myproject.dto.ListQuery;

import com.hzvtc.myproject.entity.Building;

import com.hzvtc.myproject.entity.Room;

import com.hzvtc.myproject.exception.HttpException;

import com.hzvtc.myproject.service.BuildingService;

import com.hzvtc.myproject.service.RoomService;

import com.hzvtc.myproject.utils.HttpCode;

import com.hzvtc.myproject.vo.Result;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.validation.annotation.Validated;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**

  • @author znz

  • @date 2021-12-19

*/

@RestController

@RequestMapping(“/building”)

public class BuildingController {

@Autowired

private BuildingService buildingService;

@Autowired

private RoomService roomService;

@GetMapping(“/listAll”)

@RequirePermission(permissions = {“manage:building:list”})

public Result<List> listAll() {

List list = buildingService.listAll();

return Result.<List>ok().add(list);

}

@GetMapping(“/list”)

@RequirePermission(permissions = {“manage:building:list”})

public Result<List> list() {

List list = buildingService.list();

return Result.<List>ok().add(list);

}

@GetMapping(“delete”)

@RequirePermission(permissions = {“manage:building:delete”})

@Log(“删除building”)

public Result<?> delete(@RequestParam(“id”) Long id) {

List list = roomService.listByBuildingId(id);

if (list.size() > 0) {

throw new HttpException(HttpCode.FAILED, “该节点下或子节点还有寝室,无法删除”);

}

buildingService.delete(id);

return Result.ok(“删除成功”);

}

@GetMapping(“/query”)

@RequirePermission(permissions = {“manage:building:query”})

public Result query(@RequestParam(“id”) Long id) {

Building building = buildingService.query(id).orElseThrow(() -> new HttpException(HttpCode.FAILED, “该数据不存在”));

return Result.ok().add(building);

}

@PostMapping(“/saveOrUpdate”)

@RequirePermission(permissions = {“manage:building:save”,“manage:building:update”})

@Log

public Result<?> saveOrUpdate(@RequestBody @Validated Building building) {

if (building.getId() == null) {

buildingService.save(building);

} else {

if (building.getId().equals(building.getParentId())) {

throw new HttpException(HttpCode.FAILED, “父节点不能为自己”);

}

buildingService.update(building);

}

return Result.ok(“操作成功”);

}

}

package com.hzvtc.myproject.controller;

import com.github.pagehelper.PageHelper;

import com.github.pagehelper.PageInfo;

import com.hzvtc.myproject.config.Constant;

import com.hzvtc.myproject.dto.ListQuery;

import com.hzvtc.myproject.dto.Message;

import com.hzvtc.myproject.entity.DepartApplication;

import com.hzvtc.myproject.entity.DepartApplicationUser;

import com.hzvtc.myproject.entity.SystemUser;

import com.hzvtc.myproject.exception.HttpException;

import com.hzvtc.myproject.service.DepartApplicationService;

import com.hzvtc.myproject.service.StudentService;

import com.hzvtc.myproject.service.SystemUserService;

import com.hzvtc.myproject.socket.WebSocket;

import com.hzvtc.myproject.utils.HttpCode;

import com.hzvtc.myproject.utils.RedisUtil;

import com.hzvtc.myproject.vo.Result;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**

  • @author znz

  • @date 2021-12-09

*/

@RestController

@RequestMapping(“/depart”)

public class DepartApplicationController {

@Autowired

private DepartApplicationService departApplicationService;

@Autowired

private StudentService studentService;

@Autowired

private RedisUtil redisUtil;

@Autowired

private SystemUserService systemUserService;

@PostMapping(“/listMy”)

public Result<PageInfo> listMyApplication(@RequestBody ListQuery listQuery,

@RequestHeader(Constant.HEADER_TOKEN) String token) {

Long id = redisUtil.get(token);

PageHelper.startPage(listQuery.getPage(), listQuery.getRows());

List list = departApplicationService.listMyApplication(id);

PageInfo pageInfo = new PageInfo<>(list);

return Result.<PageInfo>ok().add(pageInfo);

}

@PostMapping(“/listMyFlow”)

public Result<PageInfo> listMyFlow(@RequestBody ListQuery listQuery,

@RequestHeader(Constant.HEADER_TOKEN) String token) {

Long id = redisUtil.get(token);

PageHelper.startPage(listQuery.getPage(), listQuery.getRows());

List list = departApplicationService.listMyFlow(id);

PageInfo pageInfo = new PageInfo<>(list);

return Result.<PageInfo>ok().add(pageInfo);

}

@GetMapping(“/listFlow/{id}”)

public Result<List> listApplicationFlow(@PathVariable(“id”) Long id) {

List list = departApplicationService.listApplicationFlow(id);

return Result.<List>ok().add(list);

}

@PostMapping(“/update”)

public Result<?> update(@RequestBody DepartApplicationUser departApplicationUser,

@RequestHeader(Constant.HEADER_TOKEN) String token) {

String msg = “成功,”;

SystemUser user = redisUtil.exchange(token).get();

DepartApplicationUser applicationUser =

departApplicationService

.getApplicationUser(departApplicationUser.getId());

if (!user.getId().equals(applicationUser.getOperateUserId())) {

throw new HttpException(HttpCode.FAILED, “无法审核”);

}

if (applicationUser.getIsAgree() != null) {

throw new HttpException(HttpCode.FAILED, “已审核过,无法修改”);

}

departApplicationService.update(departApplicationUser);

DepartApplication application =

departApplicationService

.getByDepartApplicationUserId(departApplicationUser.getId());

if (departApplicationUser.getIsAgree()) {

if (user.getLeaderId() == null) {

studentService.delete(application.getStudentId());

msg += “该学生已成功退宿”;

} else {

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

img
img

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V:vip1024c 备注前端获取(资料价值较高,非无偿)
img

最后

好了,这就是整理的前端从入门到放弃的学习笔记,还有很多没有整理到,我也算是边学边去整理,后续还会慢慢完善,这些相信够你学一阵子了。

做程序员,做前端工程师,真的是一个学习就会有回报的职业,不看出身高低,不看学历强弱,只要你的技术达到应有的水准,就能够得到对应的回报。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

学习从来没有一蹴而就,都是持之以恒的,正所谓活到老学到老,真正懂得学习的人,才不会被这个时代的洪流所淘汰。

img-3xL5EaIO-1711581774242)]

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V:vip1024c 备注前端获取(资料价值较高,非无偿)
[外链图片转存中…(img-YkiATFUy-1711581774243)]

最后

好了,这就是整理的前端从入门到放弃的学习笔记,还有很多没有整理到,我也算是边学边去整理,后续还会慢慢完善,这些相信够你学一阵子了。

做程序员,做前端工程师,真的是一个学习就会有回报的职业,不看出身高低,不看学历强弱,只要你的技术达到应有的水准,就能够得到对应的回报。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

学习从来没有一蹴而就,都是持之以恒的,正所谓活到老学到老,真正懂得学习的人,才不会被这个时代的洪流所淘汰。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值