当前位置:   article > 正文

基于SpringBoot+Vue的高校学生宿舍管理系统(可做毕设课设)_基于springboot的宿舍管理系统

基于springboot的宿舍管理系统

1、系统技术栈:

  1. 后端:SpringBoot
  2. 前端:vue+element等
  3. 开发工具:IDEA
  4. 数据库:MySQL
  5. JDK版本:jdk1.8
  6. 本系统有三种角色,分别为学生、管理员、宿舍管理员

2、系统登录页面:

3、学生登录页面:

3.1我的宿舍

3.2申请调宿

3.3报修申请

4、管理员页面

4.1宿舍管理

4.2报修管理

4.3申请管理

4.4访客管理

5、系统管理员

6、主要代码截图

  1. package com.example.springboot.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.example.springboot.entity.Repair;
  6. import com.example.springboot.mapper.RepairMapper;
  7. import com.example.springboot.service.RepairService;
  8. import org.springframework.stereotype.Service;
  9. import javax.annotation.Resource;
  10. @Service
  11. public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> implements RepairService {
  12. /**
  13. * 注入DAO层对象
  14. */
  15. @Resource
  16. private RepairMapper repairMapper;
  17. /**
  18. * 添加订单
  19. */
  20. @Override
  21. public int addNewOrder(Repair repair) {
  22. int insert = repairMapper.insert(repair);
  23. return insert;
  24. }
  25. /**
  26. * 查找订单
  27. */
  28. @Override
  29. public Page find(Integer pageNum, Integer pageSize, String search) {
  30. Page page = new Page<>(pageNum, pageSize);
  31. QueryWrapper<Repair> qw = new QueryWrapper<>();
  32. qw.like("title", search);
  33. Page orderPage = repairMapper.selectPage(page, qw);
  34. return orderPage;
  35. }
  36. @Override
  37. public Page individualFind(Integer pageNum, Integer pageSize, String search, String name) {
  38. Page page = new Page<>(pageNum, pageSize);
  39. QueryWrapper<Repair> qw = new QueryWrapper<>();
  40. qw.like("title", search);
  41. qw.eq("repairer", name);
  42. Page orderPage = repairMapper.selectPage(page, qw);
  43. return orderPage;
  44. }
  45. /**
  46. * 更新订单
  47. */
  48. @Override
  49. public int updateNewOrder(Repair repair) {
  50. int i = repairMapper.updateById(repair);
  51. return i;
  52. }
  53. /**
  54. * 删除订单
  55. */
  56. @Override
  57. public int deleteOrder(Integer id) {
  58. int i = repairMapper.deleteById(id);
  59. return i;
  60. }
  61. /**
  62. * 首页顶部:报修统计
  63. */
  64. @Override
  65. public int showOrderNum() {
  66. QueryWrapper<Repair> qw = new QueryWrapper<>();
  67. int orderCount = Math.toIntExact(repairMapper.selectCount(qw));
  68. return orderCount;
  69. }
  70. }
  1. package com.example.springboot.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.example.springboot.common.JudgeBedName;
  7. import com.example.springboot.entity.AdjustRoom;
  8. import com.example.springboot.entity.DormRoom;
  9. import com.example.springboot.mapper.DormRoomMapper;
  10. import com.example.springboot.service.DormRoomService;
  11. import org.springframework.stereotype.Service;
  12. import javax.annotation.Resource;
  13. import static com.example.springboot.common.CalPeopleNum.calNum;
  14. @Service
  15. public class DormRoomImpl extends ServiceImpl<DormRoomMapper, DormRoom> implements DormRoomService {
  16. @Resource
  17. private DormRoomMapper dormRoomMapper;
  18. /**
  19. * 首页顶部:空宿舍统计
  20. */
  21. @Override
  22. public int notFullRoom() {
  23. QueryWrapper<DormRoom> qw = new QueryWrapper<>();
  24. qw.lt("current_capacity", 4);
  25. int notFullRoomNum = Math.toIntExact(dormRoomMapper.selectCount(qw));
  26. return notFullRoomNum;
  27. }
  28. /**
  29. * 添加房间
  30. */
  31. @Override
  32. public int addNewRoom(DormRoom dormRoom) {
  33. int insert = dormRoomMapper.insert(dormRoom);
  34. return insert;
  35. }
  36. /**
  37. * 查找房间
  38. */
  39. @Override
  40. public Page find(Integer pageNum, Integer pageSize, String search) {
  41. Page page = new Page<>(pageNum, pageSize);
  42. QueryWrapper<DormRoom> qw = new QueryWrapper<>();
  43. qw.like("Dormroom_id", search);
  44. Page roomPage = dormRoomMapper.selectPage(page, qw);
  45. return roomPage;
  46. }
  47. /**
  48. * 更新房间
  49. */
  50. @Override
  51. public int updateNewRoom(DormRoom dormRoom) {
  52. int i = dormRoomMapper.updateById(dormRoom);
  53. return i;
  54. }
  55. /**
  56. * 删除房间
  57. */
  58. @Override
  59. public int deleteRoom(Integer dormRoomId) {
  60. int i = dormRoomMapper.deleteById(dormRoomId);
  61. return i;
  62. }
  63. /**
  64. * 删除床位上的学生信息
  65. */
  66. @Override
  67. public int deleteBedInfo(String bedName, Integer dormRoomId, int calCurrentNum) {
  68. UpdateWrapper updateWrapper = new UpdateWrapper();
  69. updateWrapper.eq("dormroom_id", dormRoomId);
  70. updateWrapper.set(bedName, null);
  71. updateWrapper.set("current_capacity", calCurrentNum - 1);
  72. int update = dormRoomMapper.update(null, updateWrapper);
  73. return update;
  74. }
  75. /**
  76. * 床位信息,查询该学生是否已由床位
  77. */
  78. @Override
  79. public DormRoom judgeHadBed(String username) {
  80. QueryWrapper qw = new QueryWrapper();
  81. qw.eq("first_bed", username);
  82. qw.or();
  83. qw.eq("second_bed", username);
  84. qw.or();
  85. qw.eq("third_bed", username);
  86. qw.or();
  87. qw.eq("fourth_bed", username);
  88. DormRoom dormRoom = dormRoomMapper.selectOne(qw);
  89. return dormRoom;
  90. }
  91. /**
  92. * 主页 住宿人数
  93. */
  94. @Override
  95. public Long selectHaveRoomStuNum() {
  96. QueryWrapper<DormRoom> qw1 = new QueryWrapper<>();
  97. qw1.isNotNull("first_bed");
  98. Long first_bed = dormRoomMapper.selectCount(qw1);
  99. QueryWrapper<DormRoom> qw2 = new QueryWrapper<>();
  100. qw2.isNotNull("second_bed");
  101. Long second_bed = dormRoomMapper.selectCount(qw2);
  102. QueryWrapper<DormRoom> qw3 = new QueryWrapper<>();
  103. qw3.isNotNull("third_bed");
  104. Long third_bed = dormRoomMapper.selectCount(qw3);
  105. QueryWrapper<DormRoom> qw4 = new QueryWrapper<>();
  106. qw4.isNotNull("fourth_bed");
  107. Long fourth_bed = dormRoomMapper.selectCount(qw4);
  108. Long count = first_bed + second_bed + third_bed + fourth_bed;
  109. return count;
  110. }
  111. /**
  112. * 获取每栋宿舍学生总人数
  113. */
  114. @Override
  115. public Long getEachBuildingStuNum(int dormBuildId) {
  116. QueryWrapper<DormRoom> qw1 = new QueryWrapper<>();
  117. qw1.eq("dormbuild_id", dormBuildId);
  118. qw1.isNotNull("first_bed");
  119. Long first_bed = dormRoomMapper.selectCount(qw1);
  120. QueryWrapper<DormRoom> qw2 = new QueryWrapper<>();
  121. qw2.eq("dormbuild_id", dormBuildId);
  122. qw2.isNotNull("second_bed");
  123. Long second_bed = dormRoomMapper.selectCount(qw2);
  124. QueryWrapper<DormRoom> qw3 = new QueryWrapper<>();
  125. qw3.eq("dormbuild_id", dormBuildId);
  126. qw3.isNotNull("third_bed");
  127. Long third_bed = dormRoomMapper.selectCount(qw3);
  128. QueryWrapper<DormRoom> qw4 = new QueryWrapper<>();
  129. qw4.eq("dormbuild_id", dormBuildId);
  130. qw4.isNotNull("fourth_bed");
  131. Long fourth_bed = dormRoomMapper.selectCount(qw4);
  132. Long count = first_bed + second_bed + third_bed + fourth_bed;
  133. return count;
  134. }
  135. /**
  136. * 根据调宿申请表对房间表内的学生床位进行调整
  137. */
  138. @Override
  139. public int adjustRoomUpdate(AdjustRoom adjustRoom) {
  140. //调宿人
  141. String username = adjustRoom.getUsername();
  142. //当前房间号
  143. int currentRoomId = adjustRoom.getCurrentRoomId();
  144. //当前床位名称
  145. String currentBedName = JudgeBedName.getBedName(adjustRoom.getCurrentBedId());
  146. //目标房间号
  147. int towardsRoomId = adjustRoom.getTowardsRoomId();
  148. //目标目标房间号
  149. String towardsBedName = JudgeBedName.getBedName(adjustRoom.getTowardsBedId());
  150. QueryWrapper qw = new QueryWrapper();
  151. qw.eq("dormroom_id", currentRoomId);
  152. qw.isNotNull(currentBedName);
  153. DormRoom dormRoom1 = dormRoomMapper.selectOne(qw);
  154. if (dormRoom1 == null) {
  155. return -2;
  156. }
  157. int currentCapacity1 = calNum(dormRoom1);
  158. UpdateWrapper uw1 = new UpdateWrapper();
  159. uw1.eq("dormroom_id", currentRoomId);
  160. uw1.set(currentBedName, null);
  161. uw1.set("current_capacity", currentCapacity1 - 1);
  162. int result1 = dormRoomMapper.update(null, uw1);
  163. DormRoom dormRoom2 = dormRoomMapper.selectById(towardsRoomId);
  164. int currentCapacity2 = calNum(dormRoom2);
  165. if (result1 == 1) {
  166. UpdateWrapper uw2 = new UpdateWrapper();
  167. uw2.eq("dormroom_id", towardsRoomId);
  168. uw2.set(towardsBedName, username);
  169. uw2.set("current_capacity", currentCapacity2 + 1);
  170. int result2 = dormRoomMapper.update(null, uw2);
  171. return result2;
  172. }
  173. return -1;
  174. }
  175. /**
  176. * 检查该房间是否满了
  177. */
  178. @Override
  179. public DormRoom checkRoomState(Integer dormRoomId) {
  180. QueryWrapper qw = new QueryWrapper();
  181. qw.eq("dormroom_id", dormRoomId);
  182. qw.lt("current_capacity", 4);
  183. DormRoom dormRoom = dormRoomMapper.selectOne(qw);
  184. return dormRoom;
  185. }
  186. /**
  187. * 检查该房间是否存在
  188. */
  189. @Override
  190. public DormRoom checkRoomExist(Integer dormRoomId) {
  191. DormRoom dormRoom = dormRoomMapper.selectById(dormRoomId);
  192. return dormRoom;
  193. }
  194. /**
  195. * 检查床位是否有人
  196. */
  197. @Override
  198. public DormRoom checkBedState(Integer dormRoomId, int bedNum) {
  199. QueryWrapper qw = new QueryWrapper();
  200. qw.eq("dormroom_id", dormRoomId);
  201. qw.isNull(JudgeBedName.getBedName(bedNum));
  202. DormRoom dormRoom = dormRoomMapper.selectOne(qw);
  203. return dormRoom;
  204. }
  205. }

想要就私信我吧!!!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/441332
推荐阅读
相关标签
  

闽ICP备14008679号