package shop.alien.api.feign;

import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 调用Roll接口
 *
 * @author ssk
 * @version 1.0
 * @date 2024/10/24 15:04
 */
@FeignClient(url = "https://www.mxnzp.com/api", name = "roll")
public interface RollFeign {

    /**
     * 全国城市列表
     * https://www.mxnzp.com/doc/detail?id=8
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/address/list")
    JSONObject addressList(@RequestParam(value = "app_id") String appId,
                           @RequestParam(value = "app_secret") String appSecret);

    /**
     * 搜索全国城市列表
     * https://www.mxnzp.com/doc/detail?id=8
     *
     * @param type      类型 0-查询省份 1-查询城市
     * @param value     被查询的省份或者城市名称
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/address/search")
    JSONObject addressSearch(@RequestParam(value = "type") String type,
                             @RequestParam(value = "value") String value,
                             @RequestParam(value = "app_id") String appId,
                             @RequestParam(value = "app_secret") String appSecret);

    /**
     * 每日推荐精美语句
     * https://www.mxnzp.com/doc/detail?id=25
     *
     * @param count     被查询的语句条数，范围【1~20】
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/daily_word/recommend")
    JSONObject dailyWord(@RequestParam(value = "count") Integer count,
                         @RequestParam(value = "app_id") String appId,
                         @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取食物的分类列表
     * https://www.mxnzp.com/doc/detail?id=32
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/food_heat/type/list")
    JSONObject foodHeatTypeList(@RequestParam(value = "app_id") String appId,
                                @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取分类下的食物列表
     * https://www.mxnzp.com/doc/detail?id=32
     *
     * @param id        分类id
     * @param page      分页页数
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/food_heat/food/list")
    JSONObject foodHeatFoodList(@RequestParam(value = "id") String id,
                                @RequestParam(value = "page") Integer page,
                                @RequestParam(value = "app_id") String appId,
                                @RequestParam(value = "app_secret") String appSecret);

    /**
     * 搜索食物
     * https://www.mxnzp.com/doc/detail?id=32
     *
     * @param keyword   搜索关键字
     * @param page      分页页数
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/food_heat/food/search")
    JSONObject foodHeatSearch(@RequestParam(value = "keyword") String keyword,
                              @RequestParam(value = "page") Integer page,
                              @RequestParam(value = "app_id") String appId,
                              @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取食物详情
     * https://www.mxnzp.com/doc/detail?id=32
     *
     * @param foodId    食物id
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/food_heat/food/details")
    JSONObject foodHeatDetail(@RequestParam(value = "foodId") String foodId,
                              @RequestParam(value = "app_id") String appId,
                              @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取历史上的今天数据
     * https://www.mxnzp.com/doc/detail?id=18
     *
     * @param type      是否需要详情，0：不需要详情 1：需要详情 默认值 0 可不传
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/history/today")
    JSONObject historyToday(@RequestParam(value = "type") Integer type,
                            @RequestParam(value = "app_id") String appId,
                            @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定日期的节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param date          日期 格式 yyyyMMdd
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/single/{date}")
    JSONObject holidaySingle(@PathVariable(value = "date") String date,
                             @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                             @RequestParam(value = "app_id") String appId,
                             @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定多个日期的节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param dates         日期组 格式 yyyyMMdd,yyyyMMdd,yyyyMMdd （中间用英文逗号隔开）
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/multi/{dates}")
    JSONObject holidayMulti(@PathVariable(value = "dates") String dates,
                            @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                            @RequestParam(value = "app_id") String appId,
                            @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定月份的节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param date          查询的月份 格式 yyyyMM （只有年月）
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/list/month/{date}")
    JSONObject holidayListMonth(@PathVariable(value = "date") String date,
                                @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                                @RequestParam(value = "app_id") String appId,
                                @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定月份的指定类型节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param date          查询的月份 格式 yyyyMM （只有年月）
     * @param type          需要查询的类型{可选值：类型 workday 工作日 holiday 节假日 rest 休息日 festival 节日
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/list/month/{date}/{type}")
    JSONObject holidayListMonthType(@PathVariable(value = "date") String date,
                                    @PathVariable(value = "type") String type,
                                    @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                                    @RequestParam(value = "app_id") String appId,
                                    @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定年份的节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param date          查询的年份 格式 yyyy （只有年份）
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/list/year/{date}")
    JSONObject holidayListYear(@PathVariable(value = "date") String date,
                               @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                               @RequestParam(value = "app_id") String appId,
                               @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定年份的指定类型节假日及万年历信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param date          查询的月份 格式 yyyy （只有年份）
     * @param type          需要查询的类型{可选值：类型 workday 工作日 holiday 节假日 rest 休息日 festival 节日
     * @param ignoreHoliday 是否忽略节假日，仅仅获取万年历，默认值false
     * @param appId         id
     * @param appSecret     secret
     * @return JSONObject
     */
    @GetMapping("/holiday/list/year/{date}/{type}")
    JSONObject holidayListYearType(@PathVariable(value = "date") String date,
                                   @PathVariable(value = "type") String type,
                                   @RequestParam(value = "ignoreHoliday") boolean ignoreHoliday,
                                   @RequestParam(value = "app_id") String appId,
                                   @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取最近前后七个节日信息
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/holiday/recent/list")
    JSONObject holidayRecentList(@RequestParam(value = "app_id") String appId,
                                 @RequestParam(value = "app_secret") String appSecret);

    /**
     * 分页获取笑话段子列表
     * https://www.mxnzp.com/doc/detail?id=5
     *
     * @param page      分页
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/jokes/list")
    JSONObject jokesList(@RequestParam(value = "page") Integer page,
                         @RequestParam(value = "app_id") String appId,
                         @RequestParam(value = "app_secret") String appSecret);

    /**
     * 随机获取笑话段子列表
     * https://www.mxnzp.com/doc/detail?id=5
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/jokes/list/random")
    JSONObject jokesListRandom(@RequestParam(value = "app_id") String appId,
                               @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取所有新闻类型列表
     * https://www.mxnzp.com/doc/detail?id=12
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/news/types/v2")
    JSONObject newsTypes(@RequestParam(value = "app_id") String appId,
                         @RequestParam(value = "app_secret") String appSecret);

    /**
     * 根据新闻类型获取新闻列表
     * https://www.mxnzp.com/doc/detail?id=1
     *
     * @param typeId    类型id，从上面的V2新闻类型列表中获取
     * @param page      当前页数
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/news/list/v2")
    JSONObject newsList(@RequestParam(value = "typeId") String typeId,
                        @RequestParam(value = "page") String page,
                        @RequestParam(value = "app_id") String appId,
                        @RequestParam(value = "app_secret") String appSecret);

    /**
     * 根据新闻id获取新闻详情
     * https://www.mxnzp.com/doc/detail?id=5
     *
     * @param newsId    新闻唯一id，从上面的V2新闻列表中获取
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/news/details/v2")
    JSONObject newsDetails(@RequestParam(value = "newsId") String newsId,
                           @RequestParam(value = "app_id") String appId,
                           @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取访问者的ip地址信息
     * https://www.mxnzp.com/doc/detail?id=4
     *
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/ip/self")
    JSONObject ipSelf(@RequestParam(value = "app_id") String appId,
                      @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取指定ip的ip地址信息
     * https://www.mxnzp.com/doc/detail?id=4
     *
     * @param ip        被查询的ip地址 需保证是正确的ip地址格式
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/ip/aim_ip")
    JSONObject ipAimIp(@RequestParam(value = "ip") String ip,
                       @RequestParam(value = "app_id") String appId,
                       @RequestParam(value = "app_secret") String appSecret);

    /**
     * 生成随机图片验证码
     * https://www.mxnzp.com/doc/detail?id=24
     *
     * @param len       生成验证码的长度，不传默认5位
     * @param type      返回类型，0-生成图片的地址链接 1-生成验证码图片的base64字符串（注：Base64字符串前面默认添加了“data:image/jpg;base64,”，取值的时候请根据需要对这个内容进行处理）
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/verifycode/code")
    JSONObject verifyCode(@RequestParam(value = "len") Integer len,
                          @RequestParam(value = "type") Integer type,
                          @RequestParam(value = "app_id") String appId,
                          @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取特定城市今日天气
     * https://www.mxnzp.com/doc/detail?id=7
     *
     * @param city      传入你需要查询的城市，请尽量传入完整值，否则系统会自行匹配，可能会有误差
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/weather/current/{city}")
    JSONObject weatherCurrent(@PathVariable(value = "city") String city,
                              @RequestParam(value = "app_id") String appId,
                              @RequestParam(value = "app_secret") String appSecret);

    /**
     * 获取特定城市今天及未来天气
     * https://www.mxnzp.com/doc/detail?id=7
     *
     * @param city      传入你需要查询的城市，请尽量传入完整值，否则系统会自行匹配，可能会有误差
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/weather/forecast/{city}")
    JSONObject weatherForecast(@PathVariable(value = "city") String city,
                               @RequestParam(value = "app_id") String appId,
                               @RequestParam(value = "app_secret") String appSecret);

    /**
     * 今日油价查询
     * https://www.mxnzp.com/doc/detail?id=34
     *
     * @param province  省份，合法值为：【安徽、北京、重庆、福建、甘肃、广东、广西、贵州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、辽宁、内蒙古、宁夏、青海、陕西、上海、山东、山西、四川、天津、西藏、新疆、云南、浙江】
     * @param appId     id
     * @param appSecret secret
     * @return JSONObject
     */
    @GetMapping("/oil/search")
    JSONObject oilSearch(@RequestParam(value = "province") String province,
                         @RequestParam(value = "app_id") String appId,
                         @RequestParam(value = "app_secret") String appSecret);
}



