package com.ruoyi.cai.controller.app;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.cai.domain.*;
import com.ruoyi.cai.dto.app.vo.GiftVo;
import com.ruoyi.cai.service.*;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.BeanConvertUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
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.List;
import java.util.Map;

@RestController
@RequestMapping("/api/setting")
@Tag(name = "获取设置相关接口")
public class SettingAppController {

    @Autowired
    private GoodsService goodsService;
    @Autowired
    private WithdrawExchangeService withdrawExchangeService;
    @Autowired
    private ReportCateService reportCateService;
    @Autowired
    private CitysService citysService;
    @Autowired
    private GiftService giftService;

    @GetMapping("/goods")
    @Operation(summary = "充值配置")
    public R<List<Goods>> goods(){
        List<Goods> list = goodsService.list(Wrappers.lambdaQuery(Goods.class)
                .eq(Goods::getStatus,0)
                .orderByAsc(Goods::getPrice));
        return R.ok(list);
    }

    @GetMapping("/withdraw")
    @Operation(summary = "提现配置")
    public R<List<WithdrawExchange>> withdraw(){
        List<WithdrawExchange> list = withdrawExchangeService.list(Wrappers.lambdaQuery(WithdrawExchange.class)
                .orderByAsc(WithdrawExchange::getMoney));
        return R.ok(list);
    }

    @GetMapping("/report")
    @Operation(summary = "举报分类配置")
    public R<List<ReportCate>> report(){
        List<ReportCate> list = reportCateService.list(Wrappers.lambdaQuery(ReportCate.class));
        return R.ok(list);
    }


    @GetMapping("/city")
    @Operation(summary = "城市")
    public R<Map<Long,String>> city(){
        return R.ok(citysService.all());
    }

    @GetMapping("/gift")
    @Operation(summary = "礼物配置")
    public R<List<GiftVo>> gift(){
        List<Gift> res = giftService.all();
        return R.ok(BeanConvertUtil.convertListTo(res, GiftVo::new));
    }

}
