package com.mmc.iuav.user.controller.userpoints;

import com.mmc.iuav.group.Page;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.BaseController;
import com.mmc.iuav.user.model.dto.dronepilot.PilotCertificationDTO;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDTO;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDetailsDTO;
import com.mmc.iuav.user.model.qo.userpoints.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
import com.mmc.iuav.user.service.userpoints.UserPointsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author small
 * @Date 2023/8/5 16:28
 * @Version 1.0
 */
@Api(tags = "积分")
@RequestMapping("/userPoint")
@RestController
public class UserPointsController extends BaseController {

    @Autowired
    private UserPointsService userPointsService;


    @ApiOperation(value = "后台管理——积分列表")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
    @PostMapping("/userPointList")
    public ResultBody<UserPointsDTO> userPointList(HttpServletRequest request,
                                                   @Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody UserPointQO param) {
        return ResultBody.success(userPointsService.userPointList(param));
    }

    @ApiOperation(value = "后台管理——积分详情")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
    @PostMapping("/detailPoint")
    public ResultBody<UserPointsDetailsDTO> detailPoint(HttpServletRequest request,
                                                        @Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody UserPointsDetailsQO param) {
        return ResultBody.success(userPointsService.detailPoint(param));
    }

    @ApiOperation(value = "小程序用户——积分详情")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
    @PostMapping("/appDetailPoint")
    public ResultBody<UserPointsDetailsDTO> appDetailPoint(HttpServletRequest request, @Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody AppPointsDetailsQO param) {
        return ResultBody.success(userPointsService.appDetailPoint(this.getUserLoginInfoFromRedis(request).getUserAccountId(), param));
    }


}
