package com.zanxiang.game.module.manage.controller;

import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
import com.zanxiang.game.module.base.pojo.enums.OsEnum;
import com.zanxiang.game.module.base.pojo.enums.PayApplicationTypeEnum;
import com.zanxiang.game.module.manage.enums.GameStrategyTypeEnum;
import com.zanxiang.game.module.manage.enums.VipLevelEnum;
import com.zanxiang.game.module.manage.pojo.vo.*;
import com.zanxiang.game.module.manage.service.*;
import com.zanxiang.module.util.bean.BeanUtil;
import com.zanxiang.module.util.pojo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author : lingfeng
 * @time : 2022-11-03
 * @description : 条件选择接口
 */
@Api(tags = {"选择下拉接口"})
@RestController
@RequestMapping("/choice")
@Slf4j
public class ChoiceController {

    @Autowired
    private ICpService cpService;

    @Autowired
    private IGameService gameService;

    @Autowired
    private IPayWayService payWayService;

    @Autowired
    private IPayMerchantService payMerchantService;

    @Autowired
    private IGameTagService gameTagService;

    @Autowired
    private IPayApplicationService payApplicationService;

    @Autowired
    private IPayDeviceService payDeviceService;

    @Autowired
    private IPayBoxService payBoxService;

    @Autowired
    private IAgentService agentService;

    @Autowired
    private IGameAuthService gameAuthService;

    @ApiOperation(value = "vip等级选择列表")
    @GetMapping(value = "/vip/level/list")
    @PreAuthorize(permissionKey = "manage:choiceVipLevel:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = VipLevelChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<VipLevelChoiceVO>> vipLevelChoiceList() {
        return ResultVO.ok(Arrays.stream(VipLevelEnum.values())
                .map(vipLevelEnum -> BeanUtil.copy(vipLevelEnum, VipLevelChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @ApiOperation(value = "操作系统选择列表")
    @GetMapping(value = "/os/type/list")
    @PreAuthorize(permissionKey = "manage:choiceOsType:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = SystemChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<SystemChoiceVO>> systemChoiceList() {
        return ResultVO.ok(Arrays.stream(OsEnum.values())
                .map(osEnum -> BeanUtil.copy(osEnum, SystemChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @ApiOperation(value = "cp选择列表")
    @GetMapping(value = "/cp/list")
    @PreAuthorize(permissionKey = "manage:choiceCp:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = CpChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<CpChoiceVO>> cpChoiceList() {
        return ResultVO.ok(cpService.choiceList());
    }

    @ApiOperation(value = "游戏选择列表")
    @GetMapping(value = "/game/list")
    @PreAuthorize(permissionKey = "manage:gameChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<GameChoiceVO>> gameChoiceList() {
        return ResultVO.ok(gameService.choiceList());
    }

    @ApiOperation(value = "游戏应用类型选择列表")
    @GetMapping(value = "/game/category/list")
    @PreAuthorize(permissionKey = "manage:gameCategoryChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameCategoryChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<GameCategoryChoiceVO>> gameCategoryChoiceList() {
        return ResultVO.ok(Arrays.stream(GameCategoryEnum.values())
                .map(gameCategoryEnum -> BeanUtil.copy(gameCategoryEnum, GameCategoryChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @ApiOperation(value = "游戏分类标签选择列表")
    @GetMapping(value = "/game/tags/list")
    @PreAuthorize(permissionKey = "manage:gameTagsChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameTagChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<GameTagChoiceVO>> gameTagsChoiceList() {
        return ResultVO.ok(gameTagService.gameTagsChoiceList());
    }

    @ApiOperation(value = "推广渠道选择列表")
    @GetMapping(value = "/agent/list")
    @PreAuthorize(permissionKey = "manage:agentChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AgentChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<AgentChoiceVO>> agentChoiceList() {
        return ResultVO.ok(agentService.agentChoiceList());
    }

    @ApiOperation(value = "推广渠道账号选择列表")
    @GetMapping(value = "/agent/account/list")
    @PreAuthorize(permissionKey = "manage:agentAccountChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = AgentAccountChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<AgentAccountChoiceVO>> agentAccountChoiceList() {
        return ResultVO.ok(agentService.agentAccountChoiceList());
    }

    @ApiOperation(value = "归因推广人员选择列表")
    @GetMapping(value = "/agent/user/list")
    @PreAuthorize(permissionKey = "manage:agentUserChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Map.class)})
    public ResultVO<Map<Long, String>> agentUserChoiceList() {
        return ResultVO.ok(gameAuthService.agentUserChoiceList());
    }

    @ApiOperation(value = "支付方式选择列表")
    @GetMapping(value = "/pay/way/list")
    @PreAuthorize(permissionKey = "manage:payWayChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = PayWayChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<PayWayChoiceVO>> payWayChoiceList() {
        return ResultVO.ok(payWayService.payWayChoiceList());
    }

    @ApiOperation(value = "支付类型选择列表")
    @GetMapping(value = "/pay/device/list")
    @PreAuthorize(permissionKey = "manage:payDeviceChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = PayDeviceChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<PayDeviceChoiceVO>> payDeviceChoiceList() {
        return ResultVO.ok(payDeviceService.payDeviceChoiceList());
    }

    @ApiOperation(value = "商户选择列表")
    @GetMapping(value = "/pay/merchant/list")
    @PreAuthorize(permissionKey = "manage:payMerchantChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = PayMerchantChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<PayMerchantChoiceVO>> payMerchantChoiceList() {
        return ResultVO.ok(payMerchantService.payMerchantChoiceList());
    }

    @ApiOperation(value = "支付应用类型选择列表")
    @GetMapping(value = "/application/type/list")
    @PreAuthorize(permissionKey = "manage:payApplicationTypeChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = ApplicationTypeChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<ApplicationTypeChoiceVO>> applicationTypeChoiceList() {
        return ResultVO.ok(Arrays.stream(PayApplicationTypeEnum.values())
                .map(payApplicationTypeEnum -> BeanUtil.copy(payApplicationTypeEnum, ApplicationTypeChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @ApiOperation(value = "支付应用选择列表")
    @GetMapping(value = "/pay/application/list")
    @PreAuthorize(permissionKey = "manage:payApplicationChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = PayApplicationChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<PayApplicationChoiceVO>> payApplicationChoiceList() {
        return ResultVO.ok(payApplicationService.payApplicationChoiceList());
    }

    @ApiOperation(value = "支付盒子选择列表")
    @GetMapping(value = "/pay/box/list")
    @PreAuthorize(permissionKey = "manage:payBoxChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = PayBoxChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<PayBoxChoiceVO>> payBoxChoiceList() {
        return ResultVO.ok(payBoxService.payBoxChoiceList());
    }

    @ApiOperation(value = "策略类型选择列表")
    @GetMapping(value = "/game/pay/strategy/list")
    @PreAuthorize(permissionKey = "manage:gamePayStrategyChoice:list")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GamePayStrategyChoiceVO.class, responseContainer = "list")})
    public ResultVO<List<GamePayStrategyChoiceVO>> gamePayStrategyChoiceList() {
        return ResultVO.ok(Arrays.stream(GameStrategyTypeEnum.values())
                .map(gameStrategyTypeEnum -> BeanUtil.copy(gameStrategyTypeEnum, GamePayStrategyChoiceVO.class))
                .collect(Collectors.toList()));
    }
}
