package com.qmth.sop.server.api;

import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.sop.business.entity.SysUser;
import com.qmth.sop.business.service.SsoService;
import com.qmth.sop.common.annotation.OperationLog;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.enums.ExceptionResultEnum;
import com.qmth.sop.common.enums.LogTypeEnum;
import com.qmth.sop.common.util.Result;
import com.qmth.sop.common.util.ResultUtil;
import com.qmth.sop.common.util.ServletUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: 软通智能客服同步控制器
 * @Author: CaoZixuan
 * @Date: 2023-11-21
 */
@Api(tags = "软通智能客服同步 Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SSO)
public class SsoController {

    @Resource
    private SsoService ssoService;

    @ApiOperation(value = "软通智能客服单点登录")
    @ApiResponses({ @ApiResponse(code = 200, message = "软通智能客服单点登录", response = Result.class) })
    @RequestMapping(value = "/rtzf/login", method = RequestMethod.POST)
    @OperationLog(logType = LogTypeEnum.UN_KNOW)
    public Result analysisLogin() {
        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
        return ResultUtil.ok(ssoService.rtzfSsoLogin(requestUser), ExceptionResultEnum.SUCCESS.getMessage());
    }
}
