package com.hxzk.controller;
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.TbZypGround;
import com.hxzk.service.TbZypGroundService;
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-23
*/
@RestController
@RequestMapping("/")
public class TbZypGroundController {
@Autowired
TbZypGroundService tbZypGroundService;
@GetMapping("findZypGround")
result> findZypGround(Integer page, Integer limit) {
PageInfo cz = tbZypGroundService.findAll(page, limit);
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
}
@PostMapping("findZypGroundSearch")
result> findZypGroundSearch(Integer page, Integer limit, String applicant, String code) {
PageInfo cz = tbZypGroundService.findSearch(page, limit, applicant, code);
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
}
@GetMapping("findtIdZypGround")
public TbZypGround findtIdZypGround(Integer id) {
return tbZypGroundService.findtagidZypGround(id);
}
@PostMapping("addZypGround")
public void addZypGround(TbZypGround tbZypGround, HttpServletResponse response) throws IOException {
if (tbZypGround.getStartDate() != "" && tbZypGround.getEndDate() != "") {
tbZypGround.setHottime("自" + tbZypGround.getStartDate() + "至" + tbZypGround.getEndDate() + "止");
}
if (tbZypGround.getId() != null) {
tbZypGroundService.updateZypGround(tbZypGround);
} else {
tbZypGroundService.addZypGround(tbZypGround);
}
// 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/Ground.jsp");
}
@PostMapping("updateZypGround")
public void updateZypGround(TbZypGround tbZypGround, HttpServletResponse response) throws IOException {
// smsReminder.setAddtime(gettime());
tbZypGroundService.updateZypGround(tbZypGround);
response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Ground.jsp");
}
@GetMapping("deleteZypGround")
public void deleteZypGround(Integer id, HttpServletResponse response) throws IOException {
tbZypGroundService.deleteZypGround(id);
response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Ground.jsp");
}
}