瀏覽代碼

去掉elasticsearch,jmreport,单点登录

yangfeng 1 年之前
父節點
當前提交
ccaffd7ba6

+ 0 - 544
core/src/main/java/org/jeecg/common/es/JeecgElasticsearchTemplate.java

@@ -1,544 +0,0 @@
-package org.jeecg.common.es;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.jeecg.common.util.RestUtil;
-import org.jeecg.common.util.oConvertUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
- *
- * @author sunjianlei
- */
-@Slf4j
-@Component
-public class JeecgElasticsearchTemplate {
-    /** es服务地址 */
-    private String baseUrl;
-    private final String FORMAT_JSON = "format=json";
-    /** Elasticsearch 的版本号 */
-    private String version = null;
-
-    /**ElasticSearch 最大可返回条目数*/
-    public static final int ES_MAX_SIZE = 10000;
-
-    /**es7*/
-    public static final String IE_SEVEN = "7";
-
-    /**url not found 404*/
-    public static final String URL_NOT_FOUND = "404 Not Found";
-
-    public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jeecg.elasticsearch.check-enabled}") boolean checkEnabled) {
-        log.debug("JeecgElasticsearchTemplate BaseURL:" + baseUrl);
-        if (StringUtils.isNotEmpty(baseUrl)) {
-            this.baseUrl = baseUrl;
-            // 验证配置的ES地址是否有效
-            if (checkEnabled) {
-                try {
-                    this.getElasticsearchVersion();
-                    log.info("ElasticSearch 服务连接成功");
-                    log.info("ElasticSearch version: " + this.version);
-                } catch (Exception e) {
-                    this.version = "";
-                    log.warn("ElasticSearch 服务连接失败,原因:配置未通过。可能是BaseURL未配置或配置有误,也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法!");
-                }
-            }
-        }
-    }
-
-    /**
-     * 获取 Elasticsearch 的版本号信息,失败返回null
-     */
-    private void getElasticsearchVersion() {
-        if (this.version == null) {
-            String url = this.getBaseUrl().toString();
-            JSONObject result = RestUtil.get(url);
-            if (result != null) {
-                JSONObject v = result.getJSONObject("version");
-                this.version = v.getString("number");
-            }
-        }
-    }
-
-    public StringBuilder getBaseUrl(String indexName, String typeName) {
-        typeName = typeName.trim().toLowerCase();
-        return this.getBaseUrl(indexName).append("/").append(typeName);
-    }
-
-    public StringBuilder getBaseUrl(String indexName) {
-        indexName = indexName.trim().toLowerCase();
-        return this.getBaseUrl().append("/").append(indexName);
-    }
-
-    public StringBuilder getBaseUrl() {
-        return new StringBuilder("http://").append(this.baseUrl);
-    }
-
-    /**
-     * cat 查询ElasticSearch系统数据,返回json
-     */
-    private <T> ResponseEntity<T> cat(String urlAfter, Class<T> responseType) {
-        String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString();
-        return RestUtil.request(url, HttpMethod.GET, null, null, null, responseType);
-    }
-
-    /**
-     * 查询所有索引
-     * <p>
-     * 查询地址:GET http://{baseUrl}/_cat/indices
-     */
-    public JSONArray getIndices() {
-        return getIndices(null);
-    }
-
-
-    /**
-     * 查询单个索引
-     * <p>
-     * 查询地址:GET http://{baseUrl}/_cat/indices/{indexName}
-     */
-    public JSONArray getIndices(String indexName) {
-        StringBuilder urlAfter = new StringBuilder("/indices");
-        if (!StringUtils.isEmpty(indexName)) {
-            urlAfter.append("/").append(indexName.trim().toLowerCase());
-        }
-        return cat(urlAfter.toString(), JSONArray.class).getBody();
-    }
-
-    /**
-     * 索引是否存在
-     */
-    public boolean indexExists(String indexName) {
-        try {
-            JSONArray array = getIndices(indexName);
-            return array != null;
-        } catch (org.springframework.web.client.HttpClientErrorException ex) {
-            if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
-                return false;
-            } else {
-                throw ex;
-            }
-        }
-    }
-
-    /**
-     * 根据ID获取索引数据,未查询到返回null
-     * <p>
-     * 查询地址:GET http://{baseUrl}/{indexName}/{typeName}/{dataId}
-     *
-     * @param indexName 索引名称
-     * @param typeName  type,一个任意字符串,用于分类
-     * @param dataId    数据id
-     * @return
-     */
-    public JSONObject getDataById(String indexName, String typeName, String dataId) {
-        String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
-        log.info("url:" + url);
-        JSONObject result = RestUtil.get(url);
-        boolean found = result.getBoolean("found");
-        if (found) {
-            return result.getJSONObject("_source");
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * 创建索引
-     * <p>
-     * 查询地址:PUT http://{baseUrl}/{indexName}
-     */
-    public boolean createIndex(String indexName) {
-        String url = this.getBaseUrl(indexName).toString();
-
-        /* 返回结果 (仅供参考)
-        "createIndex": {
-            "shards_acknowledged": true,
-            "acknowledged": true,
-            "index": "hello_world"
-        }
-        */
-        try {
-            return RestUtil.put(url).getBoolean("acknowledged");
-        } catch (org.springframework.web.client.HttpClientErrorException ex) {
-            if (HttpStatus.BAD_REQUEST == ex.getStatusCode()) {
-                log.warn("索引创建失败:" + indexName + " 已存在,无需再创建");
-            } else {
-                ex.printStackTrace();
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 删除索引
-     * <p>
-     * 查询地址:DELETE http://{baseUrl}/{indexName}
-     */
-    public boolean removeIndex(String indexName) {
-        String url = this.getBaseUrl(indexName).toString();
-        try {
-            return RestUtil.delete(url).getBoolean("acknowledged");
-        } catch (org.springframework.web.client.HttpClientErrorException ex) {
-            if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
-                log.warn("索引删除失败:" + indexName + " 不存在,无需删除");
-            } else {
-                ex.printStackTrace();
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 获取索引字段映射(可获取字段类型)
-     * <p>
-     *
-     * @param indexName 索引名称
-     * @param typeName  分类名称
-     * @return
-     */
-    public JSONObject getIndexMapping(String indexName, String typeName) {
-        String url = this.getBaseUrl(indexName, typeName).append("/_mapping?").append(FORMAT_JSON).toString();
-        // 针对 es 7.x 版本做兼容
-        this.getElasticsearchVersion();
-        if (oConvertUtils.isNotEmpty(this.version) && this.version.startsWith(IE_SEVEN)) {
-            url += "&include_type_name=true";
-        }
-        log.info("getIndexMapping-url:" + url);
-        /*
-         * 参考返回JSON结构:
-         *
-         *{
-         *    // 索引名称
-         *    "[indexName]": {
-         *        "mappings": {
-         *            // 分类名称
-         *            "[typeName]": {
-         *                "properties": {
-         *                    // 字段名
-         *                    "input_number": {
-         *                        // 字段类型
-         *                        "type": "long"
-         *                    },
-         *                    "input_string": {
-         *                        "type": "text",
-         *                        "fields": {
-         *                            "keyword": {
-         *                                "type": "keyword",
-         *                                "ignore_above": 256
-         *                            }
-         *                        }
-         *                    }
-         *                 }
-         *            }
-         *        }
-         *    }
-         * }
-         */
-        try {
-            return RestUtil.get(url);
-        } catch (org.springframework.web.client.HttpClientErrorException e) {
-            String message = e.getMessage();
-            if (message != null && message.contains(URL_NOT_FOUND)) {
-                return null;
-            }
-            throw e;
-        }
-    }
-
-    /**
-     * 获取索引字段映射,返回Java实体类
-     *
-     * @param indexName
-     * @param typeName
-     * @return
-     */
-    public <T> Map<String, T> getIndexMappingFormat(String indexName, String typeName, Class<T> clazz) {
-        JSONObject mapping = this.getIndexMapping(indexName, typeName);
-        Map<String, T> map = new HashMap<>(5);
-        if (mapping == null) {
-            return map;
-        }
-        // 获取字段属性
-        JSONObject properties = mapping.getJSONObject(indexName)
-                .getJSONObject("mappings")
-                .getJSONObject(typeName)
-                .getJSONObject("properties");
-        // 封装成 java类型
-        for (String key : properties.keySet()) {
-            T entity = properties.getJSONObject(key).toJavaObject(clazz);
-            map.put(key, entity);
-        }
-        return map;
-    }
-
-    /**
-     * 保存数据,详见:saveOrUpdate
-     */
-    public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
-        return this.saveOrUpdate(indexName, typeName, dataId, data);
-    }
-
-    /**
-     * 更新数据,详见:saveOrUpdate
-     */
-    public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
-        return this.saveOrUpdate(indexName, typeName, dataId, data);
-    }
-
-    /**
-     * 保存或修改索引数据
-     * <p>
-     * 查询地址:PUT http://{baseUrl}/{indexName}/{typeName}/{dataId}
-     *
-     * @param indexName 索引名称
-     * @param typeName  type,一个任意字符串,用于分类
-     * @param dataId    数据id
-     * @param data      要存储的数据
-     * @return
-     */
-    public boolean saveOrUpdate(String indexName, String typeName, String dataId, JSONObject data) {
-        String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).append("?refresh=wait_for").toString();
-        /* 返回结果(仅供参考)
-       "createIndexA2": {
-            "result": "created",
-            "_shards": {
-                "total": 2,
-                "successful": 1,
-                "failed": 0
-            },
-            "_seq_no": 0,
-            "_index": "test_index_1",
-            "_type": "test_type_1",
-            "_id": "a2",
-            "_version": 1,
-            "_primary_term": 1
-        }
-         */
-
-        try {
-            // 去掉 data 中为空的值
-            Set<String> keys = data.keySet();
-            List<String> emptyKeys = new ArrayList<>(keys.size());
-            for (String key : keys) {
-                String value = data.getString(key);
-                //1、剔除空值
-                if (oConvertUtils.isEmpty(value) || "[]".equals(value)) {
-                    emptyKeys.add(key);
-                }
-                //2、剔除上传控件值(会导致ES同步失败,报异常failed to parse field [ge_pic] of type [text] )
-                if (oConvertUtils.isNotEmpty(value) && value.indexOf("[{")!=-1) {
-                    emptyKeys.add(key);
-                    log.info("-------剔除上传控件字段------------key: "+ key);
-                }
-            }
-            for (String key : emptyKeys) {
-                data.remove(key);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        try {
-            String result = RestUtil.put(url, data).getString("result");
-            return "created".equals(result) || "updated".equals(result);
-        } catch (Exception e) {
-            log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString());
-            //TODO 打印接口返回异常json
-            return false;
-        }
-    }
-
-    /**
-     * 批量保存数据
-     *
-     * @param indexName 索引名称
-     * @param typeName  type,一个任意字符串,用于分类
-     * @param dataList  要存储的数据数组,每行数据必须包含id
-     * @return
-     */
-    public boolean saveBatch(String indexName, String typeName, JSONArray dataList) {
-        String url = this.getBaseUrl().append("/_bulk").append("?refresh=wait_for").toString();
-        StringBuilder bodySb = new StringBuilder();
-        for (int i = 0; i < dataList.size(); i++) {
-            JSONObject data = dataList.getJSONObject(i);
-            String id = data.getString("id");
-            // 该行的操作
-            // {"create": {"_id":"${id}", "_index": "${indexName}", "_type": "${typeName}"}}
-            JSONObject action = new JSONObject();
-            JSONObject actionInfo = new JSONObject();
-            actionInfo.put("_id", id);
-            actionInfo.put("_index", indexName);
-            actionInfo.put("_type", typeName);
-            action.put("create", actionInfo);
-            bodySb.append(action.toJSONString()).append("\n");
-            // 该行的数据
-            data.remove("id");
-            bodySb.append(data.toJSONString()).append("\n");
-        }
-        System.out.println("+-+-+-: bodySb.toString(): " + bodySb.toString());
-        HttpHeaders headers = RestUtil.getHeaderApplicationJson();
-        RestUtil.request(url, HttpMethod.PUT, headers, null, bodySb, JSONObject.class);
-        return true;
-    }
-
-    /**
-     * 删除索引数据
-     * <p>
-     * 请求地址:DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
-     */
-    public boolean delete(String indexName, String typeName, String dataId) {
-        String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
-        /* 返回结果(仅供参考)
-        {
-            "_index": "es_demo",
-            "_type": "docs",
-            "_id": "001",
-            "_version": 3,
-            "result": "deleted",
-            "_shards": {
-                "total": 1,
-                "successful": 1,
-                "failed": 0
-            },
-            "_seq_no": 28,
-            "_primary_term": 18
-        }
-        */
-        try {
-            return "deleted".equals(RestUtil.delete(url).getString("result"));
-        } catch (org.springframework.web.client.HttpClientErrorException ex) {
-            if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
-                return false;
-            } else {
-                throw ex;
-            }
-        }
-    }
-
-
-    /* = = = 以下关于查询和查询条件的方法 = = =*/
-
-    /**
-     * 查询数据
-     * <p>
-     * 请求地址:POST http://{baseUrl}/{indexName}/{typeName}/_search
-     */
-    public JSONObject search(String indexName, String typeName, JSONObject queryObject) {
-        String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
-
-        log.info("url:" + url + " ,search: " + queryObject.toJSONString());
-        JSONObject res = RestUtil.post(url, queryObject);
-        log.info("url:" + url + " ,return res: \n" + res.toJSONString());
-        return res;
-    }
-
-    /**
-     * @param source (源滤波器)指定返回的字段,传null返回所有字段
-     * @param query
-     * @param from    从第几条数据开始
-     * @param size    返回条目数
-     * @return { "query": query }
-     */
-    public JSONObject buildQuery(List<String> source, JSONObject query, int from, int size) {
-        JSONObject json = new JSONObject();
-        if (source != null) {
-            json.put("_source", source);
-        }
-        json.put("query", query);
-        json.put("from", from);
-        json.put("size", size);
-        return json;
-    }
-
-    /**
-     * @return { "bool" : { "must": must, "must_not": mustNot, "should": should } }
-     */
-    public JSONObject buildBoolQuery(JSONArray must, JSONArray mustNot, JSONArray should) {
-        JSONObject bool = new JSONObject();
-        if (must != null) {
-            bool.put("must", must);
-        }
-        if (mustNot != null) {
-            bool.put("must_not", mustNot);
-        }
-        if (should != null) {
-            bool.put("should", should);
-        }
-        JSONObject json = new JSONObject();
-        json.put("bool", bool);
-        return json;
-    }
-
-    /**
-     * @param field 要查询的字段
-     * @param args  查询参数,参考: *哈哈* OR *哒* NOT *呵* OR *啊*
-     * @return
-     */
-    public JSONObject buildQueryString(String field, String... args) {
-        if (field == null) {
-            return null;
-        }
-        StringBuilder sb = new StringBuilder(field).append(":(");
-        if (args != null) {
-            for (String arg : args) {
-                sb.append(arg).append(" ");
-            }
-        }
-        sb.append(")");
-        return this.buildQueryString(sb.toString());
-    }
-
-    /**
-     * @return { "query_string": { "query": query }  }
-     */
-    public JSONObject buildQueryString(String query) {
-        JSONObject queryString = new JSONObject();
-        queryString.put("query", query);
-        JSONObject json = new JSONObject();
-        json.put("query_string", queryString);
-        return json;
-    }
-
-    /**
-     * @param field      查询字段
-     * @param min        最小值
-     * @param max        最大值
-     * @param containMin 范围内是否包含最小值
-     * @param containMax 范围内是否包含最大值
-     * @return { "range" : { field : { 『 "gt『e』?containMin" : min 』?min!=null , 『 "lt『e』?containMax" : max 』}} }
-     */
-    public JSONObject buildRangeQuery(String field, Object min, Object max, boolean containMin, boolean containMax) {
-        JSONObject inner = new JSONObject();
-        if (min != null) {
-            if (containMin) {
-                inner.put("gte", min);
-            } else {
-                inner.put("gt", min);
-            }
-        }
-        if (max != null) {
-            if (containMax) {
-                inner.put("lte", max);
-            } else {
-                inner.put("lt", max);
-            }
-        }
-        JSONObject range = new JSONObject();
-        range.put(field, inner);
-        JSONObject json = new JSONObject();
-        json.put("range", range);
-        return json;
-    }
-
-}
-

+ 0 - 98
core/src/main/java/org/jeecg/common/es/QueryStringBuilder.java

@@ -1,98 +0,0 @@
-package org.jeecg.common.es;
-
-/**
- * 用于创建 ElasticSearch 的 queryString
- *
- * @author sunjianlei
- */
-public class QueryStringBuilder {
-
-    StringBuilder builder;
-
-    public QueryStringBuilder(String field, String str, boolean not, boolean addQuot) {
-        builder = this.createBuilder(field, str, not, addQuot);
-    }
-
-    public QueryStringBuilder(String field, String str, boolean not) {
-        builder = this.createBuilder(field, str, not, true);
-    }
-
-    /**
-     * 创建 StringBuilder
-     *
-     * @param field
-     * @param str
-     * @param not     是否是不匹配
-     * @param addQuot 是否添加双引号
-     * @return
-     */
-    public StringBuilder createBuilder(String field, String str, boolean not, boolean addQuot) {
-        StringBuilder sb = new StringBuilder(field).append(":(");
-        if (not) {
-            sb.append(" NOT ");
-        }
-        this.addQuotEffect(sb, str, addQuot);
-        return sb;
-    }
-
-    public QueryStringBuilder and(String str) {
-        return this.and(str, true);
-    }
-
-    public QueryStringBuilder and(String str, boolean addQuot) {
-        builder.append(" AND ");
-        this.addQuot(str, addQuot);
-        return this;
-    }
-
-    public QueryStringBuilder or(String str) {
-        return this.or(str, true);
-    }
-
-    public QueryStringBuilder or(String str, boolean addQuot) {
-        builder.append(" OR ");
-        this.addQuot(str, addQuot);
-        return this;
-    }
-
-    public QueryStringBuilder not(String str) {
-        return this.not(str, true);
-    }
-
-    public QueryStringBuilder not(String str, boolean addQuot) {
-        builder.append(" NOT ");
-        this.addQuot(str, addQuot);
-        return this;
-    }
-
-    /**
-    * 添加双引号(模糊查询,不能加双引号)
-    */
-    private QueryStringBuilder addQuot(String str, boolean addQuot) {
-        return this.addQuotEffect(this.builder, str, addQuot);
-    }
-
-    /**
-     * 是否在两边加上双引号
-     * @param builder
-     * @param str
-     * @param addQuot
-     * @return
-     */
-    private QueryStringBuilder addQuotEffect(StringBuilder builder, String str, boolean addQuot) {
-        if (addQuot) {
-            builder.append('"');
-        }
-        builder.append(str);
-        if (addQuot) {
-            builder.append('"');
-        }
-        return this;
-    }
-
-    @Override
-    public String toString() {
-        return builder.append(")").toString();
-    }
-
-}

+ 0 - 21
pom.xml

@@ -34,8 +34,6 @@
     <druid.version>1.1.22</druid.version>
     <minidao.version>1.9.0</minidao.version>
 
-    <!-- 积木报表-->
-    <jimureport-spring-boot-starter.version>1.5.4</jimureport-spring-boot-starter.version>
     <commons.version>2.6</commons.version>
     <aliyun-java-sdk-dysmsapi.version>2.1.0</aliyun-java-sdk-dysmsapi.version>
     <aliyun.oss.version>3.11.2</aliyun.oss.version>
@@ -277,25 +275,6 @@
           </exclusion>
         </exclusions>
       </dependency>
-      <!-- 积木报表-->
-      <dependency>
-        <groupId>org.jeecgframework.jimureport</groupId>
-        <artifactId>jimureport-spring-boot-starter</artifactId>
-        <version>${jimureport-spring-boot-starter.version}</version>
-        <exclusions>
-          <exclusion>
-            <artifactId>autopoi-web</artifactId>
-            <groupId>org.jeecgframework</groupId>
-          </exclusion>
-        </exclusions>
-      </dependency>
-      <dependency>
-        <groupId>org.jeecgframework.jimureport</groupId>
-        <artifactId>jimureport-nosql-starter</artifactId>
-        <version>${jimureport-spring-boot-starter.version}</version>
-      </dependency>
-
-
     </dependencies>
   </dependencyManagement>
 

+ 0 - 10
system/system-biz/pom.xml

@@ -33,16 +33,6 @@
 			<groupId>org.jeecgframework</groupId>
 			<artifactId>jeewx-api</artifactId>
 		</dependency>
-		<!-- 积木报表 -->
-		<dependency>
-			<groupId>org.jeecgframework.jimureport</groupId>
-			<artifactId>jimureport-spring-boot-starter</artifactId>
-		</dependency>
-		<!-- 积木报表 mongo redis 支持包 
-		<dependency>
-			<groupId>org.jeecgframework.jimureport</groupId>
-			<artifactId>jimureport-nosql-starter</artifactId>
-		</dependency>-->
 	</dependencies>
 	
 </project>

+ 0 - 69
system/system-biz/src/main/java/org/jeecg/config/jimureport/JimuReportTokenService.java

@@ -1,69 +0,0 @@
-package org.jeecg.config.jimureport;
-
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.system.util.JwtUtil;
-import org.jeecg.common.system.vo.SysUserCacheInfo;
-import org.jeecg.common.util.RedisUtil;
-import org.jeecg.common.util.TokenUtils;
-import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
-import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 自定义积木报表鉴权(如果不进行自定义,则所有请求不做权限控制)
- *  * 1.自定义获取登录token
- *  * 2.自定义获取登录用户
- * @author: jeecg-boot
- */
-
-
-@Slf4j
-@Component
-public class JimuReportTokenService implements JmReportTokenServiceI {
-    @Autowired
-    private SysBaseApiImpl sysBaseApi;
-    @Autowired
-    @Lazy
-    private RedisUtil redisUtil;
-
-    @Override
-    public String getToken(HttpServletRequest request) {
-        return TokenUtils.getTokenByRequest(request);
-    }
-
-    @Override
-    public String getUsername(String token) {
-        return JwtUtil.getUsername(token);
-    }
-
-    @Override
-    public Boolean verifyToken(String token) {
-        return TokenUtils.verifyToken(token, sysBaseApi, redisUtil);
-    }
-
-    @Override
-    public Map<String, Object> getUserInfo(String token) {
-        Map<String, Object> map = new HashMap(5);
-        String username = JwtUtil.getUsername(token);
-        //此处通过token只能拿到一个信息 用户账号  后面的就是根据账号获取其他信息 查询数据或是走redis 用户根据自身业务可自定义
-        SysUserCacheInfo userInfo = null;
-        try {
-            userInfo = sysBaseApi.getCacheUser(username);
-        } catch (Exception e) {
-            log.error("获取用户信息异常:"+ e.getMessage());
-            return map;
-        }
-        //设置账号名
-        map.put(SYS_USER_CODE, userInfo.getSysUserCode());
-        //设置部门编码
-        map.put(SYS_ORG_CODE, userInfo.getSysOrgCode());
-        // 将所有信息存放至map 解析sql/api会根据map的键值解析
-        return map;
-    }
-}

+ 0 - 111
system/system-biz/src/main/java/org/jeecg/modules/cas/controller/CasClientController.java

@@ -1,111 +0,0 @@
-package org.jeecg.modules.cas.controller;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang.StringUtils;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.constant.CommonConstant;
-import org.jeecg.common.system.util.JwtUtil;
-import org.jeecg.common.util.RedisUtil;
-import org.jeecg.modules.cas.util.CasServiceUtil;
-import org.jeecg.modules.cas.util.XmlUtils;
-import org.jeecg.modules.system.entity.SysDepart;
-import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.service.ISysDepartService;
-import org.jeecg.modules.system.service.ISysUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.alibaba.fastjson.JSONObject;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * <p>
- * CAS单点登录客户端登录认证
- * </p>
- *
- * @Author zhoujf
- * @since 2018-12-20
- */
-@Slf4j
-@RestController
-@RequestMapping("/sys/cas/client")
-public class CasClientController {
-
-	@Autowired
-	private ISysUserService sysUserService;
-	@Autowired
-    private ISysDepartService sysDepartService;
-	@Autowired
-    private RedisUtil redisUtil;
-	
-	@Value("${cas.prefixUrl}")
-    private String prefixUrl;
-	
-	
-	@GetMapping("/validateLogin")
-	public Object validateLogin(@RequestParam(name="ticket") String ticket,
-								@RequestParam(name="service") String service,
-								HttpServletRequest request,
-								HttpServletResponse response) throws Exception {
-		Result<JSONObject> result = new Result<JSONObject>();
-		log.info("Rest api login.");
-		try {
-			String validateUrl = prefixUrl+"/p3/serviceValidate";
-			String res = CasServiceUtil.getStValidate(validateUrl, ticket, service);
-			log.info("res."+res);
-			final String error = XmlUtils.getTextForElement(res, "authenticationFailure");
-			if(StringUtils.isNotEmpty(error)) {
-				throw new Exception(error);
-			}
-			final String principal = XmlUtils.getTextForElement(res, "user");
-			if (StringUtils.isEmpty(principal)) {
-	            throw new Exception("No principal was found in the response from the CAS server.");
-	        }
-			log.info("-------token----username---"+principal);
-		    //1. 校验用户是否有效
-	  		SysUser sysUser = sysUserService.getUserByName(principal);
-	  		result = sysUserService.checkUserIsEffective(sysUser);
-	  		if(!result.isSuccess()) {
-	  			return result;
-	  		}
-	 		String token = JwtUtil.sign(sysUser.getUsername(), sysUser.getPassword());
-	 		// 设置超时时间
-	 		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
-	 		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
-
-	 		//获取用户部门信息
-			JSONObject obj = new JSONObject();
-			List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
-			obj.put("departs", departs);
-			if (departs == null || departs.size() == 0) {
-				obj.put("multi_depart", 0);
-			} else if (departs.size() == 1) {
-				sysUserService.updateUserDepart(principal, departs.get(0).getOrgCode());
-				obj.put("multi_depart", 1);
-			} else {
-				obj.put("multi_depart", 2);
-			}
-			obj.put("token", token);
-			obj.put("userInfo", sysUser);
-			result.setResult(obj);
-			result.success("登录成功");
-	  		
-		} catch (Exception e) {
-			//e.printStackTrace();
-			result.error500(e.getMessage());
-		}
-		return new HttpEntity<>(result);
-	}
-
-	
-}

+ 0 - 107
system/system-biz/src/main/java/org/jeecg/modules/cas/util/CasServiceUtil.java

@@ -1,107 +0,0 @@
-package org.jeecg.modules.cas.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-
-/**
- * @Description: CasServiceUtil
- * @author: jeecg-boot
- */
-public class CasServiceUtil {
-	
-	public static void main(String[] args) {
-		String serviceUrl = "https://cas.8f8.com.cn:8443/cas/p3/serviceValidate";
-		String service = "http://localhost:3003/user/login";
-		String ticket = "ST-5-1g-9cNES6KXNRwq-GuRET103sm0-DESKTOP-VKLS8B3";
-		String res = getStValidate(serviceUrl,ticket, service);
-		
-		System.out.println("---------res-----"+res);
-	}
-	
-	
-	/**
-     * 验证ST
-     */
-    public static String getStValidate(String url, String st, String service){
-		try {
-			url = url+"?service="+service+"&ticket="+st;
-			CloseableHttpClient httpclient = createHttpClientWithNoSsl();
-			HttpGet httpget = new HttpGet(url);
-			HttpResponse response = httpclient.execute(httpget);
-	        String res = readResponse(response);
-	        return res == null ? null : (res == "" ? null : res);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return "";
-	}
-
-    
-    /**
-     * 读取 response body 内容为字符串
-     *
-     * @param response
-     * @return
-     * @throws IOException
-     */
-    private static String readResponse(HttpResponse response) throws IOException {
-        BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-        String result = new String();
-        String line;
-        while ((line = in.readLine()) != null) {
-            result += line;
-        }
-        return result;
-    }
-    
-    
-    /**
-     * 创建模拟客户端(针对 https 客户端禁用 SSL 验证)
-     *
-     * @param cookieStore 缓存的 Cookies 信息
-     * @return
-     * @throws Exception
-     */
-    private static CloseableHttpClient createHttpClientWithNoSsl() throws Exception {
-        // Create a trust manager that does not validate certificate chains
-        TrustManager[] trustAllCerts = new TrustManager[]{
-                new X509TrustManager() {
-                    @Override
-                    public X509Certificate[] getAcceptedIssuers() {
-                        return null;
-                    }
-
-                    @Override
-                    public void checkClientTrusted(X509Certificate[] certs, String authType) {
-                        // don't check
-                    }
-
-                    @Override
-                    public void checkServerTrusted(X509Certificate[] certs, String authType) {
-                        // don't check
-                    }
-                }
-        };
-
-        SSLContext ctx = SSLContext.getInstance("TLS");
-        ctx.init(null, trustAllCerts, null);
-        LayeredConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(ctx);
-        return HttpClients.custom()
-                .setSSLSocketFactory(sslSocketFactory)
-                .build();
-    }
-
-}

+ 0 - 304
system/system-biz/src/main/java/org/jeecg/modules/cas/util/XmlUtils.java

@@ -1,304 +0,0 @@
-package org.jeecg.modules.cas.util;
-
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import org.jeecg.common.constant.CommonConstant;
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 解析cas,ST验证后的xml
- * @author: jeecg-boot
- */
-@Slf4j
-public final class XmlUtils {
-
-    /**
-     * attributes
-     */
-    private static final String ATTRIBUTES = "attributes";
-
-    /**
-     * Creates a new namespace-aware DOM document object by parsing the given XML.
-     *
-     * @param xml XML content.
-     *
-     * @return DOM document.
-     */
-    public static Document newDocument(final String xml) {
-        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        final Map<String, Boolean> features = new HashMap(5);
-        features.put(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        features.put("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
-        for (final Map.Entry<String, Boolean> entry : features.entrySet()) {
-            try {
-                factory.setFeature(entry.getKey(), entry.getValue());
-            } catch (ParserConfigurationException e) {
-                log.warn("Failed setting XML feature {}: {}", entry.getKey(), e);
-            }
-        }
-        factory.setNamespaceAware(true);
-        try {
-            return factory.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
-        } catch (Exception e) {
-            throw new RuntimeException("XML parsing error: " + e);
-        }
-    }
-
-    /**
-     * Get an instance of an XML reader from the XMLReaderFactory.
-     *
-     * @return the XMLReader.
-     */
-    public static XMLReader getXmlReader() {
-        try {
-            final XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
-            reader.setFeature("http://xml.org/sax/features/namespaces", true);
-            reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
-            reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
-            return reader;
-        } catch (final Exception e) {
-            throw new RuntimeException("Unable to create XMLReader", e);
-        }
-    }
-
-
-    /**
-     * Retrieve the text for a group of elements. Each text element is an entry
-     * in a list.
-     * <p>This method is currently optimized for the use case of two elements in a list.
-     *
-     * @param xmlAsString the xml response
-     * @param element     the element to look for
-     * @return the list of text from the elements.
-     */
-    public static List<String> getTextForElements(final String xmlAsString, final String element) {
-        final List<String> elements = new ArrayList<String>(2);
-        final XMLReader reader = getXmlReader();
-
-        final DefaultHandler handler = new DefaultHandler() {
-
-            private boolean foundElement = false;
-
-            private StringBuilder buffer = new StringBuilder();
-
-            @Override
-            public void startElement(final String uri, final String localName, final String qName,
-                                     final Attributes attributes) throws SAXException {
-                if (localName.equals(element)) {
-                    this.foundElement = true;
-                }
-            }
-
-            @Override
-            public void endElement(final String uri, final String localName, final String qName) throws SAXException {
-                if (localName.equals(element)) {
-                    this.foundElement = false;
-                    elements.add(this.buffer.toString());
-                    this.buffer = new StringBuilder();
-                }
-            }
-
-            @Override
-            public void characters(char[] ch, int start, int length) throws SAXException {
-                if (this.foundElement) {
-                    this.buffer.append(ch, start, length);
-                }
-            }
-        };
-
-        reader.setContentHandler(handler);
-        reader.setErrorHandler(handler);
-
-        try {
-            reader.parse(new InputSource(new StringReader(xmlAsString)));
-        } catch (final Exception e) {
-            log.error(e.getMessage(), e);
-            return null;
-        }
-
-        return elements;
-    }
-
-    /**
-     * Retrieve the text for a specific element (when we know there is only
-     * one).
-     *
-     * @param xmlAsString the xml response
-     * @param element     the element to look for
-     * @return the text value of the element.
-     */
-    public static String getTextForElement(final String xmlAsString, final String element) {
-        final XMLReader reader = getXmlReader();
-        final StringBuilder builder = new StringBuilder();
-
-        final DefaultHandler handler = new DefaultHandler() {
-
-            private boolean foundElement = false;
-
-            @Override
-            public void startElement(final String uri, final String localName, final String qName,
-                                     final Attributes attributes) throws SAXException {
-                if (localName.equals(element)) {
-                    this.foundElement = true;
-                }
-            }
-
-            @Override
-            public void endElement(final String uri, final String localName, final String qName) throws SAXException {
-                if (localName.equals(element)) {
-                    this.foundElement = false;
-                }
-            }
-
-            @Override
-            public void characters(char[] ch, int start, int length) throws SAXException {
-                if (this.foundElement) {
-                    builder.append(ch, start, length);
-                }
-            }
-        };
-
-        reader.setContentHandler(handler);
-        reader.setErrorHandler(handler);
-
-        try {
-            reader.parse(new InputSource(new StringReader(xmlAsString)));
-        } catch (final Exception e) {
-            log.error(e.getMessage(), e);
-            return null;
-        }
-
-        return builder.toString();
-    }
-    
-    
-    public static Map<String, Object> extractCustomAttributes(final String xml) {
-        final SAXParserFactory spf = SAXParserFactory.newInstance();
-        spf.setNamespaceAware(true);
-        spf.setValidating(false);
-        try {
-            final SAXParser saxParser = spf.newSAXParser();
-            final XMLReader xmlReader = saxParser.getXMLReader();
-            final CustomAttributeHandler handler = new CustomAttributeHandler();
-            xmlReader.setContentHandler(handler);
-            xmlReader.parse(new InputSource(new StringReader(xml)));
-            return handler.getAttributes();
-        } catch (final Exception e) {
-        	log.error(e.getMessage(), e);
-            return Collections.emptyMap();
-        }
-    }
-    
-    private static class CustomAttributeHandler extends DefaultHandler {
-
-        private Map<String, Object> attributes;
-
-        private boolean foundAttributes;
-
-        private String currentAttribute;
-
-        private StringBuilder value;
-
-        @Override
-        public void startDocument() throws SAXException {
-            this.attributes = new HashMap(5);
-        }
-
-        @Override
-        public void startElement(final String nameSpaceUri, final String localName, final String qName,
-                                 final Attributes attributes) throws SAXException {
-            if (ATTRIBUTES.equals(localName)) {
-                this.foundAttributes = true;
-            } else if (this.foundAttributes) {
-                this.value = new StringBuilder();
-                this.currentAttribute = localName;
-            }
-        }
-
-        @Override
-        public void characters(final char[] chars, final int start, final int length) throws SAXException {
-            if (this.currentAttribute != null) {
-                value.append(chars, start, length);
-            }
-        }
-
-        @Override
-        public void endElement(final String nameSpaceUri, final String localName, final String qName)
-                throws SAXException {
-            if (ATTRIBUTES.equals(localName)) {
-                this.foundAttributes = false;
-                this.currentAttribute = null;
-            } else if (this.foundAttributes) {
-                final Object o = this.attributes.get(this.currentAttribute);
-
-                if (o == null) {
-                    this.attributes.put(this.currentAttribute, this.value.toString());
-                } else {
-                    final List<Object> items;
-                    if (o instanceof List) {
-                        items = (List<Object>) o;
-                    } else {
-                        items = new LinkedList<Object>();
-                        items.add(o);
-                        this.attributes.put(this.currentAttribute, items);
-                    }
-                    items.add(this.value.toString());
-                }
-            }
-        }
-
-        public Map<String, Object> getAttributes() {
-            return this.attributes;
-        }
-    }
-    
-    
-    public static void main(String[] args) {
-		String result = "<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\r\n" + 
-				"    <cas:authenticationSuccess>\r\n" + 
-				"        <cas:user>admin</cas:user>\r\n" + 
-				"        <cas:attributes>\r\n" + 
-				"            <cas:credentialType>UsernamePasswordCredential</cas:credentialType>\r\n" + 
-				"            <cas:isFromNewLogin>true</cas:isFromNewLogin>\r\n" + 
-				"            <cas:authenticationDate>2019-08-01T19:33:21.527+08:00[Asia/Shanghai]</cas:authenticationDate>\r\n" + 
-				"            <cas:authenticationMethod>RestAuthenticationHandler</cas:authenticationMethod>\r\n" + 
-				"            <cas:successfulAuthenticationHandlers>RestAuthenticationHandler</cas:successfulAuthenticationHandlers>\r\n" + 
-				"            <cas:longTermAuthenticationRequestTokenUsed>false</cas:longTermAuthenticationRequestTokenUsed>\r\n" + 
-				"        </cas:attributes>\r\n" + 
-				"    </cas:authenticationSuccess>\r\n" + 
-				"</cas:serviceResponse>";
-		
-		String errorRes = "<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\r\n" + 
-				"    <cas:authenticationFailure code=\"INVALID_TICKET\">未能够识别出目标 &#39;ST-5-1g-9cNES6KXNRwq-GuRET103sm0-DESKTOP-VKLS8B3&#39;票根</cas:authenticationFailure>\r\n" + 
-				"</cas:serviceResponse>";
-		
-		String error = XmlUtils.getTextForElement(errorRes, "authenticationFailure");
-		System.out.println("------"+error);
-		
-		String error2 = XmlUtils.getTextForElement(result, "authenticationFailure");
-		System.out.println("------"+error2);
-		String principal = XmlUtils.getTextForElement(result, "user");
-		System.out.println("---principal---"+principal);
-		Map<String, Object> attributes = XmlUtils.extractCustomAttributes(result);
-		System.out.println("---attributes---"+attributes);
-	}
-}

+ 0 - 23
web/src/main/resources/application-dev.yml

@@ -192,11 +192,6 @@ jeecg:
     secretKey: ??
     endpoint: oss-cn-beijing.aliyuncs.com
     bucketName: jeecgdev
-  # ElasticSearch 6设置
-  elasticsearch:
-    cluster-name: jeecg-ES
-    cluster-nodes: 127.0.0.1:9200
-    check-enabled: false
   # 在线预览文件服务器地址配置
   file-view-domain: 127.0.0.1:8012
   # minio文件上传
@@ -205,24 +200,6 @@ jeecg:
     minio_name: minioadmin
     minio_pass: minioadmin
     bucketName: exam-bucket
-  #大屏报表参数设置
-  jmreport:
-    mode: dev
-    #数据字典是否进行saas数据隔离,自己看自己的字典
-    saas: false
-    #是否需要校验token
-    is_verify_token: true
-    #必须校验方法
-    verify_methods: remove,delete,save,add,update
-  #分布式锁配置
-  redisson:
-    address: 127.0.0.1:6379
-    password:
-    type: STANDALONE
-    enabled: true
-#cas单点登录
-cas:
-  prefixUrl: http://cas.example.org:8443/cas
 #Mybatis输出sql日志
 logging:
   level:

+ 0 - 23
web/src/main/resources/application-prod.yml

@@ -192,11 +192,6 @@ jeecg:
     secretKey: ??
     endpoint: oss-cn-beijing.aliyuncs.com
     bucketName: jeecgdev
-  # ElasticSearch 6设置
-  elasticsearch:
-    cluster-name: jeecg-ES
-    cluster-nodes: 127.0.0.1:9200
-    check-enabled: false
   # 在线预览文件服务器地址配置
   file-view-domain: 127.0.0.1:8012
   # minio文件上传
@@ -205,24 +200,6 @@ jeecg:
     minio_name: minioadmin
     minio_pass: minioadmin
     bucketName: exam-bucket
-  #大屏报表参数设置
-  jmreport:
-    mode: dev
-    #数据字典是否进行saas数据隔离,自己看自己的字典
-    saas: false
-    #是否需要校验token
-    is_verify_token: true
-    #必须校验方法
-    verify_methods: remove,delete,save,add,update
-  #分布式锁配置
-  redisson:
-    address: 127.0.0.1:6379
-    password:
-    type: STANDALONE
-    enabled: true
-#cas单点登录
-cas:
-  prefixUrl: http://cas.example.org:8443/cas
 #Mybatis输出sql日志
 logging:
   level: