package com.td.boss.game.complayerscore.controller;

import com.td.boss.common.controller.*;
import com.td.boss.common.pojo.Result;
import com.td.boss.game.complayerscore.pojo.ComPlayerScore;
import com.td.boss.game.complayerscore.vo.ComPlayerScoreVo;
import com.td.boss.game.complayerscore.service.ComPlayerScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/game/comPlayerScore/")
public class ComPlayerScoreController extends CommonController<ComPlayerScoreVo, ComPlayerScore, Integer> {
    @Autowired
    private ComPlayerScoreService comPlayerScoreService;

    /**
     * 积分兑换种子
     *
     * @param userId 用户ID
     * @param amount 本次兑换数量
     * @param seedId 种子id
     * @return {@link Result}<{@link String}>
     */
    @PostMapping("exchange")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public Result<String> exchange(
            @RequestParam(value = "userId") String userId,
            @RequestParam(value = "amount") Integer amount,
            @RequestParam(value = "seedId") Integer seedId
    ) {
        return comPlayerScoreService.exchange(userId, amount, seedId);
    }
}
