package org.wfc.user.controller;

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 org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.user.domain.bo.UCdrClientBo;
import org.wfc.user.domain.bo.UUCdrHistoryUserBo;
import org.wfc.user.domain.vo.UCdrClientVo;
import org.wfc.user.domain.vo.UCdrHistoryUserVo;
import org.wfc.user.domain.vo.UCdrUserVo;
import org.wfc.user.service.IUCdrService;

import java.util.List;

/**
 * <p>
 * 用户平台_用户话单表 前端控制器
 * </p>
 *
 * @author cyc
 * @since 2024-12-09
 */
@RestController
@RequestMapping("/cdr")
@Tag(name = "用户平台-CDR接口")
public class UCdrController extends BaseController {

    @Autowired
    private IUCdrService cdrService;

    /**
     * 添加话单信息通过OmadaApi
     */
    @GetMapping("/addCdrInfo")
    public R<Boolean> addCdrInfoByOmadaApi() {
        cdrService.addCdrInfoByOmadaApi();
        return R.ok(true);
    }

    /**
     * 根据用户查询话单
     *
     * @return 结果
     */
    @Operation(summary = "首页仪表盘")
    @GetMapping("/getOne")
    public R<UCdrUserVo> getByUser() {
        UCdrUserVo result = cdrService.getByUser();
        return R.ok(result);
    }

    /**
     * 根据设备查询话单
     *
     * @return 结果
     */
    @GetMapping("/pageClient")
    public TableDataInfo getByClient(UCdrClientBo clientBo) {
        startPage();
        List<UCdrClientVo> result = cdrService.getByClient(clientBo);
        return getDataTable(result);
    }

    /**
     * 根据用户查询cdr记录
     *
     * @return 结果
     */
    @Operation(summary = "CDR记录")
    @GetMapping("/pageHistory")
    public TableDataInfo getHistoryByUser(UUCdrHistoryUserBo item) {
        startPage();
        List<UCdrHistoryUserVo> result = cdrService.getHistoryByUser(item);
        return getDataTable(result);
    }

}
