package com.yc.ship.module.otc.api.agency;


import com.yc.ship.module.otc.api.agency.dto.AgencyUserLoginInfoReqDTO;
import com.yc.ship.module.otc.api.agency.dto.AgencyUserLoginInfoRespDTO;
import com.yc.ship.module.otc.service.auth.AgencyLoginLogService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.yc.ship.module.otc.enums.ErrorCodeConstants.AGENCY_LOGIN_LOG_EXCEPTION;


/**
 * &#064;Description 旅行社授权接口
 * &#064;Author qsl
 * &#064;Date 2025/6/4 15:28
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class AgencyAuthApiImpl implements AgencyAuthApi {

    @Resource
    private AgencyLoginLogService agencyLoginLogService;

    @Override
    public AgencyUserLoginInfoRespDTO getAgencyUserLoginInfo(AgencyUserLoginInfoReqDTO reqDTO) {
        AgencyUserLoginInfoRespDTO loginLog = agencyLoginLogService.getLoginLog(reqDTO);
        if(loginLog == null) {
            throw exception(AGENCY_LOGIN_LOG_EXCEPTION);
        }
        return loginLog;
    }

    @Override
    public AgencyUserLoginInfoRespDTO getStoreSellerLoginInfo(AgencyUserLoginInfoReqDTO reqDTO) {
        return agencyLoginLogService.getLoginLog(reqDTO);
    }
}
