package com.xunhong.erp.turbo.auth.controller;

import com.alibaba.cola.dto.SingleResponse;
import com.xunhong.erp.turbo.api.infra.api.ChannelServiceI;
import com.xunhong.erp.turbo.api.infra.dto.qry.ChannelShowQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.ChannelVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Channel", description = "渠道管理")
@RestController("authChannelController")
@RequestMapping("/auth")
@RequiredArgsConstructor
public class ChannelController {

	@DubboReference(version = "1.0.0")
	private final ChannelServiceI channelService;

	@GetMapping("/selectChannelByDomain")
	@Operation(summary = "根据域名获取渠道", method = "GET")
	public SingleResponse<ChannelVO> selectChannelByDomain(@RequestParam(value = "domain") String domain) {
		ChannelShowQry channelShowQry = new ChannelShowQry();
		channelShowQry.setDomain(domain);
		return SingleResponse.of(channelService.show(channelShowQry));
	}
}
