提交 c722653f 编写于 作者: sq3536's avatar sq3536

转移

上级 1d76608a
......@@ -2,14 +2,17 @@ package cn.ibizlab.core.dict.extensions.service;
import cn.ibizlab.core.dict.domain.DictCatalog;
import cn.ibizlab.core.dict.domain.DictOption;
import cn.ibizlab.core.dict.extensions.vo.Catalog;
import cn.ibizlab.core.dict.extensions.vo.CodeItem;
import cn.ibizlab.core.dict.extensions.vo.CodeList;
import cn.ibizlab.core.dict.extensions.vo.Option;
import cn.ibizlab.core.dict.filter.DictCatalogSearchContext;
import cn.ibizlab.core.dict.filter.DictOptionSearchContext;
import cn.ibizlab.core.dict.service.IDictCatalogService;
import cn.ibizlab.core.dict.service.IDictOptionService;
import cn.ibizlab.util.dict.Catalog;
import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.CodeList;
import cn.ibizlab.util.dict.Option;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,7 +22,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.sql.Wrapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -43,25 +45,62 @@ public class DictCoreService
public Catalog getDictCatalog(String code, DictOptionSearchContext context)
{
Catalog catalog = new Catalog();
DictCatalog dictCatalog = dictCatalogService.getOne(Wrappers.<DictCatalog>query().eq("ccode",code));
catalog.setCode(dictCatalog.getCode()).setName(dictCatalog.getName());
List<Option> list = new ArrayList<>();
optionService.list(context.getSelectCond().eq("cid",dictCatalog.getId()).orderByAsc("showorder")).forEach(item->{
Map<String,Object> extension = new HashMap<>();
if(!StringUtils.isEmpty(item.getExtension()))
extension = JSONObject.parseObject(item.getExtension(),Map.class);
list.add(new Option().setValue(item.getValue()).setId(item.getValue())
.setDisabled(((item.getDisabled()!=null && item.getDisabled()==1)||(item.getExpired()!=null && item.getExpired()==1))?true:false)
.setFilter(item.getFilter()).setIconClass(item.getIconClass()).setLabel(item.getLabel()).setParent(item.getParent()).setExtension(extension)
);
});
List<Option> codeItemTreeList = new ArrayList<Option>();
codeItemTreeList = loop(list, "");
catalog.setOptions(codeItemTreeList);
if(code.equalsIgnoreCase("dictcatalog"))
{
catalog.setCode("DictCatalog");
catalog.setName("字典目录");
List<Option> list = new ArrayList<>();
LambdaQueryWrapper<DictCatalog> wrapper=Wrappers.lambdaQuery();
if(!StringUtils.isEmpty(context.getN_val_like()))
wrapper.like(DictCatalog::getCode,context.getN_val_like());
if(!StringUtils.isEmpty(context.getN_val_in()))
wrapper.in(DictCatalog::getCode,context.getN_val_in());
if(!StringUtils.isEmpty(context.getN_val_leftlike()))
wrapper.likeRight(DictCatalog::getCode,context.getN_val_leftlike());
if(!StringUtils.isEmpty(context.getN_val_notin()))
wrapper.notIn(DictCatalog::getCode,context.getN_val_notin());
if(!StringUtils.isEmpty(context.getN_label_like()))
wrapper.notIn(DictCatalog::getName,context.getN_label_like());
if(!StringUtils.isEmpty(context.getN_vfilter_like()))
wrapper.like(DictCatalog::getGroup,context.getN_vfilter_like());
if(!StringUtils.isEmpty(context.getN_vfilter_in()))
wrapper.in(DictCatalog::getGroup,context.getN_vfilter_in());
if(!StringUtils.isEmpty(context.getN_vfilter_leftlike()))
wrapper.likeRight(DictCatalog::getGroup,context.getN_vfilter_leftlike());
if(!StringUtils.isEmpty(context.getN_vfilter_eq()))
wrapper.eq(DictCatalog::getGroup,context.getN_vfilter_eq());
wrapper.orderByAsc(DictCatalog::getGroup,DictCatalog::getCode);
dictCatalogService.list(wrapper).forEach(item->{
list.add(new Option().setValue(item.getCode()).setId(item.getCode())
.setDisabled(false)
.setFilter(item.getGroup()).setLabel(item.getName())
);
});
catalog.setOptions(list);
}
else
{
DictCatalog dictCatalog = dictCatalogService.getOne(Wrappers.<DictCatalog>query().eq("ccode",code));
catalog.setCode(dictCatalog.getCode()).setName(dictCatalog.getName());
List<Option> list = new ArrayList<>();
optionService.list(context.getSelectCond().eq("cid",dictCatalog.getId()).orderByAsc("showorder")).forEach(item->{
Map<String,Object> extension = new HashMap<>();
if(!StringUtils.isEmpty(item.getExtension()))
extension = JSONObject.parseObject(item.getExtension(),Map.class);
list.add(new Option().setValue(item.getValue()).setId(item.getValue())
.setDisabled(((item.getDisabled()!=null && item.getDisabled()==1)||(item.getExpired()!=null && item.getExpired()==1))?true:false)
.setFilter(item.getFilter()).setIconClass(item.getIconClass()).setLabel(item.getLabel()).setParent(item.getParent()).setExtension(extension)
);
});
List<Option> codeItemTreeList = new ArrayList<Option>();
codeItemTreeList = loop(list, "");
catalog.setOptions(codeItemTreeList);
}
return catalog;
}
......@@ -79,24 +118,60 @@ public class DictCoreService
public CodeList getCodeListCatalog(String code, DictOptionSearchContext context)
{
CodeList catalog = new CodeList();
DictCatalog dictCatalog = dictCatalogService.getOne(Wrappers.<DictCatalog>query().eq("ccode",code));
catalog.setCode(dictCatalog.getCode()).setName(dictCatalog.getName());
List<CodeItem> list = new ArrayList<>();
optionService.list(context.getSelectCond().eq("cid",dictCatalog.getId()).orderByAsc("showorder")).forEach(item->{
Map<String,Object> extension = new HashMap<>();
if(!StringUtils.isEmpty(item.getExtension()))
extension = JSONObject.parseObject(item.getExtension(),Map.class);
list.add(new CodeItem().setValue(item.getValue()).setId(item.getValue())
.setDisabled(((item.getDisabled()!=null && item.getDisabled()==1)||(item.getExpired()!=null && item.getExpired()==1))?true:false)
.setFilter(item.getFilter()).setIconClass(item.getIconClass()).setLabel(item.getLabel()).setParent(item.getParent()).setExtension(extension)
);
});
// List<CodeItem> codeItemTreeList = new ArrayList<CodeItem>();
// codeItemTreeList = loopCodeItem(list, "");
catalog.setOptions(list);
if(code.equalsIgnoreCase("dictcatalog"))
{
catalog.setCode("DictCatalog");
catalog.setName("字典目录");
List<CodeItem> list = new ArrayList<>();
LambdaQueryWrapper<DictCatalog> wrapper=Wrappers.lambdaQuery();
if(!StringUtils.isEmpty(context.getN_val_like()))
wrapper.like(DictCatalog::getCode,context.getN_val_like());
if(!StringUtils.isEmpty(context.getN_val_in()))
wrapper.in(DictCatalog::getCode,context.getN_val_in());
if(!StringUtils.isEmpty(context.getN_val_leftlike()))
wrapper.likeRight(DictCatalog::getCode,context.getN_val_leftlike());
if(!StringUtils.isEmpty(context.getN_val_notin()))
wrapper.notIn(DictCatalog::getCode,context.getN_val_notin());
if(!StringUtils.isEmpty(context.getN_label_like()))
wrapper.notIn(DictCatalog::getName,context.getN_label_like());
if(!StringUtils.isEmpty(context.getN_vfilter_like()))
wrapper.like(DictCatalog::getGroup,context.getN_vfilter_like());
if(!StringUtils.isEmpty(context.getN_vfilter_in()))
wrapper.in(DictCatalog::getGroup,context.getN_vfilter_in());
if(!StringUtils.isEmpty(context.getN_vfilter_leftlike()))
wrapper.likeRight(DictCatalog::getGroup,context.getN_vfilter_leftlike());
if(!StringUtils.isEmpty(context.getN_vfilter_eq()))
wrapper.eq(DictCatalog::getGroup,context.getN_vfilter_eq());
wrapper.orderByAsc(DictCatalog::getGroup,DictCatalog::getCode);
dictCatalogService.list(wrapper).forEach(item->{
list.add(new CodeItem().setValue(item.getCode()).setId(item.getCode())
.setDisabled(false)
.setFilter(item.getGroup()).setLabel(item.getName())
);
});
catalog.setOptions(list);
}
else {
DictCatalog dictCatalog = dictCatalogService.getOne(Wrappers.<DictCatalog>query().eq("ccode",code));
catalog.setCode(dictCatalog.getCode()).setName(dictCatalog.getName());
List<CodeItem> list = new ArrayList<>();
optionService.list(context.getSelectCond().eq("cid",dictCatalog.getId()).orderByAsc("showorder")).forEach(item->{
Map<String,Object> extension = new HashMap<>();
if(!StringUtils.isEmpty(item.getExtension()))
extension = JSONObject.parseObject(item.getExtension(),Map.class);
list.add(new CodeItem().setValue(item.getValue()).setId(item.getValue())
.setDisabled(((item.getDisabled()!=null && item.getDisabled()==1)||(item.getExpired()!=null && item.getExpired()==1))?true:false)
.setFilter(item.getFilter()).setIconClass(item.getIconClass()).setLabel(item.getLabel()).setParent(item.getParent()).setExtension(extension)
);
});
catalog.setOptions(list);
}
return catalog;
}
......
package cn.ibizlab.core.dict.extensions.vo;
import cn.ibizlab.util.annotation.DEField;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Catalog
{
private String code;
private String name;
@JSONField(name = "items")
@JsonProperty("items")
private List<Option> options = new ArrayList<>();
}
package cn.ibizlab.core.dict.extensions.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CodeItem
{
private String id;
private Object value;
private String label;
@JsonIgnore
@JSONField(serialize = false)
private List<CodeItem> children;
private String iconClass;
private String filter;
private Boolean disabled;
@JSONField(name = "pvalue")
@JsonProperty("pvalue")
private String parent;
private Map<String,Object> extension;
@JSONField(name = "text")
@JsonProperty("text")
public String getText()
{
return label;
}
}
package cn.ibizlab.core.dict.extensions.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CodeList
{
@JSONField(name = "srfkey")
@JsonProperty("srfkey")
private String code;
private String name;
@JSONField(name = "emptytext")
@JsonProperty("emptytext")
public String getEmptytext()
{
return "";
}
@JSONField(name = "items")
@JsonProperty("items")
private List<CodeItem> options = new ArrayList<>();
}
package cn.ibizlab.core.dict.extensions.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Option
{
private String id;
private Object value;
private String label;
private List<Option> children;
private String iconClass;
private String filter;
private Boolean disabled;
@JsonIgnore
@JSONField(serialize = false)
private String parent;
private Map<String,Object> extension;
}
......@@ -5,15 +5,15 @@ import cn.ibizlab.api.mapping.DictCatalogMapping;
import cn.ibizlab.core.dict.domain.DictCatalog;
import cn.ibizlab.core.dict.domain.DictOption;
import cn.ibizlab.core.dict.extensions.service.DictCoreService;
import cn.ibizlab.core.dict.extensions.vo.Catalog;
import cn.ibizlab.core.dict.extensions.vo.CodeItem;
import cn.ibizlab.core.dict.extensions.vo.CodeList;
import cn.ibizlab.core.dict.extensions.vo.Option;
import cn.ibizlab.core.dict.filter.DictCatalogSearchContext;
import cn.ibizlab.core.dict.filter.DictOptionSearchContext;
import cn.ibizlab.core.dict.service.IDictCatalogService;
import cn.ibizlab.core.dict.service.IDictOptionService;
import cn.ibizlab.util.annotation.VersionCheck;
import cn.ibizlab.util.dict.Catalog;
import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.CodeList;
import cn.ibizlab.util.dict.Option;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
......@@ -67,7 +67,7 @@ public class DictCoreResource {
}
@RequestMapping(method = {RequestMethod.GET}, value = "/dictionarys/catalogs/{code}/options")
public ResponseEntity<List<Option>> getOptions(@PathVariable("code") String code,DictOptionSearchContext context) {
public ResponseEntity<List<Option>> getOptions(@PathVariable("code") String code, DictOptionSearchContext context) {
Catalog catalog = null;
if(context==null||StringUtils.isEmpty(context.getSelectCond().getSqlSegment()))
catalog = dictCoreService.getDictCatalog(code);
......@@ -90,7 +90,7 @@ public class DictCoreResource {
@RequestMapping(method = {RequestMethod.GET}, value = "/dictionarys/codelist/{code}/items")
public ResponseEntity<List<CodeItem>> getCodeItems(@PathVariable("code") String code,DictOptionSearchContext context) {
public ResponseEntity<List<CodeItem>> getCodeItems(@PathVariable("code") String code, DictOptionSearchContext context) {
CodeList catalog = null;
if(context==null||StringUtils.isEmpty(context.getSelectCond().getSqlSegment()))
catalog = dictCoreService.getCodeListCatalog(code);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册