package com.td.WaDa.game.complayercultivate.controller;

import com.td.WaDa.common.pojo.Result;
import com.td.WaDa.game.complayercultivate.serivce.ComPlayerCultivateSerivce;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;


/**
 * 放牧\养殖\渔场
 */
@RestController
@Slf4j
@RequestMapping("/game/comPlayerCultivate/")
public class ComPlayerCultivateController {
    @Autowired
    private ComPlayerCultivateSerivce comPlayerCultivateSerivce;

    /**
     * 解锁某个土地 【牧场养殖渔场】
     *
     * @param userId
     * @param configLandId
     * @return
     */
    @PostMapping("payLand")
    @Transactional(rollbackFor = Exception.class)
    public Result<?> payLand(@RequestParam(value = "userId") String userId,
                             @RequestParam(value = "configLandId") Integer configLandId) {
        return comPlayerCultivateSerivce.payLand(userId, configLandId);
    }


    /**
     * 修改某个土地 【牧场养殖渔场】
     *
     * @param userId
     * @param configLandId
     * @param multiple
     * @return
     */
    @PostMapping("multipleLand")
    @Transactional(rollbackFor = Exception.class)
    public Result<?> multipleLand(@RequestParam(value = "userId") String userId,
                                  @RequestParam(value = "configLandId") Integer configLandId,
                                  @RequestParam(value = "multiple") Integer multiple) {
        return comPlayerCultivateSerivce.multipleLand(userId, configLandId,multiple);
    }

    /**
     * 获取租赁机会
     *
     * @param userId
     * @return
     */
    @GetMapping("getTimes")
    @Transactional(rollbackFor = Exception.class)
    public Result<?> getTimes(@RequestParam(value = "userId") String userId) {
        return Result.of(comPlayerCultivateSerivce.getTimes(userId));
    }


    /**
     * 喂养养殖场动物
     *
     * @param userId
     * @param configLandId
     * @return
     */
    @PostMapping("buyAnimalFood")
    @Transactional(rollbackFor = Exception.class)
    public Result<?> buyAnimalFood(@RequestParam(value = "userId") String userId,
                                   @RequestParam(value = "configLandId") Integer configLandId) {
        return comPlayerCultivateSerivce.buyFood(userId, configLandId);
    }
}
