package com.bohuikeji.delivery.backstage.controller.api.v2;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bohuikeji.delivery.backstage.entity.TGaodeKey;
import com.bohuikeji.delivery.backstage.service.ITGaodeKeyService;
import com.bohuikeji.frame.module.admin.base.ApiController;
import com.bohuikeji.frame.module.admin.component.RedisUtil;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.bohuikeji.frame.module.admin.entity.sys.SysConfig;
import com.bohuikeji.frame.module.admin.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;

/**
 * 高德key配置
 * @author 孙劲辉
 */
@Api(tags = {"高德key配置"})
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/gaode/v2")
@Slf4j
public class GaodeKeyApi extends ApiController {

    private static final Random rand = new Random();
    final ITGaodeKeyService gaodeKeyService;
    final RedisUtil redisUtil;

    @ApiOperation("根据配置组key查询配置项")
    @GetMapping("/get/key")
    public APIEntity getGaoDeKey(){
        List<TGaodeKey> gaodeKeys = gaodeKeyService.list(new QueryWrapper<TGaodeKey>());
        return APIEntity.success(gaodeKeys.get(rand.nextInt(gaodeKeys.size())));
    }


}
