package com.zcloud.service.integratedmanagement.access.impl;

import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.integratedmanagement.GateMachineAreaMapper;
import com.zcloud.service.integratedmanagement.access.GateMachineAreaService;
import com.zcloud.util.InitPageDataUtil;
import com.zcloud.util.Jurisdiction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Service
public class GateMachineAreaServiceImpl implements GateMachineAreaService {

    @Resource
    private GateMachineAreaMapper gateMachineAreaMapper;
    @Resource

    private         InitPageDataUtil
            initPageDataUtil;

    @Override
    public PageData findById(PageData pageData) {
        return gateMachineAreaMapper.findById(pageData);
    }

    @Override
    public List<PageData> list(Page page) {
        return gateMachineAreaMapper.datalistPage(page);
    }

    @Override
    @Transactional
    public void edit(PageData pageData) {
        initPageDataUtil.initEdit(pageData);
        gateMachineAreaMapper.edit(pageData);
    }

    @Override
    @Transactional
    public void save(PageData pageData) {
        initPageDataUtil.initSave(pageData,"AREA_ID");
        pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
        gateMachineAreaMapper.save(pageData);
    }

    @Override
    @Transactional
    public void removeByIds(PageData pageData) {
        gateMachineAreaMapper.deleteAll(pageData);
    }
}
