package com.ruoyi.fadapp.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fadapp.domain.vo.FadAppUserVo;
import com.ruoyi.fadapp.service.IFadAppUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * FAD APP用户管理Controller
 *
 * @author ruoyi
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/fadapp/user")
public class FadAppUserController extends BaseController {

    private final IFadAppUserService userService;

    /**
     * 查询用户列表
     */
    @GetMapping("/list")
    public TableDataInfo<FadAppUserVo> list(FadAppUserVo bo, PageQuery pageQuery) {
        return userService.queryUserList(bo, pageQuery);
    }

    /**
     * 获取用户详细信息
     *
     * @param userId 用户ID
     */
    @GetMapping("/{userId}")
    public R<FadAppUserVo> getInfo(@NotNull(message = "主键不能为空")
                                   @PathVariable Long userId) {
        return R.ok(userService.getUserInfo(userId));
    }

    /**
     * 根据手机号获取用户信息
     */
    @GetMapping("/phone/{phone}")
    public R<Object> getUserByPhone(@NotNull(message = "手机号不能为空")
                                   @PathVariable String phone) {
        return R.ok(userService.getUserByPhone(phone));
    }

    /**
     * 获取用户统计信息
     */
    @GetMapping("/stats")
    public R<Object> getUserStats() {
        return R.ok(userService.getUserStats());
    }
} 