package com.ruoyi.web.work.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.work.api.config.BaseController;
import com.ruoyi.web.work.domain.dto.LoginDto;
import com.ruoyi.web.work.domain.dto.UserEditDto;
import com.ruoyi.web.work.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.rmi.ServerException;

@RestController
@RequestMapping("/app/user")
@Api(tags = "用户中心")
public class Api_UserController extends BaseController {

    @Autowired
    IUserService userService;

    @ApiOperation(value = "微信登录")
    @PostMapping("/login")
    public AjaxResult login(@Validated @RequestBody LoginDto dto) throws ServerException {
        return userService.login(dto);
    }

    @GetMapping("/info")
    public AjaxResult info() {
        return userService.info();
    }

    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody UserEditDto dto) {
        return userService.edit(dto);
    }

    @GetMapping("/exit")
    public AjaxResult exit() {
        return userService.exit();
    }

}

