feat:字典表
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.cool.store.common;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新增分组
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/11/4
|
||||
*/
|
||||
public interface InsertGroup {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cool.store.common;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 更新分组
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/11/4
|
||||
*/
|
||||
public interface UpdateGroup {
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.cool.store.dao.dict;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import com.cool.store.entity.dict.SysDictColumnDO;
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.mapper.dict.SysDictColumnMapper;
|
||||
import com.cool.store.request.dict.DictColumnQueryRequest;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.vo.dict.DictColumnSimpleVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项DAO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/26
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class SysDictColumnDAO {
|
||||
private final SysDictColumnMapper sysDictColumnMapper;
|
||||
private final SysDictTableDAO sysDictTableDAO;
|
||||
|
||||
|
||||
public List<SysDictColumnDO> getList(DictColumnQueryRequest dto) {
|
||||
return sysDictColumnMapper.selectList(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id id
|
||||
* @return 字典项信息表
|
||||
*/
|
||||
public SysDictColumnDO getById(Long id) {
|
||||
return sysDictColumnMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表id查询字典项数量
|
||||
*
|
||||
* @param tableIds 字典表id列表
|
||||
* @return <字典表id, 字典项数量>
|
||||
*/
|
||||
public Map<Long, Integer> getColumnNumMapByTableIds(List<Long> tableIds) {
|
||||
if (CollectionUtil.isEmpty(tableIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<Map<String, Object>> mapList = sysDictColumnMapper.selectColumnNumByTableIds(tableIds);
|
||||
return CollStreamUtil.toMap(mapList, v -> MapUtils.getLong(v, "dict_table_id"), v -> MapUtils.getInteger(v, "num"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤存在启用字典项的字典分组id
|
||||
* @param groupIds 字典分组id列表
|
||||
* @return 字典分组id列表
|
||||
*/
|
||||
public Set<Long> filterEnableColumnByGroupIds(List<Long> groupIds) {
|
||||
if (CollectionUtil.isEmpty(groupIds)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<Map<String, Object>> list = sysDictColumnMapper.filterEnableColumnByGroupIds(groupIds);
|
||||
return CollStreamUtil.toSet(list, v -> MapUtils.getLong(v, "dict_group_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤存在启用字典项的字典表id
|
||||
* @param tableIds 字典表id列表
|
||||
* @return 字典表id列表
|
||||
*/
|
||||
public Set<Long> filterEnableColumnByTableIds(List<Long> tableIds) {
|
||||
if (CollectionUtil.isEmpty(tableIds)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<Map<String, Object>> list = sysDictColumnMapper.filterEnableColumnByTableIds(tableIds);
|
||||
return CollStreamUtil.toSet(list, v -> MapUtils.getLong(v, "dict_table_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分组id删除
|
||||
* @param groupIds 分组id列表
|
||||
*/
|
||||
public void deleteByGroupIds(List<Long> groupIds) {
|
||||
if (CollectionUtil.isEmpty(groupIds)) {
|
||||
return;
|
||||
}
|
||||
sysDictColumnMapper.deleteByGroupIds(groupIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表id删除
|
||||
* @param tableIds 字典表id列表
|
||||
*/
|
||||
public void deleteByTableIds(List<Long> tableIds) {
|
||||
if (CollectionUtil.isEmpty(tableIds)) {
|
||||
return;
|
||||
}
|
||||
sysDictColumnMapper.deleteByTableIds(tableIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典列编码查询已启用字典项信息
|
||||
* @param columnCode 字典列编码
|
||||
* @return 字典项信息
|
||||
*/
|
||||
public SysDictColumnDO getOpenColumnByCode(String columnCode) {
|
||||
return sysDictColumnMapper.selectOpenColumnByCode(columnCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典列编码查询已启用字典名
|
||||
* @param columnCode 字典列编码
|
||||
* @return 字典名
|
||||
*/
|
||||
public String getNameByCode(String columnCode) {
|
||||
SysDictColumnDO sysDictColumnDO = sysDictColumnMapper.selectOpenColumnByCode(columnCode);
|
||||
if (Objects.nonNull(sysDictColumnDO)) {
|
||||
return sysDictColumnDO.getColumnName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表编码查询启用状态的字典项
|
||||
* @param tableCodes 字典表编码列表
|
||||
* @return 字典项列表
|
||||
*/
|
||||
public List<DictColumnSimpleVO> getOpenColumnListByTableCode(List<String> tableCodes) {
|
||||
List<SysDictTableDO> tableList = sysDictTableDAO.getOpenTableListByTableCodes(tableCodes);
|
||||
if (CollectionUtils.isEmpty(tableList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> tableIds = CollStreamUtil.toList(tableList, SysDictTableDO::getId);
|
||||
List<SysDictColumnDO> columnList = sysDictColumnMapper.selectOpenColumnListByTableIds(tableIds);
|
||||
Map<Long, String> tableCodeMap = CollStreamUtil.toMap(tableList, SysDictTableDO::getId, SysDictTableDO::getTableCode);
|
||||
return CollStreamUtil.toList(columnList, v -> {
|
||||
DictColumnSimpleVO vo = BeanUtil.toBean(v, DictColumnSimpleVO.class);
|
||||
vo.setTableCode(tableCodeMap.get(v.getDictTableId()));
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.cool.store.dao.dict;
|
||||
|
||||
import com.cool.store.entity.dict.SysDictGroupDO;
|
||||
import com.cool.store.mapper.dict.SysDictGroupMapper;
|
||||
import com.cool.store.request.dict.DictGroupQueryRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典分组DAO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/26
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class SysDictGroupDAO {
|
||||
private final SysDictGroupMapper sysDictGroupMapper;
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典分组表
|
||||
*/
|
||||
public SysDictGroupDO getById(Long id) {
|
||||
return sysDictGroupMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param dto 字典分组查询DTO
|
||||
* @return 字典分组表列表
|
||||
*/
|
||||
public List<SysDictGroupDO> getList(DictGroupQueryRequest dto) {
|
||||
return sysDictGroupMapper.selectList(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.cool.store.dao.dict;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.mapper.dict.SysDictTableMapper;
|
||||
import com.cool.store.request.dict.DictTableQueryRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表DAO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/25
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class SysDictTableDAO {
|
||||
|
||||
private final SysDictTableMapper dictTableMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* @param dto 字典表查询DTO
|
||||
* @return 字典表信息表列表
|
||||
*/
|
||||
public List<SysDictTableDO> getList(DictTableQueryRequest dto) {
|
||||
return dictTableMapper.selectList(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典表信息表
|
||||
*/
|
||||
public SysDictTableDO getById(Long id) {
|
||||
return dictTableMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param ids id列表
|
||||
* @return 字典表列表
|
||||
*/
|
||||
public List<SysDictTableDO> getByIds(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return dictTableMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表id查询所属字典分组id
|
||||
* @param dictTableId 字典表id
|
||||
* @return 字典分组id
|
||||
*/
|
||||
public Long getGroupIdByTableId(Long dictTableId) {
|
||||
SysDictTableDO tableInfoDO = getById(dictTableId);
|
||||
if (Objects.nonNull(tableInfoDO)) {
|
||||
return tableInfoDO.getDictGroupId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分组id查询字典表
|
||||
* @param groupIds 字典分组id列表
|
||||
* @return 字典表VO对象列表
|
||||
*/
|
||||
public List<SysDictTableDO> getListByGroupIds(List<Long> groupIds, Integer openStatus) {
|
||||
if (CollectionUtil.isEmpty(groupIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return dictTableMapper.selectByGroupIds(groupIds, openStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤存在启用字典表的字典分组id
|
||||
* @param groupIds 字典分组id
|
||||
* @return 字典分组id列表
|
||||
*/
|
||||
public Set<Long> filterEnableTableByGroupIds(List<Long> groupIds) {
|
||||
if (CollectionUtil.isEmpty(groupIds)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<Map<String, Object>> maps = dictTableMapper.filterEnableTableByGroupIds(groupIds);
|
||||
return CollStreamUtil.toSet(maps, v -> MapUtils.getLong(v, "dict_group_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分组id删除
|
||||
* @param groupIds 分组id列表
|
||||
*/
|
||||
public void deleteByGroupIds(List<Long> groupIds) {
|
||||
if (CollectionUtil.isEmpty(groupIds)) {
|
||||
return;
|
||||
}
|
||||
dictTableMapper.deleteByGroupIds(groupIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表编码查询
|
||||
* @param tableCode 字典表编码
|
||||
* @return 字典表
|
||||
*/
|
||||
public SysDictTableDO getByTableCode(String tableCode) {
|
||||
return dictTableMapper.selectByTableCode(tableCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典表编码查询启用状态的字典表
|
||||
* @param tableCodes 字典表编码
|
||||
* @return 字典表列表
|
||||
*/
|
||||
public List<SysDictTableDO> getOpenTableListByTableCodes(List<String> tableCodes) {
|
||||
if (CollectionUtils.isEmpty(tableCodes)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return dictTableMapper.selectOpenTableListByTableCodes(tableCodes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.cool.store.mapper.dict;
|
||||
|
||||
import com.cool.store.entity.dict.SysDictColumnDO;
|
||||
import com.cool.store.request.dict.DictColumnQueryRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2025-09-25 06:34
|
||||
*/
|
||||
public interface SysDictColumnMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2025-09-25 06:34
|
||||
*/
|
||||
int insertSelective(@Param("record") SysDictColumnDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2025-09-25 06:34
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysDictColumnDO record);
|
||||
|
||||
/**
|
||||
* 查询已存在的字典项
|
||||
* @param columnCode 字典项编码
|
||||
* @return com.coolcollege.intelligent.model.dict.SysDictColumnDO
|
||||
*/
|
||||
SysDictColumnDO selectExistColumn(@Param("id") Long id,
|
||||
@Param("columnCode") String columnCode);
|
||||
|
||||
/**
|
||||
* 根据id批量删除
|
||||
* @param ids id列表
|
||||
* @return int
|
||||
*/
|
||||
int deleteByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* @param dto 查询DTO
|
||||
* @return 字典项列表
|
||||
*/
|
||||
List<SysDictColumnDO> selectList(@Param("dto") DictColumnQueryRequest dto);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id id
|
||||
* @return 字典项
|
||||
*/
|
||||
SysDictColumnDO selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据字典表id查询字典项数量
|
||||
* @param tableIds 字典表id列表
|
||||
*/
|
||||
List<Map<String, Object>> selectColumnNumByTableIds(@Param("tableIds") List<Long> tableIds);
|
||||
|
||||
/**
|
||||
* 过滤存在已启用字典项的字典表分组id
|
||||
* @param groupIds 分组id列表
|
||||
*/
|
||||
List<Map<String, Object>> filterEnableColumnByGroupIds(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
/**
|
||||
* 过滤存在已启用字典项的字典表id
|
||||
* @param tableIds 字典表id列表
|
||||
*/
|
||||
List<Map<String, Object>> filterEnableColumnByTableIds(@Param("tableIds") List<Long> tableIds);
|
||||
|
||||
/**
|
||||
* 根据分组id删除字典项
|
||||
* @param groupIds 分组id列表
|
||||
* @return int
|
||||
*/
|
||||
int deleteByGroupIds(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
/**
|
||||
* 根据字典表id删除字典项
|
||||
* @param tableIds 字典表id列表
|
||||
* @return int
|
||||
*/
|
||||
int deleteByTableIds(@Param("tableIds") List<Long> tableIds);
|
||||
|
||||
/**
|
||||
* 根据字典项编码查询字典项
|
||||
* @param columnCode 字典项编码
|
||||
* @return 字典项
|
||||
*/
|
||||
SysDictColumnDO selectOpenColumnByCode(@Param("columnCode") String columnCode);
|
||||
|
||||
/**
|
||||
* 根据字典表id查询
|
||||
* @param tableIds 字典表id列表
|
||||
* @return 字典项列表
|
||||
*/
|
||||
List<SysDictColumnDO> selectOpenColumnListByTableIds(@Param("tableIds") List<Long> tableIds);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.cool.store.mapper.dict;
|
||||
|
||||
import com.cool.store.entity.dict.SysDictGroupDO;
|
||||
import com.cool.store.request.dict.DictGroupQueryRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2025-09-25 06:35
|
||||
*/
|
||||
public interface SysDictGroupMapper {
|
||||
/**
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2025-09-25 06:35
|
||||
*/
|
||||
int insertSelective(@Param("record") SysDictGroupDO record);
|
||||
|
||||
/**
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2025-09-25 06:35
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysDictGroupDO record);
|
||||
|
||||
/**
|
||||
* 根据id批量删除
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return int
|
||||
*/
|
||||
int deleteByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id id
|
||||
* @return 字典分组
|
||||
*/
|
||||
SysDictGroupDO selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param dto 查询DTO
|
||||
* @return 字典分组列表
|
||||
*/
|
||||
List<SysDictGroupDO> selectList(@Param("dto") DictGroupQueryRequest dto);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.cool.store.mapper.dict;
|
||||
|
||||
import com.cool.store.entity.dict.SysDictTableDO;
|
||||
import com.cool.store.request.dict.DictTableQueryRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2025-09-25 06:30
|
||||
*/
|
||||
public interface SysDictTableMapper {
|
||||
/**
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2025-09-25 06:30
|
||||
*/
|
||||
int insertSelective(@Param("record") SysDictTableDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2025-09-25 06:30
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysDictTableDO record, @Param("enterpriseId") String enterpriseId);
|
||||
|
||||
/**
|
||||
* 查询重复的字典表
|
||||
*
|
||||
* @param id id
|
||||
* @param tableCode 字典表code
|
||||
* @return 字典表
|
||||
*/
|
||||
SysDictTableDO selectExistTable(@Param("id") Long id,
|
||||
@Param("tableCode") String tableCode);
|
||||
|
||||
/**
|
||||
* 根据id删除
|
||||
*
|
||||
* @param ids id列表
|
||||
*/
|
||||
int deleteByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param dto 查询DTO
|
||||
* @return 字典表列表
|
||||
*/
|
||||
List<SysDictTableDO> selectList(@Param("dto") DictTableQueryRequest dto);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id id
|
||||
* @return 字典表
|
||||
*/
|
||||
SysDictTableDO selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return 字典表列表
|
||||
*/
|
||||
List<SysDictTableDO> selectByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据分组id查询
|
||||
*
|
||||
* @param groupIds 分组id列表
|
||||
* @param openStatus 启用状态
|
||||
* @return 字典表列表
|
||||
*/
|
||||
List<SysDictTableDO> selectByGroupIds(@Param("groupIds") List<Long> groupIds,
|
||||
@Param("openStatus") Integer openStatus);
|
||||
|
||||
/**
|
||||
* 根据分组id查询已启用的字典表
|
||||
*
|
||||
* @param groupIds 分组id列表
|
||||
*/
|
||||
List<Map<String, Object>> filterEnableTableByGroupIds(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
/**
|
||||
* 根据分组id删除
|
||||
*
|
||||
* @param groupIds 分组id列表
|
||||
* @return int
|
||||
*/
|
||||
int deleteByGroupIds(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
/**
|
||||
* 根据字典表编码查询
|
||||
*
|
||||
* @param tableCode 字典表编码
|
||||
* @return 字典表
|
||||
*/
|
||||
SysDictTableDO selectByTableCode(@Param("tableCode") String tableCode);
|
||||
|
||||
/**
|
||||
* 根据字典表编码查询启用状态的字典表
|
||||
*
|
||||
* @param tableCodes 字典表编码
|
||||
* @return 字典表列表
|
||||
*/
|
||||
List<SysDictTableDO> selectOpenTableListByTableCodes(@Param("tableCodes") List<String> tableCodes);
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.dict.SysDictColumnMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.dict.SysDictColumnDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="dict_group_id" jdbcType="BIGINT" property="dictGroupId" />
|
||||
<result column="dict_table_id" jdbcType="BIGINT" property="dictTableId" />
|
||||
<result column="column_name" jdbcType="VARCHAR" property="columnName" />
|
||||
<result column="column_code" jdbcType="VARCHAR" property="columnCode" />
|
||||
<result column="open_status" jdbcType="TINYINT" property="openStatus" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, dict_group_id, dict_table_id, column_name, column_code, open_status, remark,
|
||||
deleted, create_user_id, update_user_id, create_time, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_dict_column_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.dictGroupId != null">
|
||||
dict_group_id,
|
||||
</if>
|
||||
<if test="record.dictTableId != null">
|
||||
dict_table_id,
|
||||
</if>
|
||||
<if test="record.columnName != null">
|
||||
column_name,
|
||||
</if>
|
||||
<if test="record.columnCode != null">
|
||||
column_code,
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
open_status,
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id,
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.dictGroupId != null">
|
||||
#{record.dictGroupId},
|
||||
</if>
|
||||
<if test="record.dictTableId != null">
|
||||
#{record.dictTableId},
|
||||
</if>
|
||||
<if test="record.columnName != null">
|
||||
#{record.columnName},
|
||||
</if>
|
||||
<if test="record.columnCode != null">
|
||||
#{record.columnCode},
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
#{record.openStatus},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
#{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
#{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_dict_column_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.dictGroupId != null">
|
||||
dict_group_id = #{record.dictGroupId},
|
||||
</if>
|
||||
<if test="record.dictTableId != null">
|
||||
dict_table_id = #{record.dictTableId},
|
||||
</if>
|
||||
<if test="record.columnName != null">
|
||||
column_name = #{record.columnName},
|
||||
</if>
|
||||
<if test="record.columnCode != null">
|
||||
column_code = #{record.columnCode},
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
open_status = #{record.openStatus},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark = #{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id = #{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id = #{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
|
||||
<select id="selectExistColumn" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
<where>
|
||||
<if test="id != null">
|
||||
AND id != #{id}
|
||||
</if>
|
||||
AND column_code = #{columnCode}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="deleteByIds">
|
||||
UPDATE sys_dict_column_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="dto.dictGroupId != null">
|
||||
AND dict_group_id = #{dto.dictGroupId}
|
||||
</if>
|
||||
<if test="dto.dictTableId != null">
|
||||
AND dict_table_id = #{dto.dictTableId}
|
||||
</if>
|
||||
<if test="dto.columnName != null and dto.columnName != ''">
|
||||
AND column_name LIKE CONCAT('%', #{dto.columnName}, '%')
|
||||
</if>
|
||||
<if test="dto.columnCode != null and dto.columnCode != ''">
|
||||
AND column_code = #{dto.columnCode}
|
||||
</if>
|
||||
<if test="dto.openStatus != null">
|
||||
AND open_status = #{dto.openStatus}
|
||||
</if>
|
||||
<if test="dto.remark != null and dto.remark != ''">
|
||||
AND remark LIKE CONCAT('%', #{dto.remark}, '%')
|
||||
</if>
|
||||
ORDER BY create_time ASC
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE id = #{id} AND deleted = 0 LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectColumnNumByTableIds" resultType="java.util.Map">
|
||||
SELECT COUNT(*) num, dict_table_id
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE dict_table_id IN
|
||||
<foreach collection="tableIds" item="tableId" separator="," open="(" close=")">
|
||||
#{tableId}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
GROUP BY dict_table_id
|
||||
</select>
|
||||
|
||||
<select id="filterEnableColumnByGroupIds" resultType="java.util.Map">
|
||||
SELECT DISTINCT dict_group_id
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE dict_group_id IN
|
||||
<foreach collection="groupIds" item="groupId" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
AND open_status = 1
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="filterEnableColumnByTableIds" resultType="java.util.Map">
|
||||
SELECT DISTINCT dict_table_id
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE dict_table_id IN
|
||||
<foreach collection="tableIds" item="tableId" open="(" separator="," close=")">
|
||||
#{tableId}
|
||||
</foreach>
|
||||
AND open_status = 1
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<update id="deleteByGroupIds">
|
||||
UPDATE sys_dict_column_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE dict_group_id IN
|
||||
<foreach item="groupId" collection="groupIds" separator="," open="(" close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<update id="deleteByTableIds">
|
||||
UPDATE sys_dict_column_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE dict_table_id IN
|
||||
<foreach item="tableId" collection="tableIds" separator="," open="(" close=")">
|
||||
#{tableId}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<select id="selectOpenColumnByCode" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE column_code = #{columnCode} AND deleted = 0 AND open_status = 1 LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectOpenColumnListByTableIds" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_column_${enterpriseId}
|
||||
WHERE dict_table_id IN
|
||||
<foreach item="tableId" collection="tableIds" separator="," open="(" close=")">
|
||||
#{tableId}
|
||||
</foreach>
|
||||
AND deleted = 0 AND open_status = 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.dict.SysDictGroupMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.dict.SysDictGroupDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, group_name, remark, deleted, create_user_id, update_user_id, create_time, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_dict_group_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.groupName != null">
|
||||
group_name,
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id,
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.groupName != null">
|
||||
#{record.groupName},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
#{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
#{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_dict_group_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.groupName != null">
|
||||
group_name = #{record.groupName},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark = #{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id = #{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id = #{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
|
||||
<update id="deleteByIds">
|
||||
UPDATE sys_dict_group_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM sys_dict_group_${enterpriseId}
|
||||
WHERE id = #{id} AND deleted = 0 LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_group_${enterpriseId}
|
||||
WHERE deleted = 0
|
||||
<if test="dto.groupName != null and dto.groupName != ''">
|
||||
AND group_name LIKE CONCAT('%', #{dto.groupName}, '%')
|
||||
</if>
|
||||
<if test="dto.remark != null and dto.remark != ''">
|
||||
AND remark LIKE CONCAT('%', #{dto.remark}, '%')
|
||||
</if>
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.dict.SysDictTableMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.dict.SysDictTableDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="dict_group_id" jdbcType="BIGINT" property="dictGroupId" />
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName" />
|
||||
<result column="table_code" jdbcType="VARCHAR" property="tableCode" />
|
||||
<result column="open_status" jdbcType="TINYINT" property="openStatus" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, dict_group_id, table_name, table_code, open_status, remark, deleted, create_user_id,
|
||||
update_user_id, create_time, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_dict_table_${enterpriseId}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.dictGroupId != null">
|
||||
dict_group_id,
|
||||
</if>
|
||||
<if test="record.tableName != null">
|
||||
table_name,
|
||||
</if>
|
||||
<if test="record.tableCode != null">
|
||||
table_code,
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
open_status,
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id,
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.dictGroupId != null">
|
||||
#{record.dictGroupId},
|
||||
</if>
|
||||
<if test="record.tableName != null">
|
||||
#{record.tableName},
|
||||
</if>
|
||||
<if test="record.tableCode != null">
|
||||
#{record.tableCode},
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
#{record.openStatus},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
#{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
#{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_dict_table_${enterpriseId}
|
||||
<set>
|
||||
<if test="record.dictGroupId != null">
|
||||
dict_group_id = #{record.dictGroupId},
|
||||
</if>
|
||||
<if test="record.tableName != null">
|
||||
table_name = #{record.tableName},
|
||||
</if>
|
||||
<if test="record.tableCode != null">
|
||||
table_code = #{record.tableCode},
|
||||
</if>
|
||||
<if test="record.openStatus != null">
|
||||
open_status = #{record.openStatus},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark = #{record.remark},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.createUserId != null">
|
||||
create_user_id = #{record.createUserId},
|
||||
</if>
|
||||
<if test="record.updateUserId != null">
|
||||
update_user_id = #{record.updateUserId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
|
||||
<select id="selectExistTable" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
<where>
|
||||
<if test="id != null">
|
||||
AND id != #{id}
|
||||
</if>
|
||||
AND table_code = #{tableCode}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="deleteByIds">
|
||||
UPDATE sys_dict_table_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE deleted = 0
|
||||
<if test="dto.dictGroupId != null">
|
||||
AND dict_group_id = #{dto.dictGroupId}
|
||||
</if>
|
||||
<if test="dto.tableName != null and dto.tableName != ''">
|
||||
AND table_name LIKE CONCAT('%', #{dto.tableName}, '%')
|
||||
</if>
|
||||
<if test="dto.tableCode != null and dto.tableCode != ''">
|
||||
AND table_code = #{dto.tableCode}
|
||||
</if>
|
||||
<if test="dto.openStatus != null">
|
||||
AND open_status = #{dto.openStatus}
|
||||
</if>
|
||||
<if test="dto.remark != null and dto.remark != ''">
|
||||
AND remark LIKE CONCAT('%', #{dto.remark}, '%')
|
||||
</if>
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE id = #{id} AND deleted = 0 LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByGroupIds" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
<where>
|
||||
dict_group_id IN
|
||||
<foreach item="groupId" collection="groupIds" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
<if test="openStatus != null">
|
||||
AND open_status = #{openStatus}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="filterEnableTableByGroupIds" resultType="java.util.Map">
|
||||
SELECT DISTINCT dict_group_id
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE dict_group_id IN
|
||||
<foreach collection="groupIds" item="groupId" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
AND open_status = 1
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<update id="deleteByGroupIds">
|
||||
UPDATE sys_dict_table_${enterpriseId}
|
||||
SET deleted = 1
|
||||
WHERE dict_group_id IN
|
||||
<foreach item="groupId" collection="groupIds" open="(" separator="," close=")">
|
||||
#{groupId}
|
||||
</foreach>
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<select id="selectByTableCode" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE table_code = #{tableCode} AND deleted = 0 LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectOpenTableListByTableCodes" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM sys_dict_table_${enterpriseId}
|
||||
WHERE table_code IN
|
||||
<foreach item="tableCode" collection="tableCodes" open="(" separator="," close=")">
|
||||
#{tableCode}
|
||||
</foreach>
|
||||
AND deleted = 0 AND open_status = 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.cool.store.entity.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典项
|
||||
* @author wangff
|
||||
* @date 2025-09-25 06:34
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysDictColumnDO implements Serializable {
|
||||
@ApiModelProperty("")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("merchant_dict_group.id 字典表分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("merchant_dict_table_info.id 字典表信息表id")
|
||||
private Long dictTableId;
|
||||
|
||||
@ApiModelProperty("字典项名称")
|
||||
private String columnName;
|
||||
|
||||
@ApiModelProperty("字典项编码")
|
||||
private String columnCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateUserId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.cool.store.entity.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典分组
|
||||
* @author wangff
|
||||
* @date 2025-09-25 06:35
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysDictGroupDO implements Serializable {
|
||||
@ApiModelProperty("")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("分组名称")
|
||||
private String groupName;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateUserId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.cool.store.entity.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典表
|
||||
* @author wangff
|
||||
* @date 2025-09-25 06:30
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysDictTableDO implements Serializable {
|
||||
@ApiModelProperty("")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("merchant_dict_group.id 字典表分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("字典表名称")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty("字典表编码")
|
||||
private String tableCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateUserId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.cool.store.request.dict;
|
||||
|
||||
import com.cool.store.common.PageBasicInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项查询DTO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class DictColumnQueryRequest extends PageBasicInfo {
|
||||
|
||||
@ApiModelProperty("字典表分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("字典表id")
|
||||
private Long dictTableId;
|
||||
|
||||
@ApiModelProperty("字典项名称")
|
||||
private String columnName;
|
||||
|
||||
@ApiModelProperty("字典项编码")
|
||||
private String columnCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.cool.store.request.dict;
|
||||
|
||||
import com.cool.store.common.PageBasicInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典分组查询DTO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Data
|
||||
public class DictGroupQueryRequest extends PageBasicInfo {
|
||||
@ApiModelProperty("字典分组名称")
|
||||
private String groupName;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("字典表启用状态")
|
||||
private Integer dictTableOpenStatus;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.cool.store.request.dict;
|
||||
|
||||
import com.cool.store.common.PageBasicInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表查询DTO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Data
|
||||
public class DictTableQueryRequest extends PageBasicInfo {
|
||||
@ApiModelProperty("字典分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("字典表名称")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty("字典表编码")
|
||||
private String tableCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.cool.store.vo.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项简单信息VO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/9/26
|
||||
*/
|
||||
@Data
|
||||
public class DictColumnSimpleVO {
|
||||
@ApiModelProperty("字典项名称")
|
||||
private String columnName;
|
||||
|
||||
@ApiModelProperty("字典项编码")
|
||||
private String columnCode;
|
||||
|
||||
@ApiModelProperty("字典表编码")
|
||||
private String tableCode;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.cool.store.vo.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典项VO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Data
|
||||
public class DictColumnVO {
|
||||
@ApiModelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("字典表分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("字典表id")
|
||||
private Long dictTableId;
|
||||
|
||||
@ApiModelProperty("字典项名称")
|
||||
private String columnName;
|
||||
|
||||
@ApiModelProperty("字典项编码")
|
||||
private String columnCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createUserId;
|
||||
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createUserName;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateUserId;
|
||||
|
||||
@ApiModelProperty("更新人姓名")
|
||||
private String updateUserName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.cool.store.vo.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典分组VO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/19
|
||||
*/
|
||||
@Data
|
||||
public class DictGroupVO {
|
||||
@ApiModelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("分组名称")
|
||||
private String groupName;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("字典表列表")
|
||||
private List<DictTableVO> tableList;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.cool.store.vo.dict;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表信息表VO
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/19
|
||||
*/
|
||||
@Data
|
||||
public class DictTableVO {
|
||||
@ApiModelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("字典表分组id")
|
||||
private Long dictGroupId;
|
||||
|
||||
@ApiModelProperty("字典表名称")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty("字典表编码")
|
||||
private String tableCode;
|
||||
|
||||
@ApiModelProperty("启用状态 0:不启用 1:启用")
|
||||
private Integer openStatus;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("字典数量")
|
||||
private Integer columnNum;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.cool.store.controller.webb;
|
||||
|
||||
import com.cool.store.request.dict.DictColumnQueryRequest;
|
||||
import com.cool.store.request.dict.DictGroupQueryRequest;
|
||||
import com.cool.store.request.dict.DictTableQueryRequest;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.dict.DictColumnService;
|
||||
import com.cool.store.service.dict.DictGroupService;
|
||||
import com.cool.store.service.dict.DictTableInfoService;
|
||||
import com.cool.store.vo.dict.DictColumnSimpleVO;
|
||||
import com.cool.store.vo.dict.DictColumnVO;
|
||||
import com.cool.store.vo.dict.DictGroupVO;
|
||||
import com.cool.store.vo.dict.DictTableVO;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典管理 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wangff
|
||||
* @since 2025/2/20
|
||||
*/
|
||||
@Api(tags = "字典管理")
|
||||
@RestController
|
||||
@RequestMapping("pc/sys/dict")
|
||||
@RequiredArgsConstructor
|
||||
public class DictManagerController {
|
||||
private final DictGroupService groupService;
|
||||
private final DictTableInfoService tableService;
|
||||
private final DictColumnService columnService;
|
||||
|
||||
@ApiOperation("字典分组-查询")
|
||||
@GetMapping("/group/{groupId}")
|
||||
public ResponseResult<DictGroupVO> groupGet(@PathVariable("groupId") Long groupId) {
|
||||
return ResponseResult.success(groupService.getById(groupId));
|
||||
}
|
||||
|
||||
@ApiOperation("字典分组-列表")
|
||||
@GetMapping("/group/list")
|
||||
public ResponseResult<List<DictGroupVO>> groupList(DictGroupQueryRequest dto) {
|
||||
return ResponseResult.success(groupService.getList(dto));
|
||||
}
|
||||
|
||||
@ApiOperation("字典表-查询")
|
||||
@GetMapping("/table/{tableId}")
|
||||
public ResponseResult<DictTableVO> tableGet(@PathVariable("tableId") Long tableId) {
|
||||
return ResponseResult.success(tableService.getById(tableId));
|
||||
}
|
||||
|
||||
@ApiOperation("字典表-列表")
|
||||
@GetMapping("/table/list")
|
||||
public ResponseResult<List<DictTableVO>> tableList(DictTableQueryRequest dto) {
|
||||
return ResponseResult.success(tableService.getList(dto));
|
||||
}
|
||||
|
||||
@ApiOperation("字典项-分页查询")
|
||||
@GetMapping("/column/page")
|
||||
public ResponseResult<PageInfo<DictColumnVO>> columnPage(DictColumnQueryRequest dto) {
|
||||
return ResponseResult.success(columnService.getPage(dto));
|
||||
}
|
||||
|
||||
@ApiOperation("字典项-查询")
|
||||
@GetMapping("/column/{columnId}")
|
||||
public ResponseResult<DictColumnVO> columnGet(@PathVariable("columnId") Long columnId) {
|
||||
return ResponseResult.success(columnService.getById(columnId));
|
||||
}
|
||||
|
||||
@ApiOperation("字典项-根据字典项code查询已启用的字典项")
|
||||
@GetMapping("/column/getByColumnCode")
|
||||
public ResponseResult<DictColumnSimpleVO> getColumnByColumnCode(@NotBlank(message = "字典项编码不能为空") String columnCode) {
|
||||
return ResponseResult.success(columnService.getColumnByColumnCode(columnCode));
|
||||
}
|
||||
|
||||
@ApiOperation("字典项-根据字典表code查询已启用的字典项列表")
|
||||
@PostMapping("/column/getMapByTableCodes")
|
||||
public ResponseResult<Map<String, List<DictColumnSimpleVO>>> getColumnByTableCode(@RequestBody List<String> tableCodes) {
|
||||
return ResponseResult.success(columnService.getMapListByTableCode(tableCodes));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user