|
|
@@ -0,0 +1,121 @@
|
|
|
+package com.xjrsoft.module.base.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.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.dto.AddOdsZzxxgkjcsjDto;
|
|
|
+import com.xjrsoft.module.base.dto.OdsZzxxgkjcsjListDto;
|
|
|
+import com.xjrsoft.module.base.dto.UpdateOdsZzxxgkjcsjDto;
|
|
|
+import com.xjrsoft.module.base.entity.OdsZzxxgkjcsj;
|
|
|
+import com.xjrsoft.module.base.service.IOdsZzxxgkjcsjService;
|
|
|
+import com.xjrsoft.module.base.vo.OdsZzxxgkjcsjListVo;
|
|
|
+import com.xjrsoft.module.base.vo.OdsZzxxgkjcsjVo;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 学校基本数据子类表
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2024-12-12
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/base" + "/odsZzxxgkjcsj")
|
|
|
+@Api(value = "/base" + "/odsZzxxgkjcsj",tags = "学校基本数据子类表代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class OdsZzxxgkjcsjController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IOdsZzxxgkjcsjService odsZzxxgkjcsjService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ @ApiOperation(value="学校基本数据子类表列表(不分页)")
|
|
|
+ @SaCheckPermission("odszzxxgkjcsj:detail")
|
|
|
+ public RT<List<OdsZzxxgkjcsjListVo>> list(@Valid OdsZzxxgkjcsjListDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<OdsZzxxgkjcsj> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(OdsZzxxgkjcsj::getId)
|
|
|
+ .select(OdsZzxxgkjcsj.class,x -> VoToColumnUtil.fieldsToColumns(OdsZzxxgkjcsjListVo.class).contains(x.getProperty()));
|
|
|
+
|
|
|
+ List<OdsZzxxgkjcsj> list = odsZzxxgkjcsjService.list(queryWrapper);
|
|
|
+ List<OdsZzxxgkjcsjListVo> listVos = BeanUtil.copyToList(list, OdsZzxxgkjcsjListVo.class);
|
|
|
+ return RT.ok(listVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询学校基本数据子类表信息")
|
|
|
+ @SaCheckPermission("odszzxxgkjcsj:detail")
|
|
|
+ public RT<OdsZzxxgkjcsjVo> info(@RequestParam Long id){
|
|
|
+ OdsZzxxgkjcsj odsZzxxgkjcsj = odsZzxxgkjcsjService.getById(id);
|
|
|
+ if (odsZzxxgkjcsj == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(odsZzxxgkjcsj, OdsZzxxgkjcsjVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增学校基本数据子类表")
|
|
|
+ @SaCheckPermission("odszzxxgkjcsj:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddOdsZzxxgkjcsjDto dto){
|
|
|
+ OdsZzxxgkjcsj odsZzxxgkjcsj = BeanUtil.toBean(dto, OdsZzxxgkjcsj.class);
|
|
|
+ boolean isSuccess = odsZzxxgkjcsjService.save(odsZzxxgkjcsj);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改学校基本数据子类表")
|
|
|
+ @SaCheckPermission("odszzxxgkjcsj:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateOdsZzxxgkjcsjDto dto){
|
|
|
+
|
|
|
+ OdsZzxxgkjcsj odsZzxxgkjcsj = BeanUtil.toBean(dto, OdsZzxxgkjcsj.class);
|
|
|
+ return RT.ok(odsZzxxgkjcsjService.updateById(odsZzxxgkjcsj));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除学校基本数据子类表")
|
|
|
+ @SaCheckPermission("odszzxxgkjcsj:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(odsZzxxgkjcsjService.removeBatchByIds(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+ @PostMapping("/import")
|
|
|
+ @ApiOperation(value = "导入")
|
|
|
+ public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
+ List<OdsZzxxgkjcsjListVo> savedDataList = EasyExcel.read(file.getInputStream()).head(OdsZzxxgkjcsjListVo.class).sheet().doReadSync();
|
|
|
+ Boolean result = odsZzxxgkjcsjService.saveBatch(BeanUtil.copyToList(savedDataList, OdsZzxxgkjcsj.class));
|
|
|
+ return RT.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ public ResponseEntity<byte[]> exportData(@Valid OdsZzxxgkjcsjListDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
|
|
|
+ List<OdsZzxxgkjcsjListVo> customerList = (List<OdsZzxxgkjcsjListVo>) list(dto).getData();
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(bot, OdsZzxxgkjcsjListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
|
|
|
+
|
|
|
+ return RT.fileStream(bot.toByteArray(), "OdsZzxxgkjcsj" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ }
|
|
|
+}
|