package com.sandu.ximon.admin.service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.sandu.common.execption.BusinessException; import com.sandu.common.service.impl.BaseServiceImpl; import com.sandu.ximon.admin.param.PoleGroupParam; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.dao.domain.PoleGroup; import com.sandu.ximon.dao.mapper.PoleGroupMapper; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; /** * 分组操作 * * @author chenjiantian */ @Service @AllArgsConstructor public class PoleGroupService extends BaseServiceImpl { private final PoleGroupRelationService poleGroupRelationService; public boolean addGroup(PoleGroupParam param) { PoleGroup group = new PoleGroup(); group.setClientId(SecurityUtils.getClientId()); group.setGroupName(param.getGroupName()); return save(group); } public boolean updateGroup(Long groupId, PoleGroupParam param) { PoleGroup poleGroup = getById(groupId); if (poleGroup == null) { throw new BusinessException("未找到该分组"); } PoleGroup update = new PoleGroup(); update.setGroupId(groupId); update.setGroupName(param.getGroupName()); return updateById(update); } public boolean deleteGroup(Long groupId) { PoleGroup poleGroup = getById(groupId); if (poleGroup == null) { throw new BusinessException("未找到该分组"); } return removeById(groupId); } public List groupList() { Long clientId = SecurityUtils.getClientId(); if (clientId == null) { return list(); } else { return list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId)); } } /** * 绑定灯杆 */ public boolean bindPole(Long groupId,List poleIdList) { PoleGroup poleGroup = getById(groupId); if (poleGroup == null) { throw new BusinessException("未找到该分组"); } return poleGroupRelationService.saveBinding(groupId,poleIdList); } }