/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 运维系统
 * 创建日期:2023/10/19
 */
package org.springblade.modules.baseinfo.monitorsite.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.baseinfo.monitorsite.entity.MonitorSiteRelEntity;
import org.springblade.modules.baseinfo.monitorsite.mapper.MonitorSiteRelMapper;
import org.springblade.modules.baseinfo.monitorsite.service.IMonitorSiteRelService;
import org.springframework.stereotype.Service;

import java.util.List;

/***
 * Date:2023/10/19
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Service
public class MonitorSiteRelServiceImpl extends BaseServiceImpl<MonitorSiteRelMapper, MonitorSiteRelEntity> implements IMonitorSiteRelService {

    @Override
    public boolean removeRel(String siteCode) {
        LambdaQueryWrapper<MonitorSiteRelEntity> wrapper = Wrappers.<MonitorSiteRelEntity>query().lambda();
        wrapper.eq(MonitorSiteRelEntity::getIsDeleted, 0);
        wrapper.eq(MonitorSiteRelEntity::getWiustCd, siteCode);
        List<MonitorSiteRelEntity> list = this.list(wrapper);
        for (MonitorSiteRelEntity entity : list) {
            this.deleteLogic(Func.toLongList(Func.toStr(entity.getId())));
        }
        return true;
    }
}
