package com.zcloud.basic.info.command;

import com.alibaba.cola.exception.BizException;
import com.zcloud.basic.info.domain.gateway.CorpInfoGateway;
import com.zcloud.gbscommon.utils.Const;
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * web-app
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:17
 */
@Component
@AllArgsConstructor
public class CorpInfoRemoveExe {
    private final CorpInfoGateway corpInfoGateway;
//    @Autowired
//    private ZcloudRedisUtil zcloudRedisUtil;

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(Long id) {
        boolean res = corpInfoGateway.deletedCorpInfoById(id);
        if (!res) {
            throw new BizException("删除失败");
        }
        //删除redis数据
      //  zcloudRedisUtil.del(Const.REDIS_CORP_PREFIX+id);
        return true;
    }

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(Long[] ids) {
        boolean res = corpInfoGateway.deletedCorpInfoByIds(ids);
        if (!res) {
            throw new BizException("删除失败");
        }
//        for (Long id : ids) {
//            zcloudRedisUtil.del(Const.REDIS_CORP_PREFIX+id);
//        }
        return true;
    }
}

