refactor(system): 重构字典明细查询功能

- 创建 SystemDictDetailVo 视图对象用于数据传输
- 修改控制器返回类型为 SystemDictDetailVo
- 重构查询方法使用 LambdaQueryWrapper 替代 XML 配置
- 移除 SystemDictDetailTb 中的 dict 关联字段
- 添加字典名称查询的辅助方法
- 更新前端组件移除搜索功能并简化工具栏
This commit is contained in:
2025-12-25 16:30:39 +08:00
parent 57ffdccec1
commit 6ca6fdd567
16 changed files with 242 additions and 156 deletions
@@ -4,22 +4,6 @@
<div class="my-code">点击字典查看详情</div>
</div>
<div v-else>
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input
v-model="query.label"
clearable
size="small"
placeholder="输入字典标签查询"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="toQuery"
/>
<rrOperation />
</div>
</div>
<!--表单组件-->
<el-dialog
append-to-body
@@ -91,13 +75,12 @@
import crudDictDetail from '@/api/system/dictDetail'
import CRUD, { form, header, presenter } from '@crud/crud'
import pagination from '@crud/Pagination'
import rrOperation from '@crud/RR.operation'
import udOperation from '@crud/UD.operation'
const defaultForm = { id: null, label: null, value: null, dictSort: 999 }
export default {
components: { pagination, rrOperation, udOperation },
components: { pagination, udOperation },
cruds() {
return [
CRUD({
@@ -32,7 +32,6 @@ public class SystemDictDetailTb extends KitBaseUserTimeTb {
@NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true)
@TableId(value = "id", type = IdType.AUTO) private Long id;
@TableField(value = "dict_id") @ApiModelProperty(hidden = true) private Long dictId;
@TableField(exist = false) @ApiModelProperty(value = "字典") private SystemDictTb dict;
@ApiModelProperty(value = "字典标签") private String label;
@ApiModelProperty(value = "字典值") private String value;
@ApiModelProperty(value = "排序") private Integer dictSort = 999;
@@ -0,0 +1,28 @@
/*
* Copyright 2021-2025 Odboy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.odboy.system.dal.model;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemDictDetailVo extends SystemDictDetailTb {
@ApiModelProperty(value = "字典") private SystemDictTb dict;
}
@@ -15,14 +15,14 @@
*/
package cn.odboy.system.dal.mysql;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 字典明细 Mapper
@@ -31,6 +31,14 @@ import org.apache.ibatis.annotations.Param;
*/
@Mapper
public interface SystemDictDetailMapper extends BaseMapper<SystemDictDetailTb> {
IPage<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria, Page<SystemDictDetailTb> page);
List<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria);
default List<SystemDictDetailTb> selectByDictId(Long dictId) {
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictDetailTb::getDictId, dictId);
return selectList(wrapper);
}
default IPage<SystemDictDetailTb> selectDictDetailByArgs(List<Long> dictIds, Page<SystemDictDetailTb> page) {
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CollUtil.isNotEmpty(dictIds), SystemDictDetailTb::getDictId, dictIds);
return selectPage(page, wrapper);
}
}
@@ -47,4 +47,9 @@ public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
injectQueryParams(args, wrapper);
return selectList(page, wrapper);
}
default SystemDictTb getByName(String name) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictTb::getName, name);
return selectOne(wrapper);
}
}
@@ -17,16 +17,24 @@ package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import cn.odboy.system.dal.mysql.SystemDictDetailMapper;
import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -34,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SystemDictDetailService {
@Autowired private SystemDictDetailMapper systemDictDetailMapper;
@Autowired private SystemDictMapper systemDictMapper;
/**
* 创建
@@ -69,29 +78,6 @@ public class SystemDictDetailService {
systemDictDetailMapper.deleteById(id);
}
/**
* 分页查询
*
* @param args 条件
* @param page 分页参数
* @return /
*/
public KitPageResult<SystemDictDetailTb> queryDictDetailByArgs(SystemQueryDictDetailArgs args, Page<SystemDictDetailTb> page) {
return KitPageUtil.toPage(systemDictDetailMapper.selectDictDetailByArgs(args, page));
}
/**
* 根据字典名称获取字典详情
*
* @param name 字典名称
* @return /
*/
public List<SystemDictDetailTb> queryDictDetailByName(String name) {
SystemQueryDictDetailArgs args = new SystemQueryDictDetailArgs();
args.setDictName(name);
return systemDictDetailMapper.selectDictDetailByArgs(args);
}
@Transactional(rollbackFor = Exception.class)
public void deleteDictDetailByDictIds(Set<Long> ids) {
if (CollUtil.isNotEmpty(ids)) {
@@ -100,4 +86,65 @@ public class SystemDictDetailService {
systemDictDetailMapper.delete(wrapper);
}
}
/**
* 分页查询
*
* @param args 条件
* @param page 分页参数
* @return /
*/
public KitPageResult<SystemDictDetailVo> queryDictDetailByArgs(SystemQueryDictDetailArgs args,
Page<SystemDictDetailTb> page) {
IPage<SystemDictDetailVo> iPage = new Page<>();
List<Long> dictIds = new ArrayList<>();
List<SystemDictTb> dictTbs = new ArrayList<>();
if (args == null) {
dictTbs.addAll(systemDictMapper.selectList(null));
dictIds = dictTbs.stream().map(SystemDictTb::getId).collect(Collectors.toList());
} else {
String dictName = args.getDictName();
if (StrUtil.isBlank(dictName)) {
return KitPageUtil.toPage(iPage);
}
SystemDictTb dictTb = systemDictMapper.getByName(dictName);
if (dictTb == null) {
return KitPageUtil.toPage(iPage);
} else {
dictIds.add(dictTb.getId());
dictTbs.add(dictTb);
}
}
Map<Long, SystemDictTb> id2ItemMap = dictTbs.stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i));
iPage = systemDictDetailMapper.selectDictDetailByArgs(dictIds, page)
.convert(i -> BeanUtil.copyProperties(i, SystemDictDetailVo.class));
for (SystemDictDetailVo record : iPage.getRecords()) {
record.setDict(id2ItemMap.get(record.getDictId()));
}
return KitPageUtil.toPage(iPage);
}
/**
* 根据字典名称获取字典详情
*
* @param name 字典名称
* @return /
*/
public List<SystemDictDetailVo> queryDictDetailByName(String name) {
if (StrUtil.isBlank(name)) {
return new ArrayList<>();
}
SystemDictTb systemDictTb = systemDictMapper.getByName(name);
if (systemDictTb == null) {
return new ArrayList<>();
}
return systemDictDetailMapper.selectByDictId(systemDictTb.getId()).stream().map(m -> {
SystemDictDetailVo detailVo = BeanUtil.copyProperties(m, SystemDictDetailVo.class);
detailVo.setDict(systemDictTb);
return detailVo;
}).collect(Collectors.toList());
}
}
@@ -21,9 +21,8 @@ import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictArgs;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import cn.odboy.system.dal.mysql.SystemDictDetailMapper;
import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
@@ -42,7 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SystemDictService {
@Autowired private SystemDictMapper systemDictMapper;
@Autowired private SystemDictDetailMapper systemDictDetailMapper;
// @Autowired private SystemDictDetailMapper systemDictDetailMapper;
@Autowired private SystemDictDetailService systemDictDetailService;
/**
@@ -91,9 +90,7 @@ public class SystemDictService {
public void exportDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemDictTb dict : dicts) {
SystemQueryDictDetailArgs args = new SystemQueryDictDetailArgs();
args.setDictName(dict.getName());
List<SystemDictDetailTb> dictDetails = systemDictDetailMapper.selectDictDetailByArgs(args);
List<SystemDictDetailVo> dictDetails = systemDictDetailService.queryDictDetailByName(dict.getName());
if (CollectionUtil.isNotEmpty(dictDetails)) {
for (SystemDictDetailTb dictDetail : dictDetails) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -1,33 +0,0 @@
<?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="cn.odboy.system.dal.mysql.SystemDictDetailMapper">
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.dataobject.SystemDictDetailTb">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="label" property="label" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="dict_sort" property="dictSort" jdbcType="INTEGER"/>
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<!-- 一对一关联 -->
<association property="dict" javaType="cn.odboy.system.dal.dataobject.SystemDictTb">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="selectDictDetailByArgs" resultMap="BaseResultMap">
select
dd.id, dd.label, dd.`value`, dd.`dict_sort`, dd.create_by, dd.update_by, dd.create_time, dd.update_time,
d.id as dict_id, d.name
from system_dict_detail dd, system_dict d
where dd.dict_id = d.id
<if test="criteria.dictName != null and criteria.dictName != ''">
and d.name = #{criteria.dictName}
</if>
<if test="criteria.label != null and criteria.label != ''">
and dd.label = #{criteria.label}
</if>
order by dd.dict_sort
</select>
</mapper>
@@ -19,6 +19,7 @@ import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import cn.odboy.system.service.SystemDictDetailService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -46,14 +47,14 @@ public class SystemDictDetailController {
@ApiOperation("查询字典详情")
@PostMapping
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByCrud(
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByCrud(
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
return queryDictDetailByArgs(args);
}
@ApiOperation("查询字典详情")
@PostMapping(value = "/queryDictDetailByArgs")
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByArgs(
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByArgs(
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
SystemQueryDictDetailArgs criteria = args.getArgs();
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
@@ -62,9 +63,9 @@ public class SystemDictDetailController {
@ApiOperation("查询多个字典详情")
@GetMapping(value = "/getDictDetailMaps")
public ResponseEntity<Map<String, List<SystemDictDetailTb>>> getDictDetailMaps(@RequestParam String dictName) {
public ResponseEntity<Map<String, List<SystemDictDetailVo>>> getDictDetailMaps(@RequestParam String dictName) {
String[] names = dictName.split("[,, ]");
Map<String, List<SystemDictDetailTb>> dictMap = new HashMap<>(16);
Map<String, List<SystemDictDetailVo>> dictMap = new HashMap<>(16);
for (String name : names) {
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
}
@@ -32,7 +32,6 @@ public class SystemDictDetailTb extends KitBaseUserTimeTb {
@NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true)
@TableId(value = "id", type = IdType.AUTO) private Long id;
@TableField(value = "dict_id") @ApiModelProperty(hidden = true) private Long dictId;
@TableField(exist = false) @ApiModelProperty(value = "字典") private SystemDictTb dict;
@ApiModelProperty(value = "字典标签") private String label;
@ApiModelProperty(value = "字典值") private String value;
@ApiModelProperty(value = "排序") private Integer dictSort = 999;
@@ -0,0 +1,28 @@
/*
* Copyright 2021-2025 Odboy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.odboy.system.dal.model;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemDictDetailVo extends SystemDictDetailTb {
@ApiModelProperty(value = "字典") private SystemDictTb dict;
}
@@ -15,14 +15,14 @@
*/
package cn.odboy.system.dal.mysql;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 字典明细 Mapper
@@ -31,6 +31,14 @@ import org.apache.ibatis.annotations.Param;
*/
@Mapper
public interface SystemDictDetailMapper extends BaseMapper<SystemDictDetailTb> {
IPage<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria, Page<SystemDictDetailTb> page);
List<SystemDictDetailTb> selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria);
default List<SystemDictDetailTb> selectByDictId(Long dictId) {
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictDetailTb::getDictId, dictId);
return selectList(wrapper);
}
default IPage<SystemDictDetailTb> selectDictDetailByArgs(List<Long> dictIds, Page<SystemDictDetailTb> page) {
LambdaQueryWrapper<SystemDictDetailTb> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CollUtil.isNotEmpty(dictIds), SystemDictDetailTb::getDictId, dictIds);
return selectPage(page, wrapper);
}
}
@@ -47,4 +47,9 @@ public interface SystemDictMapper extends BaseMapper<SystemDictTb> {
injectQueryParams(args, wrapper);
return selectList(page, wrapper);
}
default SystemDictTb getByName(String name) {
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemDictTb::getName, name);
return selectOne(wrapper);
}
}
@@ -17,16 +17,24 @@ package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import cn.odboy.system.dal.mysql.SystemDictDetailMapper;
import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -34,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SystemDictDetailService {
@Autowired private SystemDictDetailMapper systemDictDetailMapper;
@Autowired private SystemDictMapper systemDictMapper;
/**
* 创建
@@ -69,29 +78,6 @@ public class SystemDictDetailService {
systemDictDetailMapper.deleteById(id);
}
/**
* 分页查询
*
* @param args 条件
* @param page 分页参数
* @return /
*/
public KitPageResult<SystemDictDetailTb> queryDictDetailByArgs(SystemQueryDictDetailArgs args, Page<SystemDictDetailTb> page) {
return KitPageUtil.toPage(systemDictDetailMapper.selectDictDetailByArgs(args, page));
}
/**
* 根据字典名称获取字典详情
*
* @param name 字典名称
* @return /
*/
public List<SystemDictDetailTb> queryDictDetailByName(String name) {
SystemQueryDictDetailArgs args = new SystemQueryDictDetailArgs();
args.setDictName(name);
return systemDictDetailMapper.selectDictDetailByArgs(args);
}
@Transactional(rollbackFor = Exception.class)
public void deleteDictDetailByDictIds(Set<Long> ids) {
if (CollUtil.isNotEmpty(ids)) {
@@ -100,4 +86,65 @@ public class SystemDictDetailService {
systemDictDetailMapper.delete(wrapper);
}
}
/**
* 分页查询
*
* @param args 条件
* @param page 分页参数
* @return /
*/
public KitPageResult<SystemDictDetailVo> queryDictDetailByArgs(SystemQueryDictDetailArgs args,
Page<SystemDictDetailTb> page) {
IPage<SystemDictDetailVo> iPage = new Page<>();
List<Long> dictIds = new ArrayList<>();
List<SystemDictTb> dictTbs = new ArrayList<>();
if (args == null) {
dictTbs.addAll(systemDictMapper.selectList(null));
dictIds = dictTbs.stream().map(SystemDictTb::getId).collect(Collectors.toList());
} else {
String dictName = args.getDictName();
if (StrUtil.isBlank(dictName)) {
return KitPageUtil.toPage(iPage);
}
SystemDictTb dictTb = systemDictMapper.getByName(dictName);
if (dictTb == null) {
return KitPageUtil.toPage(iPage);
} else {
dictIds.add(dictTb.getId());
dictTbs.add(dictTb);
}
}
Map<Long, SystemDictTb> id2ItemMap = dictTbs.stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i));
iPage = systemDictDetailMapper.selectDictDetailByArgs(dictIds, page)
.convert(i -> BeanUtil.copyProperties(i, SystemDictDetailVo.class));
for (SystemDictDetailVo record : iPage.getRecords()) {
record.setDict(id2ItemMap.get(record.getDictId()));
}
return KitPageUtil.toPage(iPage);
}
/**
* 根据字典名称获取字典详情
*
* @param name 字典名称
* @return /
*/
public List<SystemDictDetailVo> queryDictDetailByName(String name) {
if (StrUtil.isBlank(name)) {
return new ArrayList<>();
}
SystemDictTb systemDictTb = systemDictMapper.getByName(name);
if (systemDictTb == null) {
return new ArrayList<>();
}
return systemDictDetailMapper.selectByDictId(systemDictTb.getId()).stream().map(m -> {
SystemDictDetailVo detailVo = BeanUtil.copyProperties(m, SystemDictDetailVo.class);
detailVo.setDict(systemDictTb);
return detailVo;
}).collect(Collectors.toList());
}
}
@@ -21,9 +21,8 @@ import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictArgs;
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
import cn.odboy.system.dal.mysql.SystemDictDetailMapper;
import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
@@ -42,7 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SystemDictService {
@Autowired private SystemDictMapper systemDictMapper;
@Autowired private SystemDictDetailMapper systemDictDetailMapper;
// @Autowired private SystemDictDetailMapper systemDictDetailMapper;
@Autowired private SystemDictDetailService systemDictDetailService;
/**
@@ -91,9 +90,7 @@ public class SystemDictService {
public void exportDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemDictTb dict : dicts) {
SystemQueryDictDetailArgs args = new SystemQueryDictDetailArgs();
args.setDictName(dict.getName());
List<SystemDictDetailTb> dictDetails = systemDictDetailMapper.selectDictDetailByArgs(args);
List<SystemDictDetailVo> dictDetails = systemDictDetailService.queryDictDetailByName(dict.getName());
if (CollectionUtil.isNotEmpty(dictDetails)) {
for (SystemDictDetailTb dictDetail : dictDetails) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -1,33 +0,0 @@
<?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="cn.odboy.system.dal.mysql.SystemDictDetailMapper">
<resultMap id="BaseResultMap" type="cn.odboy.system.dal.dataobject.SystemDictDetailTb">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="label" property="label" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="dict_sort" property="dictSort" jdbcType="INTEGER"/>
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<!-- 一对一关联 -->
<association property="dict" javaType="cn.odboy.system.dal.dataobject.SystemDictTb">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
</association>
</resultMap>
<select id="selectDictDetailByArgs" resultMap="BaseResultMap">
select
dd.id, dd.label, dd.`value`, dd.`dict_sort`, dd.create_by, dd.update_by, dd.create_time, dd.update_time,
d.id as dict_id, d.name
from system_dict_detail dd, system_dict d
where dd.dict_id = d.id
<if test="criteria.dictName != null and criteria.dictName != ''">
and d.name = #{criteria.dictName}
</if>
<if test="criteria.label != null and criteria.label != ''">
and dd.label = #{criteria.label}
</if>
order by dd.dict_sort
</select>
</mapper>