package com.ruoyi.applet.contoller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.model.domain.AppUsers;
import com.ruoyi.model.service.IAppTouristService;
import com.ruoyi.model.service.IAppUsersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "用户")
@RestController
@RequestMapping("/applet/user")
public class AppletUserController extends BaseController {

    @Autowired
    private IAppTouristService appTouristService;

    @Autowired
    private IAppUsersService appUsersService;

    @ApiOperation("游客模式")
    @GetMapping("/touristOne")
    public AjaxResult getTouristOne(){
        return AjaxResult.success(appTouristService.getAppTouristLimitOne());
    }

    @ApiOperation("单个用户")
    @GetMapping("/userById/{id}")
    public AjaxResult getUserById(@PathVariable Long id){
        return AjaxResult.success(appUsersService.selectAppUsersByUserId(id));
    }

    /**
     * 带条件查询所有用户
     * @param appUsers
     * @return
     */
    @ApiOperation("所有用户")
    @GetMapping("/allUsers")
    public TableDataInfo selectAllUsers(@RequestBody AppUsers appUsers){
        return getDataTable(appUsersService.selectAppUsersList(appUsers));
    }
}
