SceneApplyController.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.fdkankan.scene.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.fdkankan.common.constant.ErrorCode;
  5. import com.fdkankan.common.exception.BusinessException;
  6. import com.fdkankan.common.response.ResultData;
  7. import com.fdkankan.scene.entity.SceneApply;
  8. import com.fdkankan.scene.service.ISceneApplyService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. /**
  15. *
  16. * @author
  17. * @since 2022-04-27
  18. */
  19. @RestController
  20. @RequestMapping("/api/demo/scene")
  21. public class SceneApplyController {
  22. @Autowired
  23. private ISceneApplyService sceneApplyService;
  24. /**
  25. * 新增演示场景申请
  26. */
  27. @PostMapping("/save")
  28. public ResultData save(@RequestBody SceneApply sceneApplyEntity){
  29. sceneApplyService.save(sceneApplyEntity);
  30. return ResultData.ok();
  31. }
  32. @PostMapping("/pageList")
  33. public ResultData pageList(@RequestBody JSONObject param){
  34. Integer page =param.get("pageNum") == null ? 1 : param.getInteger("pageNum");
  35. Integer pageSize =param.get("pageSize") == null ? 10 : param.getInteger("pageSize");
  36. return ResultData.ok(sceneApplyService.page(new Page<>(page,pageSize)));
  37. }
  38. @PostMapping("/delete")
  39. public ResultData delete(@RequestBody JSONObject param){
  40. if(param.get("id") == null){
  41. throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
  42. }
  43. sceneApplyService.removeById(param.getInteger("id"));
  44. return ResultData.ok();
  45. }
  46. }