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

url改造

上级 d43bc8ba
package cn.ibizlab;
import cn.ibizlab.core.util.config.FilterDataResolver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
......@@ -40,7 +39,7 @@ public class DevBootApplication extends WebMvcConfigurerAdapter {
@Autowired
FilterDataResolver filterDataResolver;
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class, args);
......@@ -49,6 +48,6 @@ public class DevBootApplication extends WebMvcConfigurerAdapter {
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(filterDataResolver);
argumentResolvers.add(resolver);
}
}
......@@ -115,10 +115,20 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/ibiz-repository/**").permitAll()
.antMatchers("/ibiz-repo/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll();
.antMatchers("/"+previewpath+"/**").permitAll()
.antMatchers( HttpMethod.POST, "/ibiz-repo**/**/"+loginPath).permitAll()
//放行注销请求
.antMatchers( HttpMethod.GET, "/ibiz-repo**/**/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/ibiz-repo**/**/"+downloadpath+"/**").permitAll()
.antMatchers("/ibiz-repo**/**/"+uploadpath).permitAll()
.antMatchers("/ibiz-repo**/**/"+previewpath+"/**").permitAll()
;
for (String excludePattern : excludesPattern) {
......
package cn.ibizlab.config;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
@Component
public class DevUrlRedirectFilter extends ZuulFilter {
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
String url = request.getRequestURI();
if(url.startsWith("/ibiz-repo"))
{
String[] split = url.split("/");
if (split.length>2) {
url=url.replaceFirst("/"+split[1]+"/"+split[2]+"/", "/");
ctx.put(FilterConstants.REQUEST_URI_KEY, url);
}
}
return null;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public int filterOrder() {
return 1;
}
@Override
public String filterType() {
return FilterConstants.ROUTE_TYPE;
}
}
\ No newline at end of file
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
datasource:
username: root
password: root
......@@ -43,3 +46,61 @@ spring:
cache:
caffeine:
spec: initialCapacity=5,maximumSize=50000,expireAfterWrite=3600s
zuul:
routes:
repo-loginv7:
path: /ibiz-repo**/**/v7/login
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: true
repo-changepwd:
path: /ibiz-rep**/**/v7/changepwd
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
repo-uaa:
path: /ibiz-rep**/**/uaa/**
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
repo-config:
path: /ibiz-rep**/**/configs/**
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
repo-oucore:
path: /ibiz-rep**/**/ibzorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
repo-oudict:
path: /ibiz-rep**/**/dictionarys/**/Ibzou**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
repo-ou:
path: /ibiz-rep**/**/ibzdepartments/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
repo-uaadict:
path: /ibiz-rep**/**/dictionarys/**/SysOperator
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
repo-dict:
path: /ibiz-rep**/**/dictionarys/**
serviceId: ${ibiz.ref.service.dict:ibzdict-api}
stripPrefix: false
repo-disk:
path: /ibiz-rep**/**/net-disk/**
serviceId: ${ibiz.ref.service.disk:ibzdisk-api}
stripPrefix: false
repo-ou_sys_org:
path: /ibiz-rep**/**/sysorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
repo-ou_sys_dept:
path: /ibiz-rep**/**/sysdepartments/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
repo-lite-core:
path: /ibiz-rep**/**/lite/**
serviceId: ${ibiz.ref.service.lite:ibzlite-api}
stripPrefix: false
repo-sysauthlog:
path: /ibiz-rep**/**/sysauthlogs
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.util.ObjectUtils;
import java.io.Serializable;
import java.util.Map;
......@@ -41,6 +42,12 @@ public class BaseData extends DataObj
return this;
}
@Override
public BaseData remove(Object key) {
super.remove(key);
return this;
}
@JsonIgnore
@JSONField(serialize = false)
private POSchema _poschema;
......@@ -121,4 +128,15 @@ public class BaseData extends DataObj
{
return getSerializableValue("_key");
}
public static BaseData fromContext(Map map)
{
if(map==null)
return null;
map.remove("datasource");
if(map.size()==0)
return null;
return new BaseData().setAll(map);
}
}
......@@ -291,7 +291,7 @@ public class FilterData<T> extends BaseData
{
if(!StringUtils.isEmpty(this.getQuery()))
{
if(ObjectUtils.isEmpty(this.getPOSchema().getQuickSearch()))
if(!ObjectUtils.isEmpty(this.getPOSchema().getQuickSearch()))
{
searchCond.and(qw-> {
int i=0;
......@@ -376,4 +376,15 @@ public class FilterData<T> extends BaseData
return sql;
}
public static FilterData fromContext(Map map)
{
if(map==null)
return null;
map.remove("datasource");
if(map.size()==0)
return null;
return new FilterData().setAll(map);
}
}
......@@ -219,13 +219,16 @@ public class DynamicModelService {
for(IPSDEField defield:dataEntity.getAllPSDEFields())
{
String dict=null;
try { dict=defield.getPSCodeList()!=null?defield.getPSCodeList().getCodeName():null; } catch (Exception ex){}
FieldModel fieldModel=new FieldModel();
MetaFieldModel metaFieldModel=new MetaFieldModel();
metaFieldModel.setFieldId(defield.getId()).setFieldName(defield.getName()).setCodeName(defield.getCodeName()).setFieldLogicName(defield.getLogicName())
.setEntityId(dataEntity.getId()).setEntityCodeName(dataEntity.getCodeName()).setEntityName(dataEntity.getName()).setSystemId(metaEntityModel.getSystemId())
.setFieldUniName(dataEntity.getName()+"."+defield.getName()).setFieldShowName(String.format("%1$s-%2$s[%3$s]",defield.getName(),defield.getLogicName(),dataEntity.getName()))
.setKeyField(defield.isKeyDEField()?1:null).setMajorField(defield.isMajorDEField()?1:null).setUnionKey(defield.getUnionKeyValue()).setFieldType(defield.getDataType())
.setPredefined(defield.getPredefinedType()).setDict(defield.getPSCodeList()!=null?defield.getPSCodeList().getCodeName():null).setNullable(defield.isAllowEmpty()?1:0)
.setPredefined(defield.getPredefinedType()).setDict(dict).setNullable(defield.isAllowEmpty()?1:0)
.setPhysicalField(defield.isPhisicalDEField()?1:0).setDataType(DataType.findTypeName(defield.getStdDataType())).setDataLength(defield.getLength()).setDataPreci(defield.getPrecision())
.setIsEnableAudit(defield.isEnableAudit()?1:null).setShowOrder(defield.getImportOrder());
......
......@@ -556,7 +556,7 @@ public class POSchema {
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Segment{
public static class Segment {
private String name;
private String vendorProvider;
private String declare;
......@@ -564,13 +564,21 @@ public class POSchema {
private String format;
private Map params;
public Segment setVendorProvider(String vendorProvider)
{
if(!StringUtils.isEmpty(vendorProvider))
this.vendorProvider=provider.get(vendorProvider.toLowerCase());
public Segment setVendorProvider(String vendorProvider) {
if (!StringUtils.isEmpty(vendorProvider))
this.vendorProvider = provider.get(vendorProvider.toLowerCase());
return this;
}
@JsonIgnore
@JSONField(serialize = false)
public String getSql()
{
if(!StringUtils.isEmpty(format))
return String.format(format,body);
return body;
}
}
......@@ -622,7 +630,7 @@ public class POSchema {
@JSONField(ordinal = 12)
public Segment defaultQueryScript;
public POSchema setDefaultQueryScript(String sql)
public POSchema setDefaultQueryScriptSQL(String sql)
{
defaultQueryScript=new Segment().setName("default_query_script").setVendorProvider("").setBody(sql);
return this;
......@@ -637,7 +645,7 @@ public class POSchema {
segment=this.getSegment("dq-default-",this.getDsType());
if(segment!=null)
{
setDefaultQueryScript(segment.getBody());
setDefaultQueryScriptSQL(segment.getBody());
return defaultQueryScript;
}
else if(!StringUtils.isEmpty(this.getDsType()))
......@@ -647,7 +655,7 @@ public class POSchema {
segment=this.getSegment("dq-default-","");
if(segment!=null)
{
setDefaultQueryScript(segment.getBody().replace("`","").replace("[","").replace("]",""));
setDefaultQueryScriptSQL(segment.getBody().replace("`","").replace("[","").replace("]",""));
return defaultQueryScript;
}
}
......@@ -707,13 +715,30 @@ public class POSchema {
public BaseData trans(BaseData source)
{
if(!needTrans)
{
for (String key : resultMap.keySet()) {
if(!source.keySet().contains(key))
{
if((!key.equals(key.toUpperCase()))&&source.keySet().contains(key.toUpperCase()))
{
needTrans=true;
break;
}
else if((!key.equals(key.toLowerCase()))&&source.keySet().contains(key.toLowerCase()))
{
needTrans=true;
break;
}
}
}
}
if(!needTrans)
return source;
else {
BaseData target = new BaseData();
for (Map.Entry<String, String> entry : resultMap.entrySet()) {
if(source.keySet().contains(entry.getKey()))
target.set(entry.getValue(),source.get(entry.getKey()));
target.set(entry.getValue().toLowerCase(),source.get(entry.getKey()));
}
return target;
}
......@@ -721,6 +746,25 @@ public class POSchema {
public List<BaseData> trans(List<BaseData> source)
{
if(!needTrans&&source.size()>0)
{
BaseData src=source.get(0);
for (String key : resultMap.keySet()) {
if(!src.keySet().contains(key))
{
if((!key.equals(key.toUpperCase()))&&src.keySet().contains(key.toUpperCase()))
{
needTrans=true;
break;
}
else if((!key.equals(key.toLowerCase()))&&src.keySet().contains(key.toLowerCase()))
{
needTrans=true;
break;
}
}
}
}
if(!needTrans)
return source;
else {
......
......@@ -63,6 +63,13 @@ public class PojoSchema {
return this;
}
@JSONField(serialize = false)
@JsonIgnore
public String getCodeName()
{
return this.getOptions()==null?this.getName():this.getOptions().getStringValue("code_name",this.getName());
}
@JSONField(serialize = false)
@JsonIgnore
public String getSystem()
......
......@@ -297,7 +297,7 @@ public class TransUtils {
}
String defaultQueryScript=pojoSchema.getOptions().getDefaultQueryScript();
if(!StringUtils.isEmpty(defaultQueryScript))
poSchema.setDefaultQueryScript(defaultQueryScript);
poSchema.setDefaultQueryScriptSQL(defaultQueryScript);
return poSchema;
}
......
......@@ -165,8 +165,29 @@ public class ModelService {
String entityName=file.getName().replace(".json","");
String id=system.concat(".domain.").concat(entityName);
if(!entities.containsKey(entityName.toLowerCase()))
entities.put(entityName.toLowerCase(),id);
if(!entities.containsKey(entityName.toLowerCase())) {
entities.put(entityName.toLowerCase(), id);
try {
PojoSchema pojoSchema=PojoSchema.fromPath(file.toPath());
entityName=pojoSchema.getName();
if((StringUtils.isEmpty(entityName))&&(!entities.containsKey(pojoSchema.getName()))) {
entities.put(pojoSchema.getName(), id);
}
String codeName=pojoSchema.getCodeName();
if((StringUtils.isEmpty(codeName))&&(!entities.containsKey(codeName))) {
entities.put(codeName, id);
if(!codeName.equals(codeName.toLowerCase()))
entities.put(codeName.toLowerCase(), id);
String pluralize= Inflector.getInstance().pluralize(codeName).toLowerCase();
if(!entities.containsKey(pluralize)) {
entities.put(pluralize, id);
}
}
}catch (Exception ex){}
}
}
}
......
......@@ -240,7 +240,7 @@ public class DbDataServiceImpl implements IDataService {
@Override
public BaseData getDraft(DOModel model, String scope, String datasource, BaseData et)
{
return null;
return et;
}
@Override
......
package cn.ibizlab.core.util.config;
import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.core.data.filter.SearchContextBase;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Slf4j
@Configuration
public class FilterDataResolver implements HandlerMethodArgumentResolver {
@Value("${ibiz.pageLimit:1000}")
private int pageLimit=1000;
private static ObjectMapper objectMapper=new ObjectMapper();
@Override
public boolean supportsParameter(MethodParameter parameter) {
Class<?> type = parameter.getParameterType();
return SearchContextBase.class==type
|| FilterData.class==type
|| BaseData.class==type;
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Map<String, String[]> params = webRequest.getParameterMap();
LinkedHashMap<String,Object> set = new LinkedHashMap<>();
for (String key : params.keySet()) {
set.put(key,params.get(key)[0]);
}
if(SearchContextBase.class.isAssignableFrom(parameter.getParameterType()) && (!set.containsKey("size"))){
set.put("size", pageLimit);
}
if(FilterData.class.isAssignableFrom(parameter.getParameterType()) && (!set.containsKey("size"))){
set.put("size", pageLimit);
}
String json = objectMapper.writeValueAsString(set);
return objectMapper.readValue(json, parameter.getParameterType());
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@
select t1.* from
<choose>
<when test="schema.defaultQueryScript!=null">
( ${schema.defaultQueryScript.body} ) t1 where
( ${schema.defaultQueryScript.sql} ) t1 where
</when>
<otherwise>
${schema.name} t1 where
......@@ -50,7 +50,7 @@
select t1.* from
<choose>
<when test="schema.defaultQueryScript!=null">
( ${schema.defaultQueryScript.body} ) t1 where
( ${schema.defaultQueryScript.sql} ) t1 where
</when>
<otherwise>
${schema.name} t1 where
......@@ -74,7 +74,7 @@
select t1.* from
<choose>
<when test="schema.defaultQueryScript!=null">
( ${schema.defaultQueryScript.body} ) t1 where
( ${schema.defaultQueryScript.sql} ) t1 where
</when>
<otherwise>
${schema.name} t1 where
......
......@@ -29,7 +29,7 @@ public class AppController {
@Autowired
private AuthenticationUserService userDetailsService;
@RequestMapping(method = RequestMethod.GET, value = "/appdata")
@RequestMapping(method = RequestMethod.GET, value = {"/ibiz-repository/{system}/{scope}/appdata","/ibiz-repo/{system}/appdata","/appdata"})
public ResponseEntity<JSONObject> getAppData() {
JSONObject appData = new JSONObject() ;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册