parent
499cb048cc
commit
8a9e7e2eb0
@ -0,0 +1,79 @@
|
|||||||
|
package com.hzu.bookingsystem.controller;
|
||||||
|
|
||||||
|
import com.hzu.bookingsystem.VO.ResultVO;
|
||||||
|
import com.hzu.bookingsystem.bean.LabBean;
|
||||||
|
import com.hzu.bookingsystem.converter.Map2Object;
|
||||||
|
import com.hzu.bookingsystem.dto.LabDTO;
|
||||||
|
import com.hzu.bookingsystem.service.LabService;
|
||||||
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping("/lab")
|
||||||
|
public class LabController {
|
||||||
|
@Autowired
|
||||||
|
private LabService labService;
|
||||||
|
|
||||||
|
//创建实验室
|
||||||
|
@PostMapping(value = "/addLab" , consumes = "application/json")
|
||||||
|
public ResultVO addLab(@RequestBody Map<String,Object> map){
|
||||||
|
//转换对象
|
||||||
|
LabBean lab1 = (LabBean) Map2Object.map2Object(map,LabBean.class);
|
||||||
|
System.out.println(lab1);
|
||||||
|
//查重
|
||||||
|
if(labService.findByName(lab1.getName()) != null)
|
||||||
|
{
|
||||||
|
return ResultVOUtil.error(-1,"该实验室已存在");
|
||||||
|
}
|
||||||
|
labService.add(lab1);
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//通过LabId删除实验室
|
||||||
|
@PostMapping(value = "/deleteLab" , consumes = "application/json")
|
||||||
|
public ResultVO deleteLab(@RequestBody LabBean lab){
|
||||||
|
//查找实验室是否存在
|
||||||
|
LabBean lab1 = labService.findByLabId(lab.getLabId());
|
||||||
|
if(lab1 == null) {
|
||||||
|
return ResultVOUtil.error(-1, "该实验室不存在");
|
||||||
|
} else {
|
||||||
|
labService.deleteByLabId(lab1.getLabId());
|
||||||
|
}
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改实验室信息
|
||||||
|
@PostMapping(value = "/updateLab" , consumes = "application/json")
|
||||||
|
public ResultVO updateLab(@RequestBody Map<String,Object> map , HttpServletRequest request){
|
||||||
|
//转换对象
|
||||||
|
LabBean lab1 = (LabBean) Map2Object.map2Object(map,LabBean.class);
|
||||||
|
if(lab1.getLabId() == null){
|
||||||
|
return ResultVOUtil.error(-1,"该实验室不存在,无法修改");
|
||||||
|
} else {
|
||||||
|
labService.update(lab1);
|
||||||
|
}
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查找实验室
|
||||||
|
@GetMapping(value = "/findByLabId" , consumes = "application/json")
|
||||||
|
public ResultVO<Map<String,Object>> findByLabId(@RequestParam("LabId") Integer labId){
|
||||||
|
LabBean lab1 = labService.findByLabId(labId);
|
||||||
|
System.out.println(lab1);
|
||||||
|
return ResultVOUtil.success(lab1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查找所有实验室列表
|
||||||
|
@GetMapping(value = "/getLabList")
|
||||||
|
public ResultVO getLabList(){
|
||||||
|
List<LabDTO> labList = labService.findAllLabInfo();
|
||||||
|
return ResultVOUtil.success(labList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package com.hzu.bookingsystem.controller;
|
||||||
|
|
||||||
|
import com.hzu.bookingsystem.VO.ResultVO;
|
||||||
|
import com.hzu.bookingsystem.bean.LabTimeBean;
|
||||||
|
import com.hzu.bookingsystem.converter.Map2Object;
|
||||||
|
import com.hzu.bookingsystem.dto.LabTimeDTO;
|
||||||
|
import com.hzu.bookingsystem.service.LabTimeService;
|
||||||
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping("/labTime")
|
||||||
|
public class LabTimeController {
|
||||||
|
@Autowired
|
||||||
|
private LabTimeService labTimeService;
|
||||||
|
|
||||||
|
//创建实验室可预约时间段
|
||||||
|
@PostMapping(value = "/addLabTime" , consumes = "application/json")
|
||||||
|
public ResultVO addLabTime(@RequestBody Map<String,Object> map){
|
||||||
|
//转换对象
|
||||||
|
LabTimeBean labTime1 = (LabTimeBean) Map2Object.map2Object(map,LabTimeBean.class);
|
||||||
|
System.out.println(labTime1);
|
||||||
|
//查重
|
||||||
|
if(labTimeService.findByTime(labTime1.getTime()) != null)
|
||||||
|
{
|
||||||
|
return ResultVOUtil.error(-1,"该时间段已存在");
|
||||||
|
}
|
||||||
|
labTimeService.add(labTime1);
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//通过ltId删除实验室可预约时间段
|
||||||
|
@PostMapping(value = "/deleteLabTime" , consumes = "application/json")
|
||||||
|
public ResultVO deleteLabTime(@RequestBody LabTimeBean labTime){
|
||||||
|
//查找实验室是否存在
|
||||||
|
LabTimeBean labTime1 = labTimeService.findByLtId(labTime.getLtId());
|
||||||
|
if(labTime1 == null) {
|
||||||
|
return ResultVOUtil.error(-1, "该时间段不存在");
|
||||||
|
} else {
|
||||||
|
labTimeService.deleteByLtId(labTime1.getLabId());
|
||||||
|
}
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改实验室可预约时间段
|
||||||
|
@PostMapping(value = "/updateLabTime" , consumes = "application/json")
|
||||||
|
public ResultVO updateLabTime(@RequestBody Map<String,Object> map , HttpServletRequest request){
|
||||||
|
//转换对象
|
||||||
|
LabTimeBean labTime1 = (LabTimeBean) Map2Object.map2Object(map,LabTimeBean.class);
|
||||||
|
if(labTime1.getLtId() == null){
|
||||||
|
return ResultVOUtil.error(-1,"该实验室不存在,无法修改");
|
||||||
|
} else {
|
||||||
|
labTimeService.update(labTime1);
|
||||||
|
}
|
||||||
|
return ResultVOUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查找实验室
|
||||||
|
@GetMapping(value = "/findByLabIdTime" , consumes = "application/json")
|
||||||
|
public ResultVO<Map<String,Object>> findByLabTimeId(@RequestParam("LabTimeId") Integer labTimeId){
|
||||||
|
LabTimeBean labTime1 = labTimeService.findByLtId(labTimeId);
|
||||||
|
System.out.println(labTime1);
|
||||||
|
return ResultVOUtil.success(labTime1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查找所有实验室列表
|
||||||
|
@GetMapping(value = "/getLabListTime")
|
||||||
|
public ResultVO getLabTimeList(){
|
||||||
|
List<LabTimeDTO> labTimeList = labTimeService.findAllLabInfo();
|
||||||
|
return ResultVOUtil.success(labTimeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.hzu.bookingsystem.converter;
|
||||||
|
|
||||||
|
import com.hzu.bookingsystem.bean.LabBean;
|
||||||
|
import com.hzu.bookingsystem.dto.LabDTO;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class LabBean2LabDTO {
|
||||||
|
public static LabDTO convert(LabBean lab) {
|
||||||
|
|
||||||
|
LabDTO labDTO = new LabDTO();
|
||||||
|
BeanUtils.copyProperties(lab, labDTO);
|
||||||
|
return labDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<LabDTO> convert(List<LabBean> labList) {
|
||||||
|
return labList.stream().map(LabBean2LabDTO::convert)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.hzu.bookingsystem.converter;
|
||||||
|
|
||||||
|
import com.hzu.bookingsystem.bean.LabTimeBean;
|
||||||
|
import com.hzu.bookingsystem.dto.LabTimeDTO;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class LabTimeBean2LabTimeDTO {
|
||||||
|
public static LabTimeDTO convert(LabTimeBean labTime) {
|
||||||
|
|
||||||
|
LabTimeDTO labTimeDTO = new LabTimeDTO();
|
||||||
|
BeanUtils.copyProperties(labTime, labTimeDTO);
|
||||||
|
return labTimeDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<LabTimeDTO> convert(List<LabTimeBean> labList) {
|
||||||
|
return labList.stream().map(LabTimeBean2LabTimeDTO::convert)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.hzu.bookingsystem.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LabDTO {
|
||||||
|
private Integer labId;
|
||||||
|
// 管理员uID
|
||||||
|
private Integer managerId;
|
||||||
|
|
||||||
|
// 实验室名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 实验室地点
|
||||||
|
private String position;
|
||||||
|
|
||||||
|
// 实验室容量
|
||||||
|
private Integer capacity;
|
||||||
|
|
||||||
|
// 实验室含有的软件(逗号隔开)
|
||||||
|
private String software;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.hzu.bookingsystem.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LabTimeDTO {
|
||||||
|
private Integer ltId;
|
||||||
|
|
||||||
|
// 创建者uID
|
||||||
|
private Integer creatorId;
|
||||||
|
|
||||||
|
// 实验室ID
|
||||||
|
private Integer labId;
|
||||||
|
|
||||||
|
// 学年
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
// 学期
|
||||||
|
private String semester;
|
||||||
|
|
||||||
|
// 几周
|
||||||
|
private String week;
|
||||||
|
|
||||||
|
// 周几
|
||||||
|
private String day;
|
||||||
|
|
||||||
|
// 第几节课
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
// 状态
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
//备注
|
||||||
|
private String remind;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
Loading…
Reference in new issue