package com.xunhong.erp.turbo.user.app.service;

import com.xunhong.erp.turbo.api.facade.dto.qry.WxMaOpenidQry;
import com.xunhong.erp.turbo.api.user.api.UserServiceI;
import com.xunhong.erp.turbo.api.user.dto.cmd.*;
import com.xunhong.erp.turbo.api.user.dto.qry.UserListQry;
import com.xunhong.erp.turbo.api.user.dto.qry.UserPageQry;
import com.xunhong.erp.turbo.api.user.dto.qry.UserShowQry;
import com.xunhong.erp.turbo.api.user.dto.vo.UserVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.user.app.executor.cmd.*;
import com.xunhong.erp.turbo.user.app.executor.query.UserPageQryExe;
import com.xunhong.erp.turbo.user.app.executor.query.UserShowQryExe;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyifei
 * @author shenyifei
 */
@Slf4j
@Service
@DubboService(interfaceClass = UserServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class UserServiceImpl implements UserServiceI {
	private final UserShowQryExe userShowQryExe;
	private final UserUpdateCmdExe userUpdateCmdExe;
	private final UserPageQryExe userPageQryExe;
	private final UserCreateCmdExe userCreateCmdExe;
	private final UserDestroyCmdExe userDestroyCmdExe;
	private final UserListQryExe userListQryExe;
	private final UserDisableCmdExe userDisableCmdExe;
	private final UserEnableCmdExe userEnableCmdExe;
	private final UserUnsubscribeCmdExe userUnsubscribeCmdExe;

	@Override
	public UserVO show(UserShowQry userShowQry) {
		return userShowQryExe.execute(userShowQry);
	}

	@Override
	public UserVO update(UserUpdateCmd userUpdateCmd) {
		return userUpdateCmdExe.execute(userUpdateCmd);
	}

	@Override
	public PageDTO<UserVO> page(UserPageQry userPageQry) {
		return PageDTO.of(userPageQryExe.execute(userPageQry));
	}

	@Override
	public UserVO create(UserCreateCmd userCreateCmd) {
		return userCreateCmdExe.execute(userCreateCmd);
	}

	@Override
	public void destroy(UserDestroyCmd userDestroyCmd) {
		userDestroyCmdExe.execute(userDestroyCmd);
	}

	@Override
	public List<UserVO> list(UserListQry userListQry) {
		return userListQryExe.execute(userListQry);
	}

	@Override
	public void disable(UserDisableCmd userDisableCmd) {
		userDisableCmdExe.execute(userDisableCmd);
	}

	@Override
	public void enable(UserEnableCmd userEnableCmd) {
		userEnableCmdExe.execute(userEnableCmd);
	}

	@Override
	public void unsubscribe(WxMaOpenidQry wxMaOpenidQry) {
		userUnsubscribeCmdExe.execute(wxMaOpenidQry);
	}
}
