package org.jeecg.modules.dnc.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.jeecg.modules.dnc.entity.DeviceGroupDepart;
|
import org.jeecg.modules.dnc.mapper.DeviceGroupDepartMapper;
|
import org.jeecg.modules.dnc.ucenter.Department;
|
import org.jeecg.modules.dnc.utils.ValidateUtil;
|
import org.jeecg.modules.dnc.service.IDeviceGroupDepartService;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class DeviceGroupDepartServiceImpl extends ServiceImpl<DeviceGroupDepartMapper, DeviceGroupDepart> implements IDeviceGroupDepartService {
|
@Override
|
public List<Department> getDepartPermsByGroupId(String groupId) {
|
return super.getBaseMapper().getDepartPermsByGroupId(groupId);
|
}
|
|
@Override
|
public List<Department> getDepartNonPermsByGroupId(String groupId) {
|
return super.getBaseMapper().getDepartNonPermsByGroupId(groupId);
|
}
|
|
@Override
|
public DeviceGroupDepart getDepartByGroupAndDepartId(String groupId, String departId) {
|
if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateString(departId))
|
return null;
|
List<DeviceGroupDepart> list = super.lambdaQuery().eq(DeviceGroupDepart::getGroupId, groupId).eq(DeviceGroupDepart::getDepartId, departId).list();
|
if(list == null || list.isEmpty())
|
return null;
|
return list.get(0);
|
}
|
|
@Override
|
@Transactional(rollbackFor = {Exception.class})
|
public boolean removeByCollection(List<DeviceGroupDepart> departList) {
|
if(departList == null || departList.isEmpty())
|
return false;
|
if(departList.size() == 1)
|
return super.removeById(departList.get(0).getGroupDepartId());
|
List<String> ids = new ArrayList<>();
|
departList.forEach(item -> {
|
ids.add(item.getGroupDepartId());
|
});
|
return super.removeByIds(ids);
|
}
|
|
@Override
|
@Transactional(rollbackFor = {Exception.class})
|
public boolean deleteByGroupId(String groupId) {
|
LambdaQueryWrapper<DeviceGroupDepart> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
lambdaQueryWrapper.eq(DeviceGroupDepart::getGroupId, groupId);
|
return super.remove(lambdaQueryWrapper);
|
}
|
}
|