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 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 : 条件选择接口
 */
@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;

    @GetMapping(value = "/vip/level/list")
    @PreAuthorize(permissionKey = "manage:choiceVipLevel:list")
    public ResultVO<List<VipLevelChoiceVO>> vipLevelChoiceList() {
        return ResultVO.ok(Arrays.stream(VipLevelEnum.values())
                .map(vipLevelEnum -> BeanUtil.copy(vipLevelEnum, VipLevelChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @GetMapping(value = "/os/type/list")
    @PreAuthorize(permissionKey = "manage:choiceOsType:list")
    public ResultVO<List<SystemChoiceVO>> systemChoiceList() {
        return ResultVO.ok(Arrays.stream(OsEnum.values())
                .map(osEnum -> BeanUtil.copy(osEnum, SystemChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @GetMapping(value = "/cp/list")
    @PreAuthorize(permissionKey = "manage:choiceCp:list")
    public ResultVO<List<CpChoiceVO>> cpChoiceList() {
        return ResultVO.ok(cpService.choiceList());
    }

    @GetMapping(value = "/game/list")
    @PreAuthorize(permissionKey = "manage:gameChoice:list")
    public ResultVO<List<GameChoiceVO>> gameChoiceList() {
        return ResultVO.ok(gameService.choiceList());
    }

    @GetMapping(value = "/game/category/list")
    @PreAuthorize(permissionKey = "manage:gameCategoryChoice:list")
    public ResultVO<List<GameCategoryChoiceVO>> gameCategoryChoiceList() {
        return ResultVO.ok(Arrays.stream(GameCategoryEnum.values())
                .map(gameCategoryEnum -> BeanUtil.copy(gameCategoryEnum, GameCategoryChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @GetMapping(value = "/game/tags/list")
    @PreAuthorize(permissionKey = "manage:gameTagsChoice:list")
    public ResultVO<List<GameTagChoiceVO>> gameTagsChoiceList() {
        return ResultVO.ok(gameTagService.gameTagsChoiceList());
    }

    @GetMapping(value = "/agent/list")
    @PreAuthorize(permissionKey = "manage:agentChoice:list")
    public ResultVO<List<AgentChoiceVO>> agentChoiceList() {
        return ResultVO.ok(agentService.agentChoiceList());
    }

    @GetMapping(value = "/agent/account/list")
    @PreAuthorize(permissionKey = "manage:agentAccountChoice:list")
    public ResultVO<List<AgentAccountChoiceVO>> agentAccountChoiceList() {
        return ResultVO.ok(agentService.agentAccountChoiceList());
    }

    @GetMapping(value = "/agent/user/list")
    @PreAuthorize(permissionKey = "manage:agentUserChoice:list")
    public ResultVO<Map<Long, String>> agentUserChoiceList() {
        return ResultVO.ok(gameAuthService.agentUserChoiceList());
    }

    @GetMapping(value = "/pay/way/list")
    @PreAuthorize(permissionKey = "manage:payWayChoice:list")
    public ResultVO<List<PayWayChoiceVO>> payWayChoiceList() {
        return ResultVO.ok(payWayService.payWayChoiceList());
    }

    @GetMapping(value = "/pay/device/list")
    @PreAuthorize(permissionKey = "manage:payDeviceChoice:list")
    public ResultVO<List<PayDeviceChoiceVO>> payDeviceChoiceList() {
        return ResultVO.ok(payDeviceService.payDeviceChoiceList());
    }

    @GetMapping(value = "/pay/merchant/list")
    @PreAuthorize(permissionKey = "manage:payMerchantChoice:list")
    public ResultVO<List<PayMerchantChoiceVO>> payMerchantChoiceList() {
        return ResultVO.ok(payMerchantService.payMerchantChoiceList());
    }

    @GetMapping(value = "/application/type/list")
    @PreAuthorize(permissionKey = "manage:payApplicationTypeChoice:list")
    public ResultVO<List<ApplicationTypeChoiceVO>> applicationTypeChoiceList() {
        return ResultVO.ok(Arrays.stream(PayApplicationTypeEnum.values())
                .map(payApplicationTypeEnum -> BeanUtil.copy(payApplicationTypeEnum, ApplicationTypeChoiceVO.class))
                .collect(Collectors.toList()));
    }

    @GetMapping(value = "/pay/application/list")
    @PreAuthorize(permissionKey = "manage:payApplicationChoice:list")
    public ResultVO<List<PayApplicationChoiceVO>> payApplicationChoiceList() {
        return ResultVO.ok(payApplicationService.payApplicationChoiceList());
    }

    @GetMapping(value = "/pay/box/list")
    @PreAuthorize(permissionKey = "manage:payBoxChoice:list")
    public ResultVO<List<PayBoxChoiceVO>> payBoxChoiceList() {
        return ResultVO.ok(payBoxService.payBoxChoiceList());
    }

    @GetMapping(value = "/game/pay/strategy/list")
    @PreAuthorize(permissionKey = "manage:gamePayStrategyChoice:list")
    public ResultVO<List<GamePayStrategyChoiceVO>> gamePayStrategyChoiceList() {
        return ResultVO.ok(Arrays.stream(GameStrategyTypeEnum.values())
                .map(gameStrategyTypeEnum -> BeanUtil.copy(gameStrategyTypeEnum, GamePayStrategyChoiceVO.class))
                .collect(Collectors.toList()));
    }
}
