|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
@ -25,15 +26,21 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.dao.GuideModuleDictDao; |
|
|
|
import com.epmet.dto.GuideModuleDictDTO; |
|
|
|
import com.epmet.dto.GuideModuleDictDefaultDTO; |
|
|
|
import com.epmet.dto.ModuleDTO; |
|
|
|
import com.epmet.entity.GuideModuleDictEntity; |
|
|
|
import com.epmet.service.GuideModuleDictDefaultService; |
|
|
|
import com.epmet.service.GuideModuleDictService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 指南模块字典表 |
|
|
@ -44,6 +51,8 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class GuideModuleDictServiceImpl extends BaseServiceImpl<GuideModuleDictDao, GuideModuleDictEntity> implements GuideModuleDictService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private GuideModuleDictDefaultService guideModuleDictDefaultService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<GuideModuleDictDTO> page(Map<String, Object> params) { |
|
|
@ -97,4 +106,38 @@ public class GuideModuleDictServiceImpl extends BaseServiceImpl<GuideModuleDictD |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @Description 获取模块列表 |
|
|
|
* @Param customerId |
|
|
|
* @Return {@link List< ModuleDTO >} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/8 17:50 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public List<ModuleDTO> getModuleList(String customerId) { |
|
|
|
LambdaQueryWrapper<GuideModuleDictEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(GuideModuleDictEntity::getCustomerId, customerId); |
|
|
|
wrapper.orderByAsc(GuideModuleDictEntity::getSort); |
|
|
|
List<GuideModuleDictEntity> list = baseDao.selectList(wrapper); |
|
|
|
//结果为空,初始化默认配置
|
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
List<GuideModuleDictDefaultDTO> defaultList = guideModuleDictDefaultService.getList(); |
|
|
|
List<GuideModuleDictEntity> moduleList = ConvertUtils.sourceToTarget(defaultList, GuideModuleDictEntity.class); |
|
|
|
moduleList.forEach(item -> { |
|
|
|
item.setCustomerId(customerId); |
|
|
|
}); |
|
|
|
insertBatch(moduleList); |
|
|
|
list = baseDao.selectList(wrapper); |
|
|
|
} |
|
|
|
return list.stream().map(item -> { |
|
|
|
ModuleDTO dto = new ModuleDTO(); |
|
|
|
dto.setModuleId(item.getId()); |
|
|
|
dto.setModuleValue(item.getModuleValue()); |
|
|
|
dto.setModuleName(item.getModuleName()); |
|
|
|
return dto; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
} |