TConfInfoController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package com.ruoyi.project.plant.controller;
  2. import java.util.List;
  3. import com.ruoyi.project.plant.domain.TConfRoom;
  4. import com.ruoyi.project.plant.mapper.TConfInfoMapper;
  5. import com.ruoyi.project.plant.mapper.TConfRoomMapper;
  6. import com.ruoyi.project.plant.service.ITConfRoomService;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.framework.aspectj.lang.annotation.Log;
  18. import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
  19. import com.ruoyi.project.plant.domain.TConfInfo;
  20. import com.ruoyi.project.plant.service.ITConfInfoService;
  21. import com.ruoyi.framework.web.controller.BaseController;
  22. import com.ruoyi.framework.web.domain.AjaxResult;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.framework.web.page.TableDataInfo;
  25. import javax.annotation.Resource;
  26. /**
  27. * 会议预约信息Controller
  28. *
  29. * @author ssy
  30. * @date 2024-05-07
  31. */
  32. @RestController
  33. @RequestMapping("/plant/confInfo")
  34. public class TConfInfoController extends BaseController
  35. {
  36. @Autowired
  37. private ITConfInfoService tConfInfoService;
  38. @Autowired
  39. private ITConfRoomService tConfRoomService;
  40. @Resource
  41. private TConfRoomMapper tConfRoomMapper;
  42. @Resource
  43. private TConfInfoMapper tConfInfoMapper;
  44. /**
  45. * 查询会议预约信息列表
  46. */
  47. @PreAuthorize("@ss.hasPermi('plant:confInfo:list')")
  48. @GetMapping("/list")
  49. public TableDataInfo list(TConfInfo tConfInfo)
  50. {
  51. startPage();
  52. List<TConfInfo> list = tConfInfoService.selectTConfInfoList(tConfInfo);
  53. return getDataTable(list);
  54. }
  55. /**
  56. * 导出会议预约信息列表
  57. */
  58. @PreAuthorize("@ss.hasPermi('plant:confInfo:export')")
  59. @Log(title = "会议预约信息", businessType = BusinessType.EXPORT)
  60. @GetMapping("/export")
  61. public AjaxResult export(TConfInfo tConfInfo)
  62. {
  63. List<TConfInfo> list = tConfInfoService.selectTConfInfoList(tConfInfo);
  64. ExcelUtil<TConfInfo> util = new ExcelUtil<TConfInfo>(TConfInfo.class);
  65. return util.exportExcel(list, "confInfo");
  66. }
  67. /**
  68. * 获取会议预约信息详细信息
  69. */
  70. @PreAuthorize("@ss.hasPermi('plant:confInfo:query')")
  71. @GetMapping(value = "/{id}")
  72. public AjaxResult getInfo(@PathVariable("id") Long id)
  73. {
  74. return AjaxResult.success(tConfInfoService.selectTConfInfoById(id));
  75. }
  76. /**
  77. * 新增会议预约信息
  78. */
  79. @PreAuthorize("@ss.hasPermi('plant:confInfo:add')")
  80. @Log(title = "会议预约信息", businessType = BusinessType.INSERT)
  81. @PostMapping
  82. public AjaxResult add(@RequestBody TConfInfo tConfInfo)
  83. {
  84. //判断会议时间是否合法
  85. if (!this.checktime(tConfInfo)) {
  86. return AjaxResult.error("会议时间冲突");
  87. }
  88. TConfRoom room = tConfRoomService.selectTConfRoomById(tConfInfo.getRoomId());
  89. tConfInfo.setRoomName(room.getRoomName());
  90. return toAjax(tConfInfoService.insertTConfInfo(tConfInfo));
  91. }
  92. /**
  93. * 修改会议预约信息
  94. */
  95. @PreAuthorize("@ss.hasPermi('plant:confInfo:edit')")
  96. @Log(title = "会议预约信息", businessType = BusinessType.UPDATE)
  97. @PutMapping
  98. public AjaxResult edit(@RequestBody TConfInfo tConfInfo)
  99. {
  100. TConfRoom room = tConfRoomService.selectTConfRoomById(tConfInfo.getRoomId());
  101. tConfInfo.setRoomName(room.getRoomName());
  102. return toAjax(tConfInfoService.updateTConfInfo(tConfInfo));
  103. }
  104. /**
  105. * 删除会议预约信息
  106. */
  107. @PreAuthorize("@ss.hasPermi('plant:confInfo:remove')")
  108. @Log(title = "会议预约信息", businessType = BusinessType.DELETE)
  109. @DeleteMapping("/{ids}")
  110. public AjaxResult remove(@PathVariable Long[] ids)
  111. {
  112. return toAjax(tConfInfoService.deleteTConfInfoByIds(ids));
  113. }
  114. public boolean checktime(TConfInfo tConfInfo) {
  115. List<TConfInfo> list = tConfInfoMapper.selectTConfInfoByTime(tConfInfo);
  116. if (list.size() > 0) {
  117. return false;
  118. }
  119. return true;
  120. };
  121. }