AppFileController.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.fdkankan.manage.controller;
  2. import com.fdkankan.manage.common.ResultCode;
  3. import com.fdkankan.manage.exception.BusinessException;
  4. import com.fdkankan.manage.common.ResultData;
  5. import com.fdkankan.common.util.FileMd5Util;
  6. import com.fdkankan.manage.entity.AppFile;
  7. import com.fdkankan.manage.service.IAppFileService;
  8. import com.fdkankan.manage.vo.request.AppFileParam;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.util.ObjectUtils;
  11. import org.springframework.web.bind.annotation.*;
  12. import org.springframework.web.multipart.MultipartFile;
  13. import java.util.HashMap;
  14. import java.util.Map;
  15. /**
  16. * 产品管理/app管理
  17. */
  18. @RestController
  19. @RequestMapping("/service/manage/appFile")
  20. public class AppFileController {
  21. @Autowired
  22. IAppFileService appFileService;
  23. @PostMapping(value = "/upload", consumes = { "multipart/form-data" })
  24. private ResultData upload(@RequestParam(required = false) MultipartFile file) {
  25. // 将文件转字节-> 字符串
  26. return ResultData.ok(appFileService.upload(file));
  27. }
  28. @PostMapping(value = "/add")
  29. private ResultData add(@RequestBody AppFile param) {
  30. appFileService.saveByParam(param);
  31. return ResultData.ok();
  32. }
  33. @GetMapping(value = "/agentList")
  34. private ResultData agentList(@RequestParam(required = false) String agentName ) {
  35. return ResultData.ok(appFileService.agentList(agentName));
  36. }
  37. @PostMapping(value = "/list")
  38. private ResultData list(@RequestBody AppFileParam param) {
  39. return ResultData.ok(appFileService.pageList(param));
  40. }
  41. @PostMapping(value = "/delete")
  42. private ResultData delete(@RequestBody AppFile param) {
  43. if(ObjectUtils.isEmpty(param.getId())){
  44. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  45. }
  46. appFileService.removeById(param.getId());
  47. return ResultData.ok();
  48. }
  49. }