|
|
@ -2,14 +2,17 @@ package com.hzu.bookingsystem.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.bean.LabBean;
|
|
|
|
import com.hzu.bookingsystem.bean.LabBean;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.bean.LabTimeBean;
|
|
|
|
import com.hzu.bookingsystem.converter.Map2Object;
|
|
|
|
import com.hzu.bookingsystem.converter.Map2Object;
|
|
|
|
import com.hzu.bookingsystem.dto.LabDTO;
|
|
|
|
import com.hzu.bookingsystem.dto.LabDTO;
|
|
|
|
import com.hzu.bookingsystem.service.LabService;
|
|
|
|
import com.hzu.bookingsystem.service.LabService;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.service.LabTimeService;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -19,19 +22,36 @@ import java.util.Map;
|
|
|
|
public class LabController {
|
|
|
|
public class LabController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private LabService labService;
|
|
|
|
private LabService labService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private LabTimeService labTimeService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private UserController userController;
|
|
|
|
|
|
|
|
|
|
|
|
//创建实验室
|
|
|
|
//创建实验室
|
|
|
|
@PostMapping(value = "/addLab", consumes = "application/json")
|
|
|
|
@PostMapping(value = "/addLab", consumes = "application/json")
|
|
|
|
public ResultVO addLab(@RequestBody Map<String,Object> map){
|
|
|
|
public ResultVO addLab(@RequestBody Map<String, Object> map, HttpServletRequest request) {
|
|
|
|
//转换对象
|
|
|
|
//转换对象
|
|
|
|
|
|
|
|
System.out.println(map);
|
|
|
|
LabBean lab1 = (LabBean) Map2Object.map2Object(map, LabBean.class);
|
|
|
|
LabBean lab1 = (LabBean) Map2Object.map2Object(map, LabBean.class);
|
|
|
|
System.out.println(lab1);
|
|
|
|
//判断是否
|
|
|
|
//查重
|
|
|
|
LabBean newLab = labService.add(lab1);
|
|
|
|
if(labService.findByName(lab1.getName()) != null)
|
|
|
|
// 插入16周所有可选时间段
|
|
|
|
{
|
|
|
|
if ((Boolean) map.get("fastInsert")) {
|
|
|
|
return ResultVOUtil.error(-1,"该实验室已存在");
|
|
|
|
LabTimeBean labTime1 = (LabTimeBean) Map2Object.map2Object(map, LabTimeBean.class);
|
|
|
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
|
|
|
for (int j = 1; j <= 5; j++) {
|
|
|
|
|
|
|
|
for (int k = 1; k <= 16; k++) {
|
|
|
|
|
|
|
|
labTimeService.add(LabTimeBean.builder()
|
|
|
|
|
|
|
|
.labId(newLab.getLabId())
|
|
|
|
|
|
|
|
.year(labTime1.getYear()).semester(labTime1.getSemester()).week(k).day(i).time(j)
|
|
|
|
|
|
|
|
.creatorId(userController.getUIdByCookie(request))
|
|
|
|
|
|
|
|
.status(0)
|
|
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
labService.add(lab1);
|
|
|
|
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|