|
@@ -1,39 +1,20 @@
|
|
|
package com.xjrsoft.module.schedule.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.alibaba.excel.EasyExcel;
|
|
|
-import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
-import com.xjrsoft.common.page.ConventPage;
|
|
|
-import com.xjrsoft.common.page.PageOutput;
|
|
|
-import com.xjrsoft.module.room.dto.AddRoomDto;
|
|
|
-import com.xjrsoft.module.room.dto.RoomPageDto;
|
|
|
-import com.xjrsoft.module.room.dto.UpdateRoomDto;
|
|
|
-import com.xjrsoft.module.room.entity.Room;
|
|
|
-import com.xjrsoft.module.room.service.IRoomService;
|
|
|
-import com.xjrsoft.module.room.vo.RoomExcelVo;
|
|
|
-import com.xjrsoft.module.room.vo.RoomPageVo;
|
|
|
-import com.xjrsoft.module.room.vo.RoomVo;
|
|
|
+import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
|
|
|
+import com.xjrsoft.module.schedule.service.ICourseReceiveMsgService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* @title: 寝室
|
|
@@ -48,75 +29,25 @@ import java.util.List;
|
|
|
public class ScheduleController {
|
|
|
|
|
|
|
|
|
- private final IRoomService roomService;
|
|
|
+ private final ICourseReceiveMsgService courseReceiveMsgService;
|
|
|
|
|
|
@GetMapping(value = "/receive-msg")
|
|
|
@ApiOperation(value="接收消息")
|
|
|
@SaCheckPermission("room:detail")
|
|
|
public RT<Boolean> receiveMsg(@RequestParam String schoolId, @RequestParam String eduYearSerialNo, @RequestParam String startDate, @RequestParam String endDate){
|
|
|
-
|
|
|
+ CourseReceiveMsg courseReceiveMsg = new CourseReceiveMsg();
|
|
|
+ courseReceiveMsg.setCreateDate(new Date());
|
|
|
+ courseReceiveMsg.setSchoolId(schoolId);
|
|
|
+ courseReceiveMsg.setEduYearSerialNo(eduYearSerialNo);
|
|
|
+ courseReceiveMsg.setStartDate(startDate);
|
|
|
+ courseReceiveMsg.setEndDate(endDate);
|
|
|
+ courseReceiveMsg.setDeleteMark(DeleteMark.NODELETE.getCode());
|
|
|
+ courseReceiveMsg.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
+ courseReceiveMsgService.save(courseReceiveMsg);
|
|
|
return RT.ok(true);
|
|
|
}
|
|
|
|
|
|
- @GetMapping(value = "/info")
|
|
|
- @ApiOperation(value="根据id查询寝室信息")
|
|
|
- @SaCheckPermission("room:detail")
|
|
|
- public RT<RoomVo> info(@RequestParam Long id){
|
|
|
- Room room = roomService.getById(id);
|
|
|
- if (room == null) {
|
|
|
- return RT.error("找不到此数据!");
|
|
|
- }
|
|
|
- return RT.ok(BeanUtil.toBean(room, RoomVo.class));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping
|
|
|
- @ApiOperation(value = "新增寝室")
|
|
|
- @SaCheckPermission("room:add")
|
|
|
- public RT<String> add(@Valid @RequestBody AddRoomDto dto){
|
|
|
- String message = roomService.saveBatch(dto);
|
|
|
- if("ok".equals(message)){
|
|
|
- return RT.ok("true");
|
|
|
- }
|
|
|
- return RT.ok(message);
|
|
|
- }
|
|
|
-
|
|
|
- @PutMapping
|
|
|
- @ApiOperation(value = "修改寝室")
|
|
|
- @SaCheckPermission("room:edit")
|
|
|
- public RT<Boolean> update(@Valid @RequestBody UpdateRoomDto dto){
|
|
|
|
|
|
- Room room = BeanUtil.toBean(dto, Room.class);
|
|
|
- return RT.ok(roomService.updateById(room));
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- @DeleteMapping
|
|
|
- @ApiOperation(value = "删除寝室")
|
|
|
- @SaCheckPermission("room:delete")
|
|
|
- public RT<Boolean> delete(@Valid @RequestBody Long id){
|
|
|
- String result = roomService.deleteReachBed(id);
|
|
|
- if("ok".equals(result)){
|
|
|
- return RT.ok(true);
|
|
|
- }
|
|
|
- return RT.error(result);
|
|
|
|
|
|
- }
|
|
|
- @PostMapping("/import")
|
|
|
- @ApiOperation(value = "导入")
|
|
|
- public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
- List<RoomPageVo> savedDataList = EasyExcel.read(file.getInputStream()).head(RoomPageVo.class).sheet().doReadSync();
|
|
|
- Boolean result = roomService.saveBatch(BeanUtil.copyToList(savedDataList, Room.class));
|
|
|
- return RT.ok(result);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/export")
|
|
|
- @ApiOperation(value = "导出")
|
|
|
- public ResponseEntity<byte[]> exportData(@Valid RoomPageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
|
|
|
- List<RoomExcelVo> customerList = roomService.getList(dto);
|
|
|
- ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
- EasyExcel.write(bot, RoomExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
|
|
|
-
|
|
|
- return RT.fileStream(bot.toByteArray(), "Room" + ExcelTypeEnum.XLSX.getValue());
|
|
|
- }
|
|
|
}
|