From 711cc5ac1594268c848f964d2067a82427dc2bbe Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 16 Jan 2021 23:03:52 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E3=80=90dict=E3=80=91=E4=BF=AE=E6=94=B9bee?= =?UTF-8?q?tl=20HTML=5FTAG=5FFLAG=E9=BB=98=E8=AE=A4=E4=B8=BA'tag:'?= =?UTF-8?q?=E7=94=A8=E6=9D=A5=E5=8C=BA=E5=88=AB=E6=98=AF=E5=90=A6=E6=98=AF?= =?UTF-8?q?beetl=E7=9A=84html=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- src/main/resources/application.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 87f7b662..b5d0634f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -21,6 +21,9 @@ spring: serialization: indent_output: false +beetl: + html-tag-flag: 'tag:' + scanner: open: true From 9e99aac50312008c394ec1cc33c4bfe2482da716 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 16 Jan 2021 23:04:50 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E3=80=90dict=E3=80=91select,checkbox,radio?= =?UTF-8?q?=20=E5=AD=97=E5=85=B8=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- .../guns/config/web/BeetlConfiguration.java | 1 + .../CustomBeetlGroupUtilConfiguration.java | 10 ++ .../core/beetl/consts/BeetlConstants.java | 6 + .../core/beetl/consts/DictTagConstants.java | 78 +++++++++++ .../beetl/enums/SelectTagHeadTypeEnum.java | 67 ++++++++++ .../beetl/expander/BeetlConfigExpander.java | 9 ++ .../guns/core/beetl/tag/SysDictBaseTag.java | 125 ++++++++++++++++++ .../core/beetl/tag/SysDictCheckBoxTag.java | 77 +++++++++++ .../guns/core/beetl/tag/SysDictRadioTag.java | 84 ++++++++++++ .../guns/core/beetl/tag/SysDictSelectTag.java | 102 ++++++++++++++ .../modular/system/notice/notice_add.html | 7 +- .../modular/system/notice/notice_edit.html | 9 +- 12 files changed, 566 insertions(+), 9 deletions(-) create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/consts/DictTagConstants.java create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/enums/SelectTagHeadTypeEnum.java create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java create mode 100644 src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java diff --git a/src/main/java/cn/stylefeng/guns/config/web/BeetlConfiguration.java b/src/main/java/cn/stylefeng/guns/config/web/BeetlConfiguration.java index ec136ee4..0fbb4f98 100644 --- a/src/main/java/cn/stylefeng/guns/config/web/BeetlConfiguration.java +++ b/src/main/java/cn/stylefeng/guns/config/web/BeetlConfiguration.java @@ -68,6 +68,7 @@ public class BeetlConfiguration { Properties properties = new Properties(); properties.setProperty("DELIMITER_STATEMENT_START", BeetlConfigExpander.getDelimiterStatementStart()); properties.setProperty("DELIMITER_STATEMENT_END", BeetlConfigExpander.getDelimiterStatementEnd()); + properties.setProperty("HTML_TAG_FLAG", BeetlConfigExpander.getHtmlTagFlag()); properties.setProperty("RESOURCE.tagRoot", BeetlConfigExpander.getResourceTagRoot()); properties.setProperty("RESOURCE.tagSuffix", BeetlConfigExpander.getResourceTagSuffix()); properties.setProperty("RESOURCE.autoCheck", BeetlConfigExpander.getResourceAutoCheck()); diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java b/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java index 34cc0f38..4a35fd8c 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java @@ -1,6 +1,9 @@ package cn.stylefeng.guns.core.beetl; import cn.hutool.core.util.ObjectUtil; +import cn.stylefeng.guns.core.beetl.tag.SysDictCheckBoxTag; +import cn.stylefeng.guns.core.beetl.tag.SysDictRadioTag; +import cn.stylefeng.guns.core.beetl.tag.SysDictSelectTag; import cn.stylefeng.roses.kernel.auth.api.LoginUserApi; import cn.stylefeng.roses.kernel.system.expander.SystemConfigExpander; import org.beetl.ext.spring.BeetlGroupUtilConfiguration; @@ -31,6 +34,13 @@ public class CustomBeetlGroupUtilConfiguration extends BeetlGroupUtilConfigurati // 获取基本信息的工具 groupTemplate.registerFunctionPackage("constants", SystemConfigExpander.class); + // 下拉选字典 + groupTemplate.registerTag("dict_select", SysDictSelectTag.class); + // 单选字典 + groupTemplate.registerTag("dict_radio", SysDictRadioTag.class); + // 多选字典 + groupTemplate.registerTag("dict_checkbox", SysDictCheckBoxTag.class); + // todo 多语言 // groupTemplate.registerFunctionPackage("lang", new UserTranslationContext()); } diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/consts/BeetlConstants.java b/src/main/java/cn/stylefeng/guns/core/beetl/consts/BeetlConstants.java index 14316a8f..13f7dc7a 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/consts/BeetlConstants.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/consts/BeetlConstants.java @@ -37,4 +37,10 @@ public interface BeetlConstants { */ String DEFAULT_RESOURCE_AUTO_CHECK = "false"; + /** + * 默认beetl 支持HTML标签 + *

+ * beetl默认的是 '#' + */ + String DEFAULT_HTML_TAG_FLAG = "tag:"; } diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/consts/DictTagConstants.java b/src/main/java/cn/stylefeng/guns/core/beetl/consts/DictTagConstants.java new file mode 100644 index 00000000..75b0da28 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/consts/DictTagConstants.java @@ -0,0 +1,78 @@ +package cn.stylefeng.guns.core.beetl.consts; + +/** + * 字典html属性常量 + * + * @author liuhanqing + * @date 2021/1/16 21:06 + */ + +public interface DictTagConstants { + + /** + * html组件 id + */ + String ID = "id"; + + /** + * html组件 name + */ + String NAME = "name"; + + /** + * html组件 type + */ + String TYPE = "type"; + + /** + * 字典类型编码 + */ + String DICT_TYPE_CODE = "dictTypeCode"; + + /** + * layui元素的风格 + */ + String LAY_SKIN = "laySkin"; + + /** + * layui事件过滤器 + */ + String LAY_FILTER = "layFilter"; + + /** + * layui校验 + */ + String LAY_VERIFY = "layVerify"; + + /** + * select控件提示name + */ + String HEAD_NAME = "headName"; + + /** + * select控件提示value + */ + String HEAD_VALUE = "headValue"; + + /** + * select控件提示类型::1-全部,2-请选择 + */ + String HEAD_TYPE = "headType"; + + /** + * 默认值 + */ + String DEFAULT_VALUE = "defaultValue"; + + /** + * 工作流相关 + */ + String WORKFLOW_FORM = "workflowForm"; + + /** + * 工作流相关 + */ + String ITEM_NAME = "itemName"; + + +} diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/enums/SelectTagHeadTypeEnum.java b/src/main/java/cn/stylefeng/guns/core/beetl/enums/SelectTagHeadTypeEnum.java new file mode 100644 index 00000000..e16f4178 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/enums/SelectTagHeadTypeEnum.java @@ -0,0 +1,67 @@ +package cn.stylefeng.guns.core.beetl.enums; + +import lombok.Getter; + +/** + * 字典下拉选头类型 + * + * @author liuhanqing + * @date 2021/1/16 20:36 + */ +@Getter +public enum SelectTagHeadTypeEnum { + + /** + * 全部 + */ + ALL("1", "全部"), + + /** + * 请选择 + */ + SELECT("2", "请选择"); + + private final String code; + + private final String name; + + SelectTagHeadTypeEnum(String code, String name) { + this.code = code; + this.name = name; + } + + /** + * 根据code获取枚举 + * + * @author liuhanqing + * @date 2021/1/16 20:36 + */ + public static SelectTagHeadTypeEnum codeToEnum(String code) { + if (null != code) { + for (SelectTagHeadTypeEnum e : SelectTagHeadTypeEnum.values()) { + if (e.getCode().equals(code)) { + return e; + } + } + } + return null; + } + + /** + * 编码转化成中文含义 + * + * @author liuhanqing + * @date 2021/1/16 20:36 + */ + public static String codeToName(String code) { + if (null != code) { + for (SelectTagHeadTypeEnum e : SelectTagHeadTypeEnum.values()) { + if (e.getCode().equals(code)) { + return e.getName(); + } + } + } + return "未知"; + } + +} diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/expander/BeetlConfigExpander.java b/src/main/java/cn/stylefeng/guns/core/beetl/expander/BeetlConfigExpander.java index 812d0e7f..82a96ab3 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/expander/BeetlConfigExpander.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/expander/BeetlConfigExpander.java @@ -60,5 +60,14 @@ public class BeetlConfigExpander { public static String getResourceAutoCheck() { return ConfigContext.me().getSysConfigValueWithDefault("RESOURCE_AUTO_CHECK", String.class, BeetlConstants.DEFAULT_RESOURCE_AUTO_CHECK); } + /** + * 自定义支持HTML标签 + * + * @author liuhanqing + * @date 2021/1/16 21:06 + */ + public static String getHtmlTagFlag() { + return ConfigContext.me().getSysConfigValueWithDefault("HTML_TAG_FLAG", String.class, BeetlConstants.DEFAULT_HTML_TAG_FLAG); + } } diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java new file mode 100644 index 00000000..a5daaf5f --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java @@ -0,0 +1,125 @@ +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.service.DictService; +import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService; +import lombok.Data; +import org.beetl.core.tag.GeneralVarTagBinding; + +import java.util.Map; + +/** + * beetl字典标签基类 + * + * @author liuhanqing + * @date 2021/1/16 18:45 + */ +@Data +public class SysDictBaseTag extends GeneralVarTagBinding { + public DictService dictService = SpringUtil.getBean(DictService.class); + public DictTypeService dictTypeService = SpringUtil.getBean(DictTypeService.class); + /** + * html组件 id + */ + public String id; + /** + * html组件 name + */ + public String name; + /** + * html组件 type + */ + public String type; + /** + * 字典类型编码 + */ + public String dictTypeCode; + /** + * layui元素的风格 + */ + public String laySkin; + /** + * layui事件过滤器 + */ + public String layFilter; + /** + * layui校验 + */ + public String layVerify; + /** + * select控件提示name + */ + public String headName; + /** + * select控件提示value + */ + public String headValue; + /** + * select控件提示类型::1-全部,2-请选择 + */ + public String headType; + /** + * 默认值 + */ + public String defaultValue; + /** + * 工作流相关 + */ + public String workflowForm; + /** + * 工作流相关 + */ + public String itemName; + + public void initAttr() { + Map attrs = this.getAttributes(); + if (attrs.size() > 0) { + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.ID))) { + this.setId(attrs.get(DictTagConstants.ID).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.NAME))) { + this.setName(attrs.get(DictTagConstants.NAME).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.TYPE))) { + this.setType(attrs.get(DictTagConstants.TYPE).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.DICT_TYPE_CODE))) { + this.setDictTypeCode(attrs.get(DictTagConstants.DICT_TYPE_CODE).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.LAY_SKIN))) { + this.setLaySkin(attrs.get(DictTagConstants.LAY_SKIN).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.LAY_FILTER))) { + this.setLayFilter(attrs.get(DictTagConstants.LAY_FILTER).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.LAY_VERIFY))) { + this.setLayVerify(attrs.get(DictTagConstants.LAY_VERIFY).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.HEAD_NAME))) { + this.setHeadName(attrs.get(DictTagConstants.HEAD_NAME).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.HEAD_VALUE))) { + this.setHeadValue(attrs.get(DictTagConstants.HEAD_VALUE).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.HEAD_TYPE))) { + this.setHeadType(attrs.get(DictTagConstants.HEAD_TYPE).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.DEFAULT_VALUE))) { + this.setDefaultValue(attrs.get(DictTagConstants.DEFAULT_VALUE).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.WORKFLOW_FORM))) { + this.setWorkflowForm(attrs.get(DictTagConstants.WORKFLOW_FORM).toString()); + } + if (ObjectUtil.isNotNull(attrs.get(DictTagConstants.ITEM_NAME))) { + this.setItemName(attrs.get(DictTagConstants.ITEM_NAME).toString()); + } + } + } + + @Override + public void render() { + + } +} diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java new file mode 100644 index 00000000..6ae235a0 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java @@ -0,0 +1,77 @@ +package cn.stylefeng.guns.core.beetl.tag; + +import cn.hutool.core.util.StrUtil; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.List; + +/** + * checkbox字典组件 + * + * @author liuhanqing + * @date 2021/1/16 19:06 + */ +@Slf4j +public class SysDictCheckBoxTag extends SysDictBaseTag { + + @Override + public void render() { + // 初始属性 + initAttr(); + StringBuilder sb = new StringBuilder(); + // 当字典类型编码不为空 + if (StrUtil.isNotBlank(this.getDictTypeCode())) { + // 根据字典类型编码去查询字典类型 + LambdaQueryWrapper dictTypeQueryWrapper = new LambdaQueryWrapper<>(); + dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode()); + SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper); + // 判断字典类型不为空 + if (dictType != null) { + // 查询字典列表 + LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); + dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); + dictQueryWrapper.orderByAsc(SysDict::getDictSort); + List lst = dictService.list(dictQueryWrapper); + // 默认选中值 + String defaultValue = this.getDefaultValue(); + // 循环字典列表 + for (SysDict option : lst) { + // 生成input的id + String id = this.getType() + "_" + this.getName() + "_" + option.getDictCode(); + // 拼接html + sb.append(" "); + } + } + } + try { + this.ctx.byteWriter.writeString(sb.toString()); + } catch (IOException e) { + log.error("checkbox字典初始化异常:",e); + } + } +} diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java new file mode 100644 index 00000000..52e93a0f --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java @@ -0,0 +1,84 @@ +package cn.stylefeng.guns.core.beetl.tag; + +import cn.hutool.core.util.StrUtil; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.List; + +/** + * radio字典组件 + * + * @author liuhanqing + * @date 2021/1/16 19:59 + */ +@Slf4j +public class SysDictRadioTag extends SysDictBaseTag { + @Override + public void render() { + // 初始属性 + initAttr(); + StringBuilder sb = new StringBuilder(); + // 当字典类型编码不为空 + if (StrUtil.isNotBlank(this.getDictTypeCode())) { + // 根据字典类型编码去查询字典类型 + LambdaQueryWrapper dictTypeQueryWrapper = new LambdaQueryWrapper<>(); + dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode()); + SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper); + // 判断字典类型不为空 + if (dictType != null) { + // 查询字典列表 + LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); + dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); + dictQueryWrapper.orderByAsc(SysDict::getDictSort); + List lst = dictService.list(dictQueryWrapper); + // 默认选中值 + String defaultValue = this.getDefaultValue(); + int index = 0; + for (SysDict option : lst) { + // 生成input的id + String id = this.getType() + "_" + this.getName() + "_" + option.getDictCode(); + // 拼接html + sb.append(" "); + index++; + } + } + } + try { + this.ctx.byteWriter.writeString(sb.toString()); + } catch (IOException e) { + log.error("select字典初始化异常:", e); + } + } +} diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java new file mode 100644 index 00000000..22c060f3 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java @@ -0,0 +1,102 @@ +package cn.stylefeng.guns.core.beetl.tag; + +import cn.hutool.core.util.StrUtil; +import cn.stylefeng.guns.core.beetl.enums.SelectTagHeadTypeEnum; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; +import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.List; + +/** + * select字典组件 + * + * @author liuhanqing + * @date 2021/1/16 19:37 + */ +@Slf4j +public class SysDictSelectTag extends SysDictBaseTag { + + @Override + public void render() { + // 初始属性 + initAttr(); + StringBuilder sb = new StringBuilder(); + // 当字典类型编码不为空 + if (StrUtil.isNotBlank(this.getDictTypeCode())) { + sb.append(""); + } + try { + this.ctx.byteWriter.writeString(sb.toString()); + } catch (IOException e) { + log.error("select字典初始化异常:",e); + } + } +} diff --git a/src/main/webapp/pages/modular/system/notice/notice_add.html b/src/main/webapp/pages/modular/system/notice/notice_add.html index eaa810ea..4308f919 100644 --- a/src/main/webapp/pages/modular/system/notice/notice_add.html +++ b/src/main/webapp/pages/modular/system/notice/notice_add.html @@ -22,12 +22,15 @@

- - - - - - - + +
From f7a1c55e724fd6ec0eec06f5bf04b7952d7e8546 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 16 Jan 2021 23:43:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E3=80=90dict=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A0=87=E8=AF=86=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- .../cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java | 3 +++ .../java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java | 3 +++ .../cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java index 6ae235a0..19fbed07 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java @@ -3,6 +3,7 @@ package cn.stylefeng.guns.core.beetl.tag; import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -28,12 +29,14 @@ public class SysDictCheckBoxTag extends SysDictBaseTag { // 根据字典类型编码去查询字典类型 LambdaQueryWrapper dictTypeQueryWrapper = new LambdaQueryWrapper<>(); dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode()); + dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode()); SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper); // 判断字典类型不为空 if (dictType != null) { // 查询字典列表 LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); + dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); dictQueryWrapper.orderByAsc(SysDict::getDictSort); List lst = dictService.list(dictQueryWrapper); // 默认选中值 diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java index 52e93a0f..d6fa9aba 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java @@ -3,6 +3,7 @@ package cn.stylefeng.guns.core.beetl.tag; import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -27,12 +28,14 @@ public class SysDictRadioTag extends SysDictBaseTag { // 根据字典类型编码去查询字典类型 LambdaQueryWrapper dictTypeQueryWrapper = new LambdaQueryWrapper<>(); dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode()); + dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode()); SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper); // 判断字典类型不为空 if (dictType != null) { // 查询字典列表 LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); + dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); dictQueryWrapper.orderByAsc(SysDict::getDictSort); List lst = dictService.list(dictQueryWrapper); // 默认选中值 diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java index 22c060f3..2eca74c7 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; import cn.stylefeng.guns.core.beetl.enums.SelectTagHeadTypeEnum; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -65,11 +66,13 @@ public class SysDictSelectTag extends SysDictBaseTag { // 根据字典类型编码去查询字典类型 LambdaQueryWrapper dictTypeQueryWrapper = new LambdaQueryWrapper<>(); dictTypeQueryWrapper.eq(SysDictType::getDictTypeCode, this.getDictTypeCode()); + dictTypeQueryWrapper.ne(SysDictType::getDelFlag, YesOrNotEnum.Y.getCode()); SysDictType dictType = dictTypeService.getOne(dictTypeQueryWrapper); if (dictType != null) { // 查询字典列表 LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); + dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); dictQueryWrapper.orderByAsc(SysDict::getDictSort); List lst = dictService.list(dictQueryWrapper); // 默认选中值 From 7c22e6cd829cffe8e24e551017eb7acb67c136f0 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 16 Jan 2021 23:49:30 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E3=80=90dict=E3=80=91=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- .../guns/core/beetl/tag/SysDictBaseTag.java | 40 +++++++++++++++++++ .../core/beetl/tag/SysDictCheckBoxTag.java | 12 +----- .../guns/core/beetl/tag/SysDictRadioTag.java | 12 +----- .../guns/core/beetl/tag/SysDictSelectTag.java | 13 ++---- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java index a5daaf5f..04dd7354 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictBaseTag.java @@ -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 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 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 getDictList(){ + // 查询字典列表 + LambdaQueryWrapper dictQueryWrapper = new LambdaQueryWrapper<>(); + dictQueryWrapper.eq(SysDict::getDictTypeCode, this.getDictTypeCode()); + dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); + dictQueryWrapper.orderByAsc(SysDict::getDictSort); + return dictService.list(dictQueryWrapper); + } } diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java index 19fbed07..45482975 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictCheckBoxTag.java @@ -27,18 +27,10 @@ public class SysDictCheckBoxTag extends SysDictBaseTag { // 当字典类型编码不为空 if (StrUtil.isNotBlank(this.getDictTypeCode())) { // 根据字典类型编码去查询字典类型 - LambdaQueryWrapper 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 dictQueryWrapper = new LambdaQueryWrapper<>(); - dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); - dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); - dictQueryWrapper.orderByAsc(SysDict::getDictSort); - List lst = dictService.list(dictQueryWrapper); + List lst = getDictList(); // 默认选中值 String defaultValue = this.getDefaultValue(); // 循环字典列表 diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java index d6fa9aba..3b1f75e7 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictRadioTag.java @@ -26,18 +26,10 @@ public class SysDictRadioTag extends SysDictBaseTag { // 当字典类型编码不为空 if (StrUtil.isNotBlank(this.getDictTypeCode())) { // 根据字典类型编码去查询字典类型 - LambdaQueryWrapper 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 dictQueryWrapper = new LambdaQueryWrapper<>(); - dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); - dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); - dictQueryWrapper.orderByAsc(SysDict::getDictSort); - List lst = dictService.list(dictQueryWrapper); + List lst = getDictList(); // 默认选中值 String defaultValue = this.getDefaultValue(); int index = 0; diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java index 2eca74c7..cb10795e 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/tag/SysDictSelectTag.java @@ -64,17 +64,10 @@ public class SysDictSelectTag extends SysDictBaseTag { } } // 根据字典类型编码去查询字典类型 - LambdaQueryWrapper 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 dictQueryWrapper = new LambdaQueryWrapper<>(); - dictQueryWrapper.eq(SysDict::getDictTypeCode, dictType.getDictTypeCode()); - dictQueryWrapper.ne(SysDict::getDelFlag, YesOrNotEnum.Y.getCode()); - dictQueryWrapper.orderByAsc(SysDict::getDictSort); - List lst = dictService.list(dictQueryWrapper); + List lst = getDictList(); // 默认选中值 String defaultValue = this.getDefaultValue(); // 循环字典列表,添加下拉选项 From 0ad6ded8af67d1259045402a8a3f0586e6bc7d68 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sun, 17 Jan 2021 14:12:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E3=80=90notice=E3=80=91=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8tinymce=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhanqing <447067298@qq.com> --- .../assets/modular/system/notice/notice_add.js | 11 ++++++----- .../assets/modular/system/notice/notice_edit.js | 13 ++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/webapp/assets/modular/system/notice/notice_add.js b/src/main/webapp/assets/modular/system/notice/notice_add.js index 612f8410..9156590d 100644 --- a/src/main/webapp/assets/modular/system/notice/notice_add.js +++ b/src/main/webapp/assets/modular/system/notice/notice_add.js @@ -40,11 +40,12 @@ layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'xmSelect'], func plugins: 'code print preview fullscreen paste searchreplace save autosave link autolink image imagetools media table codesample lists advlist hr charmap emoticons anchor directionality pagebreak quickbars nonbreaking visualblocks visualchars wordcount', toolbar: 'fullscreen preview code | undo redo | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | formatselect fontselect fontsizeselect | link image media emoticons charmap anchor pagebreak codesample | ltr rtl', toolbar_drawer: 'sliding', - images_upload_url: '../../../json/tinymce-upload-ok.json', - file_picker_types: 'media', - file_picker_callback: function (callback, value, meta) { - layer.msg('演示环境不允许上传', {anim: 6}); - }, + images_upload_url: Feng.ctxPath + '/sysFileInfo/tinymceUpload', + images_upload_base_path: Feng.ctxPath, + file_picker_types: 'file image media', + // file_picker_callback: function (callback, value, meta) { + // layer.msg('演示环境不允许上传', {anim: 6}); + // }, init_instance_callback: function (editor) { console.log(editor); } diff --git a/src/main/webapp/assets/modular/system/notice/notice_edit.js b/src/main/webapp/assets/modular/system/notice/notice_edit.js index c1fa3642..5fa3d0a9 100644 --- a/src/main/webapp/assets/modular/system/notice/notice_edit.js +++ b/src/main/webapp/assets/modular/system/notice/notice_edit.js @@ -19,11 +19,12 @@ layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'xmSelect'], func plugins: 'code print preview fullscreen paste searchreplace save autosave link autolink image imagetools media table codesample lists advlist hr charmap emoticons anchor directionality pagebreak quickbars nonbreaking visualblocks visualchars wordcount', toolbar: 'fullscreen preview code | undo redo | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | formatselect fontselect fontsizeselect | link image media emoticons charmap anchor pagebreak codesample | ltr rtl', toolbar_drawer: 'sliding', - images_upload_url: '../../../json/tinymce-upload-ok.json', - file_picker_types: 'media', - file_picker_callback: function (callback, value, meta) { - layer.msg('演示环境不允许上传', {anim: 6}); - }, + images_upload_url: Feng.ctxPath + '/sysFileInfo/tinymceUpload', + images_upload_base_path: Feng.ctxPath, + file_picker_types: 'file image media', + // file_picker_callback: function (callback, value, meta) { + // layer.msg('演示环境不允许上传', {anim: 6}); + // }, init_instance_callback: function (editor) { tinymce.get('noticeContent').setContent(data.noticeContent); } @@ -128,9 +129,11 @@ layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'xmSelect'], func Feng.error("修改失败!" + data.message); }); data.field.noticeContent = tinymce.get('noticeContent').getContent(); + console.log(data.field.noticeContent) if (data.field.noticeScope !== "all") { data.field.noticeScope = userSelect.getValue('valueStr'); } + // request.setContentType("multipart/form-data"); request.set(data.field); request.start(true); //添加 return false 可成功跳转页面