package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.RegisteredLawyerUserCountVo;
import shop.alien.entity.store.vo.RegisteredStoreUserCountVo;
import shop.alien.entity.store.vo.RegisteredUserCountVo;
import shop.alien.store.service.RegisteredUserStatisticsService;

/**
 * 各端注册用户数量统计
 */
@Api(tags = {"注册用户统计"})
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/registeredUserStatistics")
@RequiredArgsConstructor
public class RegisteredUserStatisticsController {

    private final RegisteredUserStatisticsService registeredUserStatisticsService;

    @ApiOperation("查询 C 端注册用户数量")
    @ApiOperationSupport(order = 1)
    @GetMapping("/count")
    public R<RegisteredUserCountVo> countRegisteredUsers() {
        log.info("RegisteredUserStatisticsController.countRegisteredUsers");
        return R.data(registeredUserStatisticsService.countRegisteredUsers());
    }

    @ApiOperation(value = "查询 C 端注册用户数量", notes = "响应体仅为数字字符串，Content-Type: text/plain")
    @ApiOperationSupport(order = 2)
    @GetMapping(value = "/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
    public String countRegisteredUsersPlain() {
        log.info("RegisteredUserStatisticsController.countRegisteredUsersPlain");
        return String.valueOf(registeredUserStatisticsService.countRegisteredUserTotal());
    }

    @ApiOperation("查询店铺端注册用户数量")
    @ApiOperationSupport(order = 3)
    @GetMapping("/store/count")
    public R<RegisteredStoreUserCountVo> countRegisteredStoreUsers() {
        log.info("RegisteredUserStatisticsController.countRegisteredStoreUsers");
        return R.data(registeredUserStatisticsService.countRegisteredStoreUsers());
    }

    @ApiOperation(value = "查询店铺端注册用户数量", notes = "响应体仅为数字字符串，Content-Type: text/plain")
    @ApiOperationSupport(order = 4)
    @GetMapping(value = "/store/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
    public String countRegisteredStoreUsersPlain() {
        log.info("RegisteredUserStatisticsController.countRegisteredStoreUsersPlain");
        return String.valueOf(registeredUserStatisticsService.countRegisteredStoreUserTotal());
    }

    @ApiOperation("查询律师端注册用户数量")
    @ApiOperationSupport(order = 5)
    @GetMapping("/lawyer/count")
    public R<RegisteredLawyerUserCountVo> countRegisteredLawyerUsers() {
        log.info("RegisteredUserStatisticsController.countRegisteredLawyerUsers");
        return R.data(registeredUserStatisticsService.countRegisteredLawyerUsers());
    }

    @ApiOperation(value = "查询律师端注册用户数量", notes = "响应体仅为数字字符串，Content-Type: text/plain")
    @ApiOperationSupport(order = 6)
    @GetMapping(value = "/lawyer/countPlain", produces = MediaType.TEXT_PLAIN_VALUE)
    public String countRegisteredLawyerUsersPlain() {
        log.info("RegisteredUserStatisticsController.countRegisteredLawyerUsersPlain");
        return String.valueOf(registeredUserStatisticsService.countRegisteredLawyerUserTotal());
    }
}
