|
@@ -0,0 +1,94 @@
|
|
|
+package com.xjrsoft.module.room.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.room.dto.AddRoomStudentAppointDto;
|
|
|
+import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
|
|
|
+import com.xjrsoft.module.room.dto.UpdateRoomStudentAppointDto;
|
|
|
+import com.xjrsoft.module.room.entity.RoomStudentAppoint;
|
|
|
+import com.xjrsoft.module.room.service.IRoomStudentAppointService;
|
|
|
+import com.xjrsoft.module.room.vo.RoomStudentAppointPageVo;
|
|
|
+import com.xjrsoft.module.room.vo.RoomStudentAppointVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 寝室长任命
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2023-12-30
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/room" + "/roomStudentAppoint")
|
|
|
+@Api(value = "/room" + "/roomStudentAppoint",tags = "寝室干部任命代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class RoomStudentAppointController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IRoomStudentAppointService roomStudentAppointService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="寝室干部任命列表(分页)")
|
|
|
+ @SaCheckPermission("roomstudentappoint:detail")
|
|
|
+ public RT<PageOutput<RoomStudentAppointPageVo>> page(@Valid RoomStudentAppointPageDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RoomStudentAppoint> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(RoomStudentAppoint::getId)
|
|
|
+ .select(RoomStudentAppoint.class,x -> VoToColumnUtil.fieldsToColumns(RoomStudentAppointPageVo.class).contains(x.getProperty()));
|
|
|
+ IPage<RoomStudentAppoint> page = roomStudentAppointService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<RoomStudentAppointPageVo> pageOutput = ConventPage.getPageOutput(page, RoomStudentAppointPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询寝室干部信息")
|
|
|
+ @SaCheckPermission("roomstudentappoint:detail")
|
|
|
+ public RT<RoomStudentAppointVo> info(@RequestParam Long id){
|
|
|
+ RoomStudentAppoint roomStudentAppoint = roomStudentAppointService.getById(id);
|
|
|
+ if (roomStudentAppoint == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(roomStudentAppoint, RoomStudentAppointVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增寝室干部任命")
|
|
|
+ @SaCheckPermission("roomstudentappoint:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddRoomStudentAppointDto dto){
|
|
|
+ RoomStudentAppoint roomStudentAppoint = BeanUtil.toBean(dto, RoomStudentAppoint.class);
|
|
|
+ boolean isSuccess = roomStudentAppointService.save(roomStudentAppoint);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改寝室干部任命")
|
|
|
+ @SaCheckPermission("roomstudentappoint:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateRoomStudentAppointDto dto){
|
|
|
+
|
|
|
+ RoomStudentAppoint roomStudentAppoint = BeanUtil.toBean(dto, RoomStudentAppoint.class);
|
|
|
+ return RT.ok(roomStudentAppointService.updateById(roomStudentAppoint));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除寝室干部任命")
|
|
|
+ @SaCheckPermission("roomstudentappoint:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(roomStudentAppointService.removeBatchByIds(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|