| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.fdage.followheartplay.controller;
- import com.fdage.followheartplay.dto.SceneDto;
- import com.fdage.followheartplay.service.SceneService;
- import com.fdkankan.common.constant.ServerCode;
- import com.fdkankan.common.response.ResultData;
- import com.fdkankan.common.util.JwtUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestHeader;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- @RestController
- @RequestMapping("/scene")
- public class SceneController {
- @Autowired
- private SceneService sceneService;
- /**
- * 查询场景信息
- * @param token
- * @param type 0:未购买,1:已购买,空全部
- * @return
- */
- @PostMapping("/list")
- public ResultData getScenes(@RequestHeader String token, Integer type){
- String username = JwtUtil.getUsername(token);
- List<SceneDto> sceneEntities = sceneService.getScenesByTypeAndUserId(username,type);
- return ResultData.ok(sceneEntities);
- }
- /**
- * 查询场景信息
- * @param token
- * @param sceneId
- * @return
- */
- @PostMapping("/buy")
- public ResultData buy(@RequestHeader String token, Integer sceneId){
- if(ObjectUtils.isEmpty(sceneId)){
- return ResultData.error(ServerCode.PARAM_REQUIRED.code(),"缺少必要参数!");
- }
- String username = JwtUtil.getUsername(token);
- sceneService.buy(username,sceneId);
- return ResultData.ok();
- }
- }
|