Commit d229e043 authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	base-manager/src/main/java/com/mortals/xhx/module/site/model/vo/SiteVo.java
#	base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
#	base-manager/src/main/java/com/mortals/xhx/module/site/web/SiteController.java
#	portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserController.java
parents aebcbd90 ec23f567
......@@ -43,48 +43,49 @@ CREATE TABLE `mortals_sys_area` (
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '区域表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- 站点表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_sys_site`;
CREATE TABLE `mortals_sys_site` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '序号,主键,自增长',
`siteName` varchar(255) DEFAULT NULL COMMENT '站点名称',
`siteCode` varchar(64) DEFAULT NULL COMMENT '站点编号',
`areaID` varchar(32) DEFAULT NULL COMMENT '区域Id',
`areaCode` varchar(32) DEFAULT NULL COMMENT '区域编号',
`areaName` varchar(32) DEFAULT NULL COMMENT '区域名称',
`proCode` varchar(32) DEFAULT NULL COMMENT '省编码',
`cityCode` varchar(32) DEFAULT NULL COMMENT '市编码',
`districtCode` varchar(32) DEFAULT NULL COMMENT '区编码',
`siteIp` varchar(32) DEFAULT NULL COMMENT '站点服务器ip',
`sitePort` varchar(8) DEFAULT NULL COMMENT '站点服务器端口',
`longitude` varchar(32) DEFAULT NULL COMMENT '经度',
`latitude` varchar(32) DEFAULT NULL COMMENT '纬度',
`siteTel` varchar(32) DEFAULT NULL COMMENT '中心联系电话',
`detailAddress` varchar(255) DEFAULT NULL COMMENT '中心详细地址',
`siteRemark` text COMMENT '中心介绍',
`amWorkStartTime` datetime DEFAULT NULL COMMENT '上午上班开始时间',
`amWorkEndTime` datetime DEFAULT NULL COMMENT '上午上班结束时间',
`pmWorkStartTime` datetime DEFAULT NULL COMMENT '下午上班开始时间',
`pmWorkEndTime` datetime DEFAULT NULL COMMENT '下午上班结束时间',
`workday1` tinyint(2) DEFAULT '1' COMMENT '周一 (1.上班,0.不上)',
`workday2` tinyint(2) DEFAULT '1' COMMENT '周二 (1.上班,0.不上)',
`workday3` tinyint(2) DEFAULT '1' COMMENT '周三 (1.上班,0.不上)',
`workday4` tinyint(2) DEFAULT '1' COMMENT '周四 (1.上班,0.不上)',
`workday5` tinyint(2) DEFAULT '1' COMMENT '周五 (1.上班,0.不上)',
`workday6` tinyint(2) DEFAULT '0' COMMENT '周六 (1.上班,0.不上)',
`workday7` tinyint(2) DEFAULT '0' COMMENT '周日 (1.上班,0.不上)',
`level` int(4) DEFAULT 1 COMMENT '楼层',
`building` int(4) DEFAULT 1 COMMENT '楼栋',
`modelIds` varchar(256) DEFAULT '' COMMENT '部署模块,逗号分隔',
`createTime` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`createUserId` bigint(20) DEFAULT NULL COMMENT '创建用户',
`updateTime` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '站点表' ROW_FORMAT = Dynamic;
CREATE TABLE mortals_sys_site(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`siteName` varchar(255) COMMENT '站点名称',
`siteCode` varchar(64) COMMENT '站点编号',
`areaID` varchar(32) COMMENT '区域Id',
`areaCode` varchar(32) COMMENT '区域编号',
`areaName` varchar(32) COMMENT '区域名称',
`proCode` varchar(32) COMMENT '省编码',
`cityCode` varchar(32) COMMENT '市编码',
`districtCode` varchar(32) COMMENT '区编码',
`siteIp` varchar(32) COMMENT '站点服务器ip',
`sitePort` varchar(8) COMMENT '站点服务器端口',
`longitude` varchar(32) COMMENT '经度',
`latitude` varchar(32) COMMENT '纬度',
`siteTel` varchar(32) COMMENT '中心联系电话',
`detailAddress` varchar(255) COMMENT '中心详细地址',
`siteRemark` text COMMENT '中心介绍',
`amWorkStartTime` datetime COMMENT '上午上班开始时间',
`amWorkEndTime` datetime COMMENT '上午上班结束时间',
`pmWorkStartTime` datetime COMMENT '下午上班开始时间',
`pmWorkEndTime` datetime COMMENT '下午上班结束时间',
`workday1` tinyint(2) COMMENT '周一 (1.上班,0.不上)',
`workday2` tinyint(2) COMMENT '周二 (1.上班,0.不上)',
`workday3` tinyint(2) COMMENT '周三 (1.上班,0.不上)',
`workday4` tinyint(2) COMMENT '周四 (1.上班,0.不上)',
`workday5` tinyint(2) COMMENT '周五 (1.上班,0.不上)',
`workday6` tinyint(2) COMMENT '周六 (1.上班,0.不上)',
`workday7` tinyint(2) COMMENT '周日 (1.上班,0.不上)',
`level` int(4) COMMENT '楼层',
`building` int(4) COMMENT '楼栋',
`logoPath` varchar(255) COMMENT 'logo图片地址',
`englishName` varchar(255) COMMENT '英文名称',
`modelIds` varchar(256) COMMENT '部署模块,逗号分隔',
`createTime` datetime COMMENT '创建时间',
`createUserId` bigint(20) COMMENT '创建用户',
`updateTime` datetime COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='站点';
-- ----------------------------
......
......@@ -905,6 +905,9 @@ data|object|数据对象|-
  level|Integer|楼层|-
  building|Integer|楼栋|-
  modelIds|String|部署模块,逗号分隔|-
  logoPath|String|设备logo地址
  logoFullPath|String|设备logo全地址
  englishName|String|站点英文名称
  createTime|Date|创建时间|-
  createUserId|Long|创建用户|-
  updateTime|Date|修改时间|-
......@@ -1072,6 +1075,9 @@ data|object|数据对象|-
 workday7|Integer|周日 (1.上班,0.不上)|-
 level|Integer|楼层|-
 building|Integer|楼栋|-
 logoPath|String|设备logo地址
 logoFullPath|String|设备logo全地址
 englishName|String|站点英文名称
 modelIds|String|部署模块,逗号分隔|-
 createTime|Date|创建时间|-
 createUserId|Long|创建用户|-
......@@ -1134,6 +1140,8 @@ workday6|Integer|周六 (1.上班,0.不上)|是|-
workday7|Integer|周日 (1.上班,0.不上)|是|-
level|Integer|楼层|是|-
building|Integer|楼栋|是|-
logoPath|String|是|设备logo地址
englishName|String|是|站点英文名称
modelIds|String|部署模块,逗号分隔|是|-
**请求样例:**
......
......@@ -51,7 +51,7 @@ public class WebLogAspect {
public void doBefore(JoinPoint joinPoint) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
// log.debug("请求路径 {} ,进入方法 {}", request.getRequestURI(), joinPoint.getSignature().getDeclaringTypeName() + ":" + joinPoint.getSignature().getName());
// log.debug("请求路径 {} ,进入方法 {}", request.getRequestURI(), joinPoint.getSignature().getDeclaringTypeName() + ":" + joinPoint.getSignature().getName());
MDC.put("req", getRequestInfo(request).toJSONString());
MDC.put("startTime", String.valueOf(System.currentTimeMillis()));
}
......@@ -64,12 +64,19 @@ public class WebLogAspect {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
Map<String, String> map = MDC.getCopyOfContextMap();
if (map != null&&result!=null) {
if (map != null && result != null) {
String startTime = map.getOrDefault("startTime", String.valueOf(System.currentTimeMillis()));
long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime));
log.info(" \n 请求路径:{} \n 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), result == null ? "" : result.toString());
if (result instanceof String) {
log.info(" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), result);
} else {
log.info(" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), JSON.toJSONString(result));
}
}
}
......
......@@ -21,6 +21,7 @@ public class CrossInterceptor extends HandlerInterceptorAdapter {
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Content-Type", "true");
return true;
}
}
......@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -39,12 +40,19 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
response.setContentType("application/json");
JSONObject ret = new JSONObject();
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
if(handler instanceof HandlerMethod){
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
}else if(handler instanceof ResourceHttpRequestHandler){
return true;
}
try {
......
package com.mortals.xhx.base.login.interceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.model.CookieInfo;
......@@ -9,13 +9,15 @@ import com.mortals.framework.util.AESUtil;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
@Order(1)
//@Component
public class AuthJsonInterceptor extends BaseInterceptor {
......@@ -35,13 +37,17 @@ public class AuthJsonInterceptor extends BaseInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
try {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限
if (config.needCheckAuth(uri)) {
//需要校验权限
boolean auth = this.checkAuth(request, uri, config.getSecurityKey());
if (!auth) {
//不存在时候 如果是管理员也不做拦截
CookieInfo cookie = CookieService.getLoginCookie(request, config.getSecurityKey());
if (cookie == null || cookie.getUser() == null) {
writeJsonResponse(response, HttpServletResponse.SC_FORBIDDEN, "用户未登录或登录失效,请重新登录");
......
......@@ -63,4 +63,11 @@ public final class Constant {
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
/**
* 服务器http
*/
public final static String PARAM_SERVER_HTTP_IMAGE_URL = "server_http_image_url";
}
......@@ -10,6 +10,7 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.utils.SyncTreeSiteThread;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,11 +27,9 @@ import java.util.List;
* 应用场景:
* 1、应用任务,应用启动后定时或间隔执行的任务
* 2、Socket服务端
*
* @author GM
* @date 2020年7月15日
*/
@Component
@Slf4j
public class DemoStartedService implements IApplicationStartedService {
private static Log logger = LogFactory.getLog(DemoStartedService.class);
......
......@@ -3,12 +3,11 @@ package com.mortals.xhx.module.site.model;
import com.mortals.xhx.module.site.model.vo.SiteVo;
import java.util.Date;
/**
* 站点实体对象
*
* @author zxfei
* @date 2022-01-21
* @date 2022-06-29
*/
public class SiteEntity extends SiteVo {
......@@ -126,6 +125,14 @@ public class SiteEntity extends SiteVo {
* 楼栋
*/
private Integer building;
/**
* logo图片地址
*/
private String logoPath;
/**
* 英文名称
*/
private String englishName;
/**
* 部署模块,逗号分隔
*/
......@@ -526,6 +533,34 @@ public class SiteEntity extends SiteVo {
public void setBuilding(Integer building){
this.building = building;
}
/**
* 获取 logo图片地址
* @return String
*/
public String getLogoPath(){
return logoPath;
}
/**
* 设置 logo图片地址
* @param logoPath
*/
public void setLogoPath(String logoPath){
this.logoPath = logoPath;
}
/**
* 获取 英文名称
* @return String
*/
public String getEnglishName(){
return englishName;
}
/**
* 设置 英文名称
* @param englishName
*/
public void setEnglishName(String englishName){
this.englishName = englishName;
}
/**
* 获取 部署模块,逗号分隔
* @return String
......@@ -590,15 +625,17 @@ public class SiteEntity extends SiteVo {
sb.append(",workday7:").append(getWorkday7());
sb.append(",level:").append(getLevel());
sb.append(",building:").append(getBuilding());
sb.append(",logoPath:").append(getLogoPath());
sb.append(",englishName:").append(getEnglishName());
sb.append(",modelIds:").append(getModelIds());
return sb.toString();
}
public void initAttrValue(){
this.siteName = null;
this.siteName = "";
this.siteCode = null;
this.siteCode = "";
this.areaID = null;
......@@ -652,6 +689,10 @@ public class SiteEntity extends SiteVo {
this.building = 1;
this.logoPath = "";
this.englishName = "";
this.modelIds = "";
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.mortals.xhx.module.site.model.SiteEntity;
* 站点查询对象
*
* @author zxfei
* @date 2022-01-21
* @date 2022-06-29
*/
public class SiteQuery extends SiteEntity {
/** 开始 序号,主键,自增长 */
......@@ -199,6 +199,12 @@ public class SiteQuery extends SiteEntity {
/** 楼栋列表 */
private List <Integer> buildingList;
/** logo图片地址 */
private List<String> logoPathList;
/** 英文名称 */
private List<String> englishNameList;
/** 部署模块,逗号分隔 */
private List<String> modelIdsList;
......@@ -1227,6 +1233,36 @@ public class SiteQuery extends SiteEntity {
this.buildingList = buildingList;
}
/**
* 获取 logo图片地址
* @return logoPathList
*/
public List<String> getLogoPathList(){
return this.logoPathList;
}
/**
* 设置 logo图片地址
* @param logoPathList
*/
public void setLogoPathList(List<String> logoPathList){
this.logoPathList = logoPathList;
}
/**
* 获取 英文名称
* @return englishNameList
*/
public List<String> getEnglishNameList(){
return this.englishNameList;
}
/**
* 设置 英文名称
* @param englishNameList
*/
public void setEnglishNameList(List<String> englishNameList){
this.englishNameList = englishNameList;
}
/**
* 获取 部署模块,逗号分隔
* @return modelIdsList
......@@ -2110,6 +2146,44 @@ public class SiteQuery extends SiteEntity {
}
/**
* 设置 logo图片地址
* @param logoPath
*/
public SiteQuery logoPath(String logoPath){
setLogoPath(logoPath);
return this;
}
/**
* 设置 logo图片地址
* @param logoPathList
*/
public SiteQuery logoPathList(List<String> logoPathList){
this.logoPathList = logoPathList;
return this;
}
/**
* 设置 英文名称
* @param englishName
*/
public SiteQuery englishName(String englishName){
setEnglishName(englishName);
return this;
}
/**
* 设置 英文名称
* @param englishNameList
*/
public SiteQuery englishNameList(List<String> englishNameList){
this.englishNameList = englishNameList;
return this;
}
/**
* 设置 部署模块,逗号分隔
* @param modelIds
......
......@@ -25,6 +25,11 @@ public class SiteTreeSelect implements Serializable {
*/
private String id;
/**
* 站点编码
*/
private String siteCode;
/**
* 节点名称
*/
......@@ -38,6 +43,15 @@ public class SiteTreeSelect implements Serializable {
*/
private Boolean isLeaf;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
/**
* 节点类型
*/
......@@ -76,8 +90,11 @@ public class SiteTreeSelect implements Serializable {
if (!ObjectUtils.isEmpty(collect)) {
this.id = collect.stream().map(item -> item.getId().toString()).collect(Collectors.joining(","));
this.label = collect.stream().map(item -> item.getSiteName()).collect(Collectors.joining(","));
this.siteCode = collect.stream().map(item -> item.getSiteCode()).collect(Collectors.joining(","));
this.type = "site";
this.icon = "el-icon-document";
this.longitude = collect.stream().findFirst().map(item -> item.getLongitude()).orElseGet(() -> "");
this.latitude = collect.stream().findFirst().map(item -> item.getLatitude()).orElseGet(() -> "");
} else {
this.id = entity.getIid();
this.label = entity.getName();
......@@ -103,6 +120,9 @@ public class SiteTreeSelect implements Serializable {
this.type = "site";
this.icon = "el-icon-document";
this.longitude = entity.getLongitude();
this.latitude = entity.getLatitude();
}
}
\ No newline at end of file
package com.mortals.xhx.module.site.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.model.model.ModelEntity;
import com.mortals.xhx.module.site.model.SiteEntity;
......@@ -6,16 +7,15 @@ import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 站点视图对象
*
* @author zxfei
* @date 2022-01-12
*/
* 站点视图对象
*
* @author zxfei
* @date 2022-01-12
*/
@Data
public class SiteVo extends BaseEntityLong {
private List<Long> idList;
/** 站点包含的模块 */
private List<ModelEntity> modelList;
}
\ No newline at end of file
......@@ -49,10 +49,19 @@ public interface SiteService extends ICRUDCacheService<SiteEntity, Long> {
List<SiteEntity> getFlatSitesByAreaCode(String areaCode,Context context);
/**
* 根据Site获取子站点
*
* @param context
* @return
*/
List<SiteEntity> getFlatSitesBySiteId(Long siteId,Context context);
void setSiteTree(List<SiteTreeSelect> list, Context context);
List<SiteEntity> getListAllInfoByQuery(SiteQuery query,Context context) throws AppException;
void changeUrlPath(SiteEntity siteEntity);
}
\ No newline at end of file
package com.mortals.xhx.module.site.service.impl;
import cn.hutool.core.util.URLUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.SyncTreeSiteThread;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.model.AreaTreeSelect;
import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.model.model.ModelEntity;
import com.mortals.xhx.module.model.model.ModelQuery;
import com.mortals.xhx.module.model.service.ModelService;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import lombok.Getter;
import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.site.dao.SiteDao;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteService;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL;
/**
* SiteService
* 站点 service实现
......@@ -210,27 +206,51 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
throw new AppException(String.format("区域不存在!区域编码:%s", areaCode));
}
List<SiteEntity> siteEntities = this.find(new SiteQuery());
List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
for (SiteEntity siteEntity : siteEntities) {
boolean bool = getSite(areaCode,siteEntity.getAreaCode(), siteList, siteEntity);
boolean bool = getSite(areaCode, siteEntity.getAreaCode(), siteList, siteEntity);
if (bool) continue;
}
return siteList;
}
@Override
public List<SiteEntity> getFlatSitesBySiteId(Long siteId, Context context) {
List<SiteEntity> siteList = new ArrayList<>();
if (ObjectUtils.isEmpty(siteId)) {
throw new AppException("站点Id不能为空!");
}
SiteEntity siteCache = this.getCache(siteId.toString());
if (ObjectUtils.isEmpty(siteCache)) {
throw new AppException("站点不存在,siteId:" + siteId);
}
AreaEntity areaEntity = areaService.getExtCache(siteCache.getAreaCode());
if (ObjectUtils.isEmpty(areaEntity)) {
throw new AppException(String.format("区域不存在!区域编码:%s", siteCache.getAreaCode()));
}
List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
;
for (SiteEntity siteEntity : siteEntities) {
boolean bool = getSite(siteCache.getAreaCode(), siteEntity.getAreaCode(), siteList, siteEntity);
if (bool) continue;
}
return siteList;
}
private boolean getSite(String rootAreaCode,String areaCode, List<SiteEntity> siteList, SiteEntity siteEntity) {
// AreaEntity areaTemp = areaService.getExtCache(siteEntity.getAreaCode());
private boolean getSite(String rootAreaCode, String areaCode, List<SiteEntity> siteList, SiteEntity siteEntity) {
// AreaEntity areaTemp = areaService.getExtCache(siteEntity.getAreaCode());
if (rootAreaCode.equals(areaCode)) {
siteList.add(siteEntity);
log.info("add site:{}", siteEntity.getSiteCode());
return true;
} else {
AreaEntity areaTemp = areaService.getExtCache(areaCode);
if (!ObjectUtils.isEmpty(areaTemp.getPid())) {
if (!ObjectUtils.isEmpty(areaTemp)&&!ObjectUtils.isEmpty(areaTemp.getPid())) {
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().iid(areaTemp.getPid()));
if (!ObjectUtils.isEmpty(areaEntity)) {
return getSite(rootAreaCode,areaEntity.getAreaCode(), siteList, siteEntity);
return getSite(rootAreaCode, areaEntity.getAreaCode(), siteList, siteEntity);
}
}
return false;
......@@ -242,24 +262,24 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
siteTreeMap.put(context.getUser().getId(), list);
}
@Override
public List<SiteEntity> getListAllInfoByQuery(SiteQuery query, Context context) throws AppException {
List<SiteEntity> list = this.find(query,context);
if(CollectionUtils.isNotEmpty(list)){
list.stream().forEach(item->{
ModelQuery modelQuery = new ModelQuery();
List<String> modelIds = StringUtils.converStr2List(item.getModelIds());
List<Long> ids = modelIds.stream().map(s -> DataUtil.converStr2Long(s.trim(),0)).collect(Collectors.toList());
if(ids.isEmpty()){
ids.add(0l);
}
modelQuery.setIdList(ids);
List<ModelEntity> modelEntityList = modelService.find(modelQuery);
item.setModelList(modelEntityList);
});
protected void findAfter(SiteEntity params, PageInfo pageInfo, Context context, List<SiteEntity> list) throws AppException {
list.stream().forEach(site -> changeUrlPath(site));
super.findAfter(params, pageInfo, context, list);
}
@Override
public void changeUrlPath(SiteEntity siteEntity) {
if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_IMAGE_URL, "http://192.168.0.98:11091");
String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath());
siteEntity.setLogoFullPath(fullPath);
}
return list;
if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getModelIds())) {
List<ModelEntity> collect = Arrays.asList(siteEntity.getModelIds().split(",")).stream().map(modelId -> modelService.get(Long.parseLong(modelId))).collect(Collectors.toList());
siteEntity.setModelList(collect);
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package com.mortals.xhx.module.site.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
......@@ -126,7 +125,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Map<String, Object> model = new HashMap<>();
String busiDesc = "根据区域编码查询站点列表" + this.getModuleDesc();
try {
String siteIds = site.getAreaIDList().stream().flatMap(areaId ->
String siteIds = site.getAreaCodeList().stream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).map(item -> item.getId().toString()).distinct().collect(Collectors.joining(","));
......@@ -143,35 +142,38 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
}
/**
* 条件查询,无分页信息
* @param query
* @return
* 根据站点id查询站点列表子集,包含当前站点
*/
@PostMapping({"list/noPage"})
@PostMapping(value = "getFlatSitesBySiteId")
@UnAuth
public Rest<Object> getList(@RequestBody SiteQuery query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code=1;
public String getFlatSitesBySiteId(@RequestBody SiteQuery site) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = "根据站点id查询站点列表子集" + this.getModuleDesc();
try {
List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
List<SiteEntity> siteEntityList = this.service.getFlatSitesBySiteId(site.getId(), getContext());
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, siteEntityList);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc+"成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
//this.init(model, context);
ret.setCode(code);
ret.setData(model);
//ret.setDict(model.remove("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
return jsonObject.toJSONString();
}
@Override
protected int infoAfter(Long id, Map<String, Object> model, SiteEntity entity, Context context) throws AppException {
this.service.changeUrlPath(entity);
return super.infoAfter(id, model, entity, context);
}
public static void main(String[] args) {
//深度克隆
/**
* 包含站点下面的模块以及模块下面的数据统计
* @param query
......
......@@ -11,9 +11,11 @@ spring:
max-file-size: 500MB
max-request-size: 5000MB
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
serialization:
WRITE_DATES_AS_TIMESTAMPS: true
default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
dao:
exceptiontranslation:
enabled: false
......
......@@ -6,6 +6,6 @@
"baseUrl": "http://192.168.0.217:17211/base"
},
"base-test": {
"baseUrl": "http://192.168.0.98:11071/zwfw"
"baseUrl": "http://192.168.0.98:11078/base"
}
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
* @author: zxfei
* @date: 2022/5/30 10:40
*/
@FeignClient(name = "base-manager", path = "/zwfw", fallback = AreaFeignFallbackFactory.class)
@FeignClient(name = "base-manager", path = "/base", fallback = AreaFeignFallbackFactory.class)
public interface IApiAreaFeign extends IFeign {
......
package com.mortals.xhx.feign.user;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.feign.req.BaseUserQuery;
import com.mortals.xhx.feign.req.BaseUserReq;
import com.mortals.xhx.feign.rsp.ApiResp;
import com.mortals.xhx.feign.rsp.UserRsp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 用户服务
*
* @author: zxfei
* @date: 2022/5/30 10:40
*/
@FeignClient(name = "portal-manager", path = "/zwfw", fallback = UserFeignFallbackFactory.class)
public interface IApiUserFeign extends IFeign {
/**
* 查询用户列表
*
* @param req
* @return
*/
@PostMapping("/api/user/findAllUser")
ApiResp<UserRsp> findAllUser(@RequestBody BaseUserReq<BaseUserQuery> req);
}
@Slf4j
@Component
class UserFeignFallbackFactory implements FallbackFactory<IApiUserFeign> {
@Override
public IApiUserFeign create(Throwable t) {
return new IApiUserFeign() {
@Override
public ApiResp<UserRsp> findAllUser(BaseUserReq<BaseUserQuery> req) {
ApiResp<UserRsp> failResp = new ApiResp<>();
failResp.setCode(ApiRespCodeEnum.FAILED.getValue());
failResp.setMsg("暂时无法获取站点列表,请稍后再试!");
return failResp;
}
};
}
}
\ No newline at end of file
package com.mortals.xhx.feign.user;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
/**
* 用户信息业务 Feign接口
* @author zxfei
* @date 2022-07-06
*/
@FeignClient(name = "portal-manager", path = "/zwfw", fallback = UserFeignFallbackFactory.class)
public interface IUserFeign extends IFeign {
/**
* 查看用户信息业务列表
*
* @param userPdu
* @return
*/
@PostMapping(value = "/user/list")
String list(@RequestBody UserPdu userPdu);
/**
* 查看用户信息业务
*
* @param id
* @return
*/
@GetMapping(value = "/user/info")
String info(@RequestParam(value = "id") Long id);
/**
* 删除用户信息业务
*
* @param ids
* @return
*/
@GetMapping(value = "/user/delete")
String delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 用户信息业务保存更新
*
* @param userPdu
* @return
*/
@PostMapping(value = "/user/save")
String save(@RequestBody UserPdu userPdu,@RequestHeader("Authorization") String authorization);
/**
* 查询用户列表
*
* @param userPdu
* @return
*/
@PostMapping("/api/user/findAllUser")
String findAllUser(@RequestBody UserPdu userPdu);
}
@Slf4j
@Component
class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
@Override
public IUserFeign create(Throwable t) {
return new IUserFeign() {
@Override
public String list(UserPdu userPdu) {
return JSON.toJSONString(Rest.fail("暂时无法获取用户信息业务列表,请稍后再试!"));
}
@Override
public String info(Long id) {
return JSON.toJSONString(Rest.fail("暂时无法获取用户信息业务详细,请稍后再试!"));
}
@Override
public String delete(Long[] ids, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法删除用户信息业务,请稍后再试!"));
}
@Override
public String save(UserPdu userPdu, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法保存用户信息业务,请稍后再试!"));
}
@Override
public String findAllUser(UserPdu userPdu) {
return JSON.toJSONString(Rest.fail("暂时无法获取用户信息业务列表,请稍后再试!"));
}
};
}
}
package com.mortals.xhx.base.framework.interceptor;
import com.alibaba.druid.support.http.ResourceServlet;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.service.IAuthTokenService;
......@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -50,6 +52,8 @@ public class AuthUserInterceptor extends BaseInterceptor {
//取消校验
return true;
}
}else if(handler instanceof ResourceHttpRequestHandler){
return true;
}
String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限
......
package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
......@@ -10,6 +13,7 @@ import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.req.BaseUserQuery;
import com.mortals.xhx.feign.req.BaseUserReq;
import com.mortals.xhx.feign.rsp.UserRsp;
import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.model.UserQuery;
import com.mortals.xhx.module.user.service.UserService;
import lombok.extern.apachecommons.CommonsLog;
......@@ -21,9 +25,13 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.mortals.framework.ap.SysConstains.PAGEINFO_KEY;
/**
* 用户对外服务接口
*
......@@ -39,42 +47,32 @@ public class UserApiController {
/**
* 用户列表
* @param req
* @param userPdu
* @return
*/
@PostMapping("/findAllUser")
public ApiResp<UserRsp> findAllUser(@RequestBody BaseUserReq<BaseUserQuery> req) {
ApiResp<UserRsp> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
public String findAllUser(@RequestBody UserEntity userPdu) {
Rest<Object> rest = Rest.ok("获取列表成功");
PageInfo page = new PageInfo();
page.setPrePageResult(-1);
UserRsp userRsp = new UserRsp();
try {
if (!ObjectUtils.isEmpty(req.getPage())) {
page.setPrePageResult(req.getPage().getPer() == 0 ? -1 : req.getPage().getPer());
page.setCurrPage(req.getPage().getSize() == 0 ? 1 : req.getPage().getSize());
if (!ObjectUtils.isEmpty(userPdu.getPage())) {
page.setPrePageResult(userPdu.getSize() );
page.setCurrPage(userPdu.getPage());
}
Result<UserEntity> result = userService.find(userPdu, page, null);
Map<String, Object> model = new HashMap<>();
model.put("data", result.getList());
model.put(PAGEINFO_KEY, result.getPageInfo());
rest.setData(model);
UserQuery userQuery = new UserQuery();
BeanUtils.copyProperties(req.getQuery(), userQuery, BeanUtil.getNullPropertyNames(req.getQuery()));
List<UserPdu> collect = userService.find(userQuery, page, null).getList().stream().map(item -> {
UserPdu userPdu = new UserPdu();
BeanUtils.copyProperties(item, userPdu, BeanUtil.getNullPropertyNames(item));
return userPdu;
}).collect(Collectors.toList());
userRsp.setList(collect);
userRsp.setPage(req.getPage());
} catch (Exception e) {
log.error("获取用户列表异常", e);
rsp.setCode(YesNoEnum.NO.getValue());
rsp.setMsg(e.getMessage());
return rsp;
rest.setCode(YesNoEnum.NO.getValue());
rest.setMsg(e.getMessage());
}
rsp.setData(userRsp);
log.info("响应【用户列表】【响应体】--> " + JSONObject.toJSONString(rsp));
return rsp;
log.info("响应【用户列表】【响应体】--> " + JSONObject.toJSONString(rest));
return JSON.toJSONString(rest);
}
}
......@@ -96,6 +96,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
}
@Override
@UnAuth
public Rest<Object> list(UserEntity query) {
Map<String, Object> model = new HashMap();
Rest<Object> ret = new Rest<>();
......@@ -108,6 +109,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
Result result = this.getService().findExt(query, pageInfo, context);
model.put("data", result.getList());
model.put("pageInfo", result.getPageInfo());
super.parsePageInfo(model,result.getPageInfo());
this.parsePageInfo(model, result.getPageInfo());
code = this.doListAfter(query, model, context);
this.recordSysLog(this.request, busiDesc + " 【成功】");
......@@ -119,7 +121,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get(KEY_RESULT_DICT)==null?null:(Map<String,Object>)model.remove(KEY_RESULT_DICT));
ret.setDict(model.get(KEY_RESULT_DICT));
ret.setMsg(model.get(MESSAGE_INFO)==null?"":model.remove(MESSAGE_INFO).toString());
return ret;
}
......
......@@ -11,8 +11,11 @@ spring:
max-file-size: 500MB
max-request-size: 5000MB
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
serialization:
WRITE_DATES_AS_TIMESTAMPS: true
default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
dao:
exceptiontranslation:
enabled: false
......
......@@ -6,6 +6,6 @@
"baseUrl": "http://192.168.0.217:17212/zwfw"
},
"portal-test": {
"baseUrl": "http://192.168.0.98:11072/zwfw"
"baseUrl": "http://192.168.0.98:11078/zwfw"
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@
</activation>
<properties>
<profiles.active>develop</profiles.active>
<profiles.server.port>17213</profiles.server.port>
<profiles.server.port>17214</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
......@@ -37,7 +37,7 @@
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.server.port>17213</profiles.server.port>
<profiles.server.port>17214</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
......@@ -52,7 +52,7 @@
<id>product</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.server.port>17213</profiles.server.port>
<profiles.server.port>17214</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.kafka.brokers>192.168.0.100:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.100</profiles.rabbitmq.host>
......@@ -156,7 +156,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<outputDirectory>${project.parent.basedir}/dist/${project.parent.artifactId}/boot</outputDirectory>
<outputDirectory>${project.basedir}/dist/${project.artifactId}/boot</outputDirectory>
<layout>ZIP</layout>
</configuration>
</plugin>
......
#! /bin/sh
PORT="17211"
PORT="@profiles.server.port@"
BASEDIR=`dirname $0`
BASEDIR=`(cd "$BASEDIR"; pwd)`
PROJECT_NAME="appbuild-manager"
PROJECT_NAME="@project.artifactId@"
MAIN_CLASS="$PROJECT_NAME";
if [ ! -n "$PORT" ]; then
......@@ -19,7 +19,7 @@ fi
echo "stoping application $PROJECT_NAME......"
kill ${pid}
kill -9 ${pid}
echo "Send shutdown request to Server $PROJECT_NAME OK"
......
package com.mortals.xhx.base.framework.config;
import com.mortals.xhx.base.framework.handler.SentinelFallbackHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
......@@ -18,11 +17,11 @@ import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@EnableWebFluxSecurity
public class GatewayConfig {
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
return new SentinelFallbackHandler();
}
// @Bean
// @Order(Ordered.HIGHEST_PRECEDENCE)
// public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
// return new SentinelFallbackHandler();
// }
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
......
......@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
* @author: zxfei
* @date: 2022/6/17 15:18
*/
@Configuration
//@Configuration
public class AuthFilter {
/**
......
......@@ -16,7 +16,7 @@ import java.util.regex.Pattern;
* @author: zxfei
* @date: 2022/6/20 16:49
*/
@Component
//@Component
public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> {
@Override
public GatewayFilter apply(Config config) {
......
......@@ -14,7 +14,7 @@ import reactor.core.publisher.Mono;
* @author: zxfei
* @date: 2022/6/20 16:57
*/
@Component
//@Component
public class ForwardAuthFilter implements GlobalFilter {
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
......
......@@ -15,7 +15,7 @@ import reactor.core.publisher.Mono;
* @author: zxfei
* @date: 2022/6/20 16:59
*/
@Component
//@Component
public class GlobalCacheRequestFilter implements GlobalFilter, Ordered {
@Override
......
......@@ -32,7 +32,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.G
* @date: 2022/6/20 17:00
*/
@Slf4j
@Component
//@Component
public class GlobalLogFilter implements GlobalFilter, Ordered {
@Autowired
......
......@@ -19,18 +19,22 @@ public class SentinelFallbackHandler implements WebExceptionHandler {
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
ex.printStackTrace();
// TODO: 2022/7/6
return Mono.error(ex);
/* ex.printStackTrace();
if (exchange.getResponse().isCommitted()) {
return Mono.error(ex);
}
return null;
/* if (!BlockException.isBlockException(ex)) {
if (!BlockException.isBlockException(ex)) {
return Mono.error(ex);
}
return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));*/
return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));
*/
}
/* private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable) {
/*private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable) {
return GatewayCallbackManager.getBlockHandler().handleRequest(exchange, throwable);
}*/
}
......@@ -98,7 +98,6 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
String verifyKey = Constant.CAPTCHA_CODE_KEY + uuid;
String captcha = cacheService.get(verifyKey);
cacheService.del(verifyKey);
// RedisUtils.deleteObject(verifyKey);
if (!code.equalsIgnoreCase(captcha)) {
throw new CaptchaException();
}
......
......@@ -16,6 +16,14 @@ spring:
cloud:
# 网关配置
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods: "*"
default-filters:
- DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
httpclient:
connect-timeout: 1000
response-timeout: 5s
......@@ -34,6 +42,17 @@ spring:
- Path=/base/**
# filters:
# - StripPrefix=1
# 门户服务
- id: portal-manager
# uri: http://127.0.0.1:17211
uri: lb://portal-manager
predicates:
- Path=/zwfw/**
# 设备管理服务
- id: device-manager
uri: lb://device-manager
predicates:
- Path=/m/**
nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery:
......
<?xml version="1.0" encoding="utf-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 定义变量后,可以使“${}”来使用变量 source来源为spring 上下文信息 -->
<springProperty scope="context" name="springApplicationName" source="spring.application.name"/>
<springProperty scope="context" name="serverPort" source="server.port"/>
<springProperty scope="context" name="logFilePath" source="application.log.path" defaultValue="/mortals/www.iot.com/logs" />
<springProperty scope="context" name="logFilePath" source="application.log.path" defaultValue="/mortals/app/logs" />
<springProperty scope="context" name="logLevel" source="application.log.level" defaultValue="INFO" />
<property name="logFilePath" value="${logFilePath:-/mortals/www.iot.com/logs}" />
<property name="logLevel" value="${logLevel:-INFO}" />
<!-- appender用来格式化日志输出节点,有俩个属性name和class,class用来指定哪种输出策略,常用就是控制台输出策略和文件输出策略 -->
<!-- 控制台输出策略-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%X{traceId}] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
</encoder>
</appender>
<!-- 文件输出策略-->
<appender name="fileInfo" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%X{traceId}] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
</encoder>
<file>${logFilePath}/${springApplicationName:-default}/${serverPort:-default}-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件保存策略-->
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${serverPort:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</appender>
<!-- 异常文件输出策略-->
<appender name="fileError" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%X{traceId}] [%thread] [%.50c\(%L\)] - %msg%n</pattern>
</encoder>
<file>${logFilePath}/${springApplicationName:-default}/${serverPort:-default}-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${serverPort:-default}-error.log.%d{yyyyMMdd}</fileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</appender>
<root level="${logLevel}">
<appender-ref ref="console"/>
<appender-ref ref="fileInfo"/>
<appender-ref ref="fileError"/>
</root>
<!--TRACE < DEBUG < INFO < WARN < ERROR < FATAL -->
<!--用来设置某一个包或者具体的某一个类的日志打印级别、以及指定<appender>。<logger>仅有一个name属性,一个可选的level和一个可选的additivity属性。-->
<!-- name 用来指定受此loger约束的某一个包或者具体的某一个类-->
<!-- level 用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。如果未设置此属性,那么当前logger将会继承上级的级别-->
<!-- additivity 是否向上级logger传递打印信息。默认是true。false:表示只用当前logger的appender-ref。true:表示当前logger的appender-ref和rootLogger的appender-ref都有效。-->
<logger name="com.mortals" level="INFO" additivity="false">
<appender-ref ref="console"/>
<appender-ref ref="fileInfo"/>
<appender-ref ref="fileError"/>
</logger>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment