| | |
| | | package com.java110.order.smo.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.utils.cache.ServiceBusinessCache; |
| | | import com.java110.core.factory.DataTransactionFactory; |
| | | import com.java110.db.dao.IQueryServiceDAO; |
| | | import com.java110.dto.basePrivilege.BasePrivilegeDto; |
| | | import com.java110.entity.center.AppRoute; |
| | | import com.java110.entity.mapping.Mapping; |
| | | import com.java110.entity.order.ServiceBusiness; |
| | | import com.java110.entity.service.ServiceSql; |
| | | import com.java110.order.dao.ICenterServiceDAO; |
| | | import com.java110.order.smo.ICenterServiceCacheSMO; |
| | | import com.java110.utils.cache.AppRouteCache; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.cache.ServiceSqlCache; |
| | | import com.java110.service.context.DataQuery; |
| | | import com.java110.utils.cache.*; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.core.factory.DataTransactionFactory; |
| | | import com.java110.entity.center.AppRoute; |
| | | import com.java110.entity.mapping.Mapping; |
| | | import com.java110.service.context.DataQuery; |
| | | import com.java110.entity.service.ServiceSql; |
| | | import com.java110.db.dao.IQueryServiceDAO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public void flush(DataQuery dataQuery) throws SMOException{ |
| | | |
| | | |
| | | |
| | | //1.0 封装 AppRoute |
| | | flushAppRoute(dataQuery); |
| | | |
| | |
| | | //4.0 刷新业务信息 |
| | | flushServiceBusiness(dataQuery); |
| | | |
| | | //5.0 刷新基础权限 |
| | | flushPrivilege(dataQuery); |
| | | |
| | | dataQuery.setResponseInfo(DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_SUCCESS,"刷新成功")); |
| | | } |
| | | |
| | | /** |
| | | * 根据缓存类别刷新缓存 |
| | | * |
| | | * @param headers 缓存类别 |
| | | */ |
| | | public void flush(Map<String,String> headers) throws SMOException{ |
| | |
| | | |
| | | //4.0 刷新业务信息 |
| | | flushServiceBusiness(headers); |
| | | |
| | | //5.0 刷新基础权限 |
| | | flushPrivilege(headers); |
| | | } |
| | | |
| | | /** |
| | |
| | | doFlushServiceSql(); |
| | | |
| | | doFlushServiceBusiness(); |
| | | |
| | | //5.0 刷新全新 |
| | | doFlushPrivilege(); |
| | | } |
| | | |
| | | |
| | | private void checkCacheParam(DataQuery dataQuery) throws SMOException{ |
| | | JSONObject params = dataQuery.getRequestParams(); |
| | |
| | | throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR,"请求报文错误,未包含字段 "+CommonConstant.CACHE_PARAM_NAME); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 3.0 分装 ServiceSql |
| | | */ |
| | |
| | | doFlushMapping(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 刷新 Mapping 数据 |
| | | */ |
| | | private void flushPrivilege(DataQuery dataQuery) { |
| | | |
| | | JSONObject params = dataQuery.getRequestParams(); |
| | | |
| | | if (!CommonConstant.CACHE_PRIVILEGE.equals(params.getString(CommonConstant.CACHE_PARAM_NAME))) { |
| | | return; |
| | | } |
| | | |
| | | doFlushPrivilege(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新 Mapping 数据 |
| | | */ |
| | | private void flushPrivilege(Map<String, String> headers) { |
| | | |
| | | Assert.hasKey(headers, CommonConstant.CACHE_PARAM, "未包含cache参数" + headers.toString()); |
| | | |
| | | if (!CommonConstant.CACHE_PRIVILEGE.equals(headers.get(CommonConstant.CACHE_PARAM)) |
| | | && !CommonConstant.CACHE_ALL.equals(headers.get(CommonConstant.CACHE_PARAM))) { |
| | | return; |
| | | } |
| | | |
| | | doFlushPrivilege(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新 Mapping 数据 |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | private void doFlushPrivilege() { |
| | | logger.debug("开始刷新 Mapping数据到redis数据库中"); |
| | | List<BasePrivilegeDto> basePrivilegeDtos = centerServiceDAOImpl.getPrivilegeAll(); |
| | | //删除原始数据 |
| | | PrivilegeCache.removeData(PrivilegeCache.DEFAULT_PRIVILEGE); |
| | | PrivilegeCache.setValue(basePrivilegeDtos); |
| | | } |
| | | |
| | | /** |
| | | * 刷新AppRoute数据 |
| | | */ |