package org.jeecg.modules.xcx.user.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.modules.xcx.user.req.EditUserReq;
import org.jeecg.modules.xcx.user.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(tags = "用户接口接口")
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;


    @ApiOperation(value = "用户信息")
    @GetMapping("/info")
    public Result<?> getUserInfo(HttpServletRequest request){
        return userService.getUserInfo(TokenUtils.getTokenByRequest(request));
    }

    @ApiOperation(value = "修改用户数据")
    @PostMapping("/edit")
    public Result<?> editUserInfo(HttpServletRequest request, EditUserReq editUserReq){
        return userService.editUserInfo(editUserReq,TokenUtils.getTokenByRequest(request));
    }

}
