package com.qiwuai.garden.controller; import com.qiwuai.garden.common.utils.RequestConversionUtil; import com.qiwuai.garden.dto.base.CommonRequest; import com.qiwuai.garden.dto.base.CommonResponse; import com.qiwuai.garden.dto.base.ResultResponse; import com.qiwuai.garden.dto.request.CallRequest; import com.qiwuai.garden.dto.request.OperationRequest; import com.qiwuai.garden.service.backPackService.BackPackService; import com.qiwuai.garden.service.gardenerService.GardenerService; import com.qiwuai.garden.service.marketService.MarketService; import com.qiwuai.garden.service.nurseryService.NurseryService; import com.qiwuai.garden.service.petService.PetService; import com.qiwuai.garden.service.plantService.PlantService; 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; @RestController @RequestMapping("/secretGarden") public class CommonController { @Autowired private GardenerService gardenerService; @Autowired private NurseryService nurseryService; @Autowired private PlantService plantService; @Autowired private BackPackService backPackService; @Autowired private PetService petService; @Autowired private MarketService marketService; @PostMapping(value = "/call", produces = "application/json;charset=UTF-8") public CommonResponse createGardener(@RequestBody CommonRequest commonRequest) { OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); CommonResponse result = new CommonResponse(); switch (commonRequest.getVars().get操作名()) { case "种植": result = plantService.seedCheck(operationReq); break; case "确认种植": result = plantService.seed(operationReq); break; case "取消种植": result = plantService.seedCancel(operationReq); break; case "铲除植物": result = plantService.clearPlantCheck(operationReq); break; case "收获并铲除植物": result = plantService.clearAfterHarvest(operationReq); break; case "确认铲除植物": result = plantService.clearPlant(operationReq); break; case "取消铲除植物": result = plantService.clearPlantCancel(operationReq); break; case "查看花圃升级类型": result = nurseryService.searchNurseryToType(operationReq); break; case "查看花圃升级条件": result = nurseryService.searchUpgradeCondition(operationReq); break; case "升级花圃": result = nurseryService.nurseryUpgrade(operationReq); break; case "取消升级花圃": result = nurseryService.nurseryUpgradeCancel(operationReq); break; case "重置花圃": result = nurseryService.NurseryResetCheck(operationReq); break; case "确认重置花圃": result = nurseryService.nurseryReset(operationReq); break; case "取消重置花圃": result = nurseryService.nurseryResetCancel(operationReq); break; case "查询花圃状态": result = nurseryService.checkNurseryByNum(operationReq); break; case "园丁升级": result = gardenerService.gardenerUpgradeCheck(operationReq); break; case "确认园丁升级": result = gardenerService.gardenerUpgrade(operationReq); break; case "取消园丁升级": result = gardenerService.gardenerUpgradeCancel(operationReq); break; case "使用技能": result = gardenerService.learnSkillCheck(operationReq); break; case "确认使用技能": result = gardenerService.learnSkill(operationReq); break; case "取消使用技能": result = gardenerService.learnSkillCancel(operationReq); break; case "重置技能": result = gardenerService.resetSkillCheck(operationReq); break; case "确认重置技能": result = gardenerService.resetSkill(operationReq); break; case "取消重置技能": result = gardenerService.resetSkillCancel(operationReq); break; case "更改园丁姓名": result = gardenerService.renameCheck(operationReq); break; case "确认更改园丁姓名": result = gardenerService.rename(operationReq); break; case "取消更改园丁姓名": result = gardenerService.renameCancel(operationReq); break; case "查看宠物": result = petService.petView(operationReq); break; case "宠物移动指令": result = petService.petMove(operationReq); break; case "宠物删除指令": result = petService.petDeleteCheck(operationReq); break; case "确认宠物删除指令": result = petService.petDelete(operationReq); break; case "取消宠物删除指令": result = petService.petDeleteCancel(operationReq); break; case "宠物换位指令": result = petService.petSetPosition(operationReq); break; case "宠物位置调换指令": result = petService.petSwitch(operationReq); break; case "查询宠物栏状态指令": result = petService.petCheck(operationReq); break; case "查询花圃宠物数量指令": result = petService.nurseryPetCheck(operationReq); break; case "购买指令": result = marketService.buyCheck(operationReq); break; case "确认购买指令": result = marketService.buy(operationReq); break; case "取消购买指令": result = marketService.buyCancel(operationReq); break; } return result; } }