package com.fdkankan.scene.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fdkankan.common.constant.ErrorCode; import com.fdkankan.common.exception.BusinessException; import com.fdkankan.common.response.ResultData; import com.fdkankan.scene.entity.SceneApply; import com.fdkankan.scene.service.ISceneApplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * * @author * @since 2022-04-27 */ @RestController @RequestMapping("/api/demo/scene") public class SceneApplyController { @Autowired private ISceneApplyService sceneApplyService; /** * 新增演示场景申请 */ @PostMapping("/save") public ResultData save(@RequestBody SceneApply sceneApplyEntity){ sceneApplyService.save(sceneApplyEntity); return ResultData.ok(); } @PostMapping("/pageList") public ResultData pageList(@RequestBody JSONObject param){ Integer page =param.get("pageNum") == null ? 1 : param.getInteger("pageNum"); Integer pageSize =param.get("pageSize") == null ? 10 : param.getInteger("pageSize"); return ResultData.ok(sceneApplyService.page(new Page<>(page,pageSize))); } @PostMapping("/delete") public ResultData delete(@RequestBody JSONObject param){ if(param.get("id") == null){ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS); } sceneApplyService.removeById(param.getInteger("id")); return ResultData.ok(); } }