package shop.alien.lawyer.controller;

import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.LawyerOrderStatisticsVO;
import shop.alien.lawyer.service.LawyerStatisticsService;

/**
 * 律师统计 前端控制器
 *
 * @author system
 * @since 2025-01-XX
 */
@Slf4j
@Api(tags = {"律师平台-统计管理"})
@ApiSort(15)
@CrossOrigin
@RestController
@RequestMapping("/lawyer/statistics")
@RequiredArgsConstructor
public class LawyerStatisticsController {

    private final LawyerStatisticsService lawyerStatisticsService;

    @ApiOperation("获取律师订单统计数据")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lawyerUserId", value = "律师用户ID", dataType = "Integer", paramType = "query", required = true)
    })
    @GetMapping("/getOrderStatistics")
    public R<LawyerOrderStatisticsVO> getOrderStatistics(@RequestParam(value = "lawyerUserId", required = true) Integer lawyerUserId) {
        log.info("LawyerStatisticsController.getOrderStatistics?lawyerUserId={}", lawyerUserId);
        if (lawyerUserId == null || lawyerUserId <= 0) {
            log.warn("获取律师订单统计数据失败：律师用户ID为空或无效");
            return R.fail("律师用户ID不能为空");
        }
        return lawyerStatisticsService.getOrderStatistics(lawyerUserId);
    }
}

