*
* @author geekidea
- * @since 2019-10-05
+ * @since 2019-10-11
*/
public interface SysLogService extends BaseService {
@@ -45,9 +29,9 @@ public interface SysLogService extends BaseService {
/**
* 获取分页对象
*
- * @param SysLogQueryParam
+ * @param sysLogQueryParam
* @return
*/
- Paging getSysLogPageList(SysLogQueryParam SysLogQueryParam) throws Exception;
+ Paging getSysLogPageList(SysLogQueryParam sysLogQueryParam) throws Exception;
}
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/SysUserService.java b/src/main/java/io/geekidea/springbootplus/system/service/SysUserService.java
index c328ca30..c9622aa9 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/SysUserService.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/SysUserService.java
@@ -1,26 +1,10 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
package io.geekidea.springbootplus.system.service;
import io.geekidea.springbootplus.system.entity.SysUser;
import io.geekidea.springbootplus.common.service.BaseService;
-import io.geekidea.springbootplus.system.web.param.SysUserQueryParam;
-import io.geekidea.springbootplus.system.web.vo.SysUserQueryVo;
-import io.geekidea.springbootplus.common.web.vo.Paging;
+import io.geekidea.springbootplus.system.param.SysUserQueryParam;
+import io.geekidea.springbootplus.system.vo.SysUserQueryVo;
+import io.geekidea.springbootplus.common.vo.Paging;
import java.io.Serializable;
@@ -30,7 +14,7 @@
*
*
* @author geekidea
- * @since 2019-10-05
+ * @since 2019-10-11
*/
public interface SysUserService extends BaseService {
@@ -45,9 +29,9 @@ public interface SysUserService extends BaseService {
/**
* 获取分页对象
*
- * @param SysUserQueryParam
+ * @param sysUserQueryParam
* @return
*/
- Paging getSysUserPageList(SysUserQueryParam SysUserQueryParam) throws Exception;
+ Paging getSysUserPageList(SysUserQueryParam sysUserQueryParam) throws Exception;
}
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/impl/IpServiceImpl.java b/src/main/java/io/geekidea/springbootplus/system/service/impl/IpServiceImpl.java
index c960c9d8..26c3052c 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/impl/IpServiceImpl.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/impl/IpServiceImpl.java
@@ -1,29 +1,21 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
package io.geekidea.springbootplus.system.service.impl;
-import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.system.entity.Ip;
import io.geekidea.springbootplus.system.mapper.IpMapper;
import io.geekidea.springbootplus.system.service.IpService;
+import io.geekidea.springbootplus.system.param.IpQueryParam;
+import io.geekidea.springbootplus.system.vo.IpQueryVo;
+import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl;
+import io.geekidea.springbootplus.common.vo.Paging;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import java.io.Serializable;
/**
@@ -32,15 +24,26 @@
*
*
* @author geekidea
- * @since 2019-08-04
+ * @since 2019-10-11
*/
+@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
-@Slf4j
public class IpServiceImpl extends BaseServiceImpl implements IpService {
@Autowired
private IpMapper ipMapper;
+ @Override
+ public IpQueryVo getIpById(Serializable id) throws Exception {
+ return ipMapper.getIpById(id);
+ }
+
+ @Override
+ public Paging getIpPageList(IpQueryParam ipQueryParam) throws Exception {
+ Page page = setPageParam(ipQueryParam, OrderItem.desc("create_time"));
+ IPage iPage = ipMapper.getIpPageList(page, ipQueryParam);
+ return new Paging(iPage);
+ }
}
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysLogServiceImpl.java b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysLogServiceImpl.java
index 9c325627..fc4e0432 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysLogServiceImpl.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysLogServiceImpl.java
@@ -1,28 +1,12 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
package io.geekidea.springbootplus.system.service.impl;
import io.geekidea.springbootplus.system.entity.SysLog;
import io.geekidea.springbootplus.system.mapper.SysLogMapper;
import io.geekidea.springbootplus.system.service.SysLogService;
-import io.geekidea.springbootplus.system.web.param.SysLogQueryParam;
-import io.geekidea.springbootplus.system.web.vo.SysLogQueryVo;
+import io.geekidea.springbootplus.system.param.SysLogQueryParam;
+import io.geekidea.springbootplus.system.vo.SysLogQueryVo;
import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl;
-import io.geekidea.springbootplus.common.web.vo.Paging;
+import io.geekidea.springbootplus.common.vo.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,7 +24,7 @@
*
*
* @author geekidea
- * @since 2019-10-05
+ * @since 2019-10-11
*/
@Slf4j
@Service
@@ -48,17 +32,17 @@
public class SysLogServiceImpl extends BaseServiceImpl implements SysLogService {
@Autowired
- private SysLogMapper SysLogMapper;
+ private SysLogMapper sysLogMapper;
@Override
public SysLogQueryVo getSysLogById(Serializable id) throws Exception {
- return SysLogMapper.getSysLogById(id);
+ return sysLogMapper.getSysLogById(id);
}
@Override
- public Paging getSysLogPageList(SysLogQueryParam SysLogQueryParam) throws Exception {
- Page page = setPageParam(SysLogQueryParam, OrderItem.desc("create_time"));
- IPage iPage = SysLogMapper.getSysLogPageList(page, SysLogQueryParam);
+ public Paging getSysLogPageList(SysLogQueryParam sysLogQueryParam) throws Exception {
+ Page page = setPageParam(sysLogQueryParam, OrderItem.desc("create_time"));
+ IPage iPage = sysLogMapper.getSysLogPageList(page, sysLogQueryParam);
return new Paging(iPage);
}
diff --git a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysUserServiceImpl.java b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysUserServiceImpl.java
index 3a59640b..0b3bb866 100644
--- a/src/main/java/io/geekidea/springbootplus/system/service/impl/SysUserServiceImpl.java
+++ b/src/main/java/io/geekidea/springbootplus/system/service/impl/SysUserServiceImpl.java
@@ -1,28 +1,12 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
package io.geekidea.springbootplus.system.service.impl;
import io.geekidea.springbootplus.system.entity.SysUser;
import io.geekidea.springbootplus.system.mapper.SysUserMapper;
import io.geekidea.springbootplus.system.service.SysUserService;
-import io.geekidea.springbootplus.system.web.param.SysUserQueryParam;
-import io.geekidea.springbootplus.system.web.vo.SysUserQueryVo;
+import io.geekidea.springbootplus.system.param.SysUserQueryParam;
+import io.geekidea.springbootplus.system.vo.SysUserQueryVo;
import io.geekidea.springbootplus.common.service.impl.BaseServiceImpl;
-import io.geekidea.springbootplus.common.web.vo.Paging;
+import io.geekidea.springbootplus.common.vo.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,7 +24,7 @@
*
*
* @author geekidea
- * @since 2019-10-05
+ * @since 2019-10-11
*/
@Slf4j
@Service
@@ -48,17 +32,17 @@
public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService {
@Autowired
- private SysUserMapper SysUserMapper;
+ private SysUserMapper sysUserMapper;
@Override
public SysUserQueryVo getSysUserById(Serializable id) throws Exception {
- return SysUserMapper.getSysUserById(id);
+ return sysUserMapper.getSysUserById(id);
}
@Override
- public Paging getSysUserPageList(SysUserQueryParam SysUserQueryParam) throws Exception {
- Page page = setPageParam(SysUserQueryParam, OrderItem.desc("create_time"));
- IPage iPage = SysUserMapper.getSysUserPageList(page, SysUserQueryParam);
+ public Paging getSysUserPageList(SysUserQueryParam sysUserQueryParam) throws Exception {
+ Page page = setPageParam(sysUserQueryParam, OrderItem.desc("create_time"));
+ IPage iPage = sysUserMapper.getSysUserPageList(page, sysUserQueryParam);
return new Paging(iPage);
}
diff --git a/src/main/java/io/geekidea/springbootplus/system/vo/IpQueryVo.java b/src/main/java/io/geekidea/springbootplus/system/vo/IpQueryVo.java
new file mode 100644
index 00000000..77986a44
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/system/vo/IpQueryVo.java
@@ -0,0 +1,39 @@
+package io.geekidea.springbootplus.system.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+import java.util.Date;
+
+/**
+ *
+ * IP地址 查询结果对象
+ *
+ *
+ * @author geekidea
+ * @date 2019-10-11
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "IpQueryVo对象", description = "IP地址查询参数")
+public class IpQueryVo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+private String ipStart;
+
+private String ipEnd;
+
+private String area;
+
+private String operator;
+
+private Long id;
+
+private Long ipStartNum;
+
+private Long ipEndNum;
+
+}
\ No newline at end of file
diff --git a/src/main/java/io/geekidea/springbootplus/system/web/vo/SysLogQueryVo.java b/src/main/java/io/geekidea/springbootplus/system/vo/SysLogQueryVo.java
similarity index 55%
rename from src/main/java/io/geekidea/springbootplus/system/web/vo/SysLogQueryVo.java
rename to src/main/java/io/geekidea/springbootplus/system/vo/SysLogQueryVo.java
index 1106f903..423c646b 100644
--- a/src/main/java/io/geekidea/springbootplus/system/web/vo/SysLogQueryVo.java
+++ b/src/main/java/io/geekidea/springbootplus/system/vo/SysLogQueryVo.java
@@ -1,20 +1,4 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.geekidea.springbootplus.system.web.vo;
+package io.geekidea.springbootplus.system.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -30,7 +14,7 @@
*
*
* @author geekidea
- * @date 2019-10-05
+ * @date 2019-10-11
*/
@Data
@Accessors(chain = true)
diff --git a/src/main/java/io/geekidea/springbootplus/system/web/vo/SysUserQueryVo.java b/src/main/java/io/geekidea/springbootplus/system/vo/SysUserQueryVo.java
similarity index 62%
rename from src/main/java/io/geekidea/springbootplus/system/web/vo/SysUserQueryVo.java
rename to src/main/java/io/geekidea/springbootplus/system/vo/SysUserQueryVo.java
index 574b2dd4..4b16b434 100644
--- a/src/main/java/io/geekidea/springbootplus/system/web/vo/SysUserQueryVo.java
+++ b/src/main/java/io/geekidea/springbootplus/system/vo/SysUserQueryVo.java
@@ -1,26 +1,9 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.geekidea.springbootplus.system.web.vo;
+package io.geekidea.springbootplus.system.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
-
import java.io.Serializable;
import java.util.Date;
@@ -31,7 +14,7 @@
*
*
* @author geekidea
- * @date 2019-10-05
+ * @date 2019-10-11
*/
@Data
@Accessors(chain = true)
diff --git a/src/main/java/io/geekidea/springbootplus/system/web/param/SysLogQueryParam.java b/src/main/java/io/geekidea/springbootplus/system/web/param/SysLogQueryParam.java
deleted file mode 100644
index f23755be..00000000
--- a/src/main/java/io/geekidea/springbootplus/system/web/param/SysLogQueryParam.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.geekidea.springbootplus.system.web.param;
-
-import io.swagger.annotations.ApiModel;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import io.geekidea.springbootplus.common.web.param.QueryParam;
-
-/**
- *
- * 系统日志 查询参数对象
- *
- *
- * @author geekidea
- * @date 2019-10-05
- */
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "SysLogQueryParam对象", description = "系统日志查询参数")
-public class SysLogQueryParam extends QueryParam {
- private static final long serialVersionUID = 1L;
-}
diff --git a/src/main/java/io/geekidea/springbootplus/system/web/param/SysUserQueryParam.java b/src/main/java/io/geekidea/springbootplus/system/web/param/SysUserQueryParam.java
deleted file mode 100644
index 8ec57d78..00000000
--- a/src/main/java/io/geekidea/springbootplus/system/web/param/SysUserQueryParam.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.geekidea.springbootplus.system.web.param;
-
-import io.swagger.annotations.ApiModel;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import io.geekidea.springbootplus.common.web.param.QueryParam;
-
-/**
- *
- * SystemUser 查询参数对象
- *
- *
- * @author geekidea
- * @date 2019-10-05
- */
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = true)
-@ApiModel(value = "SysUserQueryParam对象", description = "SystemUser查询参数")
-public class SysUserQueryParam extends QueryParam {
- private static final long serialVersionUID = 1L;
-}
diff --git a/src/main/java/io/geekidea/springbootplus/system/web/vo/IpQueryVo.java b/src/main/java/io/geekidea/springbootplus/system/web/vo/IpQueryVo.java
deleted file mode 100644
index 1150cae7..00000000
--- a/src/main/java/io/geekidea/springbootplus/system/web/vo/IpQueryVo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2019-2029 geekidea(https://github.com/geekidea)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.geekidea.springbootplus.system.web.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- *
- * IP地址 查询结果对象
- *
- *
- * @author geekidea
- * @date 2019-08-04
- */
-@Data
-@ApiModel(value="IpQueryVo对象", description="IP地址查询参数")
-public class IpQueryVo implements Serializable{
-
- private static final long serialVersionUID = 1L;
-
- @ApiModelProperty(value = "ip开始地址")
- private String ipStart;
-
- @ApiModelProperty(value = "ip结束地址")
- private String ipEnd;
-
- @ApiModelProperty(value = "区域")
- private String area;
-
- @ApiModelProperty(value = "运营商")
- private String operator;
-
- @ApiModelProperty(value = "主键")
- private Long id;
-
- @ApiModelProperty(value = "ip开始地址数字")
- private Long ipStartNum;
-
- @ApiModelProperty(value = "ip结束地址数字")
- private Long ipEndNum;
-
-}
\ No newline at end of file
diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssFilter.java b/src/main/java/io/geekidea/springbootplus/xss/XssFilter.java
new file mode 100644
index 00000000..02815830
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/xss/XssFilter.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.xss;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * Xss过滤器
+ *
+ * @author geekidea
+ * @date 2019-10-10
+ * @since 1.3.1.RELEASE
+ **/
+@Slf4j
+@WebFilter(filterName = "xssFilter", urlPatterns = "/*", asyncSupported = true)
+public class XssFilter implements Filter {
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ HttpServletRequest request = (HttpServletRequest) servletRequest;
+ XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper(request);
+ filterChain.doFilter(xssHttpServletRequestWrapper, servletResponse);
+ }
+}
diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java b/src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java
new file mode 100644
index 00000000..8a91ccd0
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/xss/XssHttpServletRequestWrapper.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.xss;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.text.StringEscapeUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * XSS 跨站脚本攻击(Cross Site Scripting) 处理
+ *
+ * @author geekidea
+ * @date 2019-10-10
+ * @since 1.3.1.RELEASE
+ **/
+public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
+
+ public XssHttpServletRequestWrapper(HttpServletRequest request) {
+ super(request);
+ }
+
+ @Override
+ public String getQueryString() {
+ return StringEscapeUtils.escapeHtml4(super.getQueryString());
+ }
+
+ @Override
+ public String getParameter(String name) {
+ return StringEscapeUtils.escapeHtml4(super.getParameter(name));
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ String[] values = super.getParameterValues(name);
+ if (ArrayUtils.isEmpty(values)) {
+ return values;
+ }
+ int length = values.length;
+ String[] escapeValues = new String[length];
+ for (int i = 0; i < length; i++) {
+ escapeValues[i] = StringEscapeUtils.escapeHtml4(values[i]);
+ }
+ return escapeValues;
+ }
+
+}
diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java b/src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java
new file mode 100644
index 00000000..d612dbdb
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/xss/XssJacksonDeserializer.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.xss;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import org.apache.commons.text.StringEscapeUtils;
+
+import java.io.IOException;
+
+/**
+ * Jackson请求参数字符串转义处理
+ *
+ * @author geekidea
+ * @date 2019-10-10
+ * @since 1.3.1.RELEASE
+ **/
+public class XssJacksonDeserializer extends JsonDeserializer {
+
+ @Override
+ public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ return StringEscapeUtils.escapeHtml4(jsonParser.getText());
+ }
+
+}
diff --git a/src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java b/src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java
new file mode 100644
index 00000000..71bdbde8
--- /dev/null
+++ b/src/main/java/io/geekidea/springbootplus/xss/XssJacksonSerializer.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.geekidea.springbootplus.xss;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.text.StringEscapeUtils;
+
+import java.io.IOException;
+
+/**
+ * Jackson响应参数字符串转义处理
+ *
+ * @author geekidea
+ * @date 2019-10-10
+ * @since 1.3.1.RELEASE
+ **/
+@Slf4j
+public class XssJacksonSerializer extends JsonSerializer {
+
+ @Override
+ public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ jsonGenerator.writeString(StringEscapeUtils.escapeHtml4(s));
+ }
+
+}
diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml
index 5c3e4ff9..88f2e405 100644
--- a/src/main/resources/config/application.yml
+++ b/src/main/resources/config/application.yml
@@ -1,15 +1,15 @@
# spring-boot-plus Common Config
-############################# 访问路径、端口tomcat start ############################
+############################# 访问路径、端口tomcat start #############################
server:
port: 8888
servlet:
- context-path: /api
+ context-path: /
tomcat:
max-threads: 1000
min-spare-threads: 30
uri-encoding: UTF-8
-############################# 访问路径、端口tomcat end ##############################
+############################# 访问路径、端口tomcat end ###############################
################################ spring config start ###############################
@@ -38,33 +38,39 @@ spring:
############################## spring-boot-plus start ##############################
spring-boot-plus:
+ # 是否启用ansi控制台输出有颜色的字体
+ enable-ansi: true
+ # 请求日志在控制台是否格式化输出
+ request-log-format: true
+ # 响应日志在控制台是否格式化输出
+ response-log-format: true
+ # 过滤器配置
+ filter:
+ # 请求路径Filter配置
+ request-path:
+ enabled: true
+ include-paths: /**
+ # 排除路径,多行字符串配置
+ exclude-paths: |
+ /applications/**,/actuator/**,/instances/**,/logfile,/sba-settings.js,/assets/img/favicon.png,
+ /swagger-ui.html,/swagger-resources/**,/webjars/springfox-swagger-ui/**,/v2/api-docs,
+ /druid/**,/favicon.ico
# 拦截器配置
- interceptor-config:
- permission-config:
+ interceptor:
+ permission:
enabled: false
include-paths: /**
exclude-paths: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/adminLogin,/sysLogin,/login.html,/verificationCode,/doc/**,/error/**,/docs,/resource/**
- resource-config:
+ resource:
enabled: true
include-paths: ${spring-boot-plus.resource-access-patterns}
- upload-config:
+ upload:
enabled: true
include-paths: /upload/**
- download-config:
+ download:
enabled: true
include-paths: /download/**
- # 过滤器配置
- filter-config:
- # 请求路径Filter配置
- request-path-config:
- enabled: true
- include-paths: /**
- # 跨域Filter配置
- cross-domain-config:
- enabled: true
- include-paths: /**
-
# 文件上传下载配置
# 上传路径配置
upload-path: /opt/upload/
@@ -78,12 +84,36 @@ spring-boot-plus:
allow-upload-file-extensions: jpg,png,docx,xlsx,pptx,pdf
allow-download-file-extensions: jpg,png,docx,xlsx,pptx,pdf
+ ############################ CORS start ############################
+ # CORS跨域配置,默认允许跨域
+ cors:
+ # 是否启用跨域,默认启用
+ enable: true
+ # CORS过滤的路径,默认:/**
+ path: /**
+ # 允许访问的源
+ allowed-origins: '*'
+ # 允许访问的请求头
+ allowed-headers: x-requested-with,content-type,token
+ # 是否允许发送cookie
+ allow-credentials: true
+ # 允许访问的请求方式
+ allowed-methods: OPTION,GET,POST
+ # 允许响应的头
+ exposed-headers: token
+ # 该响应的有效时间默认为30分钟,在有效时间内,浏览器无须为同一请求再次发起预检请求
+ max-age: 1800
+
+ ############################ CORS end ##############################
+
+ ########################## Resource start ##########################
# 静态资源访问配置
resource-handlers: |
/static/**=classpath:/static/
/templates/**=classpath:/templates/
swagger-ui.html=classpath:/META-INF/resources/
/webjars/**=classpath:/META-INF/resources/webjars/
+ ########################## Resource end ############################
######################## Spring Shiro start ########################
shiro:
@@ -92,8 +122,12 @@ spring-boot-plus:
/=anon
/static/**=anon
/templates/**=anon
+ /druid/**=anon
+ /hello/world=anon
+ /ip/**=anon
+ /sysLog/**=anon
# 权限配置
- permission-config:
+ permission:
# 排除登陆登出相关
- urls: /login,/logout
permission: anon
@@ -101,7 +135,7 @@ spring-boot-plus:
- urls: /static/**,/templates/**
permission: anon
# 排除Swagger
- - urls: /docs,/swagger-ui.html, /webjars/springfox-swagger-ui/**,/swagger-resources/**,/v2/api-docs
+ - urls: /docs,/swagger-ui.html,/webjars/springfox-swagger-ui/**,/swagger-resources/**,/v2/api-docs
permission: anon
# 排除SpringBootAdmin
- urls: /,/favicon.ico,/actuator/**,/instances/**,/assets/**,/sba-settings.js,/applications/**
@@ -113,9 +147,13 @@ spring-boot-plus:
############################ JWT start #############################
jwt:
+ # token请求头名称
token-name: token
+ # jwt密钥
secret: 666666
+ # 发行人
issuer: spring-boot-plus
+ # 观众
audience: web
# 默认过期时间1小时,单位:秒
expire-second: 3600
@@ -145,10 +183,10 @@ mybatis-plus:
logic-delete-value: 0
logic-not-delete-value: 1
mapper-locations: classpath*:mapper/**/*Mapper.xml
-################################ mybatis-plus end #################################
+################################ mybatis-plus end ##################################
-############################### DRUID数据源配置 start ##############################
+############################### DRUID数据源配置 start ################################
---
spring:
datasource:
@@ -193,12 +231,6 @@ spring:
---
spring:
redis:
- jedis:
- pool:
- max-active: 2000
- max-wait: -1ms
- min-idle: 8
- max-idle: 200
timeout: 10s
lettuce:
pool:
diff --git a/src/main/resources/mapper/system/IpMapper.xml b/src/main/resources/mapper/system/IpMapper.xml
index 58ba5df5..24ebdfa9 100644
--- a/src/main/resources/mapper/system/IpMapper.xml
+++ b/src/main/resources/mapper/system/IpMapper.xml
@@ -1,20 +1,4 @@
-
-
@@ -23,5 +7,16 @@
ip_start, ip_end, area, operator, id, ip_start_num, ip_end_num
+
+
+
diff --git a/src/main/resources/mapper/system/SysLogMapper.xml b/src/main/resources/mapper/system/SysLogMapper.xml
index e66f8b64..aa52bdaf 100644
--- a/src/main/resources/mapper/system/SysLogMapper.xml
+++ b/src/main/resources/mapper/system/SysLogMapper.xml
@@ -1,20 +1,4 @@
-
-
@@ -23,13 +7,13 @@
log_id, type, content, create_id, create_time
-