package com.pnkx.web.controller.common;

import com.pnkx.common.annotation.Log;
import com.pnkx.common.core.controller.BaseController;
import com.pnkx.common.core.domain.AjaxResult;
import com.pnkx.common.enums.OperatorType;
import com.pnkx.common.utils.ip.IpUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 开放式接口Controller
 *
 * @author phy
 * @date 2021-10-30
 */
@RestController
@RequestMapping("/open")
public class OpenController extends BaseController {

    /**
     * 获取ip
     */
    @ApiOperation("获取IP")
    @Log(title = "获取IP", operatorType = OperatorType.OTHER)
    @GetMapping("/getIp")
    public AjaxResult getIp(HttpServletRequest request) {
        return AjaxResult.success("获取IP成功！", IpUtils.getIpAddr(request));
    }
}
