package com.muyu.enterprise.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.enterprise.mapper.FencegroupMapper;
import com.muyu.enterprise.service.IFencegroupService;
import com.muyu.domain.FenceGroup;
import com.muyu.domain.req.FenceGroupAddReq;
import com.muyu.domain.req.FenceGroupReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 围栏组Service业务层处理
 *
 * @author muyu
 * @date 2024-09-19
 */
@Service
public class FencegroupServiceImpl
        extends ServiceImpl<FencegroupMapper, FenceGroup>
        implements IFencegroupService {

    @Autowired
    private FencegroupMapper fencegroupMapper;

    @Override
    public List<FenceGroup> showGroupList(FenceGroupReq req) {
        List<FenceGroup> fenceGroups = fencegroupMapper.showGroupList(req);
        return fenceGroups;
    }

    @Override
    public void addGroup(FenceGroupAddReq addReq) {
        FenceGroup build = FenceGroup.build(addReq);
        this.save(build);
        //添加中间表
        Long fenceGroupId = build.getFenceGroupId();
        fencegroupMapper.addMiddle(addReq.getFenceIds(),fenceGroupId);

    }


}
