package com.skr.mdm.controller;

import com.skr.mdm.constant.CmdTypeConstants;
import com.skr.mdm.dto.LoginUserDTO;
import com.skr.mdm.result.ResponseResult;
import com.skr.mdm.service.CmdHandlerService;
import com.skr.mdm.service.StrategyFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author nfq
 * @date 2020/9/23 14:51
 */
@RestController
@Api(tags = "用户信息")
public class UserController {

    @PostMapping("userInfo")
    @ApiOperation(value = "获取用户信息")
    public ResponseResult userInfo(@ApiIgnore Authentication authentication) {
        LoginUserDTO loginUserDTO = (LoginUserDTO) authentication.getPrincipal();
        CmdHandlerService strategy = StrategyFactory.getStrategy(CmdTypeConstants.USER_INFO);
        return strategy.cmdHandler(loginUserDTO.getId(), null);
    }
}
