package com.hxzk.controller;
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.TbZypSpace;
import com.hxzk.service.TbZypSpaceService;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
*
* 航锦化工受限空间安全作业证 前端控制器
*
*
* @author wangfei
* @since 2024-04-22
*/
@RestController
@RequestMapping("/")
public class TbZypSpaceController {
@Autowired
TbZypSpaceService tbZypSpaceService;
@GetMapping("findSpace")
result> findDongHuo(Integer page, Integer limit) {
PageInfo cz = tbZypSpaceService.findAll(page, limit);
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
}
@PostMapping("findSpaceSearch")
result> findSpaceSearch(Integer page, Integer limit, String applicant, String code) {
PageInfo cz = tbZypSpaceService.findSearch(page, limit, applicant, code);
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
}
@GetMapping("findtIdSpace")
public TbZypSpace findtIdSpace(Integer id) {
return tbZypSpaceService.findtagidSpace(id);
}
@PostMapping("addSpace")
public void addSpace(TbZypSpace tbZypSpace, HttpServletResponse response) throws IOException {
if (tbZypSpace.getStartDate() != null) {
tbZypSpace.setHottime("自" + tbZypSpace.getStartDate() + "至" + tbZypSpace.getEndDate() + "止");
}
if (tbZypSpace.getId() != null) {
tbZypSpaceService.updateSpace(tbZypSpace);
} else {
tbZypSpaceService.addSpace(tbZypSpace);
}
// Calendar calendar = Calendar.getInstance();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String dateStr = sdf.format(calendar.getTime());
// company.setAddtime(dateStr);
// TbScreenSettings screenSettings = new TbScreenSettings();
// screenSettings.setCompanyname(company.getCompanyname());
// screenService.AddScreen(screenSettings);
// TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
// systemOperationLog.setName(UserController.username);
// systemOperationLog.setTime(gettime());
// systemOperationLog.setContent("增加了一个公司,该公司名称为:"+company.getCompanyname());
// systemLogService.insertSystem(systemOperationLog);
response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Space.jsp");
}
@PostMapping("updateSpace")
public void updateSpace(TbZypSpace tbZypSpace, HttpServletResponse response) throws IOException {
// smsReminder.setAddtime(gettime());
tbZypSpaceService.updateSpace(tbZypSpace);
response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Space.jsp");
}
@GetMapping("deleteSpace")
public void deleteSpace(Integer id, HttpServletResponse response) throws IOException {
tbZypSpaceService.deleteSpace(id);
response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Space.jsp");
}
}