package com.gkhy.safePlatform.account.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.safePlatform.account.entity.schedule.GroupInfo;
|
import com.gkhy.safePlatform.account.entity.schedule.GroupInfoDO;
|
import com.gkhy.safePlatform.account.entity.schedule.GroupStrategyInfoDO;
|
import com.gkhy.safePlatform.account.model.bo.GroupInfoBO;
|
import com.gkhy.safePlatform.account.model.bo.GroupInfoPageBO;
|
import com.gkhy.safePlatform.account.model.query.db.GroupDBQuery;
|
import com.gkhy.safePlatform.account.model.query.db.GroupPageDBQuery;
|
import com.gkhy.safePlatform.account.repository.schedule.GroupInfoRepository;
|
import com.gkhy.safePlatform.account.service.baseService.GroupInfoService;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.exception.BusinessException;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Collection;
|
import java.util.List;
|
|
|
@Service("groupInfoService")
|
public class GroupInfoServiceImpl extends ServiceImpl<GroupInfoRepository, GroupInfo> implements GroupInfoService {
|
|
@Autowired
|
private GroupInfoRepository groupInfoRepository;
|
|
@Override
|
public GroupInfoDO getGroupInfoById(Long groupId) {
|
if (groupId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.getGroupInfoDOById(groupId);
|
}
|
|
@Override
|
public List<GroupInfoDO> listGroupInfoDO(GroupDBQuery groupDBQuery) {
|
if (groupDBQuery == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.listGroupInfoDO(groupDBQuery);
|
}
|
|
@Override
|
public GroupStrategyInfoDO getGroupStrategyByGroupId(Long groupId) {
|
if (groupId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.getGroupStrategyByGroupId(groupId);
|
}
|
|
@Override
|
public List<Long> listGroupIdsByGroupStrategyId(Long groupStrategyId) {
|
if (groupStrategyId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.getGroupIdsByGroupStrategyId(groupStrategyId);
|
}
|
|
@Override
|
public void unbindBatchGroupStrategyByGroupIds(List<Long> groupIds) {
|
if (groupIds == null || groupIds.size() == 0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
groupInfoRepository.deleteGroupStrategyByGroupIds(groupIds);
|
}
|
|
@Override
|
public void unbindGroupStrategyByGroupStrategyId(Long groupStrategyId) {
|
if (groupStrategyId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
groupInfoRepository.deleteGroupStrategyByGroupStrategyId(groupStrategyId);
|
}
|
|
@Override
|
public List<GroupInfoDO> listGroupInfoDOsByGroupStrategyId(Long groupStrategyId) {
|
if (groupStrategyId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.getGroupInfosByGroupStrategyId(groupStrategyId);
|
}
|
|
@Override
|
public List<GroupInfoPageBO> listGroupInfo(Page<GroupInfo> page, GroupPageDBQuery dbQuery) {
|
if (dbQuery == null || page == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.listGroupInfo(page,dbQuery);
|
}
|
|
@Override
|
public List<GroupInfoBO> listGroupInfoBO(GroupDBQuery dbQuery) {
|
if (dbQuery == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.listGroupInfoBO(dbQuery);
|
}
|
|
@Override
|
public void deleteGroupInfo(GroupInfo groupInfo) {
|
if (groupInfo == null || groupInfo.getId() == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
groupInfoRepository.deleteGroupInfo(groupInfo);
|
}
|
|
@Override
|
public boolean isExistGroupMountedByDepartment(Long depId) {
|
if (depId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
List<GroupInfo> groupInfos = groupInfoRepository.selectList(new LambdaQueryWrapper<GroupInfo>()
|
// 部门id
|
.eq(GroupInfo::getDepId, depId)
|
// 一条记录
|
.last("limit 1"));
|
|
return groupInfos.size() > 0;
|
}
|
|
|
|
@Override
|
public List<GroupInfoDO> listGroupDOByGroupIds(Collection<Long> groupIds) {
|
if (groupIds == null || groupIds.size() == 0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return groupInfoRepository.listGroupDOByGroupIds(groupIds);
|
}
|
|
}
|