package com.zcloud.basic.info.service;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.basic.info.api.UserServiceI;
import com.zcloud.basic.info.command.UserAddExe;
import com.zcloud.basic.info.command.UserImportExe;
import com.zcloud.basic.info.command.UserRemoveExe;
import com.zcloud.basic.info.command.UserUpdateExe;
import com.zcloud.basic.info.command.query.UserQueryExe;
import com.zcloud.basic.info.dto.*;
import com.zcloud.basic.info.dto.clientobject.*;
import com.zcloud.basic.info.persistence.dataobject.UserImgDO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * web-app
 *
 * @Author zhangyue
 * @Date 2025-11-04 14:07:37
 */
@Service
@AllArgsConstructor
public class UserServiceImpl implements UserServiceI {
    private final UserAddExe userAddExe;
    private final UserUpdateExe userUpdateExe;
    private final UserRemoveExe userRemoveExe;
    private final UserQueryExe userQueryExe;
    private final UserImportExe userImportExe;

    @Override
    public PageResponse<UserCO> listPage(UserPageQry qry) {

        return userQueryExe.execute(qry);
    }

    @Override
    public SingleResponse add(UserAddCmd cmd) {

        userAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> register(AppUserRegisterCmd cmd) {
        userAddExe.executeRegister(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> registerYanshi(AppUserRegisterCmd cmd) {
        userAddExe.executeRegisterYanshi(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> passwordRecover(AppUserRegisterCmd cmd) {
        userUpdateExe.executePasswordRecover(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> perfectUserInfo(AppUserInfoCmd cmd) {
        userAddExe.executePerfectUserInfo(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> onboarding(AppUserOnboardingCmd cmd) {
        userAddExe.executeOnboarding(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<UserCO> verifyPhone(UserVerifyPhoneCmd cmd) {
        userQueryExe.executeVerifyPhone(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public SingleResponse<Boolean> sendPhoneCode(UserVerifyPhoneCmd cmd) {
        return SingleResponse.of(userAddExe.executeSendPhoneCode(cmd));
    }


    @Override
    public SingleResponse addXgf(UserXgfAddCmd cmd) {
        userAddExe.executeXgf(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public void edit(UserUpdateCmd userUpdateCmd) {
        userUpdateExe.execute(userUpdateCmd);
    }

    @Override
    public void editData(UserQryCmd userUpdateCmd) {
        userUpdateExe.editData(userUpdateCmd);
    }

    @Override
    public void exportUserTable(HttpServletResponse httpServletResponse, Long[] ids, Long corpinfoId) {
        userQueryExe.exportUserTable(httpServletResponse, ids, corpinfoId);
    }

    @Override
    public void importUserTable(MultipartFile file, Integer corpFlag) {
        userImportExe.importUserTable(file, corpFlag);
    }

    @Override
    public void remove(Long id) {
        userRemoveExe.execute(id);
    }

    @Override
    public void removeBatch(Long[] ids) {
        userRemoveExe.execute(ids);
    }

    @Override
    public MultiResponse<UserCO> listAll(UserQryCmd userQryCmd) {
        return userQueryExe.executeListAll(userQryCmd);
    }

    @Override
    public List<UserCO> listByUserIds(Collection<Long> collection) {
       return userQueryExe.listByUserIds(collection);

    }

    @Override
    public List<UserCO> listUserByUserName(Collection<String> collection) {
        return userQueryExe.listUserByUserName(collection);
    }

    @Override
    public List<UserCO> listUserByUserNameV1(Collection<String> collection) {
        return userQueryExe.listUserByUserNameV1(collection);
    }

    @Override
    public List<UserCO> getUserList() {
        return userQueryExe.getUserList();
    }

    @Override
    public UserCO getInfoByUserId(Long aLong) {
        return userQueryExe.getInfoByUserId(aLong);
    }

    @Override
    public SingleResponse<UserCO> getInfoById(Long id) {
        return userQueryExe.executeGetInfo(id);
    }
    @Override
    public SingleResponse<UserCO> getInfoByUserName(String userName) {
        return userQueryExe.executeGetInfoByUserName(userName);
    }

    @Override
    public Response verifyUser(UserVerifyQryCmd userVerifyQryCmd) {
        return userQueryExe.executeVerifyUser(userVerifyQryCmd);
    }

    @Override
    public SingleResponse<UserCO> getInfoBySession() {
        return userQueryExe.executeGetInfoBySession();
    }

    @Override
    public void changePassword(Long id) {
        userUpdateExe.executeChangePassword(id);
    }

    @Override
    public Response updatePassword(UserUpdatePassWordCmd userUpdatePassWordCmd) {
        return userUpdateExe.executeUpdatePassword(userUpdatePassWordCmd);
    }

    @Override
    public Boolean updateUserFaceUrl(UserUpdateFaceUrlCmd cmd) {
        return userUpdateExe.updateUserFaceUrl(cmd);
    }

    @Override
    public SingleResponse<UserCO> getEncryInfo(UserCheckPassWordCmd userCheckPassWordCmd) {
        return userQueryExe.getEncryInfo(userCheckPassWordCmd);
    }

    @Override
    public PageResponse<UserXmfCO> listXgf(UserPageQry qry) {
        return userQueryExe.listXgf(qry);

    }

    @Override
    public void resignation(UserResignationCmd userResignationCmd) {
        userUpdateExe.executeResignation(userResignationCmd);
    }
    @Override
    public void reviewStatus(UserReviewStatusCmd userReviewStatusCmd) {
        userUpdateExe.executeReviewStatus(userReviewStatusCmd);
    }

    @Override
    public void appUserResignation(AppUserResignationCmd appUserResignationCmd) {
        userUpdateExe.appUserResignation(appUserResignationCmd);

    }

    @Override
    public Boolean updatePasswordFromApp(AppUserUpdatePassWordCmd cmd) {
        return userUpdateExe.updatePasswordFromApp(cmd);
    }

    @Override
    public void logOut(AppUserLogOutCmd cmd) {
        userRemoveExe.executeLogOut(cmd);
    }

    @Override
    public UserLoginCO login(UserAppLoginCmd cmd) {
        return userQueryExe.login(cmd);

    }

    @Override
    public UserLoginCO getUserCorpByPhone(UserAppPhoneCmd cmd) {
        return userQueryExe.getUserCorpByPhone(cmd);
    }

    @Override
    public List<UserImgDO> listBase64ByUrl(Map<String, Object> map) {
        return userQueryExe.listBase64ByUrl(map);
    }

    @Override
    public List<UserCorpInfoCO> getUserCorpList(Long id) {
        return userQueryExe.getUserCorpList(id);
    }

    @Override
    public CaptchaCO generateCaptcha() {

        return userQueryExe.generateCaptcha();
    }

    @Override
    public SingleResponse<UserCO> getUserIdByPhone(GetUserIdByPhoneCmd getUserIdByPhoneCmd) {
        return userQueryExe.getUserIdByPhone(getUserIdByPhoneCmd);
    }

    @Override
    public PageResponse<UserCO> pageByNopermission(UserPageQry qry) {
        return userQueryExe.pageByNopermission(qry);
    }
}

