feat:字典表
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.cool.store.service.dict;
|
||||
|
||||
import com.cool.store.request.dict.DictColumnQueryRequest;
|
||||
import com.cool.store.vo.dict.DictColumnSimpleVO;
|
||||
import com.cool.store.vo.dict.DictColumnVO;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
public interface DictColumnService {
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典项VO
|
||||
*/
|
||||
DictColumnVO getById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param dto 字典项查询DTO
|
||||
* @return 字典项VO分页对象
|
||||
*/
|
||||
PageInfo<DictColumnVO> getPage(DictColumnQueryRequest dto);
|
||||
|
||||
/**
|
||||
* 根据编码查询已启用的字典项
|
||||
* @param columnCode 字典项编码
|
||||
* @return 字典项简单信息VO
|
||||
*/
|
||||
DictColumnSimpleVO getColumnByColumnCode(String columnCode);
|
||||
|
||||
/**
|
||||
* 根据表编码查询字典项
|
||||
* @param tableCodes 字典表编码列表
|
||||
* @return 字典项简单信息映射
|
||||
*/
|
||||
Map<String, List<DictColumnSimpleVO>> getMapListByTableCode(List<String> tableCodes);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cool.store.service.dict;
|
||||
|
||||
import com.cool.store.request.dict.DictGroupQueryRequest;
|
||||
import com.cool.store.vo.dict.DictGroupVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典分组
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
public interface DictGroupService {
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典分组VO
|
||||
*/
|
||||
DictGroupVO getById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param queryDTO 字典分组查询DTO
|
||||
* @return 字典分组实体列表
|
||||
*/
|
||||
List<DictGroupVO> getList(DictGroupQueryRequest queryDTO);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cool.store.service.dict;
|
||||
|
||||
import com.cool.store.request.dict.DictTableQueryRequest;
|
||||
import com.cool.store.vo.dict.DictTableVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
public interface DictTableInfoService {
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典表信息表VO
|
||||
*/
|
||||
DictTableVO getById(Long id);
|
||||
|
||||
/**
|
||||
* VO列表查询
|
||||
* @param dto 字典表查询DTO
|
||||
* @return 字典表信息表VO列表
|
||||
*/
|
||||
List<DictTableVO> getList(DictTableQueryRequest dto);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.cool.store.service.dict.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.dict.SysDictColumnDAO;
|
||||
import com.cool.store.dao.dict.SysDictTableDAO;
|
||||
import com.cool.store.entity.dict.SysDictColumnDO;
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.request.dict.DictColumnQueryRequest;
|
||||
import com.cool.store.service.dict.DictColumnService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.vo.dict.DictColumnSimpleVO;
|
||||
import com.cool.store.vo.dict.DictColumnVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictColumnServiceImpl implements DictColumnService {
|
||||
private final SysDictColumnDAO columnDAO;
|
||||
private final SysDictTableDAO tableDAO;
|
||||
private final EnterpriseUserDAO userDAO;
|
||||
|
||||
@Override
|
||||
public DictColumnVO getById(Long id) {
|
||||
SysDictColumnDO column = columnDAO.getById(id);
|
||||
return BeanUtil.toBean(column, DictColumnVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<DictColumnVO> getPage(DictColumnQueryRequest dto) {
|
||||
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
||||
List<SysDictColumnDO> list = columnDAO.getList(dto);
|
||||
PageInfo<SysDictColumnDO> page = new PageInfo<>(list);
|
||||
PageInfo<DictColumnVO> result = BeanUtil.toPage(page, DictColumnVO.class);
|
||||
Set<String> userIds = new HashSet<>();
|
||||
result.getList().forEach(item -> {
|
||||
userIds.add(item.getCreateUserId());
|
||||
userIds.add(item.getUpdateUserId());
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(userIds)) {
|
||||
Map<String, String> userNameMap = userDAO.getUserNameMap(new ArrayList<>(userIds));
|
||||
result.getList().forEach(v -> {
|
||||
v.setCreateUserName(userNameMap.get(v.getCreateUserId()));
|
||||
v.setUpdateUserName(userNameMap.get(v.getUpdateUserId()));
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictColumnSimpleVO getColumnByColumnCode(String columnCode) {
|
||||
SysDictColumnDO column = columnDAO.getOpenColumnByCode(columnCode);
|
||||
SysDictTableDO table = tableDAO.getById(column.getDictTableId());
|
||||
DictColumnSimpleVO vo = BeanUtil.toBean(column, DictColumnSimpleVO.class);
|
||||
if (Objects.nonNull(table)) {
|
||||
vo.setTableCode(table.getTableCode());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictColumnSimpleVO>> getMapListByTableCode(List<String> tableCodes) {
|
||||
if (CollectionUtils.isEmpty(tableCodes)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<DictColumnSimpleVO> list = columnDAO.getOpenColumnListByTableCode(tableCodes);
|
||||
return CollStreamUtil.groupByKey(list, DictColumnSimpleVO::getTableCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.cool.store.service.dict.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import com.cool.store.dao.dict.SysDictColumnDAO;
|
||||
import com.cool.store.dao.dict.SysDictGroupDAO;
|
||||
import com.cool.store.dao.dict.SysDictTableDAO;
|
||||
import com.cool.store.entity.dict.SysDictGroupDO;
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.request.dict.DictGroupQueryRequest;
|
||||
import com.cool.store.service.dict.DictGroupService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.vo.dict.DictGroupVO;
|
||||
import com.cool.store.vo.dict.DictTableVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典分组 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictGroupServiceImpl implements DictGroupService {
|
||||
private final SysDictGroupDAO groupDAO;
|
||||
private final SysDictTableDAO tableDAO;
|
||||
private final SysDictColumnDAO columnDAO;
|
||||
|
||||
@Override
|
||||
public DictGroupVO getById(Long id) {
|
||||
SysDictGroupDO group = groupDAO.getById(id);
|
||||
return BeanUtil.toBean(group, DictGroupVO.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DictGroupVO> getList(DictGroupQueryRequest queryDTO) {
|
||||
List<SysDictGroupDO> list = groupDAO.getList(queryDTO);
|
||||
List<DictGroupVO> result = BeanUtil.toList(list, DictGroupVO.class);
|
||||
// 查询字典表
|
||||
List<Long> groupIds = CollStreamUtil.toList(result, DictGroupVO::getId);
|
||||
List<SysDictTableDO> tableList = tableDAO.getListByGroupIds(groupIds, queryDTO.getDictTableOpenStatus());
|
||||
List<DictTableVO> tableVOList = BeanUtil.toList(tableList, DictTableVO.class);
|
||||
// 查询字典项数量
|
||||
List<Long> tableIds = CollStreamUtil.toList(tableVOList, DictTableVO::getId);
|
||||
Map<Long, Integer> columnNumMap = columnDAO.getColumnNumMapByTableIds(tableIds);
|
||||
|
||||
tableVOList.forEach(v -> v.setColumnNum(columnNumMap.getOrDefault(v.getId(), 0)));
|
||||
|
||||
Map<Long, List<DictTableVO>> tableMap = CollStreamUtil.groupByKey(tableVOList, DictTableVO::getDictGroupId);
|
||||
result.forEach(v -> v.setTableList(tableMap.getOrDefault(v.getId(), Collections.emptyList())));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.cool.store.service.dict.impl;
|
||||
|
||||
import com.cool.store.dao.dict.SysDictColumnDAO;
|
||||
import com.cool.store.dao.dict.SysDictTableDAO;
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.request.dict.DictTableQueryRequest;
|
||||
import com.cool.store.service.dict.DictTableInfoService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.vo.dict.DictTableVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictTableInfoServiceImpl implements DictTableInfoService {
|
||||
private final SysDictTableDAO dictTableInfoDAO;
|
||||
private final SysDictColumnDAO columnInfoDAO;
|
||||
|
||||
|
||||
@Override
|
||||
public DictTableVO getById(Long id) {
|
||||
SysDictTableDO table = dictTableInfoDAO.getById(id);
|
||||
return BeanUtil.toBean(table, DictTableVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTableVO> getList(DictTableQueryRequest dto) {
|
||||
List<SysDictTableDO> list = dictTableInfoDAO.getList(dto);
|
||||
return BeanUtil.toList(list, DictTableVO.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user