【dict】整理代码

Signed-off-by: liuhanqing <447067298@qq.com>
pull/65/head
liuhanqing 2021-01-16 23:49:30 +08:00
parent f7a1c55e72
commit 7c22e6cd82
4 changed files with 47 additions and 30 deletions

View File

@ -3,11 +3,16 @@ package cn.stylefeng.guns.core.beetl.tag;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.guns.core.beetl.consts.DictTagConstants;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType;
import cn.stylefeng.roses.kernel.dict.modular.service.DictService;
import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Data;
import org.beetl.core.tag.GeneralVarTagBinding;
import java.util.List;
import java.util.Map;
/**
@ -73,6 +78,12 @@ public class SysDictBaseTag extends GeneralVarTagBinding {
*/
public String itemName;
/**
*
*
* @author liuhanqing
* @date 2021/1/16 23:49
*/
public void initAttr() {
Map<String, Object> attrs = this.getAttributes();
if (attrs.size() > 0) {
@ -122,4 +133,33 @@ public class SysDictBaseTag extends GeneralVarTagBinding {
public void render() {
}
/**
*
* @return
* @author liuhanqing
* @date 2021/1/16 23:46
*/
public SysDictType getDictType(){
// 根据字典类型编码去查询字典类型
LambdaQueryWrapper<SysDictType> dictTypeQueryWrapper = new LambdaQueryWrapper<>();
dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode());
dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode());
return dictTypeService.getOne(dictTypeQueryWrapper);
}
/**
*
*
* @return
* @author liuhanqing
* @date 2021/1/16 23:46
*/
public List<SysDict> getDictList(){
// 查询字典列表
LambdaQueryWrapper<SysDict> dictQueryWrapper = new LambdaQueryWrapper<>();
dictQueryWrapper.eq(SysDict::getDictTypeCode, this.getDictTypeCode());
dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode());
dictQueryWrapper.orderByAsc(SysDict::getDictSort);
return dictService.list(dictQueryWrapper);
}
}

View File

@ -27,18 +27,10 @@ public class SysDictCheckBoxTag extends SysDictBaseTag {
// 当字典类型编码不为空
if (StrUtil.isNotBlank(this.getDictTypeCode())) {
// 根据字典类型编码去查询字典类型
LambdaQueryWrapper<SysDictType> dictTypeQueryWrapper = new LambdaQueryWrapper<>();
dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode());
dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode());
SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper);
SysDictType dictType = getDictType();
// 判断字典类型不为空
if (dictType != null) {
// 查询字典列表
LambdaQueryWrapper<SysDict> dictQueryWrapper = new LambdaQueryWrapper<>();
dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode());
dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode());
dictQueryWrapper.orderByAsc(SysDict::getDictSort);
List<SysDict> lst = dictService.list(dictQueryWrapper);
List<SysDict> lst = getDictList();
// 默认选中值
String defaultValue = this.getDefaultValue();
// 循环字典列表

View File

@ -26,18 +26,10 @@ public class SysDictRadioTag extends SysDictBaseTag {
// 当字典类型编码不为空
if (StrUtil.isNotBlank(this.getDictTypeCode())) {
// 根据字典类型编码去查询字典类型
LambdaQueryWrapper<SysDictType> dictTypeQueryWrapper = new LambdaQueryWrapper<>();
dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode());
dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode());
SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper);
SysDictType dictType = getDictType();
// 判断字典类型不为空
if (dictType != null) {
// 查询字典列表
LambdaQueryWrapper<SysDict> dictQueryWrapper = new LambdaQueryWrapper<>();
dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode());
dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode());
dictQueryWrapper.orderByAsc(SysDict::getDictSort);
List<SysDict> lst = dictService.list(dictQueryWrapper);
List<SysDict> lst = getDictList();
// 默认选中值
String defaultValue = this.getDefaultValue();
int index = 0;

View File

@ -64,17 +64,10 @@ public class SysDictSelectTag extends SysDictBaseTag {
}
}
// 根据字典类型编码去查询字典类型
LambdaQueryWrapper<SysDictType> dictTypeQueryWrapper = new LambdaQueryWrapper<>();
dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode());
dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode());
SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper);
SysDictType dictType = getDictType();
// 判断字典类型不为空
if (dictType != null) {
// 查询字典列表
LambdaQueryWrapper<SysDict> dictQueryWrapper = new LambdaQueryWrapper<>();
dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode());
dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode());
dictQueryWrapper.orderByAsc(SysDict::getDictSort);
List<SysDict> lst = dictService.list(dictQueryWrapper);
List<SysDict> lst = getDictList();
// 默认选中值
String defaultValue = this.getDefaultValue();
// 循环字典列表,添加下拉选项