处理各类bug问题
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package com.jero.common.util.jsonschema;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 列 配置基本信息
|
||||
*/
|
||||
@Data
|
||||
public class BaseColumn {
|
||||
|
||||
/**
|
||||
* 列配置 描述 -对应数据库字段描述
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 列配置 名称 -对应数据库字段名
|
||||
*/
|
||||
private String field;
|
||||
|
||||
public BaseColumn(){}
|
||||
|
||||
public BaseColumn(String title,String field){
|
||||
this.title = title;
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
package com.jero.common.util.jsonschema;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 验证通用属性
|
||||
*/
|
||||
public abstract class CommonProperty implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -426159949502493187L;
|
||||
|
||||
|
||||
protected String key;
|
||||
|
||||
|
||||
/**
|
||||
* <p>此关键字的值必须是字符串或数组。如果它是一个数组,那么数组的元素必须是字符串,并且必须是唯一的。
|
||||
* <p>字符串值必须是六种基本类型之一(“null”,“boolean”,“object”,“array”,“number”或“string”),或“integer”,它匹配任何数字,零分数部分。
|
||||
* <p>当且仅当实例位于为此关键字列出的任何集合中时,实例才会验证。
|
||||
*
|
||||
*/
|
||||
protected String type;
|
||||
|
||||
/**
|
||||
* 对应JsonSchema的enum
|
||||
* <p>该关键字的值必须是一个数组。这个数组应该至少有一个元素。数组中的元素应该是唯一的。如果实例的值等于此关键字的数组值中的某个元素,则实例将对此关键字成功验证。
|
||||
* 数组中的元素可以是任何值,包括null
|
||||
*
|
||||
* {
|
||||
* "type": "string",
|
||||
* "enum": ["1", "2", "3"] 需要的话可以通过这个include转一下
|
||||
* }
|
||||
*/
|
||||
protected List<DictModel> include;
|
||||
|
||||
/**
|
||||
* 对应JsonSchema的const
|
||||
* <p>此关键字的值可以是任何类型,包括null。
|
||||
* 如果实例的值等于关键字的值,则实例将针对此关键字成功验证。
|
||||
*/
|
||||
protected Object constant;
|
||||
|
||||
//三个自定义 属性
|
||||
protected String view;// 展示类型
|
||||
protected String title;//数据库字段备注
|
||||
protected Integer order;//字段显示排序
|
||||
|
||||
protected boolean disabled;//是否禁用
|
||||
|
||||
protected String defVal; // 字段默认值
|
||||
|
||||
protected String fieldExtendJson;//扩展参数
|
||||
|
||||
protected Integer dbPointLength;//小数点
|
||||
|
||||
public String getDefVal() {
|
||||
return defVal;
|
||||
}
|
||||
|
||||
public void setDefVal(String defVal) {
|
||||
this.defVal = defVal;
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
public String getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setView(String view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<DictModel> getInclude() {
|
||||
return include;
|
||||
}
|
||||
|
||||
public void setInclude(List<DictModel> include) {
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
public Object getConstant() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
public void setConstant(Object constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getFieldExtendJson() {
|
||||
return fieldExtendJson;
|
||||
}
|
||||
|
||||
public void setFieldExtendJson(String fieldExtendJson) {
|
||||
this.fieldExtendJson = fieldExtendJson;
|
||||
}
|
||||
|
||||
public Integer getDbPointLength() {
|
||||
return dbPointLength;
|
||||
}
|
||||
|
||||
public void setDbPointLength(Integer dbPointLength) {
|
||||
this.dbPointLength = dbPointLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个map有两个key
|
||||
* <P>key ---> Property JSON的key
|
||||
* <P>prop --> JSON object
|
||||
* @return
|
||||
*/
|
||||
public abstract Map<String,Object> getPropertyJson();
|
||||
|
||||
public JSONObject getCommonJson() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("type", type);
|
||||
if(include!=null && include.size()>0) {
|
||||
json.put("enum", include);
|
||||
}
|
||||
if(constant!=null) {
|
||||
json.put("const", constant);
|
||||
}
|
||||
if(title!=null) {
|
||||
json.put("title", title);
|
||||
}
|
||||
if(order!=null) {
|
||||
json.put("order", order);
|
||||
}
|
||||
if(view==null) {
|
||||
json.put("view", "input");
|
||||
}else {
|
||||
json.put("view", view);
|
||||
}
|
||||
if(disabled) {
|
||||
String str = "{\"widgetattrs\":{\"disabled\":true}}";
|
||||
JSONObject ui = JSONObject.parseObject(str);
|
||||
json.put("ui", ui);
|
||||
}
|
||||
if (defVal!=null && defVal.length()>0) {
|
||||
json.put("defVal", defVal);
|
||||
}
|
||||
if(fieldExtendJson != null){
|
||||
json.put("fieldExtendJson", fieldExtendJson);
|
||||
}
|
||||
if(dbPointLength !=null ) {
|
||||
json.put("dbPointLength", dbPointLength);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.jero.common.util.jsonschema;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JsonSchema 模式类
|
||||
* < http://json-schema.org/draft-07/schema# >
|
||||
*/
|
||||
public class JsonSchemaDescrip implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7682073117441544718L;
|
||||
|
||||
|
||||
private String $schema = "http://json-schema.org/draft-07/schema#";
|
||||
|
||||
/**
|
||||
* 用它给我们的模式提供了标题。
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 关于模式的描述。
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
*type 关键字在我们的 JSON 数据上定义了第一个约束:必须是一个 JSON 对象。 可以直接设置成object
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private List<String> required;
|
||||
|
||||
|
||||
public List<String> getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(List<String> required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String get$schema() {
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public void set$schema(String $schema) {
|
||||
this.$schema = $schema;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public JsonSchemaDescrip() {}
|
||||
|
||||
public JsonSchemaDescrip(List<String> required) {
|
||||
this.description="我是一个jsonschema description";
|
||||
this.title="我是一个jsonschema title";
|
||||
this.type="object";
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.jero.common.util.jsonschema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class JsonschemaUtil {
|
||||
|
||||
/**
|
||||
* 生成JsonSchema
|
||||
*
|
||||
* @param descrip
|
||||
* @param propertyList
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject getJsonSchema(JsonSchemaDescrip descrip, List<CommonProperty> propertyList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("$schema", descrip.get$schema());
|
||||
obj.put("type", descrip.getType());
|
||||
obj.put("title", descrip.getTitle());
|
||||
|
||||
List<String> requiredArr = descrip.getRequired();
|
||||
obj.put("required", requiredArr);
|
||||
|
||||
JSONObject properties = new JSONObject();
|
||||
for (CommonProperty commonProperty : propertyList) {
|
||||
Map<String, Object> map = commonProperty.getPropertyJson();
|
||||
properties.put(map.get("key").toString(), map.get("prop"));
|
||||
}
|
||||
obj.put("properties", properties);
|
||||
//鬼知道这里为什么报错 com.jero.modules.system.model.DictModel cannot be cast to com.jero.modules.system.model.DictModel
|
||||
//log.info("---JSONSchema--->"+obj.toJSONString());
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成JsonSchema 用于子对象
|
||||
* @param title 子对象描述
|
||||
* @param requiredArr 子对象必填属性名集合
|
||||
* @param propertyList 子对象属性集合
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject getSubJsonSchema(String title,List<String> requiredArr,List<CommonProperty> propertyList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", "object");
|
||||
obj.put("view", "tab");
|
||||
obj.put("title", title);
|
||||
|
||||
if(requiredArr==null) {
|
||||
requiredArr = new ArrayList<String>();
|
||||
}
|
||||
obj.put("required", requiredArr);
|
||||
|
||||
JSONObject properties = new JSONObject();
|
||||
for (CommonProperty commonProperty : propertyList) {
|
||||
Map<String, Object> map = commonProperty.getPropertyJson();
|
||||
properties.put(map.get("key").toString(), map.get("prop"));
|
||||
}
|
||||
obj.put("properties", properties);
|
||||
//log.info("---JSONSchema--->"+obj.toString());
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 字典属性
|
||||
* @author 86729
|
||||
*
|
||||
*/
|
||||
public class DictProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = 3786503639885610767L;
|
||||
|
||||
//字典三属性
|
||||
private String dictCode;
|
||||
private String dictTable;
|
||||
private String dictText;
|
||||
|
||||
public String getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(String dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public String getDictTable() {
|
||||
return dictTable;
|
||||
}
|
||||
|
||||
public void setDictTable(String dictTable) {
|
||||
this.dictTable = dictTable;
|
||||
}
|
||||
|
||||
public String getDictText() {
|
||||
return dictText;
|
||||
}
|
||||
|
||||
public void setDictText(String dictText) {
|
||||
this.dictText = dictText;
|
||||
}
|
||||
|
||||
public DictProperty() {}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*/
|
||||
public DictProperty(String key,String title,String dictTable,String dictCode,String dictText) {
|
||||
this.type = "string";
|
||||
this.view = "sel_search";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.dictCode = dictCode;
|
||||
this.dictTable= dictTable;
|
||||
this.dictText= dictText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
if(dictCode!=null) {
|
||||
prop.put("dictCode",dictCode);
|
||||
}
|
||||
if(dictTable!=null) {
|
||||
prop.put("dictTable",dictTable);
|
||||
}
|
||||
if(dictText!=null) {
|
||||
prop.put("dictText",dictText);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
//TODO 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 字典属性
|
||||
* @author 86729
|
||||
*
|
||||
*/
|
||||
public class HiddenProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = -8939298551502162479L;
|
||||
|
||||
public HiddenProperty() {}
|
||||
|
||||
public HiddenProperty(String key,String title) {
|
||||
this.type = "string";
|
||||
this.view = "hidden";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
prop.put("hidden",true);
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.util.jsonschema.BaseColumn;
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 级联下拉
|
||||
*/
|
||||
public class LinkDownProperty extends CommonProperty {
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
String dictTable;
|
||||
|
||||
/**
|
||||
* 级联下拉组件 的其他级联列
|
||||
*/
|
||||
List<BaseColumn> otherColumns;
|
||||
|
||||
public String getDictTable(){
|
||||
return this.dictTable;
|
||||
}
|
||||
|
||||
public void setDictTable(String dictTable){
|
||||
this.dictTable = dictTable;
|
||||
}
|
||||
|
||||
public List<BaseColumn> getOtherColumns(){
|
||||
return this.otherColumns;
|
||||
}
|
||||
|
||||
public void setOtherColumns(List<BaseColumn> otherColumns){
|
||||
this.otherColumns = otherColumns;
|
||||
}
|
||||
|
||||
public LinkDownProperty() {}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*/
|
||||
public LinkDownProperty(String key,String title,String dictTable) {
|
||||
this.type = "string";
|
||||
this.view = "link_down";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.dictTable= dictTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("key", getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
JSONObject temp = JSONObject.parseObject(this.dictTable);
|
||||
prop.put("config", temp);
|
||||
prop.put("others", otherColumns);
|
||||
map.put("prop", prop);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class NumberProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = -558615331436437200L;
|
||||
|
||||
/**
|
||||
* 倍数
|
||||
* 验证实例是否为此数值的倍数
|
||||
* “multipleOf”的值必须是一个数字,严格大于0。
|
||||
*/
|
||||
private Integer multipleOf;
|
||||
|
||||
/**
|
||||
* 小于等于
|
||||
* “maximum”的值必须是一个数字,表示数字实例的包含上限。
|
||||
* 如果实例是数字,则仅当实例小于或等于“最大”时,此关键字才会生效。
|
||||
*/
|
||||
private Integer maxinum;
|
||||
|
||||
/**
|
||||
* 小于
|
||||
* “exclusiveMaximum”的值必须是数字,表示数字实例的独占上限。
|
||||
* 如果实例是数字,则实例仅在其值严格小于(不等于)“exclusiveMaximum”时才有效。
|
||||
*/
|
||||
private Integer exclusiveMaximum;
|
||||
|
||||
/**
|
||||
* 大于等于
|
||||
*/
|
||||
private Integer minimum;
|
||||
|
||||
/**
|
||||
* 大于等于
|
||||
*/
|
||||
private Integer exclusiveMinimum;
|
||||
|
||||
private String pattern;
|
||||
|
||||
public Integer getMultipleOf() {
|
||||
return multipleOf;
|
||||
}
|
||||
|
||||
public void setMultipleOf(Integer multipleOf) {
|
||||
this.multipleOf = multipleOf;
|
||||
}
|
||||
|
||||
public Integer getMaxinum() {
|
||||
return maxinum;
|
||||
}
|
||||
|
||||
public void setMaxinum(Integer maxinum) {
|
||||
this.maxinum = maxinum;
|
||||
}
|
||||
|
||||
public Integer getExclusiveMaximum() {
|
||||
return exclusiveMaximum;
|
||||
}
|
||||
|
||||
public void setExclusiveMaximum(Integer exclusiveMaximum) {
|
||||
this.exclusiveMaximum = exclusiveMaximum;
|
||||
}
|
||||
|
||||
public Integer getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
public void setMinimum(Integer minimum) {
|
||||
this.minimum = minimum;
|
||||
}
|
||||
|
||||
public Integer getExclusiveMinimum() {
|
||||
return exclusiveMinimum;
|
||||
}
|
||||
|
||||
public void setExclusiveMinimum(Integer exclusiveMinimum) {
|
||||
this.exclusiveMinimum = exclusiveMinimum;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public NumberProperty() {}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
* @param key 字段名
|
||||
* @param title 字段备注
|
||||
* @param type number和integer
|
||||
*/
|
||||
public NumberProperty(String key,String title,String type) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.title = title;
|
||||
this.view = "number";
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表类型的走这个构造器 字典里存储的都是字符串 没法走这个构造器
|
||||
* @param key
|
||||
* @param type
|
||||
* @param view list-checkbox-radio
|
||||
* @param include
|
||||
*/
|
||||
public NumberProperty(String key,String title,String view,List<DictModel> include) {
|
||||
this.type = "integer";
|
||||
this.key = key;
|
||||
this.view = view;
|
||||
this.title = title;
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
if(multipleOf!=null) {
|
||||
prop.put("multipleOf",multipleOf);
|
||||
}
|
||||
if(maxinum!=null) {
|
||||
prop.put("maxinum",maxinum);
|
||||
}
|
||||
if(exclusiveMaximum!=null) {
|
||||
prop.put("exclusiveMaximum",exclusiveMaximum);
|
||||
}
|
||||
if(minimum!=null) {
|
||||
prop.put("minimum",minimum);
|
||||
}
|
||||
if(exclusiveMinimum!=null) {
|
||||
prop.put("exclusiveMinimum",exclusiveMinimum);
|
||||
}
|
||||
if(pattern!=null) {
|
||||
prop.put("pattern",pattern);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class PopupProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = -3200493311633999539L;
|
||||
|
||||
private String code;
|
||||
|
||||
private String destFields;
|
||||
|
||||
private String orgFields;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDestFields() {
|
||||
return destFields;
|
||||
}
|
||||
|
||||
public void setDestFields(String destFields) {
|
||||
this.destFields = destFields;
|
||||
}
|
||||
|
||||
public String getOrgFields() {
|
||||
return orgFields;
|
||||
}
|
||||
|
||||
public void setOrgFields(String orgFields) {
|
||||
this.orgFields = orgFields;
|
||||
}
|
||||
|
||||
public PopupProperty() {}
|
||||
|
||||
public PopupProperty(String key,String title,String code,String destFields,String orgFields) {
|
||||
this.view = "popup";
|
||||
this.type = "string";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.code = code;
|
||||
this.destFields=destFields;
|
||||
this.orgFields=orgFields;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
if(code!=null) {
|
||||
prop.put("code",code);
|
||||
}
|
||||
if(destFields!=null) {
|
||||
prop.put("destFields",destFields);
|
||||
}
|
||||
if(orgFields!=null) {
|
||||
prop.put("orgFields",orgFields);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class StringProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = -3200493311633999539L;
|
||||
|
||||
private Integer maxLength;
|
||||
|
||||
private Integer minLength;
|
||||
|
||||
/**
|
||||
* 根据ECMA 262正则表达式方言,该字符串应该是有效的正则表达式。
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 错误提示信息
|
||||
*/
|
||||
private String errorInfo;
|
||||
|
||||
public Integer getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxLength(Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public Integer getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public void setMinLength(Integer minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public String getErrorInfo() {
|
||||
return errorInfo;
|
||||
}
|
||||
|
||||
|
||||
public void setErrorInfo(String errorInfo) {
|
||||
this.errorInfo = errorInfo;
|
||||
}
|
||||
|
||||
|
||||
public StringProperty() {}
|
||||
|
||||
/**
|
||||
* 一般字符串类型走这个构造器
|
||||
* @param key 字段名
|
||||
* @param title 字段备注
|
||||
* @param view 展示控件
|
||||
* @param maxLength 数据库字段最大长度
|
||||
*/
|
||||
public StringProperty(String key,String title,String view,Integer maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
this.key = key;
|
||||
this.view = view;
|
||||
this.title = title;
|
||||
this.type = "string";
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表类型的走这个构造器
|
||||
* @param key 字段名
|
||||
* @param title 字段备注
|
||||
* @param view 展示控件 list-checkbox-radio
|
||||
* @param maxLength 数据库字段最大长度
|
||||
* @param include 数据字典
|
||||
*/
|
||||
public StringProperty(String key,String title,String view,Integer maxLength,List<DictModel> include) {
|
||||
this.maxLength = maxLength;
|
||||
this.key = key;
|
||||
this.view = view;
|
||||
this.title = title;
|
||||
this.type = "string";
|
||||
this.include = include;
|
||||
}
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
if(maxLength!=null) {
|
||||
prop.put("maxLength",maxLength);
|
||||
}
|
||||
if(minLength!=null) {
|
||||
prop.put("minLength",minLength);
|
||||
}
|
||||
if(pattern!=null) {
|
||||
prop.put("pattern",pattern);
|
||||
}
|
||||
if(errorInfo!=null) {
|
||||
prop.put("errorInfo",errorInfo);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开关 属性
|
||||
*/
|
||||
public class SwitchProperty extends CommonProperty {
|
||||
|
||||
//扩展参数配置信息
|
||||
private String extendStr;
|
||||
|
||||
public SwitchProperty() {}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*/
|
||||
public SwitchProperty(String key, String title, String extendStr) {
|
||||
this.type = "string";
|
||||
this.view = "switch";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.extendStr = extendStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
JSONArray array = new JSONArray();
|
||||
if(extendStr!=null) {
|
||||
array = JSONArray.parseArray(extendStr);
|
||||
prop.put("extendOption",array);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
//TODO 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
package com.jero.common.util.jsonschema.validate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jero.common.util.jsonschema.CommonProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 字典属性
|
||||
* @author 86729
|
||||
*
|
||||
*/
|
||||
public class TreeSelectProperty extends CommonProperty {
|
||||
|
||||
private static final long serialVersionUID = 3786503639885610767L;
|
||||
|
||||
private String dict;//表名,文本,id
|
||||
private String pidField;//父级字段 默认pid
|
||||
private String pidValue;//父级节点的值 暂时没用到 默认为0
|
||||
private String hasChildField;
|
||||
private String textField;//树形下拉保存text值的字段名
|
||||
|
||||
/**
|
||||
* 是不是pid 组件 1是 0否
|
||||
*/
|
||||
private Integer pidComponent = 0;
|
||||
|
||||
public String getDict() {
|
||||
return dict;
|
||||
}
|
||||
|
||||
public void setDict(String dict) {
|
||||
this.dict = dict;
|
||||
}
|
||||
|
||||
public String getPidField() {
|
||||
return pidField;
|
||||
}
|
||||
|
||||
public void setPidField(String pidField) {
|
||||
this.pidField = pidField;
|
||||
}
|
||||
|
||||
public String getPidValue() {
|
||||
return pidValue;
|
||||
}
|
||||
|
||||
public void setPidValue(String pidValue) {
|
||||
this.pidValue = pidValue;
|
||||
}
|
||||
|
||||
public String getHasChildField() {
|
||||
return hasChildField;
|
||||
}
|
||||
|
||||
public void setHasChildField(String hasChildField) {
|
||||
this.hasChildField = hasChildField;
|
||||
}
|
||||
|
||||
public TreeSelectProperty() {}
|
||||
|
||||
public String getTextField() {
|
||||
return textField;
|
||||
}
|
||||
|
||||
public void setTextField(String textField) {
|
||||
this.textField = textField;
|
||||
}
|
||||
|
||||
public Integer getPidComponent() {
|
||||
return pidComponent;
|
||||
}
|
||||
|
||||
public void setPidComponent(Integer pidComponent) {
|
||||
this.pidComponent = pidComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器 构造普通树形下拉
|
||||
*/
|
||||
public TreeSelectProperty(String key,String title,String dict,String pidField,String pidValue) {
|
||||
this.type = "string";
|
||||
this.view = "sel_tree";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.dict = dict;
|
||||
this.pidField= pidField;
|
||||
this.pidValue= pidValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典下拉专用
|
||||
* @param key
|
||||
* @param title
|
||||
* @param pidValue
|
||||
*/
|
||||
public TreeSelectProperty(String key,String title,String pidValue) {
|
||||
this.type = "string";
|
||||
this.view = "cat_tree";
|
||||
this.key = key;
|
||||
this.title = title;
|
||||
this.pidValue = pidValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典 支持存储text 下拉专用
|
||||
* @param key
|
||||
* @param title
|
||||
* @param pidValue
|
||||
* @param textField
|
||||
*/
|
||||
public TreeSelectProperty(String key,String title,String pidValue,String textField) {
|
||||
this(key,title,pidValue);
|
||||
this.textField = textField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPropertyJson() {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("key",getKey());
|
||||
JSONObject prop = getCommonJson();
|
||||
if(dict!=null) {
|
||||
prop.put("dict",dict);
|
||||
}
|
||||
if(pidField!=null) {
|
||||
prop.put("pidField",pidField);
|
||||
}
|
||||
if(pidValue!=null) {
|
||||
prop.put("pidValue",pidValue);
|
||||
}
|
||||
if(textField!=null) {
|
||||
prop.put("textField",textField);
|
||||
}
|
||||
if(hasChildField!=null) {
|
||||
prop.put("hasChildField",hasChildField);
|
||||
}
|
||||
if(pidComponent!=null) {
|
||||
prop.put("pidComponent",pidComponent);
|
||||
}
|
||||
map.put("prop",prop);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-8
@@ -425,11 +425,11 @@ public class SysCategoryController {
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("sys:category:list")
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids) {
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
@@ -437,13 +437,8 @@ public class SysCategoryController {
|
||||
result.setMessage("ids 不能为空");
|
||||
return result;
|
||||
}
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
List<String> textList = sysCategoryService.loadDictItem(ids, delNotExist);
|
||||
result.setSuccess(true);
|
||||
result.setResult(textList);
|
||||
return result;
|
||||
|
||||
+27
@@ -6,6 +6,7 @@ import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -130,6 +131,32 @@ public class SysDepartController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param departId 根据departId查
|
||||
* @param orgCode 根据orgCode查,departId和orgCode必须有一个不为空
|
||||
*/
|
||||
@GetMapping("/queryAllParentId")
|
||||
public Result queryParentIds(
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name = "orgCode", required = false) String orgCode
|
||||
) {
|
||||
try {
|
||||
JSONObject data;
|
||||
if (oConvertUtils.isNotEmpty(departId)) {
|
||||
data = sysDepartService.queryAllParentIdByDepartId(departId);
|
||||
} else if (oConvertUtils.isNotEmpty(orgCode)) {
|
||||
data = sysDepartService.queryAllParentIdByOrgCode(orgCode);
|
||||
} else {
|
||||
return Result.error("departId 和 orgCode 不能都为空!");
|
||||
}
|
||||
return Result.OK(data);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新数据 添加用户新建的部门对象数据,并保存到数据库
|
||||
|
||||
+68
-57
@@ -124,47 +124,23 @@ public class SysDictController {
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据字典编码获取字典数据", notes = "字典控制器-根据字典编码获取字典数据")
|
||||
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
|
||||
log.info(" dictCode : "+ dictCode);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
List<DictModel> ls = null;
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
String[] params = dictCode.split(",");
|
||||
|
||||
if(params.length<3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {params[0],params[1],params[2]};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
|
||||
if(params.length==4) {
|
||||
//SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用)
|
||||
SqlInjectionUtil.specialFilterContent(params[3]);
|
||||
ls = sysDictService.queryTableDictItemsByCodeAndFilter(params[0],params[1],params[2],params[3]);
|
||||
}else if (params.length==3) {
|
||||
ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]);
|
||||
}else{
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
}else {
|
||||
//字典表
|
||||
ls = sysDictService.queryDictItemsByCode(dictCode);
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -205,52 +181,87 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
* @param dictCode
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-通过字典code获取字典数据", notes = "字典控制器-通过字典code获取字典数据")
|
||||
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,
|
||||
@RequestParam(name="keyword") String keyword,
|
||||
@RequestParam(value = "sign",required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
@RequestParam(name="keyword") String keyword,
|
||||
@RequestParam(value = "sign",required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
log.info(" 加载字典表数据,加载关键字: "+ keyword);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
List<DictModel> ls = null;
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
if(pageSize!=null){
|
||||
ls = sysDictService.queryLittleTableDictItems(params[0],params[1],params[2],keyword, pageSize);
|
||||
}else{
|
||||
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.info(result.toString());
|
||||
}else {
|
||||
List<DictModel> ls = sysDictService.loadDict(dictCode, keyword, pageSize);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.info(result.toString());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 【给表单设计器的表字典使用】下拉搜索模式,有值时动态拼接数据
|
||||
* @param dictCode
|
||||
* @param keyword 当前控件的值,可以逗号分割
|
||||
* @param sign
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadDictOrderByValue(
|
||||
@PathVariable String dictCode,
|
||||
@RequestParam(name = "keyword") String keyword,
|
||||
@RequestParam(value = "sign", required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
// 首次查询查出来用户选中的值,并且不分页
|
||||
Result<List<DictModel>> firstRes = this.loadDict(dictCode, keyword, sign, null);
|
||||
if (!firstRes.isSuccess()) {
|
||||
return firstRes;
|
||||
}
|
||||
// 然后再查询出第一页的数据
|
||||
Result<List<DictModel>> result = this.loadDict(dictCode, "", sign, pageSize);
|
||||
if (!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
// 合并两次查询的数据
|
||||
List<DictModel> firstList = firstRes.getResult();
|
||||
List<DictModel> list = result.getResult();
|
||||
for (DictModel firstItem : firstList) {
|
||||
// anyMatch 表示:判断的条件里,任意一个元素匹配成功,返回true
|
||||
// allMatch 表示:判断条件里的元素,所有的都匹配成功,返回true
|
||||
// noneMatch 跟 allMatch 相反,表示:判断条件里的元素,所有的都匹配失败,返回true
|
||||
boolean none = list.stream().noneMatch(item -> item.getValue().equals(firstItem.getValue()));
|
||||
// 当元素不存在时,再添加到集合里
|
||||
if (none) {
|
||||
list.add(0, firstItem);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 根据字典code加载字典text 返回
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @param sign
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据字典code加载字典text", notes = "字典控制器-根据字典code加载字典text")
|
||||
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@PathVariable String dictCode, @RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
|
||||
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign,@RequestParam(value = "delNotExist",required = false,defaultValue = "true") boolean delNotExist,HttpServletRequest request) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
@@ -259,7 +270,7 @@ public class SysDictController {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys);
|
||||
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys, delNotExist);
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(texts);
|
||||
|
||||
+35
-8
@@ -170,8 +170,8 @@ public class SysUserController {
|
||||
throw new JeroBootException("邮箱和手机号解密失败!", e);
|
||||
}
|
||||
|
||||
sysUserService.addUserWithRole(user, selectedRoles);
|
||||
sysUserService.addUserWithDepart(user, selectedDeparts);
|
||||
// 保存用户走一个service 保证事务
|
||||
sysUserService.saveUser(user, selectedRoles, selectedDeparts);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -217,9 +217,8 @@ public class SysUserController {
|
||||
user.setUpdateTime(new Date());
|
||||
//String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
|
||||
user.setPassword(sysUser.getPassword());
|
||||
sysUserService.editUserWithRole(user, roles);
|
||||
sysUserService.editUserWithDepart(user, departs);
|
||||
sysUserService.updateNullPhoneEmail();
|
||||
// 修改用户走一个service 保证事务
|
||||
sysUserService.editUser(user, roles, departs);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -313,6 +312,7 @@ public class SysUserController {
|
||||
result.setResult(true);
|
||||
try {
|
||||
//通过传入信息查询新的用户信息
|
||||
sysUser.setPassword(null);
|
||||
SysUser user = sysUserService.getOne(new QueryWrapper<SysUser>(sysUser));
|
||||
if (user != null) {
|
||||
result.setSuccess(false);
|
||||
@@ -329,8 +329,9 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequiresPermissions("user:edit")
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@RequestMapping(value = "/changePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changePassword(@RequestBody SysUser sysUser) {
|
||||
SysUser u = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, sysUser.getUsername()));
|
||||
@@ -424,6 +425,23 @@ public class SysUserController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户选择组件 专用 根据用户账号或部门分页查询
|
||||
* @param departId
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryUserComponentData", method = RequestMethod.GET)
|
||||
public Result<IPage<SysUser>> queryUserComponentData(
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name="realname",required=false) String realname,
|
||||
@RequestParam(name="username",required=false) String username) {
|
||||
IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
@@ -559,13 +577,20 @@ public class SysUserController {
|
||||
* 首页用户重置密码
|
||||
*/
|
||||
@RequestMapping(value = "/updatePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changPassword(@RequestBody JSONObject json) {
|
||||
public Result<?> updatePassword(@RequestBody JSONObject json) {
|
||||
String username = json.getString("username");
|
||||
String oldpassword = json.getString("oldpassword");
|
||||
String password = json.getString("password");
|
||||
String confirmpassword = json.getString("confirmpassword");
|
||||
String RSAPublicKey = json.getString("rsaPublicKey");
|
||||
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
if(!sysUser.getUsername().equals(username)){
|
||||
return Result.error("只允许修改自己的密码!");
|
||||
}
|
||||
|
||||
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
|
||||
|
||||
try {
|
||||
oldpassword = CommonUtils.decryptBtRsaPriKey(oldpassword, RSAPrivateKey);
|
||||
password = CommonUtils.decryptBtRsaPriKey(password, RSAPrivateKey);
|
||||
@@ -573,6 +598,7 @@ public class SysUserController {
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
SysUser user = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
||||
if(user==null) {
|
||||
return Result.error("用户不存在!");
|
||||
@@ -1342,4 +1368,5 @@ public class SysUserController {
|
||||
sysUserService.updateById(user);
|
||||
return Result.OK("手机号设置成功!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-1
@@ -99,7 +99,8 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(@Param("query") String query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
|
||||
@Deprecated
|
||||
List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名拼接树结构
|
||||
@@ -151,4 +152,26 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
*/
|
||||
@Deprecated
|
||||
public Page<DictModel> queryDictTablePageList(Page page, @Param("query") DictQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 查询 字典表数据 支持查询条件 分页
|
||||
* @param page
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
IPage<DictModel> queryTableDictWithFilter(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
|
||||
/**
|
||||
* 查询 字典表数据 支持查询条件 查询所有
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
}
|
||||
|
||||
+22
@@ -1,6 +1,10 @@
|
||||
package com.jero.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.system.entity.SysUserDepart;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -8,4 +12,22 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
public interface SysUserDepartMapper extends BaseMapper<SysUserDepart>{
|
||||
|
||||
List<SysUserDepart> getUserDepartByUid(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 查询指定部门下的用户 并且支持用户真实姓名模糊查询
|
||||
* @param orgCode
|
||||
* @param realname
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryDepartUserList(@Param("orgCode") String orgCode, @Param("realname") String realname);
|
||||
|
||||
/**
|
||||
* 根据部门查询部门用户
|
||||
* @param page
|
||||
* @param orgCode
|
||||
* @param username
|
||||
* @param realname
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> queryDepartUserPageList(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("username") String username, @Param("realname") String realname);
|
||||
}
|
||||
|
||||
+16
@@ -121,4 +121,20 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 分页-->
|
||||
<select id="queryTableDictWithFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table}
|
||||
<if test="filterSql != null and filterSql != ''">
|
||||
${filterSql}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 获取所有 -->
|
||||
<select id="queryAllTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table}
|
||||
<if test="filterSql != null and filterSql != ''">
|
||||
${filterSql}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
+27
@@ -6,4 +6,31 @@
|
||||
FROM sys_user_depart
|
||||
WHERE user_id = #{userId, jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询指定部门下的用户 并且支持用户账号模糊查询 -->
|
||||
<select id="queryDepartUserList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select a.* from sys_user a
|
||||
join sys_user_depart b on b.user_id = a.id
|
||||
join sys_depart c on b.dep_id = c.id
|
||||
where a.del_flag = 0 and c.org_code like '${orgCode}%'
|
||||
<if test="realname!=null and realname!=''">
|
||||
and a.realname like '%${realname}%'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据部门查询部门用户 分页 -->
|
||||
<select id="queryDepartUserPageList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select a.*, c.depart_name as org_code_txt from sys_user a
|
||||
join sys_user_depart b on b.user_id = a.id
|
||||
join sys_depart c on b.dep_id = c.id
|
||||
where a.del_flag = 0 and c.org_code like '${orgCode}%'
|
||||
<if test="username!=null and username!=''">
|
||||
and a.username like '%${username}%'
|
||||
</if>
|
||||
<if test="realname!=null and realname!=''">
|
||||
and a.realname like '%${realname}%'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+18
-1
@@ -58,5 +58,22 @@ public interface ISysCategoryService extends IService<SysCategory> {
|
||||
* @param ids
|
||||
*/
|
||||
void deleteSysCategory(String ids);
|
||||
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> loadDictItem(String ids);
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
List<String> loadDictItem(String ids, boolean delNotExist);
|
||||
|
||||
}
|
||||
|
||||
+17
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
@@ -129,11 +130,27 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryTreeListByPid(String parentId);
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param departId 根据departId查
|
||||
*/
|
||||
JSONObject queryAllParentIdByDepartId(String departId);
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param orgCode 根据orgCode查
|
||||
*/
|
||||
JSONObject queryAllParentIdByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 获取公司信息
|
||||
* @return
|
||||
*/
|
||||
SysDepart queryCompByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 获取下级部门
|
||||
* @return
|
||||
|
||||
+35
-3
@@ -38,6 +38,9 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
@Deprecated
|
||||
List<String> queryTableDictByKeys(String table, String text, String code, String keys);
|
||||
|
||||
@Deprecated
|
||||
List<String> queryTableDictByKeys(String table, String text, String code, String keys,boolean delNotExist);
|
||||
|
||||
/**
|
||||
* 根据字典类型删除关联表中其对应的数据
|
||||
*
|
||||
@@ -82,10 +85,21 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code,String keyword, int pageSize);
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String condition, String keyword, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* 查询字典表所有数据
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param condition
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryAllTableDictItems(String table, String text, String code, String condition, String keyword);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
@@ -94,7 +108,8 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(String query,String table, String text, String code, String pidField,String pid,String hasChildField);
|
||||
@Deprecated
|
||||
List<TreeSelectModel> queryTreeList(Map<String, String> query,String table, String text, String code, String pidField,String pid,String hasChildField);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 和查询条件拼接树结构
|
||||
@@ -135,6 +150,23 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
@Deprecated
|
||||
public List<DictModel> queryDictTablePageList(DictQuery query,int pageSize, int pageNo);
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
* @param dictCode 字典code
|
||||
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> getDictItems(String dictCode);
|
||||
|
||||
/**
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> loadDict(String dictCode, String keyword, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 刷新dict缓存
|
||||
* @date 2021/4/8 9:06
|
||||
|
||||
+15
-2
@@ -3,6 +3,7 @@ package com.jero.modules.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.entity.SysUserDepart;
|
||||
import com.jero.modules.system.model.DepartIdModel;
|
||||
@@ -34,8 +35,20 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryUserByDepId(String depId);
|
||||
/**
|
||||
|
||||
/**
|
||||
* 根据部门code,查询当前部门和下级部门的用户信息
|
||||
*/
|
||||
public List<SysUser> queryUserByDepCode(String depCode,String realname);
|
||||
List<SysUser> queryUserByDepCode(String depCode,String realname);
|
||||
|
||||
/**
|
||||
* 用户组件数据查询
|
||||
* @param departId
|
||||
* @param username
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo);
|
||||
|
||||
}
|
||||
|
||||
+21
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.system.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -233,4 +234,24 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryByDepIds(List<String> departIds, String username);
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
* @param user 用户
|
||||
* @param selectedRoles 选择的角色id,多个以逗号隔开
|
||||
* @param selectedDeparts 选择的部门id,多个以逗号隔开
|
||||
*/
|
||||
void saveUser(SysUser user, String selectedRoles, String selectedDeparts);
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
* @param user 用户
|
||||
* @param roles 选择的角色id,多个以逗号隔开
|
||||
* @param departs 选择的部门id,多个以逗号隔开
|
||||
*/
|
||||
void editUser(SysUser user, String roles, String departs);
|
||||
|
||||
/** userId转为username */
|
||||
List<String> userIdToUsername(Collection<String> userIdList);
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -199,6 +199,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
info.setSysUserCode(user.getUsername());
|
||||
info.setSysUserName(user.getRealname());
|
||||
info.setSysOrgCode(user.getOrgCode());
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
//多部门支持in查询
|
||||
List<SysDepart> list = departMapper.queryUserDeparts(user.getId());
|
||||
@@ -265,7 +267,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
return sysDictService.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
+30
@@ -1,8 +1,10 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -204,4 +206,32 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
return sb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids) {
|
||||
return this.loadDictItem(ids, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids, boolean delNotExist) {
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList;
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
if (delNotExist) {
|
||||
textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
} else {
|
||||
textList = new ArrayList<>();
|
||||
for (String id : idArray) {
|
||||
List<SysCategory> res = list.stream().filter(i -> id.equals(i.getId())).collect(Collectors.toList());
|
||||
textList.add(res.size() > 0 ? res.get(0).getName() : id);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
return textList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+58
-1
@@ -2,8 +2,11 @@ package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
@@ -473,7 +476,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
FindsDepartsChildrenUtil.convertSysDepartToSysDepartTreeModel(depart, treeModel);
|
||||
|
||||
//TODO 异步树加载key拼接__+时间戳,以便于每次展开节点会刷新数据
|
||||
treeModel.setKey(treeModel.getKey()+"__"+System.currentTimeMillis());
|
||||
treeModel.setKey(treeModel.getKey());
|
||||
Integer count=this.baseMapper.queryCountByPid(depart.getId());
|
||||
if(count>0){
|
||||
treeModel.setIsLeaf(false);
|
||||
@@ -484,6 +487,60 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllParentIdByDepartId(String departId) {
|
||||
JSONObject result = new JSONObject();
|
||||
for (String id : departId.split(",")) {
|
||||
JSONObject all = this.queryAllParentId("id", id);
|
||||
result.put(id, all);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllParentIdByOrgCode(String orgCode) {
|
||||
JSONObject result = new JSONObject();
|
||||
for (String code : orgCode.split(",")) {
|
||||
JSONObject all = this.queryAllParentId("org_code", code);
|
||||
result.put(code, all);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个部门的所有父ID信息
|
||||
*
|
||||
* @param fieldName 字段名
|
||||
* @param value 值
|
||||
*/
|
||||
private JSONObject queryAllParentId(String fieldName, String value) {
|
||||
JSONObject data = new JSONObject();
|
||||
// 父ID集合,有序
|
||||
data.put("parentIds", new JSONArray());
|
||||
// 父ID的部门数据,key是id,value是数据
|
||||
data.put("parentMap", new JSONObject());
|
||||
this.queryAllParentIdRecursion(fieldName, value, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归调用查询父部门接口
|
||||
*/
|
||||
private void queryAllParentIdRecursion(String fieldName, String value, JSONObject data) {
|
||||
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(fieldName, value);
|
||||
SysDepart depart = super.getOne(queryWrapper);
|
||||
if (depart != null) {
|
||||
data.getJSONArray("parentIds").add(0, depart.getId());
|
||||
data.getJSONObject("parentMap").put(depart.getId(), depart);
|
||||
if (oConvertUtils.isNotEmpty(depart.getParentId())) {
|
||||
this.queryAllParentIdRecursion("id", depart.getParentId(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDepart queryCompByOrgCode(String orgCode) {
|
||||
int length = YouBianCodeUtil.zhanweiLength;
|
||||
|
||||
+124
-14
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.util.SqlInjectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
@@ -53,7 +54,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
log.debug("无缓存dictCache的时候调用这里!");
|
||||
return sysDictMapper.queryDictItemsByCode(code);
|
||||
@@ -89,7 +90,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code+':'+#key")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code+':'+#key", unless = "#result == null ")
|
||||
public String queryDictTextByKey(String code, String key) {
|
||||
log.debug("无缓存dictText的时候调用这里!");
|
||||
return sysDictMapper.queryDictTextByKey(code, key);
|
||||
@@ -126,12 +127,17 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE)
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE, unless = "#result == null ")
|
||||
public String queryTableDictTextByKey(String table,String text,String code, String key) {
|
||||
log.debug("无缓存dictTable的时候调用这里!");
|
||||
return sysDictMapper.queryTableDictTextByKey(table,text,code,key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
|
||||
return this.queryTableDictByKeys(table, text, code, keys, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code 获取字典,包含text和value
|
||||
* dictTableCache采用redis缓存有效期10分钟
|
||||
@@ -139,28 +145,33 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys (逗号分隔)
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
//update-begin--Author:lvdandan Date:20201204 for:JT-36【online】树形列表bug修改后,还是显示原来值 暂时去掉缓存
|
||||
//@Cacheable(value = CacheConstant.SYS_DICT_TABLE_BY_KEYS_CACHE)
|
||||
//update-end--Author:lvdandan Date:20201204 for:JT-36【online】树形列表bug修改后,还是显示原来值 暂时去掉缓存
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys, boolean delNotExist) {
|
||||
if(oConvertUtils.isEmpty(keys)){
|
||||
return null;
|
||||
}
|
||||
String[] keyArray = keys.split(",");
|
||||
List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray);
|
||||
List<String> texts = new ArrayList<>(dicts.size());
|
||||
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
// 查询出来的顺序可能是乱的,需要排个序
|
||||
for (String key : keyArray) {
|
||||
for (DictModel dict : dicts) {
|
||||
if (key.equals(dict.getValue())) {
|
||||
texts.add(dict.getText());
|
||||
break;
|
||||
}
|
||||
List<DictModel> res = dicts.stream().filter(i -> key.equals(i.getValue())).collect(Collectors.toList());
|
||||
if (res.size() > 0) {
|
||||
texts.add(res.get(0).getText());
|
||||
} else if (!delNotExist) {
|
||||
texts.add(key);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
|
||||
return texts;
|
||||
}
|
||||
|
||||
@@ -208,15 +219,53 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String keyword, int pageSize) {
|
||||
Page<DictModel> page = new Page<DictModel>(1, pageSize);
|
||||
IPage<DictModel> pageList = baseMapper.queryTableDictItems(page, table, text, code, "%"+keyword+"%");
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String condition, String keyword, int pageSize) {
|
||||
Page<DictModel> page = new Page<DictModel>(1, pageSize);
|
||||
page.setSearchCount(false);
|
||||
String filterSql = getFilterSql(text, code, condition, keyword);
|
||||
IPage<DictModel> pageList = baseMapper.queryTableDictWithFilter(page, table, text, code, filterSql);
|
||||
return pageList.getRecords();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取条件语句
|
||||
* @param text
|
||||
* @param code
|
||||
* @param condition
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
private String getFilterSql(String text, String code, String condition, String keyword){
|
||||
String keywordSql = null, filterSql = "", sql_where = " where ";
|
||||
if(oConvertUtils.isNotEmpty(keyword)){
|
||||
// 判断是否是多选
|
||||
if (keyword.contains(",")) {
|
||||
String inKeywords = "\"" + keyword.replaceAll(",", "\",\"") + "\"";
|
||||
keywordSql = "(" + text + " in (" + inKeywords + ") or " + code + " in (" + inKeywords + "))";
|
||||
} else {
|
||||
keywordSql = "("+text + " like '%"+keyword+"%' or "+ code + " like '%"+keyword+"%')";
|
||||
}
|
||||
}
|
||||
if(oConvertUtils.isNotEmpty(condition) && oConvertUtils.isNotEmpty(keywordSql)){
|
||||
filterSql+= sql_where + condition + " and " + keywordSql;
|
||||
}else if(oConvertUtils.isNotEmpty(condition)){
|
||||
filterSql+= sql_where + condition;
|
||||
}else if(oConvertUtils.isNotEmpty(keywordSql)){
|
||||
filterSql+= sql_where + keywordSql;
|
||||
}
|
||||
return filterSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryTreeList(String query,String table, String text, String code, String pidField, String pid, String hasChildField) {
|
||||
return baseMapper.queryTreeList(query, table, text, code, pidField, pid,hasChildField);
|
||||
public List<DictModel> queryAllTableDictItems(String table, String text, String code, String condition, String keyword) {
|
||||
String filterSql = getFilterSql(text, code, condition, keyword);
|
||||
List<DictModel> ls = baseMapper.queryAllTableDictItems(table, text, code, filterSql);
|
||||
return ls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryTreeList(Map<String, String> query,String table, String text, String code, String pidField,String pid,String hasChildField) {
|
||||
return baseMapper.queryTreeList(query,table, text, code, pidField, pid,hasChildField);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,6 +337,65 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
Page<DictModel> pageList = baseMapper.queryDictTablePageList(page, query);
|
||||
return pageList.getRecords();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DictModel> getDictItems(String dictCode) {
|
||||
List<DictModel> ls;
|
||||
if (dictCode.contains(",")) {
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
String[] params = dictCode.split(",");
|
||||
if (params.length < 3) {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {params[0], params[1], params[2]};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
if (params.length == 4) {
|
||||
// SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用)
|
||||
SqlInjectionUtil.specialFilterContent(params[3]);
|
||||
ls = this.queryTableDictItemsByCodeAndFilter(params[0], params[1], params[2], params[3]);
|
||||
} else if (params.length == 3) {
|
||||
ls = this.queryTableDictItemsByCode(params[0], params[1], params[2]);
|
||||
} else {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
//字典表
|
||||
ls = this.queryDictItemsByCode(dictCode);
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> loadDict(String dictCode, String keyword, Integer pageSize) {
|
||||
if (dictCode.contains(",")) {
|
||||
//update-begin-author:taoyan date:20210329 for: 下拉搜索不支持表名后加查询条件
|
||||
String[] params = dictCode.split(",");
|
||||
String condition = null;
|
||||
if (params.length != 3 && params.length != 4) {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
} else if (params.length == 4) {
|
||||
condition = params[3];
|
||||
}
|
||||
List<DictModel> ls;
|
||||
if (pageSize != null) {
|
||||
ls = this.queryLittleTableDictItems(params[0], params[1], params[2], condition, keyword, pageSize);
|
||||
} else {
|
||||
ls = this.queryAllTableDictItems(params[0], params[1], params[2], condition, keyword);
|
||||
}
|
||||
//update-end-author:taoyan date:20210329 for: 下拉搜索不支持表名后加查询条件
|
||||
return ls;
|
||||
} else {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新dict缓存
|
||||
* @date 2021/4/8 9:07
|
||||
@@ -299,12 +407,14 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
//清空字典缓存
|
||||
Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
|
||||
Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
|
||||
Set keys21 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_BY_KEYS_CACHE + "*");
|
||||
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
|
||||
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
|
||||
Set keys5 = redisTemplate.keys( "jmreport:cache:dict*");
|
||||
Set keys6 = redisTemplate.keys( "jmreport:cache:dictTable*");
|
||||
redisTemplate.delete(keys);
|
||||
redisTemplate.delete(keys2);
|
||||
redisTemplate.delete(keys21);
|
||||
redisTemplate.delete(keys3);
|
||||
redisTemplate.delete(keys4);
|
||||
redisTemplate.delete(keys5);
|
||||
|
||||
+56
-28
@@ -1,11 +1,15 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
@@ -100,34 +104,58 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> queryUserByDepCode(String depCode,String realname) {
|
||||
LambdaQueryWrapper<SysDepart> queryByDepCode = new LambdaQueryWrapper<SysDepart>();
|
||||
queryByDepCode.likeRight(SysDepart::getOrgCode,depCode);
|
||||
List<SysDepart> sysDepartList = sysDepartService.list(queryByDepCode);
|
||||
List<String> depIds = sysDepartList.stream().map(SysDepart::getId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
|
||||
queryUDep.in(SysUserDepart::getDepId, depIds);
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
List<SysUserDepart> uDepList = this.list(queryUDep);
|
||||
if(uDepList != null && uDepList.size() > 0) {
|
||||
for(SysUserDepart uDep : uDepList) {
|
||||
userIdList.add(uDep.getUserId());
|
||||
}
|
||||
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>();
|
||||
queryUser.in(SysUser::getId,userIdList);
|
||||
if(oConvertUtils.isNotEmpty(realname)){
|
||||
queryUser.like(SysUser::getRealname,realname.trim());
|
||||
}
|
||||
List<SysUser> userList = (List<SysUser>) sysUserService.list(queryUser);
|
||||
//update-begin-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
for (SysUser sysUser : userList) {
|
||||
sysUser.setSalt("");
|
||||
sysUser.setPassword("");
|
||||
}
|
||||
//update-end-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
return userList;
|
||||
//update-begin-author:taoyan date:20210422 for: 根据部门选择用户接口代码优化
|
||||
if(oConvertUtils.isNotEmpty(realname)){
|
||||
realname = realname.trim();
|
||||
}
|
||||
return new ArrayList<SysUser>();
|
||||
List<SysUser> userList = this.baseMapper.queryDepartUserList(depCode, realname);
|
||||
Map<String, SysUser> map = new HashMap<String, SysUser>();
|
||||
for (SysUser sysUser : userList) {
|
||||
// 返回的用户数据去掉密码信息
|
||||
sysUser.setSalt("");
|
||||
sysUser.setPassword("");
|
||||
map.put(sysUser.getId(), sysUser);
|
||||
}
|
||||
return new ArrayList<SysUser>(map.values());
|
||||
//update-end-author:taoyan date:20210422 for: 根据部门选择用户接口代码优化
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo) {
|
||||
IPage<SysUser> pageList = null;
|
||||
// 部门ID不存在 直接查询用户表即可
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
if(oConvertUtils.isEmpty(departId)){
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
if(oConvertUtils.isNotEmpty(username)){
|
||||
query.like(SysUser::getUsername, username);
|
||||
}
|
||||
pageList = sysUserService.page(page, query);
|
||||
}else{
|
||||
// 有部门ID 需要走自定义sql
|
||||
SysDepart sysDepart = sysDepartService.getById(departId);
|
||||
pageList = this.baseMapper.queryDepartUserPageList(page, sysDepart.getOrgCode(), username, realname);
|
||||
}
|
||||
List<SysUser> userList = pageList.getRecords();
|
||||
if(userList!=null && userList.size()>0){
|
||||
List<String> userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
Map<String, SysUser> map = new HashMap<String, SysUser>();
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
// 查部门名称
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
userList.forEach(item->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCodeTxt(useDepNames.get(item.getId()));
|
||||
item.setSalt("");
|
||||
item.setPassword("");
|
||||
// 去重
|
||||
map.put(item.getId(), item);
|
||||
});
|
||||
}
|
||||
pageList.setRecords(new ArrayList<SysUser>(map.values()));
|
||||
}
|
||||
return pageList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+85
@@ -439,4 +439,89 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return userMapper.queryByDepIds(departIds,username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) {
|
||||
//step.1 保存用户
|
||||
this.save(user);
|
||||
//step.2 保存角色
|
||||
if(oConvertUtils.isNotEmpty(selectedRoles)) {
|
||||
String[] arr = selectedRoles.split(",");
|
||||
for (String roleId : arr) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
//step.3 保存所属部门
|
||||
if(oConvertUtils.isNotEmpty(selectedDeparts)) {
|
||||
String[] arr = selectedDeparts.split(",");
|
||||
for (String deaprtId : arr) {
|
||||
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId);
|
||||
sysUserDepartMapper.insert(userDeaprt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void editUser(SysUser user, String roles, String departs) {
|
||||
//step.1 修改用户基础信息
|
||||
this.updateById(user);
|
||||
//step.2 修改角色
|
||||
//处理用户角色 先删后加
|
||||
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(roles)) {
|
||||
String[] arr = roles.split(",");
|
||||
for (String roleId : arr) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
|
||||
//step.3 修改部门
|
||||
String[] arr = {};
|
||||
if(oConvertUtils.isNotEmpty(departs)){
|
||||
arr = departs.split(",");
|
||||
}
|
||||
//查询已关联部门
|
||||
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
|
||||
if(userDepartList != null && userDepartList.size()>0){
|
||||
for(SysUserDepart depart : userDepartList ){
|
||||
//修改已关联部门删除部门用户角色关系
|
||||
if(!Arrays.asList(arr).contains(depart.getDepId())){
|
||||
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList(
|
||||
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId()));
|
||||
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
|
||||
if(roleIds != null && roleIds.size()>0){
|
||||
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId())
|
||||
.in(SysDepartRoleUser::getDroleId,roleIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//先删后加
|
||||
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(departs)) {
|
||||
for (String departId : arr) {
|
||||
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
|
||||
sysUserDepartMapper.insert(userDepart);
|
||||
}
|
||||
}
|
||||
//step.4 修改手机号和邮箱
|
||||
// 更新手机号、邮箱空字符串为 null
|
||||
userMapper.updateNullByEmptyString("email");
|
||||
userMapper.updateNullByEmptyString("phone");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> userIdToUsername(Collection<String> userIdList) {
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysUser::getId, userIdList);
|
||||
List<SysUser> userList = super.list(queryWrapper);
|
||||
return userList.stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.jero.modules.system.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 多租户 tenant_id存储器
|
||||
*/
|
||||
@Slf4j
|
||||
public class TenantContext {
|
||||
|
||||
private static ThreadLocal<String> currentTenant = new ThreadLocal<>();
|
||||
|
||||
public static void setTenant(String tenant) {
|
||||
log.debug(" setting tenant to " + tenant);
|
||||
currentTenant.set(tenant);
|
||||
}
|
||||
|
||||
public static String getTenant() {
|
||||
return currentTenant.get();
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
currentTenant.remove();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user