package com.persagy.adm.server.auth.controller;

import com.persagy.adm.server.auth.domain.LoginVo;
import com.persagy.adm.server.auth.service.AdmAuthService;
import com.persagy.dmp.auth.client.BossAuthFacade;
import com.persagy.dmp.auth.client.PaasAccountFacade;
import com.persagy.dmp.auth.domain.BossAuthUser;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 00-登录及权限控制
 * 后端服务名:adm-server
 * @author : lijie
 * Update By 2022/1/12 14:00
 */
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AdmAuthController {

    private final AdmAuthService admAuthService;

    /**
     * 000101-登录-登录接口
     * @param loginVo : 登录信息
     * @return : com.persagy.dmp.common.model.response.CommonResult<java.lang.String>
     * @author : lijie
     * Update By 2022/1/7 21:57
     */
    @PostMapping(value = "/account/login")
    public CommonResult<String> accountLogin(@RequestBody LoginVo loginVo) {
        return PaasAccountFacade.accountLogin(loginVo);
    }

    /**
     * 000102-登录-获取当前登录人的信息
     * @return : com.persagy.dmp.common.model.response.CommonResult<com.persagy.dmp.auth.domain.BossAuthUser>
     * @author : lijie
     * Update By 2022/1/11 15:50
     */
    @PostMapping(value = "/login/loginInfo")
    public CommonResult<BossAuthUser> loginInfo() {
        return ResultHelper.single(admAuthService.loginInfo());
    }


}
