package com.zcloud.personnel.positioning.service;

import com.zcloud.personnel.positioning.api.AlarmRuleServiceI;
import com.zcloud.personnel.positioning.command.AlarmRuleAddExe;
import com.zcloud.personnel.positioning.command.AlarmRuleRemoveExe;
import com.zcloud.personnel.positioning.command.AlarmRuleUpdateExe;
import com.zcloud.personnel.positioning.command.query.AlarmRuleQueryExe;
import com.zcloud.personnel.positioning.dto.AlarmRuleAddCmd;
import com.zcloud.personnel.positioning.dto.AlarmRuleCompanyPageQry;
import com.zcloud.personnel.positioning.dto.AlarmRulePageQry;
import com.zcloud.personnel.positioning.dto.AlarmRuleUpdateCmd;
import com.zcloud.personnel.positioning.dto.clientobject.AlarmRuleCO;
import com.zcloud.personnel.positioning.dto.clientobject.AlarmRuleCompanyStatCO;
import com.zcloud.personnel.positioning.dto.clientobject.OptionCO;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * web-app
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Service
@AllArgsConstructor
public class AlarmRuleServiceImpl implements AlarmRuleServiceI {
    private final AlarmRuleAddExe alarmRuleAddExe;
    private final AlarmRuleUpdateExe alarmRuleUpdateExe;
    private final AlarmRuleRemoveExe alarmRuleRemoveExe;
    private final AlarmRuleQueryExe alarmRuleQueryExe;

    @Override
    public PageResponse<AlarmRuleCompanyStatCO> listCompanyStats(AlarmRuleCompanyPageQry qry) {
        return alarmRuleQueryExe.listCompanyStats(qry);
    }

    @Override
    public List<OptionCO> listCompanyOptions(String keyword) {
        return alarmRuleQueryExe.listCompanyOptions(keyword);
    }

    @Override
    public PageResponse<AlarmRuleCO> listPage(AlarmRulePageQry qry) {
        return alarmRuleQueryExe.execute(qry);
    }

    @Override
    public List<AlarmRuleCO> listAll() {
        return alarmRuleQueryExe.listAll();
    }

    @Override
    public AlarmRuleCO queryById(Long id) {
        return alarmRuleQueryExe.queryById(id);
    }

    @Override
    public SingleResponse<AlarmRuleCO> add(AlarmRuleAddCmd cmd) {
        alarmRuleAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public void edit(AlarmRuleUpdateCmd cmd) {
        alarmRuleUpdateExe.execute(cmd);
    }

    @Override
    public void enable(Long id) {
        alarmRuleUpdateExe.changeStatus(id, true);
    }

    @Override
    public void disable(Long id) {
        alarmRuleUpdateExe.changeStatus(id, false);
    }

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

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