|
|
@@ -0,0 +1,111 @@
|
|
|
+package com.xjrsoft.module.student.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+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.student.dto.AddBaseNewStudentDto;
|
|
|
+import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
|
|
|
+import com.xjrsoft.module.student.dto.UpdateBaseNewStudentDto;
|
|
|
+import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
|
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
|
|
|
+import com.xjrsoft.module.student.vo.BaseNewStudentVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+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.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 新生维护信息
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2024-06-27
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/student" + "/baseNewStudent")
|
|
|
+@Api(value = "/student" + "/baseNewStudent",tags = "新生维护信息代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class BaseNewStudentController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IBaseNewStudentService baseNewStudentService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="新生维护信息列表(分页)")
|
|
|
+ @SaCheckPermission("basenewstudent:detail")
|
|
|
+ public RT<PageOutput<BaseNewStudentPageVo>> page(@Valid BaseNewStudentPageDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BaseNewStudent> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(BaseNewStudent::getId)
|
|
|
+ .select(BaseNewStudent.class,x -> VoToColumnUtil.fieldsToColumns(BaseNewStudentPageVo.class).contains(x.getProperty()));
|
|
|
+ IPage<BaseNewStudent> page = baseNewStudentService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<BaseNewStudentPageVo> pageOutput = ConventPage.getPageOutput(page, BaseNewStudentPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询新生维护信息信息")
|
|
|
+ @SaCheckPermission("basenewstudent:detail")
|
|
|
+ public RT<BaseNewStudentVo> info(@RequestParam Long id){
|
|
|
+ BaseNewStudent baseNewStudent = baseNewStudentService.getById(id);
|
|
|
+ if (baseNewStudent == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(baseNewStudent, BaseNewStudentVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增新生维护信息")
|
|
|
+ @SaCheckPermission("basenewstudent:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddBaseNewStudentDto dto){
|
|
|
+ BaseNewStudent baseNewStudent = BeanUtil.toBean(dto, BaseNewStudent.class);
|
|
|
+ boolean isSuccess = baseNewStudentService.save(baseNewStudent);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改新生维护信息")
|
|
|
+ @SaCheckPermission("basenewstudent:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateBaseNewStudentDto dto){
|
|
|
+
|
|
|
+ BaseNewStudent baseNewStudent = BeanUtil.toBean(dto, BaseNewStudent.class);
|
|
|
+ return RT.ok(baseNewStudentService.updateById(baseNewStudent));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除新生维护信息")
|
|
|
+ @SaCheckPermission("basenewstudent:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(baseNewStudentService.removeBatchByIds(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+ @PostMapping("/import")
|
|
|
+ @ApiOperation(value = "导入")
|
|
|
+ public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
+ List<BaseNewStudentPageVo> savedDataList = EasyExcel.read(file.getInputStream()).head(BaseNewStudentPageVo.class).sheet().doReadSync();
|
|
|
+ Boolean result = baseNewStudentService.saveBatch(BeanUtil.copyToList(savedDataList, BaseNewStudent.class));
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|