Merge branch 'main' of https://bdgit.educoder.net/p93hkfmuj/spring
commit
d03da57f92
@ -0,0 +1,122 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Absence;
|
||||
import com.yanzhen.entity.Dormitory;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.AbsenceService;
|
||||
import com.yanzhen.service.DormitoryService;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
//导入list和Map集合
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
//缺勤管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/absence")
|
||||
public class AbsenceController {
|
||||
|
||||
//注入实例
|
||||
//注入缺席的服务类
|
||||
@Autowired
|
||||
private AbsenceService absenceService;
|
||||
//注入学生的服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//注入宿舍的服务类
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Absence absence){
|
||||
//在缺席的服务类中引用create方法啦创建新的实例
|
||||
int flag = absenceService.create(absence);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//根据学生id进行删除缺勤信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在缺席的服务类中引用delete方法删除实例
|
||||
int flag = absenceService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//更新缺勤信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Absence absence){
|
||||
//在缺席的服务类中引用updateSelective方法更新信息
|
||||
int flag = absenceService.updateSelective(absence);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//根据id删除缺席信息
|
||||
@GetMapping("detail")
|
||||
public Absence detail(Integer id){
|
||||
//返回结果
|
||||
return absenceService.detail(id);
|
||||
}
|
||||
|
||||
// 根据name查询学生ID--并分页的形式展示出
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Absence absence){
|
||||
//创建分页对象
|
||||
PageInfo<Absence> pageInfo = new PageInfo<Absence>();
|
||||
//判断absence的页码是否为空
|
||||
if(absence.getName() != null){
|
||||
//不为空则调取缺席的名字赋给detailId
|
||||
Student detailId = studentService.detailByName(absence.getName());
|
||||
//如果detailId不为空再获取缺席的id
|
||||
if(detailId != null){
|
||||
absence.setStudentId(detailId.getId());
|
||||
}else{
|
||||
//若为空修改值都为null
|
||||
pageInfo.setList(null);
|
||||
//设置大小为0
|
||||
pageInfo.setSize(0);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
||||
//给pageInfo赋值
|
||||
pageInfo = absenceService.query(absence);
|
||||
// 遍历查询结果列表
|
||||
pageInfo.getList().forEach(entity->{
|
||||
//创建对象
|
||||
Student detail = studentService.detail(entity.getStudentId());
|
||||
// 修改学生信息
|
||||
entity.setStudent(detail);
|
||||
Dormitory dormitory = dormitoryService.detail(entity.getDormitoryId());
|
||||
entity.setDormitory(dormitory);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Bed;
|
||||
import com.yanzhen.service.BedService;
|
||||
import com.yanzhen.service.DormitoryStudentService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
//BedController控制类
|
||||
@RestController
|
||||
@RequestMapping("/bed")
|
||||
public class BedController {
|
||||
|
||||
//注入实例--处理与学生宿舍相关的业务逻辑
|
||||
//注入床位的实例
|
||||
@Autowired
|
||||
private BedService bedService;
|
||||
//注入学生宿舍的实例
|
||||
@Autowired
|
||||
private DormitoryStudentService dormitoryStudentService;
|
||||
|
||||
//创建床位对象
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Bed bed){
|
||||
//调用床位的服务层create方法删除床位
|
||||
int flag = bedService.create(bed);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//根据床位id删除床位
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//调用床位的服务层delete方法删除床位
|
||||
int flag = bedService.delete(ids);
|
||||
//判断删除是否成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
// 更新床位记录
|
||||
@PostMapping("update")
|
||||
// 从请求体中获取更新后的Bed对象
|
||||
public Result update(@RequestBody Bed bed){
|
||||
//调用床位的服务层update方法更新床位
|
||||
int flag = bedService.update(bed);
|
||||
//判断更新是否成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历查询--为每个床位设置对应的学生信息
|
||||
@GetMapping("detail")
|
||||
// 调用bedService的detail方法获取床位详情并返回
|
||||
public Bed detail(Integer id){
|
||||
return bedService.detail(id);
|
||||
}
|
||||
//分页查询
|
||||
@PostMapping("query")
|
||||
// 从请求体中获取查询条件Bed对象--分页显示
|
||||
public Map<String,Object> query(@RequestBody Bed bed){
|
||||
//创建分页对象
|
||||
PageInfo<Bed> pageInfo = bedService.query(bed);
|
||||
//遍历
|
||||
pageInfo.getList().forEach(entity->{
|
||||
entity.setStudent(dormitoryStudentService.queryStudentByBedId(entity.getId()));
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Building;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.service.BuildingService;
|
||||
import com.yanzhen.service.UserService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
//BuildingController控制类
|
||||
@RestController
|
||||
@RequestMapping("/building")
|
||||
public class BuildingController {
|
||||
|
||||
//注入实例
|
||||
//注入BuildingService实例
|
||||
@Autowired
|
||||
private BuildingService buildingService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//创建楼宇对象
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Building building){
|
||||
//调用服务类create方法
|
||||
int flag = buildingService.create(building);
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
// 删除楼宇
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//调用服务类delete方法
|
||||
int flag = buildingService.delete(ids);
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
// 更新楼宇信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Building building){
|
||||
//调用服务类update方法
|
||||
int flag = buildingService.update(building);
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//返回失败信息
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//删除信息
|
||||
@GetMapping("detail")
|
||||
//根据id删除信息
|
||||
public Building detail(Integer id){
|
||||
//返回信息
|
||||
return buildingService.detail(id);
|
||||
}
|
||||
|
||||
// 调用服务层--获取用户详情
|
||||
@PostMapping("query")
|
||||
//查询用户详细信息并且分页显示
|
||||
public Map<String,Object> query(@RequestBody Building building, HttpServletRequest request){
|
||||
// 从请求中获取用户信息
|
||||
User param = (User)request.getAttribute("user");
|
||||
//创建对象
|
||||
User loginUser = userService.detail(param.getId());
|
||||
//判断用户是否是用户
|
||||
if(loginUser.getType() == 1){
|
||||
//设置当前用户id
|
||||
building.setUserId(loginUser.getId());
|
||||
}
|
||||
//创建分页对象
|
||||
PageInfo<Building> pageInfo = buildingService.query(building);
|
||||
// 遍历查询结果中的每个楼宇
|
||||
pageInfo.getList().forEach(entity->{
|
||||
//在服务器中获取用户id
|
||||
User user = userService.detail(entity.getUserId());
|
||||
// 将用户信息应用到楼宇对象中
|
||||
entity.setUser(user);
|
||||
});
|
||||
//返回成功标识
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.DormitorySet;
|
||||
import com.yanzhen.service.DormitorySetService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//DormitorySet的控制器
|
||||
@RestController
|
||||
@RequestMapping("/dormitorySet")
|
||||
public class DormitorySetController {
|
||||
//注入实例
|
||||
// 注入 DormitorySet服务类
|
||||
@Autowired
|
||||
private DormitorySetService dormitorySetService;
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody DormitorySet dormitorySet){
|
||||
//在DormitorySet的服务类中引用create方法
|
||||
int flag = dormitorySetService.create(dormitorySet);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//根据ID删除DormitorySet信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在DormitorySet的服务类引用delete方法
|
||||
int flag = dormitorySetService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新DormitorySet信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody DormitorySet dormitorySet){
|
||||
//在DormitorySet服务类中引用update方法
|
||||
int flag = dormitorySetService.update(dormitorySet);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取详细信息
|
||||
@GetMapping("detail")
|
||||
public DormitorySet detail(Integer id){
|
||||
//返回结果
|
||||
return dormitorySetService.detail(id);
|
||||
}
|
||||
//查询DormitorySet信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody DormitorySet dormitorySet){
|
||||
//创建分页对象
|
||||
PageInfo<DormitorySet> pageInfo = dormitorySetService.query(dormitorySet);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.DormitoryStudent;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.DormitoryService;
|
||||
import com.yanzhen.service.DormitoryStudentService;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//学生宿舍管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/dormitoryStudent")
|
||||
public class DormitoryStudentController {
|
||||
//注入实例
|
||||
// 注入DormitoryStudent服务类
|
||||
@Autowired
|
||||
private DormitoryStudentService dormitoryStudentService;
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//注入宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody DormitoryStudent dormitoryStudent){
|
||||
//在学生宿舍服务类引用create方法
|
||||
int flag = dormitoryStudentService.create(dormitoryStudent);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//根据ID删除学生宿舍记录
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在学生宿舍服务类引用delete方法
|
||||
int flag = dormitoryStudentService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新学生宿舍记录
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody DormitoryStudent dormitoryStudent){
|
||||
//在学生宿舍服务类引用update方法
|
||||
int flag = dormitoryStudentService.update(dormitoryStudent);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取学生宿舍记录详细信息
|
||||
@GetMapping("detail")
|
||||
public DormitoryStudent detail(Integer id){
|
||||
//返回结果
|
||||
return dormitoryStudentService.detail(id);
|
||||
}
|
||||
//查询学生宿舍记录
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody DormitoryStudent dormitoryStudent){
|
||||
//创建分页对象
|
||||
PageInfo<DormitoryStudent> pageInfo = dormitoryStudentService.query(dormitoryStudent);
|
||||
//遍历查询结果
|
||||
pageInfo.getList().forEach(entity->{
|
||||
//根据学生宿舍记录获取对应学生详细信息
|
||||
Student detail = studentService.detail(entity.getStudentId());
|
||||
entity.setStudent(detail);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Grade;
|
||||
import com.yanzhen.service.GradeService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//成绩管理grade的控制器
|
||||
@RestController
|
||||
@RequestMapping("/grade")
|
||||
public class GradeController {
|
||||
//注入实例
|
||||
//注入成绩管理服务类
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Grade grade){
|
||||
//在成绩管理服务类中引用create方法
|
||||
int flag = gradeService.create(grade);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//删除成绩记录
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在成绩管理服务类中引用delete方法
|
||||
int flag = gradeService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//更新成绩记录
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Grade grade){
|
||||
//在成绩管理服务类中引用update方法
|
||||
int flag = gradeService.update(grade);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//获取成绩记录详细信息
|
||||
@GetMapping("detail")
|
||||
public Grade detail(Integer id){
|
||||
//返回结果
|
||||
return gradeService.detail(id);
|
||||
}
|
||||
|
||||
//查询成绩记录
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Grade grade){
|
||||
//创建分页对象
|
||||
PageInfo<Grade> pageInfo = gradeService.query(grade);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.framework.jwt.JWTUtil;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.service.UserService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
//登录管理的控制器
|
||||
@RestController
|
||||
public class LoginController {
|
||||
//注入实例
|
||||
//注入用户服务类
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
//登录界面
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody User user){
|
||||
//判断登录用户类型
|
||||
//判断是否是学生
|
||||
if(user.getType() == 2){
|
||||
//在登录管理服务类引用login方法
|
||||
Student entity = studentService.login(user.getUserName(),user.getPassword());
|
||||
//判断学生信息是否存在
|
||||
if(entity != null){
|
||||
String token = JWTUtil.signForStudent(entity);
|
||||
//返回数据存入Map
|
||||
Map map = new HashMap();
|
||||
map.put(JWTUtil.token,token);
|
||||
//学生信息存入Map
|
||||
map.put("student",entity);
|
||||
//返回存在结果--登陆成功
|
||||
return Result.ok("登陆成功",map);
|
||||
}else{
|
||||
//返回不存在结果--登陆失败
|
||||
return Result.fail("用户名或密码错误");
|
||||
}
|
||||
}else{
|
||||
//用户类型是管理员或宿管员
|
||||
//在登录管理服务类引用login方法
|
||||
User entity = userService.login(user.getUserName(),user.getPassword());
|
||||
//判断用户信息是否存在
|
||||
if(entity != null){
|
||||
String token = JWTUtil.sign(entity);
|
||||
//返回数据存入Map
|
||||
Map map = new HashMap();
|
||||
map.put(JWTUtil.token,token);
|
||||
//用户信息存入Map
|
||||
map.put("user",entity);
|
||||
//返回存在结果--登陆成功
|
||||
return Result.ok("登陆成功",map);
|
||||
}else{
|
||||
//返回不存在结果--登陆失败
|
||||
return Result.fail("用户名或密码错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Building;
|
||||
import com.yanzhen.entity.Dormitory;
|
||||
import com.yanzhen.entity.Notice;
|
||||
import com.yanzhen.service.BuildingService;
|
||||
import com.yanzhen.service.DormitoryService;
|
||||
import com.yanzhen.service.DormitoryStudentService;
|
||||
import com.yanzhen.service.NoticeService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
//首页管理服务的控制器
|
||||
@RestController
|
||||
@RequestMapping("/main")
|
||||
public class MainController {
|
||||
//注入实例
|
||||
//注入楼宇服务类
|
||||
@Autowired
|
||||
private BuildingService buildingService;
|
||||
//注入宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
//注入学生宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryStudentService dormitoryStudentService;
|
||||
//注入公告通知服务类
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
|
||||
//创建新的实例
|
||||
@GetMapping("/building")
|
||||
public Result building(){
|
||||
//创建楼宇信息
|
||||
Building building = new Building();
|
||||
//设置查询限制
|
||||
building.setLimit(1000);
|
||||
//在首页服务类中引用building方法
|
||||
PageInfo<Building> pageInfo = buildingService.query(building);
|
||||
//楼宇信息存入列表
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
//定义一个格式化工具
|
||||
DecimalFormat df = new DecimalFormat("######0.00");
|
||||
// 遍历查询到的楼宇列表。
|
||||
pageInfo.getList().forEach(entity->{
|
||||
//楼宇信息存入Map中
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
//创建新的宿舍
|
||||
Dormitory param = new Dormitory();
|
||||
//获取宿舍对应的楼宇信息ID
|
||||
param.setBuildingId(entity.getId());
|
||||
//设置限制
|
||||
param.setLimit(1000000);
|
||||
|
||||
//在首页服务类中引用param方法
|
||||
PageInfo<Dormitory> dormitoryPageInfo = dormitoryService.query(param);
|
||||
//获取楼宇宿舍信息
|
||||
int all = dormitoryPageInfo.getList().size();
|
||||
//楼宇宿舍信息存入Map
|
||||
map.put("name",entity.getName());
|
||||
map.put("all",all);
|
||||
//获取已分配宿舍的学生信息
|
||||
int used = dormitoryStudentService.countByBuildingId(entity.getId());
|
||||
//已分配学生信息存入Map中
|
||||
map.put("used",used);
|
||||
//计算未分配宿舍的数量
|
||||
int unused = all-used;
|
||||
//未分配学生信息存入Map
|
||||
map.put("unused",unused);
|
||||
//判断宿舍数量
|
||||
if(all == 0){
|
||||
//返回宿舍信息
|
||||
map.put("percent",0);
|
||||
}else{
|
||||
//返回信息
|
||||
map.put("percent",df.format((float)used/all));
|
||||
}
|
||||
//当前楼宇的信息添加到列表
|
||||
list.add(map);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
//获取公告通知
|
||||
@GetMapping("/notice")
|
||||
public Result notice(){
|
||||
//创建公告
|
||||
Notice notice = new Notice();
|
||||
//设置查询条件
|
||||
notice.setLimit(5);
|
||||
//创建分页对象
|
||||
PageInfo<Notice> pageInfo = noticeService.query(notice);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo.getList());
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.yanzhen.entity.Menu;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.service.MenuService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
//菜单管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
public class MenuController {
|
||||
//注入实例
|
||||
//注入菜单服务类
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
//查询菜单信息
|
||||
@GetMapping("/query")
|
||||
public Result query(HttpServletRequest request){
|
||||
//创建菜单列表
|
||||
List<Menu> menus = new ArrayList<>();
|
||||
//判断查询请求的属性
|
||||
//如果是用户属性
|
||||
if(request.getAttribute("user") != null){
|
||||
//获取用户信息
|
||||
User user = (User) request.getAttribute("user");
|
||||
//根据用户ID查询菜单
|
||||
menus = menuService.query(user.getId());
|
||||
}
|
||||
//如果是学生属性
|
||||
else if(request.getAttribute("student") != null){
|
||||
//查询所有学生类型的菜单
|
||||
menus = menuService.queryByType();
|
||||
}
|
||||
//创建菜单
|
||||
List<Menu> menuList1 = new ArrayList<>();
|
||||
//找出一级菜单
|
||||
//遍历所有菜单项
|
||||
for (Menu menu : menus) {
|
||||
//判断是否为一级菜单
|
||||
if(menu.getParentId() == 0){
|
||||
//添加到一级菜单中
|
||||
menuList1.add(menu);
|
||||
}
|
||||
}
|
||||
|
||||
//嵌套循环找出关联设置child属性
|
||||
//遍历一级菜单
|
||||
for (Menu parent : menuList1) {
|
||||
//创建子菜单
|
||||
List<Menu> child = new ArrayList<>();
|
||||
//遍历所有菜单项
|
||||
for (Menu entity : menus) {
|
||||
//判断当前菜单是否为子菜单
|
||||
if(parent.getId() == entity.getParentId()){
|
||||
//添加到子菜单中
|
||||
child.add(entity);
|
||||
}
|
||||
}
|
||||
//设置一级菜单
|
||||
parent.setChild(child);
|
||||
}
|
||||
|
||||
//返回结果
|
||||
return Result.ok(menuList1);
|
||||
}
|
||||
//获取tree信息
|
||||
@GetMapping("/tree")
|
||||
public Result tree(Integer checked,HttpServletRequest request){
|
||||
//check查询的时候是否选中状态
|
||||
//创建已选中菜单ID列表
|
||||
List<Integer> checkedMenuId = new ArrayList<>();
|
||||
//判断是否包含checked
|
||||
if(checked != null){
|
||||
// 获取用户信息
|
||||
User user = (User) request.getAttribute("user");
|
||||
//查询出来自己已经设置过的menuId
|
||||
checkedMenuId = menuService.queryCheckMenuId(user.getId());
|
||||
}
|
||||
//获取菜单
|
||||
List<Menu> list = menuService.list();
|
||||
//菜单存入tree
|
||||
List<Map<String,Object>> menus = new ArrayList<>();
|
||||
//嵌套循环所有菜单项找出一级菜单
|
||||
for (Menu menu : list) {
|
||||
//判断是否为一级菜单
|
||||
if(menu.getParentId()==0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
//添加菜单ID
|
||||
map.put("id",menu.getId());
|
||||
//添加菜单名称
|
||||
map.put("name",menu.getTitle());
|
||||
//标记为父节点
|
||||
map.put("isParent",true);
|
||||
map.put("open",true);
|
||||
//判断是否已选中
|
||||
if(checked != null){
|
||||
map.put("checked",checkedMenuId.contains(menu.getId()));
|
||||
}
|
||||
//创建子菜单
|
||||
List<Map<String,Object>> child = new ArrayList<>();
|
||||
// 遍历所有菜单项
|
||||
for (Menu menu1 : list) {
|
||||
//判断当前菜单是否为子菜单
|
||||
if(menu1.getParentId()!=0 && menu.getId() == menu1.getParentId()){
|
||||
Map<String,Object> map2 = new HashMap<>();
|
||||
//添加子菜单ID
|
||||
map2.put("id",menu1.getId());
|
||||
//添加子菜单名称
|
||||
map2.put("name",menu1.getTitle());
|
||||
//标记为子节点
|
||||
map2.put("isParent",false);
|
||||
//判断是否已选中
|
||||
if(checked != null){
|
||||
map2.put("checked",checkedMenuId.contains(menu1.getId()));
|
||||
}
|
||||
//添加到子菜单中
|
||||
child.add(map2);
|
||||
}
|
||||
}
|
||||
//将子菜单列表添加到一级菜单中
|
||||
map.put("children",child);
|
||||
//将一级菜单添加到结果中
|
||||
menus.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
//返回结果
|
||||
return Result.ok(menus);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Notice;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.service.NoticeService; //
|
||||
import com.yanzhen.service.UserService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
//公告通知管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/notice")
|
||||
public class NoticeController {
|
||||
//注入实例
|
||||
//注入通知公告服务类
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
//注入用户服务类
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Notice notice, HttpServletRequest request){
|
||||
//获取当前登录的用户信息
|
||||
User user = (User) request.getAttribute("user");
|
||||
// 设置当前用户的ID
|
||||
notice.setUserId(user.getId());
|
||||
//在通知公告服务类中引用create方法
|
||||
int flag = noticeService.create(notice);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除通知公告信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在通知公告服务类中引用delete方法
|
||||
int flag = noticeService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新通知公告信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Notice notice){
|
||||
//在通知公告服务类中引用update方法
|
||||
int flag = noticeService.updateSelective(notice);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取通知公告详细信息
|
||||
@GetMapping("detail")
|
||||
public Notice detail(Integer id){
|
||||
//返回结果
|
||||
return noticeService.detail(id);
|
||||
}
|
||||
//查询通知公告信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Notice notice){
|
||||
//创建分页对象
|
||||
PageInfo<Notice> pageInfo = noticeService.query(notice);
|
||||
//遍历查询结果列表
|
||||
pageInfo.getList().forEach(entity->{
|
||||
// 为公告设置对应的用户信息
|
||||
entity.setUser(userService.detail(entity.getUserId()));
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.NoticeReceive;
|
||||
import com.yanzhen.service.NoticeReceiveService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map; // 导入Map接口
|
||||
//公告接收管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/noticeReceive")
|
||||
public class NoticeReceiveController {
|
||||
//注入实例
|
||||
//注入公告接收的服务类
|
||||
@Autowired
|
||||
private NoticeReceiveService noticeReceiveService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody NoticeReceive noticeReceive){
|
||||
//在公告接收服务类中引用create方法
|
||||
int flag = noticeReceiveService.create(noticeReceive);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除公告接收信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在公告接收服务类中引用delete方法
|
||||
int flag = noticeReceiveService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新公告接收信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody NoticeReceive noticeReceive){
|
||||
//在公告接收服务类中引用update方法
|
||||
int flag = noticeReceiveService.update(noticeReceive);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取公告接收的详细信息
|
||||
@GetMapping("detail")
|
||||
public NoticeReceive detail(Integer id){
|
||||
//返回结果
|
||||
return noticeReceiveService.detail(id);
|
||||
}
|
||||
//查询公告接收信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody NoticeReceive noticeReceive){
|
||||
//创建分页对象
|
||||
PageInfo<NoticeReceive> pageInfo = noticeReceiveService.query(noticeReceive);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
//定义包名
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo; // 导入分页插件
|
||||
import com.yanzhen.entity.Org; // 导入组织实体类
|
||||
import com.yanzhen.service.OrgService; // 导入组织服务接口
|
||||
import com.yanzhen.utils.Result; // 导入结果工具类
|
||||
import org.springframework.beans.factory.annotation.Autowired; // 导入自动装配注解
|
||||
import org.springframework.web.bind.annotation.*; // 导入Spring MVC相关注解
|
||||
|
||||
import java.util.ArrayList; // 导入ArrayList类
|
||||
import java.util.HashMap; // 导入HashMap类
|
||||
import java.util.List; // 导入List接口
|
||||
import java.util.Map; // 导入Map接口
|
||||
//组织管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/org")
|
||||
public class OrgController {
|
||||
//注入实例
|
||||
//注入组织服务类
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
//获取组织信息存入tree
|
||||
@GetMapping("tree")
|
||||
public Result tree(){
|
||||
//查询所有组织信息
|
||||
PageInfo<Org> pageInfo = orgService.query(null);
|
||||
//所有的树形信息
|
||||
List<Org> list = pageInfo.getList();
|
||||
//要构建的树形结构
|
||||
List<Map<String,Object>> trees = new ArrayList<>();
|
||||
//嵌套查询组织信息
|
||||
for (Org entity : list) {
|
||||
//判断是否为顶级节点
|
||||
if(entity.getParentId() == 0){
|
||||
//创建Map对象
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
//组织ID存入Map
|
||||
map.put("id",entity.getId());
|
||||
//组织名称存入Map
|
||||
map.put("name",entity.getName());
|
||||
//判断是否有子节点
|
||||
if(entity.getType()<4){
|
||||
//标记为父节点
|
||||
map.put("isParent",true);
|
||||
map.put("open",true);
|
||||
//递归获取子节点信息存入Map
|
||||
map.put("children",getChild(entity,list));
|
||||
}else{
|
||||
//标记为叶子节点
|
||||
map.put("isParent",false);
|
||||
}
|
||||
//将Map加到树形结构中
|
||||
trees.add(map);
|
||||
}
|
||||
}
|
||||
//返回结果
|
||||
return Result.ok(trees);
|
||||
}
|
||||
|
||||
//自己调自己、有出口
|
||||
public List<Map<String,Object>> getChild(Org parent,List<Org> list){
|
||||
//初始化
|
||||
List<Map<String,Object>> child = new ArrayList<>();
|
||||
//遍历查询组织信息
|
||||
for (Org org : list) {
|
||||
//判断父节点信息
|
||||
if(parent.getId() == org.getParentId()){
|
||||
//创建Map对象
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
//组织ID存入Map
|
||||
map.put("id",org.getId());
|
||||
//将组织名称放入Map
|
||||
map.put("name",org.getName());
|
||||
//判断是否有子节点
|
||||
if(org.getType()<4){
|
||||
//标记为父节点
|
||||
map.put("isParent",true);
|
||||
//获取子节点存入Map
|
||||
map.put("children",getChild(org,list));
|
||||
}else{
|
||||
//标记为叶子节点
|
||||
map.put("isParent",false);
|
||||
}
|
||||
//Map加到子节点中
|
||||
child.add(map);
|
||||
}
|
||||
}
|
||||
//返回结果
|
||||
return child;
|
||||
}
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Org org){
|
||||
//未设置则为一级栏目
|
||||
//判断是否为顶节点
|
||||
if(org.getParentId() == null){
|
||||
org.setParentId(0);
|
||||
}
|
||||
//在组织管理服务类中引用create方法
|
||||
int flag = orgService.create(org);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除组织信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String id){
|
||||
//在组织管理服务类中引用delete方法
|
||||
int flag = orgService.delete(id);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新组织信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Org org){
|
||||
//在组织管理服务类中引用update方法
|
||||
int flag = orgService.update(org);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取组织详细信息
|
||||
@GetMapping("detail")
|
||||
public Org detail(Integer id){
|
||||
//返回结果
|
||||
return orgService.detail(id);
|
||||
}
|
||||
//查询组织信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Org org){
|
||||
//在组织管理服务类中引用查询方法
|
||||
PageInfo<Org> pageInfo = orgService.query(org);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.yanzhen.controller; // 定义包名
|
||||
|
||||
import com.github.pagehelper.PageInfo; // 导入分页插件
|
||||
import com.yanzhen.entity.Record; // 导入记录实体类
|
||||
import com.yanzhen.service.RecordService; // 导入记录服务接口
|
||||
import com.yanzhen.utils.Result; // 导入结果工具类
|
||||
import org.springframework.beans.factory.annotation.Autowired; // 导入自动装配注解
|
||||
import org.springframework.web.bind.annotation.*; // 导入Spring MVC相关注解
|
||||
|
||||
import java.util.Map; // 导入Map接口
|
||||
//记录管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/record")
|
||||
public class RecordController {
|
||||
//注入实例
|
||||
//注入记录服务类
|
||||
@Autowired
|
||||
private RecordService recordService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Record record){
|
||||
//在记录管理服务类中引用create方法
|
||||
int flag = recordService.create(record);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除记录管理信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在记录管理服务类中引用delete方法
|
||||
int flag = recordService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新记录管理信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Record record){
|
||||
//在记录管理服务类中引用update方法
|
||||
int flag = recordService.update(record);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取记录详细信息
|
||||
@GetMapping("detail")
|
||||
public Record detail(Integer id){
|
||||
//返回结果
|
||||
return recordService.detail(id);
|
||||
}
|
||||
//查询记录管理信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Record record){
|
||||
//创建分页对象
|
||||
PageInfo<Record> pageInfo = recordService.query(record);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Repair;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.BuildingService;
|
||||
import com.yanzhen.service.DormitoryService;
|
||||
import com.yanzhen.service.RepairService;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//报修管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/repair")
|
||||
public class RepairController {
|
||||
|
||||
//注入实例
|
||||
//注入报修管理的服务类
|
||||
@Autowired
|
||||
private RepairService repairService;
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//注入宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
//注入楼宇服务类
|
||||
@Autowired
|
||||
private BuildingService buildingService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Repair repair){
|
||||
//在报修管理服务类中引用create方法
|
||||
int flag = repairService.create(repair);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//删除报修信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在报修管理服务类中引用delete方法
|
||||
int flag = repairService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//更新报修信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Repair repair){
|
||||
//在报修管理服务类中引用update方法
|
||||
int flag = repairService.updateSelective(repair);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//获取报修详细信息
|
||||
@GetMapping("detail")
|
||||
public Repair detail(Integer id){
|
||||
//返回结果
|
||||
return repairService.detail(id);
|
||||
}
|
||||
|
||||
//查询报修信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Repair repair){
|
||||
//创建分页对象
|
||||
PageInfo<Repair> pageInfo = new PageInfo<>();
|
||||
//判断查询条件是否包含学生姓名
|
||||
if(repair.getName() != null){
|
||||
//根据姓名查找学生ID
|
||||
Student detailId = studentService.detailByName(repair.getName());
|
||||
//判断是否找到学生ID
|
||||
if(detailId != null){
|
||||
//设置查询条件
|
||||
repair.setStudentId(detailId.getId());
|
||||
}else{
|
||||
//设置分页列表为空
|
||||
pageInfo.setList(null);
|
||||
//设置分页大小
|
||||
pageInfo.setSize(0);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
||||
//在报修管理服务类中引用query方法
|
||||
pageInfo = repairService.query(repair);
|
||||
//遍历查询结果列表
|
||||
pageInfo.getList().forEach(entity->{
|
||||
//设置维修记录的楼宇信息
|
||||
entity.setBuilding(buildingService.detail(entity.getBuildingId()));
|
||||
//设置维修记录的学生信息
|
||||
entity.setStudent(studentService.detail(entity.getStudentId()));
|
||||
//设置维修记录的宿舍信息
|
||||
entity.setDormitory(dormitoryService.detail(entity.getDormitoryId()));
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Org;
|
||||
import com.yanzhen.entity.Selection;
|
||||
import com.yanzhen.service.OrgService;
|
||||
import com.yanzhen.service.SelectionJoinerService;
|
||||
import com.yanzhen.service.SelectionService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
//选择管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/selection")
|
||||
public class SelectionController {
|
||||
|
||||
//注入实例
|
||||
//注入选择管理的服务类
|
||||
@Autowired
|
||||
private SelectionService selectionService;
|
||||
//注入SelectionJoiner的服务类
|
||||
@Autowired
|
||||
private SelectionJoinerService selectionJoinerService;
|
||||
//注入宿舍服务类
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Selection selection){
|
||||
//在选择管理服务类中引用create方法
|
||||
int flag = selectionService.create(selection);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除选择记录
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在选择管理服务类中引用delete方法
|
||||
int flag = selectionService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新选择信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Selection selection){
|
||||
//在选择管理服务类中引用update方法
|
||||
int flag = selectionService.update(selection);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取选择的详细信息
|
||||
@GetMapping("detail")
|
||||
public Selection detail(Integer id){
|
||||
//返回结果
|
||||
return selectionService.detail(id);
|
||||
}
|
||||
//查询选择信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Selection selection){
|
||||
//创建分页对象
|
||||
PageInfo<Selection> pageInfo = selectionService.query(selection);
|
||||
//遍历查询
|
||||
pageInfo.getList().forEach(item->{
|
||||
//根据选择ID查询组织信息
|
||||
List<Org> clazzes = orgService.queryOrgBySelectionId(item.getId());
|
||||
//组织信息设置到选择项中
|
||||
item.setClazzes(clazzes);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.SelectionDormitory;
|
||||
import com.yanzhen.service.SelectionDormitoryService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//选择宿舍管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/selectionDormitory")
|
||||
public class SelectionDormitoryController {
|
||||
|
||||
//注入实例
|
||||
//注入选择宿舍服务类
|
||||
@Autowired
|
||||
private SelectionDormitoryService selectionDormitoryService;
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Map<String,String> map){
|
||||
|
||||
//获取clazzId,dormitoryIds
|
||||
String clazzId = map.get("clazzId");
|
||||
String dormitoryIds = map.get("dormitoryIds");
|
||||
//在选择宿舍管理服务类中引用create方法
|
||||
int flag = selectionDormitoryService.create(clazzId,dormitoryIds);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除选择宿舍信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在选择宿舍管理服务类中引用delete方法
|
||||
int flag = selectionDormitoryService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新选择宿舍信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody SelectionDormitory selectionDormitory){
|
||||
//在选择宿舍管理服务类中引用update方法
|
||||
int flag = selectionDormitoryService.update(selectionDormitory);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取选择宿舍的详细信息
|
||||
@GetMapping("detail")
|
||||
public SelectionDormitory detail(Integer id){
|
||||
//返回结果
|
||||
return selectionDormitoryService.detail(id);
|
||||
}
|
||||
//查询选择宿舍的信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody SelectionDormitory selectionDormitory){
|
||||
//创建分页对象
|
||||
PageInfo<SelectionDormitory> pageInfo = selectionDormitoryService.query(selectionDormitory);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.SelectionJoiner;
|
||||
import com.yanzhen.service.SelectionJoinerService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//SelectionJoiner管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/selectionJoiner")
|
||||
public class SelectionJoinerController {
|
||||
//注入实例
|
||||
//注入SelectionJoiner管理的服务类
|
||||
@Autowired
|
||||
private SelectionJoinerService selectionJoinerService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody SelectionJoiner selectionJoiner){
|
||||
//从SelectionJoiner服务类引用create方法
|
||||
int flag = selectionJoinerService.create(selectionJoiner);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除SelectionJoiner的信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在SelectionJoiner的服务类中引用delete方法
|
||||
int flag = selectionJoinerService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新SelectionJoiner信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody SelectionJoiner selectionJoiner){
|
||||
//在SelectionJoiner服务类中引用update方法
|
||||
int flag = selectionJoinerService.update(selectionJoiner);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取SelectionJoiner详细信息
|
||||
@GetMapping("detail")
|
||||
public SelectionJoiner detail(Integer id){
|
||||
//返回结果
|
||||
return selectionJoinerService.detail(id);
|
||||
}
|
||||
|
||||
//查询SelectionJoiner信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody SelectionJoiner selectionJoiner){
|
||||
//创建分页对象
|
||||
PageInfo<SelectionJoiner> pageInfo = selectionJoinerService.query(selectionJoiner);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Storey;
|
||||
import com.yanzhen.service.StoreyService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//Storey管理的服务类
|
||||
@RestController
|
||||
@RequestMapping("/storey")
|
||||
public class StoreyController {
|
||||
|
||||
//注入实例
|
||||
//注入Storey服务类
|
||||
@Autowired
|
||||
private StoreyService storeyService;
|
||||
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Storey storey){
|
||||
//在Storey服务类引用create方法
|
||||
int flag = storeyService.create(storey);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
|
||||
//删除Storey信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在Storey服务类中引用delete方法
|
||||
int flag = storeyService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新Storey信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Storey storey){
|
||||
//在Storey服务类中引用update方法
|
||||
int flag = storeyService.update(storey);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取Storey详细信息
|
||||
@GetMapping("detail")
|
||||
public Storey detail(Integer id){
|
||||
//返回结果
|
||||
return storeyService.detail(id);
|
||||
}
|
||||
//查询Storey信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Storey storey){
|
||||
//创建分页对象
|
||||
PageInfo<Storey> pageInfo = storeyService.query(storey);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,262 @@
|
||||
// 定义包名
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo; // 导入分页插件
|
||||
import com.yanzhen.entity.*; // 导入实体类
|
||||
import com.yanzhen.service.*; // 导入服务接口
|
||||
import com.yanzhen.utils.Result; // 导入结果封装类
|
||||
import org.springframework.beans.factory.annotation.Autowired; // 导入自动装配注解
|
||||
import org.springframework.web.bind.annotation.*; // 导入Spring MVC相关注解
|
||||
|
||||
import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类
|
||||
import java.util.ArrayList; // 导入ArrayList类
|
||||
import java.util.Date; // 导入Date类
|
||||
import java.util.HashMap; // 导入HashMap类
|
||||
import java.util.List; // 导入List接口
|
||||
import java.util.Map; // 导入Map接口
|
||||
//学生管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/stu")
|
||||
public class StuController {
|
||||
//注入实例
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
//注入组织服务类
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
//注入 成绩服务类
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
//注入选择宿舍服务类
|
||||
@Autowired
|
||||
private SelectionDormitoryService selectionDormitoryService;
|
||||
//注入宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryService dormitoryService;
|
||||
//注入学生宿舍服务类
|
||||
@Autowired
|
||||
private DormitoryStudentService dormitoryStudentService;
|
||||
//注入缺勤服务类
|
||||
@Autowired
|
||||
private AbsenceService absenceService;
|
||||
//注入报修服务类
|
||||
@Autowired
|
||||
private RepairService repairService;
|
||||
//注入通知公告服务类
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
//注入用户服务类
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//注入楼宇服务类
|
||||
@Autowired
|
||||
private BuildingService buildingService;
|
||||
//注入选择服务类
|
||||
@Autowired
|
||||
private SelectionService selectionService;
|
||||
//获取学生信息
|
||||
@GetMapping("/info") // 映射GET请求到/info路径
|
||||
public Result info(HttpServletRequest request) {
|
||||
//从请求属性中获取学生信息
|
||||
Student param = (Student)request.getAttribute("student");
|
||||
//根据学生ID获取学生详细信息
|
||||
Student student = studentService.detail(param.getId());
|
||||
//设置学生组织信息
|
||||
student.setOrg(orgService.detail(student.getClazzId()));
|
||||
//设置学生成绩信息
|
||||
student.setGrade(gradeService.detail(student.getGradeId()));
|
||||
//返回结果
|
||||
return Result.ok(student);
|
||||
}
|
||||
//获取选择宿舍信息
|
||||
@GetMapping("/select_dormitory")
|
||||
public Result select_dormitory(HttpServletRequest request) {
|
||||
//从请求属性中获取学生信息
|
||||
Student param = (Student)request.getAttribute("student");
|
||||
//根据学生ID获取学生详细信息
|
||||
Student student = studentService.detail(param.getId());
|
||||
//创建SelectionDormitory对象
|
||||
SelectionDormitory selectionDormitory = new SelectionDormitory();
|
||||
//设置班级ID
|
||||
selectionDormitory.setClazzId(student.getClazzId());
|
||||
//设置查询限制条数
|
||||
selectionDormitory.setLimit(1000);
|
||||
//查询可选宿舍列表
|
||||
PageInfo<SelectionDormitory> pageInfo = selectionDormitoryService.query(selectionDormitory);
|
||||
//创建用于存储宿舍信息的列表
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
// 获取查询结果列表
|
||||
List<SelectionDormitory> selectionDormitorys = pageInfo.getList();
|
||||
// 遍历查询结果列表
|
||||
for (SelectionDormitory sd : selectionDormitorys) {
|
||||
// 创建用于存储单个宿舍信息的Map对象
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
//查询宿舍的基本信息
|
||||
Dormitory dormitory = dormitoryService.detail(sd.getDormitoryId());
|
||||
// 设置宿舍容量
|
||||
map.put("capacity",dormitory.getCapacity());
|
||||
// 设置宿舍ID
|
||||
map.put("id",dormitory.getId());
|
||||
// 设置宿舍编号
|
||||
map.put("no",dormitory.getNo());
|
||||
// 设置宿舍性别要求
|
||||
map.put("sex",dormitory.getSex());
|
||||
// 设置宿舍所在建筑名称
|
||||
map.put("buildingName",buildingService.detail(dormitory.getBuildingId()).getName());
|
||||
//查询已选择的所有学生
|
||||
DormitoryStudent ds = new DormitoryStudent();
|
||||
// 设置宿舍ID
|
||||
ds.setDormitoryId(sd.getDormitoryId());
|
||||
// 设置查询限制条数
|
||||
ds.setLimit(1000);
|
||||
// 查询已选择的学生列表
|
||||
PageInfo<DormitoryStudent> pageInfo1 = dormitoryStudentService.query(ds);
|
||||
// 设置已选择的学生数量
|
||||
map.put("selected",pageInfo1.getTotal());
|
||||
|
||||
//构造已经选择的同学信息
|
||||
List<Map<String,Object>> studentList = new ArrayList<>();
|
||||
// 获取已选择学生列表
|
||||
List<DormitoryStudent> list1 = pageInfo1.getList();
|
||||
// 遍历已选择学生列表
|
||||
for(DormitoryStudent ds1 : list1){
|
||||
// 创建用于存储单个学生信息的Map对象
|
||||
Map<String,Object> studentMap = new HashMap<>();
|
||||
// 根据学生ID获取学生详细信息
|
||||
Student detail = studentService.detail(ds1.getStudentId());
|
||||
// 设置学生学号
|
||||
studentMap.put("stuNo",detail.getStuNo());
|
||||
// 设置学生姓名
|
||||
studentMap.put("name",detail.getName());
|
||||
// 设置学生床位ID
|
||||
studentMap.put("bedId",ds1.getBedId());
|
||||
// 将学生信息添加到列表中
|
||||
studentList.add(studentMap);
|
||||
}
|
||||
// 将已选择学生信息列表添加到宿舍信息Map中
|
||||
map.put("studentList",studentList);
|
||||
// 将宿舍信息添加到最终列表中
|
||||
list.add(map);
|
||||
}
|
||||
//返回结果
|
||||
return Result.ok(list);
|
||||
|
||||
}
|
||||
//提交选择宿舍信息
|
||||
@PostMapping("select_dormitory_submit")
|
||||
public Result select_dormitory(@RequestBody Map<String,String> map, HttpServletRequest request){
|
||||
// 从请求属性中获取学生信息
|
||||
Student param = (Student)request.getAttribute("student");
|
||||
// 根据学生ID获取学生详细信息
|
||||
Student student = studentService.detail(param.getId());
|
||||
// 根据班级ID查询可选时间段列表
|
||||
List<Selection> selections = selectionService.queryByClazzId(student.getClazzId());
|
||||
// 如果未设置或没有可选时间段
|
||||
if(selections != null && selections.size()==0){
|
||||
// 返回结果
|
||||
return Result.fail("操作失败,未设置!请联系管理员");
|
||||
}
|
||||
// 获取第一个可选时间段
|
||||
Selection selection = selections.get(0);
|
||||
//判断当前时间是否在可选时间段内
|
||||
if(selection.getStartTime().getTime() > System.currentTimeMillis() || System.currentTimeMillis() > selection.getEndTime().getTime()){
|
||||
// 返回结果
|
||||
return Result.fail("操作失败,不在时间段内选择");
|
||||
}
|
||||
// 从请求体中获取床位ID
|
||||
String bedId = map.get("bedId");
|
||||
// 从请求体中获取宿舍ID
|
||||
String dormitoryId = map.get("dormitoryId");
|
||||
// 根据学生ID、宿舍ID和床位ID提交选择宿舍请求
|
||||
int row = dormitoryStudentService.select_dormitory_submit(student.getId(),Integer.parseInt(dormitoryId),Integer.parseInt(bedId));
|
||||
//判断是否提交成功
|
||||
if(row > 0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//创建报修记录
|
||||
@PostMapping("repair_create")
|
||||
public Result repair_create(@RequestBody Repair repair,HttpServletRequest request){
|
||||
// 从请求属性中获取学生信息
|
||||
Student param = (Student)request.getAttribute("student");
|
||||
// 创建DormitoryStudent对象
|
||||
DormitoryStudent ds = new DormitoryStudent();
|
||||
// 设置学生ID
|
||||
ds.setStudentId(param.getId());
|
||||
// 查询学生的宿舍信息
|
||||
PageInfo<DormitoryStudent> pageInfo = dormitoryStudentService.query(ds);
|
||||
// 初始化
|
||||
PageInfo<Notice> noticePageInfo = null;
|
||||
// 判断是否存在关联的宿舍信息
|
||||
if(pageInfo.getList() != null && pageInfo.getList().size() > 0){
|
||||
// 获取第一个关联的宿舍信息
|
||||
DormitoryStudent dormitoryStudent = pageInfo.getList().get(0);
|
||||
// 根据宿舍ID获取宿舍详细信息
|
||||
Dormitory detail = dormitoryService.detail(dormitoryStudent.getDormitoryId());
|
||||
// 设置维修记录的建筑ID
|
||||
repair.setBuildingId(detail.getBuildingId());
|
||||
// 设置维修记录的宿舍ID
|
||||
repair.setDormitoryId(dormitoryStudent.getDormitoryId());
|
||||
// 设置维修记录的学生ID
|
||||
repair.setStudentId(param.getId());
|
||||
// 设置维修记录的创建日期
|
||||
repair.setCreateDate(new Date());
|
||||
// 设置维修记录的状态
|
||||
repair.setStatus(0);
|
||||
// 提交维修记录并获取操作结果标志
|
||||
int flag = repairService.create(repair);
|
||||
//判断是否提交成功
|
||||
if(flag > 0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}else{
|
||||
//返回结果
|
||||
return Result.fail("操作失败,没有关联的宿舍");
|
||||
}
|
||||
}
|
||||
//查询公告信息
|
||||
@PostMapping("notice_query")
|
||||
public Map<String, Object> notice_query(@RequestBody Notice notice,HttpServletRequest request){
|
||||
// 从请求属性中获取学生信息
|
||||
Student param = (Student)request.getAttribute("student");
|
||||
// 创建DormitoryStudent对象
|
||||
DormitoryStudent ds = new DormitoryStudent();
|
||||
// 设置学生ID
|
||||
ds.setStudentId(param.getId());
|
||||
// 查询学生关联的宿舍信息
|
||||
PageInfo<DormitoryStudent> pageInfo = dormitoryStudentService.query(ds);
|
||||
// 初始化
|
||||
PageInfo<Notice> noticePageInfo = null;
|
||||
// 判断是否存在关联的宿舍信息
|
||||
if(pageInfo.getList() != null && pageInfo.getList().size() > 0){
|
||||
// 获取第一个关联的宿舍信息
|
||||
DormitoryStudent dormitoryStudent = pageInfo.getList().get(0);
|
||||
// 根据宿舍ID获取宿舍详细信息
|
||||
Dormitory detail = dormitoryService.detail(dormitoryStudent.getDormitoryId());
|
||||
// 设置通知的建筑ID
|
||||
notice.setBuildingId(detail.getBuildingId());
|
||||
// 根据建筑ID查询通知列表
|
||||
noticePageInfo = noticeService.queryByBuildingId(notice);
|
||||
// 遍历通知列表
|
||||
noticePageInfo.getList().forEach(entity->{
|
||||
// 根据用户ID获取用户详细信息并设置到通知中
|
||||
entity.setUser(userService.detail(entity.getUserId()));
|
||||
});
|
||||
}else{
|
||||
// 如果不存在关联的宿舍信息初始化
|
||||
noticePageInfo = new PageInfo<>(null);
|
||||
}
|
||||
//返回结果
|
||||
return Result.ok(noticePageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Grade;
|
||||
import com.yanzhen.entity.Org;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.GradeService;
|
||||
import com.yanzhen.service.OrgService;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
//学生管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/student")
|
||||
public class StudentController {
|
||||
//注入实例
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//注入成绩服务类
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
//注入组织服务类
|
||||
@Autowired
|
||||
private OrgService orgService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Student student){
|
||||
//在学生管理服务类中引用create方法
|
||||
int flag = studentService.create(student);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除学生信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在学生管理服务类中引用delete方法
|
||||
int flag = studentService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新学生信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Student student){
|
||||
//在学生管理服务类中引用update方法
|
||||
int flag = studentService.updateSelective(student);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取学生详细信息
|
||||
@GetMapping("detail")
|
||||
public Student detail(Integer id){
|
||||
//返回结果
|
||||
return studentService.detail(id);
|
||||
}
|
||||
//查询学生信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Student student){
|
||||
//创建分页对象
|
||||
PageInfo<Student> pageInfo = studentService.query(student);
|
||||
// 遍历查询结果中的每个学生
|
||||
pageInfo.getList().forEach(entity->{
|
||||
// 根据学生的年级 ID 获取对应的年级信息。
|
||||
Grade grade = gradeService.detail(entity.getGradeId());
|
||||
// 成绩信息设置到学生中
|
||||
entity.setGrade(grade);
|
||||
// 根据学生的班级 ID 获取对应的班级信息。
|
||||
Org org = orgService.detail(entity.getClazzId());
|
||||
// 将班级信息设置到学生对象中。
|
||||
entity.setOrg(org);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.service.UserService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
//用户管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
//注入实例
|
||||
//注入用户管理的服务类
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody User user){
|
||||
//在用户管理服务类中引用create方法
|
||||
int flag = userService.create(user);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除用户信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在用户管理服务类中引用delete方法
|
||||
int flag = userService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新用户信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody User user){
|
||||
//在用户管理服务类中引用update方法
|
||||
int flag = userService.updateSelective(user);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取用户详细信息
|
||||
@GetMapping("detail")
|
||||
public User detail(Integer id){
|
||||
//返回结果
|
||||
return userService.detail(id);
|
||||
}
|
||||
//获取用户信息
|
||||
@GetMapping("info")
|
||||
public Result info(HttpServletRequest request){
|
||||
//获取当前用户对象。
|
||||
User user = (User)request.getAttribute("user");
|
||||
//返回结果
|
||||
return Result.ok(userService.detail(user.getId()));
|
||||
}
|
||||
//修改用户密码
|
||||
@PostMapping("pwd")
|
||||
public Result pwd(@RequestBody Map<String,String> map,HttpServletRequest request){
|
||||
// 获取原密码
|
||||
String spassword = map.get("spassword");
|
||||
// 获取新密码
|
||||
String npassword = map.get("npassword");
|
||||
//用户修改
|
||||
if(request.getAttribute("user") != null){
|
||||
// 获取当前用户对象。
|
||||
User user = (User)request.getAttribute("user");
|
||||
// 获取用户详细信息。
|
||||
User entity = userService.detail(user.getId());
|
||||
//判断原密码是否正确
|
||||
if(entity.getPassword().equals(spassword)){
|
||||
// 创建新的 User 对象用于更新密码
|
||||
User param = new User();
|
||||
// 设置用户 ID
|
||||
param.setId(entity.getId());
|
||||
// 设置新密码
|
||||
param.setPassword(npassword);
|
||||
// 更新密码
|
||||
userService.updatePwd(param);
|
||||
//成功
|
||||
return Result.ok("修改密码成功");
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail("原密码错误");
|
||||
}
|
||||
}
|
||||
//学生修改
|
||||
if(request.getAttribute("student") != null){
|
||||
// 获取当前学生对象
|
||||
Student student = (Student)request.getAttribute("student");
|
||||
//获取学生详细信息
|
||||
Student entity = studentService.detail(student.getId());
|
||||
//判断原密码是否正确
|
||||
if(entity.getPassword().equals(spassword)){
|
||||
// 更新密码
|
||||
Student param = new Student();
|
||||
// 设置学生 ID
|
||||
param.setId(entity.getId());
|
||||
// 设置新密码
|
||||
param.setPassword(npassword);
|
||||
// 更新密码
|
||||
studentService.updateSelective(param);
|
||||
//成功
|
||||
return Result.ok("修改密码成功");
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail("原密码错误");
|
||||
}
|
||||
}
|
||||
return Result.ok(); // 如果既不是普通用户也不是学生,返回成功的 Result 对象。
|
||||
}
|
||||
//查询用户信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody User user){
|
||||
//创建分页对象
|
||||
PageInfo<User> pageInfo = userService.query(user);
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.entity.Visit;
|
||||
import com.yanzhen.service.StudentService;
|
||||
import com.yanzhen.service.VisitService;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
//来访管理的控制器
|
||||
@RestController
|
||||
@RequestMapping("/visit")
|
||||
public class VisitController {
|
||||
//注入实例
|
||||
//注入来访管理服务类
|
||||
@Autowired
|
||||
private VisitService visitService;
|
||||
//注入学生服务类
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
//创建新的实例
|
||||
@PostMapping("create")
|
||||
public Result create(@RequestBody Visit visit){
|
||||
//在来访管理服务类中引用create方法
|
||||
int flag = visitService.create(visit);
|
||||
//判断是否创建成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//删除来访记录信息
|
||||
@GetMapping("delete")
|
||||
public Result delete(String ids){
|
||||
//在来访管理服务类中引用delete方法
|
||||
int flag = visitService.delete(ids);
|
||||
//判断是否删除成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//更新来访信息
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Visit visit){
|
||||
//在来访管理服务类中引用update方法
|
||||
int flag = visitService.updateSelective(visit);
|
||||
//判断是否更新成功
|
||||
if(flag>0){
|
||||
//成功
|
||||
return Result.ok();
|
||||
}else{
|
||||
//失败
|
||||
return Result.fail();
|
||||
}
|
||||
}
|
||||
//获取来访详细信息
|
||||
@GetMapping("detail")
|
||||
public Visit detail(Integer id){
|
||||
//返回结果
|
||||
return visitService.detail(id);
|
||||
}
|
||||
//查询来访信息
|
||||
@PostMapping("query")
|
||||
public Map<String,Object> query(@RequestBody Visit visit){
|
||||
//创建分页对象
|
||||
PageInfo<Visit> pageInfo = visitService.query(visit);
|
||||
// 遍历查询结果中的每条记录
|
||||
pageInfo.getList().forEach(entity->{
|
||||
// 根据学生 ID 获取学生的详细信息
|
||||
Student detail = studentService.detail(entity.getStudentId());
|
||||
// 将学生详细信息设置到访问记录中
|
||||
entity.setStudent(detail);
|
||||
});
|
||||
//返回结果
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue