package com.ruoyi.predict.controller;

import cn.hutool.core.convert.Convert;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.json.JSONObject;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author hlf
 * @date 2022/9/19 14:31
 * 文件说明：用户信息
 */
@Api(value = "用户信息Controller", tags = {"用户信息操作接口"})
@Controller
@RequestMapping("/predict/api/uic")
public class UserInfoController extends BaseController {

    @Autowired
    private ISysUserService sysUserService;

    @ApiOperation("获取个人信息")
    @PostMapping("/personalInformation")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户主键", required = true),
            @ApiImplicitParam(name = "loginName", value = "登录名称"),
            @ApiImplicitParam(name = "userName", value = "用户名称"),
    })
    public AjaxResult personalInformation(@RequestParam(value = "userId") String userId) {
        JSONObject json = new JSONObject();
        SysUser user = sysUserService.selectUserById(Convert.toLong(userId));
        json.put("user", user);
        return AjaxResult.success(json);
    }
}
