package com.liquidnet.service.sweet.controller;


import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.param.SweetCityVoteParam;
import com.liquidnet.service.sweet.service.ISweetCityVoteService;
import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 城市投票表 前端控制器
 * </p>
 *
 * @author jiangxiulong
 * @since 2021-09-15
 */
@Api(tags = "活动-城市投票")
@RestController
@RequestMapping("/sweetCityVote")
public class SweetCityVoteController {

    @Autowired
    private ISweetCityVoteService sweetCityVoteService;

    @GetMapping("statList")
    @ApiOperation("城市投票排名")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "phone", value = "手机号", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "unionId", value = "unionId", required = true)
    })
    public ResponseDto<List<SweetCItyVoteStatVo>> getList(
            @RequestParam String phone,
            @RequestParam String unionId
    ) {
        return sweetCityVoteService.getList(phone, unionId);
    }

    @PostMapping("createVote")
    @ApiOperation("用户投票记录")
    public ResponseDto createVote(@Valid @RequestBody SweetCityVoteParam param) {
        return sweetCityVoteService.createVote(param);
    }

    @GetMapping("setStatList")
    @ApiOperation("统计投票排名")
    public ResponseDto setStatList() {
        return sweetCityVoteService.setStatList();
    }

}
