package com.zcloud.basic.info.service;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.security.starter.api.co.DecryptCmd;
import com.zcloud.basic.info.api.CorpInfoServiceI;
import com.zcloud.basic.info.command.*;
import com.zcloud.basic.info.command.query.CorpInfoQueryExe;
import com.zcloud.basic.info.domain.enums.CorpTypeEnum;
import com.zcloud.basic.info.dto.*;
import com.zcloud.basic.info.dto.clientobject.*;
import com.zcloud.gbscommon.utils.Tools;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:17
 */
@Service
@AllArgsConstructor
public class CorpInfoServiceImpl implements CorpInfoServiceI {
    private final CorpInfoAddExe corpInfoAddExe;
    private final CorpInfoUpdateExe corpInfoUpdateExe;
    private final CorpInfoRemoveExe corpInfoRemoveExe;
    private final CorpInfoQueryExe corpInfoQueryExe;
    // TODO 下面的sysUser废弃了，后续写完写的执行器需要重新完善
    private final UserAddExe userAddExe;
    private final DepartmentAddExe departmentAddExe;
    private final UserUpdateExe userUpdateExe;
//    private final SysUserUpdateExe sysUserUpdateExe;

    @Override
    public PageResponse<CorpInfoCO> listPage(CorpInfoPageQry qry) {

        return corpInfoQueryExe.execute(qry);
    }
    @Override
    public PageResponse<CorpInfoCO> listPageBasic(CorpInfoPageQry qry) {

        return corpInfoQueryExe.executeBasic(qry);
    }

    @Override
    public PageResponse<CorpInfoCO> listPageNoPms(CorpInfoPageQry qry) {
        return corpInfoQueryExe.executeNoPms(qry);
    }

    @Override
    public MultiResponse<CorpInfoCO> listAll(CorpInfoQry corpInfoQry) {
        return corpInfoQueryExe.executeListAll(corpInfoQry);
    }

    @Override
    public SingleResponse add(CorpInfoAddCmd cmd) {
        corpInfoAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public Boolean checkCorpCode(CorpInfoCheckCodeQry qry) {
        return corpInfoQueryExe.execute(qry);
    }

    @Override
    public Boolean checkCorpName(CorpInfoCheckNameQry qry) {
        return corpInfoQueryExe.executeCheckCorpName(qry);
    }

    @Override
    public void edit(CorpInfoUpdateCmd corpInfoUpdateCmd) {
        corpInfoUpdateExe.execute(corpInfoUpdateCmd);
    }

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

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

    @Override
    public CorpInfoCO info(Long id) {
        return corpInfoQueryExe.info(id);
    }

    @Override
    public DecryptCmd getEncryInfo(UserCheckPassWordCmd userCheckPassWordCmd) {
        return corpInfoQueryExe.CorpInfoEncryCO(userCheckPassWordCmd);
    }

    @Override
    public void deleteCorpAndDown(List<Long>  ids) {
        corpInfoRemoveExe.deleteCorpAndDown(ids);
    }

    @Override
    public PageResponse<CorpDepartmentCO> corpDepartlist(CorpDepartmentQry qry) {
        return corpInfoQueryExe.corpDepartlist(qry);
    }

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

    @Override
    public void changeCompanyName(CorpInfoUpdateCmd corpInfoUpdateCmd) {
        corpInfoUpdateExe.changeCompanyName(corpInfoUpdateCmd);
        Long userId = AuthContext.getUserId();
//        sysUserUpdateExe.changeCompanyName(userId,corpInfoUpdateCmd.getCorpName());
    }

    @Override
    public void changeEnableFlag(CorpInfoUpdateUseFlagCmd corpInfoUpdateUseFlagCmd) {
        corpInfoUpdateExe.changeEnableFlag(corpInfoUpdateUseFlagCmd);
    }

    @Override
    public PageResponse<CorpUserMiddleCO> corpUserMiddlePage(CorpUserMiddleQry qry) {
        return corpInfoQueryExe.corpUserMiddlePage(qry);
    }

    @Override
    public List<CorpInfoCO> getCorpList() {
        return corpInfoQueryExe.getCorpList();
    }

    @Override
    public List<CorpInfoCO> listByCorpIds(Collection<Long> collection) {
        return corpInfoQueryExe.listByCorpIds(collection);
    }

    @Override
    public Boolean verifyCorpInfo() {
        return corpInfoQueryExe.verifyCorpInfo();

    }
}

