From 1fb74d90c124303a3aa9b0f3f6733f31432f3dec Mon Sep 17 00:00:00 2001 From: pxh4iabou <2044878308@qq.com> Date: Sun, 30 Apr 2023 01:24:30 +0800 Subject: [PATCH] ADD file via upload --- .../com/controller/CollectInfoController.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/main/java/com/controller/CollectInfoController.java diff --git a/src/main/java/com/controller/CollectInfoController.java b/src/main/java/com/controller/CollectInfoController.java new file mode 100644 index 0000000..b99021c --- /dev/null +++ b/src/main/java/com/controller/CollectInfoController.java @@ -0,0 +1,74 @@ +package com.example.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import com.example.common.Result; +import com.example.common.ResultCode; +import com.example.entity.CollectInfo; +import com.example.service.*; +import com.example.vo.CollectInfoVo; +import com.example.vo.CollectInfoVo; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping(value = "/collectInfo") +public class CollectInfoController { + @Resource + private CollectInfoService collectInfoService; + + @PostMapping + public Result add(@RequestBody CollectInfoVo collectInfo, HttpServletRequest request) { + collectInfoService.add(collectInfo, request); + return Result.success(collectInfo); + } + + @DeleteMapping("/{id}") + public Result delete(@PathVariable Long id) { + collectInfoService.delete(id); + return Result.success(); + } + + @PutMapping + public Result update(@RequestBody CollectInfoVo collectInfo) { + collectInfoService.update(collectInfo); + return Result.success(); + } + + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + CollectInfo collectInfo = collectInfoService.findById(id); + return Result.success(collectInfo); + } + + @GetMapping + public Result> all() { + return Result.success(collectInfoService.findAll()); + } + + @GetMapping("/page/{name}") + public Result> page(@PathVariable String name, + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "5") Integer pageSize, + HttpServletRequest request) { + return Result.success(collectInfoService.findPage(name, pageNum, pageSize, request)); + } + +}