package com.xiaoniu.system.platformusers.user.controller;

import com.xiaoniu.common.core.resdata.ChangeStatusDTO;
import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.system.platformusers.user.dto.ClientUserListQueryDTO;
import com.xiaoniu.system.platformusers.user.dto.EditClientUserDTO;
import com.xiaoniu.system.platformusers.user.dto.LogoutAndBlockDTO;
import com.xiaoniu.system.platformusers.user.dto.UserOrderListQueryDTO;
import com.xiaoniu.system.platformusers.user.service.ITbClientUserService;
import com.xiaoniu.system.platformusers.user.vo.ClientUserDetailsVO;
import com.xiaoniu.system.platformusers.user.vo.ClientUserListVO;
import com.xiaoniu.system.platformusers.user.vo.UserOrderInfoVO;
import com.xiaoniu.system.platformusers.user.vo.UserOrderListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户端用户信息表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-10-14 11:55:30
 */
@Tag(name = "平台用户管理")
@RestController
@RequestMapping("/clientUser")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbClientUserController {

    private final ITbClientUserService tbClientUserService;

    @Operation(summary = "平台用户列表")
    @PostMapping("/list")
    public Result<RowsData<ClientUserListVO>> list(@RequestBody ClientUserListQueryDTO dto) {
        return Result.success("查询成功", tbClientUserService.clientUserList(dto));
    }

    @Operation(summary = "修改平台用户")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody @Validated EditClientUserDTO dto) {
        tbClientUserService.editClientUser(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "平台用户详情")
    @GetMapping("/details")
    public Result<ClientUserDetailsVO> details(@RequestParam Long id) {
        return Result.success("查询成功", tbClientUserService.details(id));
    }

    @Operation(summary = "注销平台用户")
    @PostMapping("/logoutAndBlock")
    public Result<String> logoutAndBlock(@RequestBody LogoutAndBlockDTO dto) {
        tbClientUserService.logoutAndBlock(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "用户订单列表")
    @PostMapping("/orderList")
    public Result<RowsData<UserOrderListVO>> orderList(@RequestBody UserOrderListQueryDTO dto) {
        return Result.success("查询成功", tbClientUserService.orderList(dto));
    }

    @Operation(summary = "获取订单详情")
    @GetMapping("/getOrderInfo")
    public Result<UserOrderInfoVO> getOrderInfo(@RequestParam Long orderId) {
        return Result.success("查询成功", tbClientUserService.getOrderInfo(orderId));
    }

}
