Commit 9815183f authored by zengchao's avatar zengchao
Browse files

doing: 正在处理前端UI中的下拉选择器的逻辑

parent 0666fbe8
package com.ibeetl.admin.core.dao; package com.ibeetl.admin.core.dao;
import com.ibeetl.admin.core.entity.DictType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -21,6 +22,15 @@ public interface CoreDictDao extends BaseMapper<CoreDict> { ...@@ -21,6 +22,15 @@ public interface CoreDictDao extends BaseMapper<CoreDict> {
*/ */
List<CoreDict> findAllList(String type); List<CoreDict> findAllList(String type);
/**
* 查询某个类型下的字典集合<br/>
* 主要用于提供给前端的下拉选择菜单使用,业务上请使用返回值为{@link CoreDict}的方法
*
* @param type 字典类型
* @return
*/
List<DictType> findAllDictType(String type);
/** /**
* 查询字段类型列表 * 查询字段类型列表
* *
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert; ...@@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ClassUtil; import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.ibeetl.admin.core.dao.SQLManagerBaseDao;
import com.ibeetl.admin.core.entity.DictType; import com.ibeetl.admin.core.entity.DictType;
import com.ibeetl.admin.core.util.AnnotationUtil; import com.ibeetl.admin.core.util.AnnotationUtil;
import com.ibeetl.admin.core.util.FileDownloadUtil; import com.ibeetl.admin.core.util.FileDownloadUtil;
...@@ -43,8 +44,7 @@ public class CoreBaseService<T> { ...@@ -43,8 +44,7 @@ public class CoreBaseService<T> {
@Autowired protected CoreDictService dictUtil; @Autowired protected CoreDictService dictUtil;
@Autowired @Autowired
@Qualifier("baseDataSourceSqlManagerFactoryBean") protected SQLManagerBaseDao sqlManager;
protected SQLManager sqlManager;
/** /**
* 根据id查询对象,如果主键ID不存在 * 根据id查询对象,如果主键ID不存在
...@@ -53,7 +53,7 @@ public class CoreBaseService<T> { ...@@ -53,7 +53,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public T queryById(Object id) { public T queryById(Object id) {
T t = sqlManager.single(getCurrentEntityClassz(), id); T t = sqlManager.getSQLManager().single(getCurrentEntityClassz(), id);
queryEntityAfter((Object) t); queryEntityAfter((Object) t);
return t; return t;
} }
...@@ -66,7 +66,7 @@ public class CoreBaseService<T> { ...@@ -66,7 +66,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public T queryById(Class<T> classz, Object id) { public T queryById(Class<T> classz, Object id) {
T t = sqlManager.unique(classz, id); T t = sqlManager.getSQLManager().unique(classz, id);
queryEntityAfter((Object) t); queryEntityAfter((Object) t);
return t; return t;
} }
...@@ -78,7 +78,7 @@ public class CoreBaseService<T> { ...@@ -78,7 +78,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public boolean save(T model) { public boolean save(T model) {
return sqlManager.insert(model, true) > 0; return sqlManager.getSQLManager().insert(model, true) > 0;
} }
/** /**
...@@ -103,7 +103,7 @@ public class CoreBaseService<T> { ...@@ -103,7 +103,7 @@ public class CoreBaseService<T> {
list.add(map); list.add(map);
} }
int[] count = sqlManager.updateBatchTemplateById(getCurrentEntityClassz(), list); int[] count = sqlManager.getSQLManager().updateBatchTemplateById(getCurrentEntityClassz(), list);
int successCount = 0; int successCount = 0;
for (int successFlag : count) { for (int successFlag : count) {
successCount += successFlag; successCount += successFlag;
...@@ -117,7 +117,7 @@ public class CoreBaseService<T> { ...@@ -117,7 +117,7 @@ public class CoreBaseService<T> {
// always id,delFlag for pojo // always id,delFlag for pojo
map.put("id", id); map.put("id", id);
map.put("delFlag", DelFlagEnum.DELETED.getValue()); map.put("delFlag", DelFlagEnum.DELETED.getValue());
int ret = sqlManager.updateTemplateById(getCurrentEntityClassz(), map); int ret = sqlManager.getSQLManager().updateTemplateById(getCurrentEntityClassz(), map);
return ret == 1; return ret == 1;
} }
/** /**
...@@ -127,7 +127,7 @@ public class CoreBaseService<T> { ...@@ -127,7 +127,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public int forceDelete(Long id) { public int forceDelete(Long id) {
return sqlManager.deleteById(getCurrentEntityClassz(), id); return sqlManager.getSQLManager().deleteById(getCurrentEntityClassz(), id);
} }
/** /**
...@@ -137,7 +137,7 @@ public class CoreBaseService<T> { ...@@ -137,7 +137,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public int forceDelete(Class<T> classz, Long id) { public int forceDelete(Class<T> classz, Long id) {
return sqlManager.deleteById(classz, id); return sqlManager.getSQLManager().deleteById(classz, id);
} }
/** /**
...@@ -147,7 +147,7 @@ public class CoreBaseService<T> { ...@@ -147,7 +147,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public boolean updateTemplate(T model) { public boolean updateTemplate(T model) {
return sqlManager.updateTemplateById(model) > 0; return sqlManager.getSQLManager().updateTemplateById(model) > 0;
} }
/** /**
...@@ -157,7 +157,7 @@ public class CoreBaseService<T> { ...@@ -157,7 +157,7 @@ public class CoreBaseService<T> {
* @return * @return
*/ */
public boolean update(T model) { public boolean update(T model) {
return sqlManager.updateById(model) > 0; return sqlManager.getSQLManager().updateById(model) > 0;
} }
/** /**
......
...@@ -46,7 +46,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> { ...@@ -46,7 +46,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
/** /**
* 级联字典查询,必须提供一个字典类型 * 级联字典查询,必须提供一个字典类型
* *
* @param group * @param type
* @param value * @param value
* @return * @return
*/ */
...@@ -59,7 +59,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> { ...@@ -59,7 +59,7 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
/** /**
* 级联字段下一级的字段列表 * 级联字段下一级的字段列表
* *
* @param parentValue * @param id : 父级的 parentValue
* @return * @return
*/ */
@Cacheable(value = CorePlatformService.DICT_CACHE_CHILDREN) @Cacheable(value = CorePlatformService.DICT_CACHE_CHILDREN)
......
package com.ibeetl.admin.core.service;
import com.ibeetl.admin.core.dao.CoreDictDao;
import com.ibeetl.admin.core.entity.DictType;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class DictTypeService {
@Autowired private CoreDictDao dictDao;
public List<DictType> findAllList(String type) {
return dictDao.findAllDictType(type);
}
}
package com.ibeetl.admin.core.web;
import com.ibeetl.admin.core.entity.CoreDict;
import com.ibeetl.admin.core.entity.DictType;
import com.ibeetl.admin.core.service.CoreDictService;
import com.ibeetl.admin.core.service.CorePlatformService;
import com.ibeetl.admin.core.service.DictTypeService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 字典数据获取
*
* @author 一日看尽长安花
*/
@Slf4j
@RestController
@RequestMapping(value = "/core/dicts")
public class DictDataElController {
@Autowired CorePlatformService platformService;
@Autowired CoreDictService dictService;
@Autowired DictTypeService dictTypeService;
/**
* 查看字典类型对应的列表
*
* @param type
* @return
*/
@GetMapping
public JsonResult<List<DictType>> dictList(String type) {
List<DictType> list = dictTypeService.findAllList(type);
return JsonResult.success(list);
}
}
...@@ -5,6 +5,14 @@ findAllList ...@@ -5,6 +5,14 @@ findAllList
and type = #type# and type = #type#
@} @}
ORDER BY type, sort DESC ORDER BY type, sort DESC
findAllDictType
===
select * from core_dict where del_flag = 0
@if(!isEmpty(type)){
and type = #type#
@}
ORDER BY type, sort DESC
findTypeList findTypeList
=== ===
......
<!-- <!--
* @Author: 一日看尽长安花 * @Author: 一日看尽长安花
* @since: 2019-10-12 16:14:37 * @since: 2019-10-12 16:14:37
* @LastEditTime: 2019-11-24 10:52:05 * @LastEditTime: 2019-12-17 14:07:33
* @LastEditors: 一日看尽长安花 * @LastEditors: 一日看尽长安花
* @Description: * @Description:
--> -->
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<el-table-column <el-table-column
v-for="(val, key) in metedata" v-for="(val, key) in metedata"
:key="key" :key="key"
:prop="key" :prop="val.type === 'dict' ? key + '.name' : key"
:label="val.name" :label="val.name"
:sortable="val.sortable" :sortable="val.sortable"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
......
<!-- <!--
* @Author: 一日看尽长安花 * @Author: 一日看尽长安花
* @since: 2019-10-12 16:14:37 * @since: 2019-10-12 16:14:37
* @LastEditTime: 2019-10-17 17:41:15 * @LastEditTime: 2019-12-17 14:41:21
* @LastEditors: 一日看尽长安花 * @LastEditors: 一日看尽长安花
* @Description: * @Description:
--> -->
...@@ -174,4 +174,4 @@ export default { ...@@ -174,4 +174,4 @@ export default {
} }
}; };
</script> </script>
<style scoped></style> <style></style>
<!-- <!--
* @Author: 一日看尽长安花 * @Author: 一日看尽长安花
* @since: 2019-10-12 16:14:37 * @since: 2019-10-12 16:14:37
* @LastEditTime: 2019-11-25 22:58:49 * @LastEditTime: 2019-12-17 14:41:14
* @LastEditors: 一日看尽长安花 * @LastEditors: 一日看尽长安花
* @Description: * @Description:
--> -->
...@@ -129,7 +129,7 @@ export default { ...@@ -129,7 +129,7 @@ export default {
} }
}; };
</script> </script>
<style scoped> <style>
.filter-container { .filter-container {
margin-top: 1rem; margin-top: 1rem;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment