commit
3304f71a09
32 changed files with 1825 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||
# Created by .ignore support plugin (hsz.mobi) |
|||
### Example user template template |
|||
### Example user template |
|||
target |
|||
target/ |
|||
target/* |
|||
# IntelliJ project files |
|||
.idea |
|||
.idea/ |
|||
.idea/* |
|||
*.iml |
|||
.mvn |
|||
.mvn/ |
|||
.mvn/* |
|||
out |
|||
gen |
|||
### Java template |
|||
# Compiled class file |
|||
*.class |
|||
|
|||
# Log file |
|||
*.log |
|||
|
|||
# BlueJ files |
|||
*.ctxt |
|||
|
|||
# Mobile Tools for Java (J2ME) |
|||
.mtj.tmp/ |
|||
|
|||
# Package Files # |
|||
*.jar |
|||
*.war |
|||
*.nar |
|||
*.ear |
|||
*.zip |
|||
*.tar.gz |
|||
*.rar |
|||
|
|||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml |
|||
hs_err_pid* |
|||
mbg.xml |
|||
resources/mbg.xml |
|||
resources/application.yml |
@ -0,0 +1,280 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>com.ccsens</groupId> |
|||
<artifactId>basicserver</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
|
|||
<properties> |
|||
<java.version>1.8</java.version> |
|||
</properties> |
|||
<parent> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-parent</artifactId> |
|||
<version>2.1.8.RELEASE</version> |
|||
<relativePath/> <!-- lookup parent from repository --> |
|||
</parent> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.ccsensptos</groupId> |
|||
<artifactId>wechatutil</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<scope>compile</scope> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-amqp</artifactId> |
|||
</exclusion> |
|||
<exclusion> |
|||
<groupId>com.ccsensptos</groupId> |
|||
<artifactId>cloudutil</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.aspectj</groupId> |
|||
<artifactId>aspectjweaver</artifactId> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/io.netty/netty-all --> |
|||
<dependency> |
|||
<groupId>io.netty</groupId> |
|||
<artifactId>netty-all</artifactId> |
|||
<version>4.1.32.Final</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-redis</artifactId> |
|||
</dependency> |
|||
<!--spring 缓存--> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-cache</artifactId> |
|||
</dependency> |
|||
<!--多redis配置--> |
|||
<!--<dependency> |
|||
<groupId>redis.clients</groupId> |
|||
<artifactId>jedis</artifactId> |
|||
</dependency>--> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-jdbc</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-tomcat</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-jetty</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-configuration-processor</artifactId> |
|||
<optional>true</optional> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.projectlombok</groupId> |
|||
<artifactId>lombok</artifactId> |
|||
<optional>true</optional> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
<exclusions> <!--排除android-json,与腾讯短信接口qcloudsms冲突--> |
|||
<exclusion> |
|||
<groupId>com.vaadin.external.google</groupId> |
|||
<artifactId>android-json</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-actuator</artifactId> |
|||
</dependency> |
|||
|
|||
<!-- hutool-all --> |
|||
<dependency> |
|||
<groupId>cn.hutool</groupId> |
|||
<artifactId>hutool-all</artifactId> |
|||
<version>4.1.21</version> |
|||
</dependency> |
|||
|
|||
<!--Poi Excel --> |
|||
<dependency> |
|||
<groupId>org.apache.poi</groupId> |
|||
<artifactId>poi</artifactId> |
|||
<version>3.17</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.apache.poi</groupId> |
|||
<artifactId>poi-ooxml</artifactId> |
|||
<version>3.17</version> |
|||
</dependency> |
|||
<!--websocket--> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-websocket</artifactId> |
|||
</dependency> |
|||
<!-- spring RabbitMQ--> |
|||
<!--<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-amqp</artifactId> |
|||
</dependency>--> |
|||
<!-- spring MyBatis --> |
|||
<dependency> |
|||
<groupId>org.mybatis.spring.boot</groupId> |
|||
<artifactId>mybatis-spring-boot-starter</artifactId> |
|||
<version>1.1.1</version> |
|||
</dependency> |
|||
<!-- mybatis pagehelper包--> |
|||
<dependency> |
|||
<groupId>com.github.pagehelper</groupId> |
|||
<artifactId>pagehelper</artifactId> |
|||
<version>4.1.4</version> |
|||
</dependency> |
|||
<!-- MySQL数据库 --> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
</dependency> |
|||
<!--Durid数据源--> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid</artifactId> |
|||
<version>1.1.10</version> |
|||
</dependency> |
|||
<!--jjwt--> |
|||
<dependency> |
|||
<groupId>io.jsonwebtoken</groupId> |
|||
<artifactId>jjwt</artifactId> |
|||
<version>0.7.0</version> |
|||
</dependency> |
|||
|
|||
|
|||
<!--Jackson Xml--> |
|||
<dependency> |
|||
<groupId>com.fasterxml.jackson.dataformat</groupId> |
|||
<artifactId>jackson-dataformat-xml</artifactId> |
|||
<version>2.9.0</version> |
|||
</dependency> |
|||
|
|||
<!-- ehcache 缓存 --> |
|||
<!--<dependency> |
|||
<groupId>net.sf.ehcache</groupId> |
|||
<artifactId>ehcache</artifactId> |
|||
</dependency>--> |
|||
<!--Shiro --> |
|||
<dependency> |
|||
<groupId>org.apache.shiro</groupId> |
|||
<artifactId>shiro-spring</artifactId> |
|||
<version>1.4.0</version> |
|||
</dependency> |
|||
<!-- shiro ehcache --> |
|||
<dependency> |
|||
<groupId>org.apache.shiro</groupId> |
|||
<artifactId>shiro-ehcache</artifactId> |
|||
<version>1.4.0</version> |
|||
</dependency> |
|||
<!--HtmlCleaner--> |
|||
<dependency> |
|||
<groupId>net.sourceforge.htmlcleaner</groupId> |
|||
<artifactId>htmlcleaner</artifactId> |
|||
<version>2.22</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> |
|||
<dependency> |
|||
<groupId>org.apache.commons</groupId> |
|||
<artifactId>commons-lang3</artifactId> |
|||
<version>3.8.1</version> |
|||
</dependency> |
|||
|
|||
|
|||
<!--Swagger --> |
|||
<dependency> |
|||
<groupId>io.springfox</groupId> |
|||
<artifactId>springfox-swagger2</artifactId> |
|||
<version>2.9.2</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>io.springfox</groupId> |
|||
<artifactId>springfox-swagger-ui</artifactId> |
|||
<version>2.9.2</version> |
|||
</dependency> |
|||
<!--mybatis generator包--> |
|||
<dependency> |
|||
<groupId>org.mybatis.generator</groupId> |
|||
<artifactId>mybatis-generator-core</artifactId> |
|||
<version>1.3.7</version> |
|||
</dependency> |
|||
|
|||
<!-- https://mvnrepository.com/artifact/org.beanshell/bsh --> |
|||
<dependency> |
|||
<groupId>org.beanshell</groupId> |
|||
<artifactId>bsh</artifactId> |
|||
<version>2.0b5</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> |
|||
<dependency> |
|||
<groupId>org.apache.httpcomponents</groupId> |
|||
<artifactId>httpclient</artifactId> |
|||
<version>4.5.1</version> |
|||
</dependency> |
|||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --> |
|||
<dependency> |
|||
<groupId>org.apache.httpcomponents</groupId> |
|||
<artifactId>httpcore</artifactId> |
|||
<version>4.4.3</version> |
|||
</dependency> |
|||
<!--腾讯短信--> |
|||
<dependency> |
|||
<groupId>com.github.qcloudsms</groupId> |
|||
<artifactId>qcloudsms</artifactId> |
|||
<version>1.0.5</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>fastjson</artifactId> |
|||
<version>1.2.62</version> |
|||
</dependency> |
|||
|
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.mybatis.generator</groupId> |
|||
<artifactId>mybatis-generator-maven-plugin</artifactId> |
|||
<version>1.3.7</version> |
|||
<configuration> |
|||
<configurationFile>${basedir}/src/main/resources/mbg.xml</configurationFile> |
|||
<overwrite>true</overwrite> |
|||
</configuration> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
<version>5.1.34</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
</project> |
@ -0,0 +1,24 @@ |
|||
package com.ccsens.basicserver; |
|||
|
|||
import org.mybatis.spring.annotation.MapperScan; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.web.servlet.ServletComponentScan; |
|||
import org.springframework.cache.annotation.EnableCaching; |
|||
import org.springframework.context.annotation.ComponentScan; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/9 14:53 |
|||
*/ |
|||
@MapperScan(basePackages = {"com.ccsens.basicserver.persist.*"}) |
|||
@ServletComponentScan |
|||
@EnableCaching |
|||
@SpringBootApplication |
|||
@ComponentScan(basePackages = {"com.ccsens"}) |
|||
public class BasicServerApplication { |
|||
public static void main(String[] args) { |
|||
SpringApplication.run(BasicServerApplication.class, args); |
|||
} |
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.ccsens.basicserver.api; |
|||
|
|||
import com.ccsens.util.JsonResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/8 8:42 |
|||
*/ |
|||
@Api(tags = "DEBUG" , description = "DebugController | ") |
|||
@RestController |
|||
@RequestMapping("/debug") |
|||
@Slf4j |
|||
public class DebugController { |
|||
|
|||
|
|||
@ApiOperation(value = "/测试",notes = "") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse debug(HttpServletRequest request) throws Exception { |
|||
return JsonResponse.newInstance().ok("hello world!"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.ccsens.basicserver.api; |
|||
|
|||
import cn.hutool.http.HttpUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.basicserver.bean.vo.epidemic.EpidemicTangVo; |
|||
import com.ccsens.basicserver.bean.vo.weather.WeatherTangVo; |
|||
import com.ccsens.basicserver.bean.vo.weather.WeatherVo; |
|||
import com.ccsens.basicserver.util.BasicServerCodeError; |
|||
import com.ccsens.basicserver.util.BasicServerConstant; |
|||
import com.ccsens.util.JsonResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 11:00 |
|||
*/ |
|||
@Api(tags = "疫情" ) |
|||
@RestController |
|||
@RequestMapping("/epidemic") |
|||
@Slf4j |
|||
public class EpidemicController { |
|||
|
|||
@ApiOperation(value = "疫情查询", notes = "来源:汤同伟提供") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value = "tang", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<WeatherVo.Weather> tang() { |
|||
log.info("疫情查询,路径:{}", BasicServerConstant.Tang.WEATHER_AND_EPIDEMIC_URL); |
|||
String result = HttpUtil.get(BasicServerConstant.Tang.WEATHER_AND_EPIDEMIC_URL); |
|||
log.info("疫情查询返回:{}", result); |
|||
JSONObject resultJson = JSONObject.parseObject(result); |
|||
if (resultJson.getIntValue(BasicServerConstant.Tang.ERROR_CODE) != BasicServerConstant.Tang.CURRENT_CODE) { |
|||
return JsonResponse.newInstance().fail(BasicServerCodeError.THIRD_ERROR.getCode(), resultJson.getString(BasicServerConstant.Tang.ERROR_MSG)); |
|||
} |
|||
EpidemicTangVo.Epidemic epidemic = JSONObject.parseObject(resultJson.getString(BasicServerConstant.Tang.DATA), EpidemicTangVo.Epidemic.class); |
|||
return JsonResponse.newInstance().ok(epidemic.transform()); |
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.ccsens.basicserver.api; |
|||
|
|||
import cn.hutool.http.HttpUtil; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.basicserver.bean.dto.news.NewsTangDto; |
|||
import com.ccsens.basicserver.bean.vo.news.NewsVo; |
|||
import com.ccsens.basicserver.util.BasicServerConstant; |
|||
import com.ccsens.util.JsonResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/9 15:50 |
|||
*/ |
|||
@Api(tags = "新闻" ) |
|||
@RestController |
|||
@RequestMapping("/news") |
|||
@Slf4j |
|||
public class NewsController { |
|||
|
|||
|
|||
|
|||
|
|||
@ApiOperation(value = "地区新闻查询", notes = "来源:汤同伟提供") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value = "tang", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<List<NewsVo.NewsBase>> tang(@ApiParam @Validated @RequestBody NewsTangDto.Area param) { |
|||
List<NewsVo.NewsBase> news = new ArrayList<>(); |
|||
log.info("地区新闻查询,路径:{},参数:{}", BasicServerConstant.Tang.NEWS_URL, param); |
|||
String result = HttpUtil.post(BasicServerConstant.Tang.NEWS_URL, JSONObject.toJSONString(param)); |
|||
log.info("查询地区新闻返回:{}", result); |
|||
JSONObject resultJson = JSONObject.parseObject(result); |
|||
|
|||
if (resultJson.getIntValue(BasicServerConstant.Tang.ERROR_CODE) != BasicServerConstant.Tang.CURRENT_CODE |
|||
|| param.getPageNo() > resultJson.getJSONObject(BasicServerConstant.Tang.DATA).getIntValue(BasicServerConstant.Tang.PAGE_NO)) { |
|||
return JsonResponse.newInstance().ok(news); |
|||
} |
|||
JSONArray array = resultJson.getJSONObject(BasicServerConstant.Tang.DATA).getJSONArray(BasicServerConstant.Tang.DATA); |
|||
for (Object obj: array) { |
|||
NewsVo.NewsBase base = JSONObject.parseObject(((JSONObject)obj).toJSONString(), NewsVo.NewsBase.class); |
|||
news.add(base); |
|||
} |
|||
log.info("地区新闻查询结果:{}", news); |
|||
return JsonResponse.newInstance().ok(news); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,50 @@ |
|||
package com.ccsens.basicserver.api; |
|||
|
|||
import cn.hutool.http.HttpUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.basicserver.bean.vo.weather.WeatherTangVo; |
|||
import com.ccsens.basicserver.bean.vo.weather.WeatherVo; |
|||
import com.ccsens.basicserver.util.BasicServerCodeError; |
|||
import com.ccsens.basicserver.util.BasicServerConstant; |
|||
import com.ccsens.util.JsonResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 9:21 |
|||
*/ |
|||
@Api(tags = "天气" ) |
|||
@RestController |
|||
@RequestMapping("/weather") |
|||
@Slf4j |
|||
public class WeatherController { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ApiOperation(value = "天气查询", notes = "来源:汤同伟提供") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value = "tang", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<WeatherVo.Weather> tang() { |
|||
log.info("天气查询,路径:{}", BasicServerConstant.Tang.WEATHER_AND_EPIDEMIC_URL); |
|||
String result = HttpUtil.get(BasicServerConstant.Tang.WEATHER_AND_EPIDEMIC_URL); |
|||
log.info("天气查询返回:{}", result); |
|||
JSONObject resultJson = JSONObject.parseObject(result); |
|||
if (resultJson.getIntValue(BasicServerConstant.Tang.ERROR_CODE) != BasicServerConstant.Tang.CURRENT_CODE) { |
|||
return JsonResponse.newInstance().fail(BasicServerCodeError.THIRD_ERROR.getCode(), resultJson.getString(BasicServerConstant.Tang.ERROR_MSG)); |
|||
} |
|||
WeatherTangVo.Weather weather = JSONObject.parseObject(resultJson.getString(BasicServerConstant.Tang.DATA), WeatherTangVo.Weather.class); |
|||
return JsonResponse.newInstance().ok(weather.transform()); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.ccsens.basicserver.bean.dto; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 12:02 |
|||
*/ |
|||
public class Demo { |
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.ccsens.basicserver.bean.dto.news; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/9 16:03 |
|||
*/ |
|||
public class NewsTangDto { |
|||
@ApiModel("新闻请求-汤同伟提供") |
|||
@Data |
|||
public static class Area { |
|||
@ApiModelProperty("第几页") |
|||
private Integer pageNo = 1; |
|||
@ApiModelProperty("每页几条信息") |
|||
private Integer pageSize = 10; |
|||
@ApiModelProperty("地区,查看太原新闻:taiyuan,查看国内新闻:guonei,查看山西新闻:shanxi") |
|||
private String area = "taiyuan"; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.ccsens.basicserver.bean.vo.epidemic; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.ccsens.util.StringUtil; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 11:06 |
|||
*/ |
|||
public class EpidemicTangVo { |
|||
|
|||
@Data |
|||
@ApiModel("疫情-汤同伟") |
|||
public static class Epidemic{ |
|||
@ApiModelProperty("全球累计死亡") |
|||
private String worldDead; |
|||
@ApiModelProperty("全球累积确诊") |
|||
private String worldConfirm; |
|||
@ApiModelProperty("境外输入确诊病例人数") |
|||
private String importedCase; |
|||
@ApiModelProperty("国内昨日新增本土确诊病例人数") |
|||
private String localConfirmadd; |
|||
@ApiModelProperty("中风险地区") |
|||
private List<String> middleRisk; |
|||
@ApiModelProperty("高风险地区") |
|||
private List<String> highRisk; |
|||
|
|||
public EpidemicVo.Epidemic transform(){ |
|||
EpidemicVo.Epidemic epidemic = new EpidemicVo.Epidemic(); |
|||
epidemic.setWorldDead(this.worldDead); |
|||
epidemic.setWorldConfirm(this.worldConfirm); |
|||
epidemic.setImportedCase(this.importedCase); |
|||
epidemic.setLocalConfirmAdd(this.localConfirmadd); |
|||
|
|||
if (CollectionUtil.isNotEmpty(this.middleRisk)) { |
|||
epidemic.setMiddleRiskAreas(getCity(this.middleRisk)); |
|||
} |
|||
if (CollectionUtil.isNotEmpty(this.highRisk)) { |
|||
epidemic.setHighRiskAreas(getCity(this.highRisk)); |
|||
} |
|||
return epidemic; |
|||
} |
|||
private int getIndex(String risk) { |
|||
String key1 = "盟"; |
|||
String key2 = "州"; |
|||
String key3 = "市"; |
|||
return risk.indexOf(key1) > 0 ? risk.indexOf(key1) + 1 : |
|||
risk.indexOf(key2) > 0 ? risk.indexOf(key2) + 1 : |
|||
risk.indexOf(key3) > 0 ? risk.indexOf(key3) + 1 : |
|||
risk.length(); |
|||
} |
|||
|
|||
private List<String> getCity(List<String> areas) { |
|||
Set<String> highRiskAreas = new HashSet<>(); |
|||
areas.forEach(risk -> highRiskAreas.add(StringUtil.replaceStr(risk.substring(0, getIndex(risk))))); |
|||
List<String> list = new ArrayList<>(); |
|||
list.addAll(highRiskAreas); |
|||
Collections.sort(list); |
|||
return list; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.ccsens.basicserver.bean.vo.epidemic; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 11:06 |
|||
*/ |
|||
public class EpidemicVo { |
|||
|
|||
@Data |
|||
@ApiModel("疫情-返回") |
|||
public static class Epidemic{ |
|||
@ApiModelProperty("全球累计死亡") |
|||
private String worldDead; |
|||
@ApiModelProperty("全球累积确诊") |
|||
private String worldConfirm; |
|||
@ApiModelProperty("境外输入确诊病例人数") |
|||
private String importedCase; |
|||
@ApiModelProperty("国内昨日新增本土确诊病例人数") |
|||
private String localConfirmAdd; |
|||
@ApiModelProperty("中风险地区") |
|||
private List<String> middleRiskAreas; |
|||
@ApiModelProperty("高风险地区") |
|||
private List<String> highRiskAreas; |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ccsens.basicserver.bean.vo.news; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/9 16:01 |
|||
*/ |
|||
public class NewsVo { |
|||
|
|||
|
|||
@ApiModel("新闻信息-返回") |
|||
@Data |
|||
public static class NewsBase{ |
|||
@ApiModelProperty("新闻概览") |
|||
private String overview; |
|||
@ApiModelProperty("发布时间") |
|||
private String time; |
|||
@ApiModelProperty("来源") |
|||
private String source; |
|||
@ApiModelProperty("标题") |
|||
private String title; |
|||
@ApiModelProperty("新闻地址") |
|||
private String url; |
|||
@ApiModelProperty("新闻图片") |
|||
private String imgUrl; |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
package com.ccsens.basicserver.bean.vo.weather; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 10:26 |
|||
*/ |
|||
public class WeatherTangVo { |
|||
@Data |
|||
@ApiModel("天气-返回") |
|||
public static class Weather{ |
|||
private Current current; |
|||
private List<Future> future; |
|||
|
|||
public WeatherVo.Weather transform(){ |
|||
WeatherVo.Weather weather = new WeatherVo.Weather(); |
|||
weather.setCurrent(this.current == null ? null : this.current.transform()); |
|||
List<WeatherVo.Future> futures = new ArrayList<>(); |
|||
if (CollectionUtil.isNotEmpty(this.future)) { |
|||
this.future.forEach(f -> futures.add(f.transform())); |
|||
} |
|||
weather.setFutures(futures); |
|||
return weather; |
|||
} |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("天气-今天") |
|||
private static class Current { |
|||
@ApiModelProperty("气压,例:气压912hpa") |
|||
private String pa; |
|||
@ApiModelProperty("大气状态,例:霾") |
|||
private String cludy; |
|||
@ApiModelProperty("今天天气概况,例:今天:-8-0° 小雪转阴") |
|||
private String today; |
|||
@ApiModelProperty("空气湿度,例:湿度 59%") |
|||
private String humidity; |
|||
@ApiModelProperty("空气污染程度,例:轻度") |
|||
private String air; |
|||
@ApiModelProperty("温度,例:0°/0℃/0-18℃") |
|||
private String tem; |
|||
@ApiModelProperty("风力和风向,例:东南风 1级") |
|||
private String wind; |
|||
@ApiModelProperty("紫外线,例:紫外线 弱") |
|||
private String sunblack; |
|||
|
|||
public WeatherVo.Current transform(){ |
|||
WeatherVo.Current current = new WeatherVo.Current(); |
|||
current.setHpa(this.pa); |
|||
current.setState(this.cludy); |
|||
current.setSituation(this.today); |
|||
current.setHumidity(this.humidity); |
|||
current.setPollution(this.air); |
|||
current.setTemp(this.tem); |
|||
current.setWind(this.wind); |
|||
current.setUltraviolet(this.sunblack); |
|||
return current; |
|||
} |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("天气-未来") |
|||
private static class Future { |
|||
@ApiModelProperty("大气状态,例:霾") |
|||
private String cloudy; |
|||
@ApiModelProperty("时间") |
|||
private String time; |
|||
@ApiModelProperty("空气污染程度,例:轻度") |
|||
private String air; |
|||
@ApiModelProperty("温度,例:0°/0℃/0-18℃") |
|||
private String tem; |
|||
@ApiModelProperty("风力和风向,例:东南风 1级") |
|||
private String wind; |
|||
public WeatherVo.Future transform(){ |
|||
WeatherVo.Future future = new WeatherVo.Future(); |
|||
future.setState(this.cloudy); |
|||
future.setTime(this.time); |
|||
future.setPollution(this.air); |
|||
future.setTemp(this.tem); |
|||
future.setWind(this.wind); |
|||
return future; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.ccsens.basicserver.bean.vo.weather; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 9:35 |
|||
*/ |
|||
public class WeatherVo { |
|||
|
|||
@Data |
|||
@ApiModel("天气-返回") |
|||
public static class Weather{ |
|||
private Current current; |
|||
private List<Future> futures; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("天气-今天") |
|||
public static class Current { |
|||
@ApiModelProperty("气压,例:气压912hpa") |
|||
private String hpa; |
|||
@ApiModelProperty("大气状态,例:霾") |
|||
private String state; |
|||
@ApiModelProperty("今天天气概况,例:今天:-8-0° 小雪转阴") |
|||
private String situation; |
|||
@ApiModelProperty("空气湿度,例:湿度 59%") |
|||
private String humidity; |
|||
@ApiModelProperty("空气污染程度,例:轻度") |
|||
private String pollution; |
|||
@ApiModelProperty("温度,例:0°/0℃/0-18℃") |
|||
private String temp; |
|||
@ApiModelProperty("风力和风向,例:东南风 1级") |
|||
private String wind; |
|||
@ApiModelProperty("紫外线,例:紫外线 弱") |
|||
private String ultraviolet; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("天气-未来") |
|||
public static class Future { |
|||
@ApiModelProperty("大气状态,例:霾") |
|||
private String state; |
|||
@ApiModelProperty("时间") |
|||
private String time; |
|||
@ApiModelProperty("空气污染程度,例:轻度") |
|||
private String pollution; |
|||
@ApiModelProperty("温度,例:0°/0℃/0-18℃") |
|||
private String temp; |
|||
@ApiModelProperty("风力和风向,例:东南风 1级") |
|||
private String wind; |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.ccsens.basicserver.config; |
|||
|
|||
import com.ccsens.basicserver.intercept.MybatisInterceptor; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.cors.CorsConfiguration; |
|||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|||
import org.springframework.web.filter.CorsFilter; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: wuHuiJuan |
|||
* @create: 2019/12/03 18:01 |
|||
*/ |
|||
@Configuration |
|||
public class BeanConfig { |
|||
/** |
|||
* 注册拦截器 |
|||
*/ |
|||
@Bean |
|||
public MybatisInterceptor mybatisInterceptor() { |
|||
MybatisInterceptor interceptor = new MybatisInterceptor(); |
|||
return interceptor; |
|||
} |
|||
private CorsConfiguration buildConfig() { |
|||
CorsConfiguration corsConfiguration = new CorsConfiguration(); |
|||
corsConfiguration.addAllowedOrigin("*"); |
|||
corsConfiguration.addAllowedHeader("*"); |
|||
corsConfiguration.addAllowedMethod("*"); |
|||
// 预检请求的有效期,单位为秒。
|
|||
corsConfiguration.setMaxAge(3600L); |
|||
// 是否支持安全证书(必需参数)
|
|||
corsConfiguration.setAllowCredentials(true); |
|||
return corsConfiguration; |
|||
} |
|||
|
|||
@Bean |
|||
public CorsFilter corsFilter() { |
|||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
|||
source.registerCorsConfiguration("/**", buildConfig()); |
|||
return new CorsFilter(source); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,140 @@ |
|||
package com.ccsens.basicserver.config; |
|||
|
|||
|
|||
import cn.hutool.core.lang.Snowflake; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import com.ccsens.util.PropUtil; |
|||
import com.ccsens.util.config.DruidProps; |
|||
import com.fasterxml.jackson.databind.DeserializationFeature; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.module.SimpleModule; |
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.converter.HttpMessageConverter; |
|||
import org.springframework.http.converter.StringHttpMessageConverter; |
|||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|||
import org.springframework.web.servlet.config.annotation.*; |
|||
|
|||
import javax.annotation.Resource; |
|||
import javax.sql.DataSource; |
|||
import java.nio.charset.Charset; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.TimeZone; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
@Configuration |
|||
public class SpringConfig implements WebMvcConfigurer { |
|||
@Resource |
|||
private DruidProps druidPropsUtil; |
|||
@Value("${spring.snowflake.workerId}") |
|||
private String workerId; |
|||
@Value("${spring.snowflake.dataCenterId}") |
|||
private String dataCenterId; |
|||
|
|||
|
|||
/** |
|||
* 配置Converter |
|||
* @return |
|||
*/ |
|||
@Bean |
|||
public HttpMessageConverter<String> responseStringConverter() { |
|||
return new StringHttpMessageConverter( |
|||
Charset.forName("UTF-8")); |
|||
} |
|||
|
|||
@Bean |
|||
public HttpMessageConverter<Object> responseJsonConverter(){ |
|||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); |
|||
List<MediaType> mediaTypeList = new ArrayList<>(); |
|||
mediaTypeList.add(MediaType.TEXT_HTML); |
|||
mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); |
|||
converter.setSupportedMediaTypes(mediaTypeList); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
SimpleModule simpleModule = new SimpleModule(); |
|||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
|||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
|||
objectMapper.registerModule(simpleModule); |
|||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
|||
objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); |
|||
converter.setObjectMapper(objectMapper); |
|||
|
|||
return converter; |
|||
} |
|||
|
|||
@Override |
|||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|||
converters.add(responseStringConverter()); |
|||
converters.add(responseJsonConverter()); |
|||
} |
|||
|
|||
@Override |
|||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { |
|||
configurer.favorPathExtension(false); |
|||
} |
|||
|
|||
@Override |
|||
public void addCorsMappings(CorsRegistry registry) { |
|||
registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") |
|||
// 允许提交请求的方法,*表示全部允许
|
|||
.allowedMethods("*") |
|||
// #允许向该服务器提交请求的URI,*表示全部允许
|
|||
.allowedOrigins("*") |
|||
// 允许cookies跨域
|
|||
.allowCredentials(true) |
|||
// #允许访问的头信息,*表示全部
|
|||
.allowedHeaders("*") |
|||
// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
|
|||
.maxAge(18000L); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 配置静态资源 |
|||
*/ |
|||
@Override |
|||
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
|||
registry.addResourceHandler("swagger-ui.html") |
|||
.addResourceLocations("classpath:/META-INF/resources/"); |
|||
registry.addResourceHandler("/webjars/**") |
|||
.addResourceLocations("classpath:/META-INF/resources/webjars/"); |
|||
|
|||
registry.addResourceHandler("/uploads/**") |
|||
.addResourceLocations("file:" + PropUtil.path); |
|||
|
|||
registry.addResourceHandler("/static/**") |
|||
.addResourceLocations("classpath:/static/"); |
|||
} |
|||
|
|||
/** |
|||
* 配置拦截器 |
|||
* @param registry 拦截器 |
|||
*/ |
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry) { |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 配置数据源(单数据源) |
|||
*/ |
|||
@Bean |
|||
public DataSource dataSource(){ |
|||
return druidPropsUtil.createDruidDataSource(); |
|||
} |
|||
|
|||
@Bean |
|||
public Snowflake snowflake(){ |
|||
return IdUtil.createSnowflake(Long.parseLong(workerId),Long.parseLong(dataCenterId)); |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.ccsens.basicserver.config; |
|||
|
|||
import com.ccsens.util.WebConstant; |
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import springfox.documentation.builders.ParameterBuilder; |
|||
import springfox.documentation.builders.RequestHandlerSelectors; |
|||
import springfox.documentation.schema.ModelRef; |
|||
import springfox.documentation.service.ApiInfo; |
|||
import springfox.documentation.service.Parameter; |
|||
import springfox.documentation.spi.DocumentationType; |
|||
import springfox.documentation.spring.web.plugins.Docket; |
|||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
@Configuration |
|||
@EnableSwagger2 |
|||
@ConditionalOnExpression("${swagger.enable}") |
|||
public class SwaggerConfigure { |
|||
@Bean |
|||
public Docket customDocket() { |
|||
//
|
|||
return new Docket(DocumentationType.SWAGGER_2) |
|||
.apiInfo(apiInfo()) |
|||
.select() |
|||
.apis(RequestHandlerSelectors |
|||
.basePackage("com.ccsens.basicserver.api")) |
|||
.build() |
|||
.globalOperationParameters(setHeaderToken()); |
|||
} |
|||
|
|||
private ApiInfo apiInfo() { |
|||
return new ApiInfo("Swagger Tall-game", |
|||
"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", |
|||
"1.0.0", |
|||
"http://swagger.io/terms/", |
|||
"zhangsan", |
|||
"Apache 2.0", |
|||
"http://www.apache.org/licenses/LICENSE-2.0.html" |
|||
); |
|||
} |
|||
|
|||
private List<Parameter> setHeaderToken() { |
|||
ParameterBuilder tokenPar = new ParameterBuilder(); |
|||
List<Parameter> pars = new ArrayList<>(); |
|||
tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") |
|||
.defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) |
|||
.modelRef(new ModelRef("string")).parameterType("header").required(false).build(); |
|||
pars.add(tokenPar.build()); |
|||
return pars; |
|||
} |
|||
} |
@ -0,0 +1,159 @@ |
|||
package com.ccsens.basicserver.intercept; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.ccsens.util.WebConstant; |
|||
import org.apache.ibatis.executor.Executor; |
|||
import org.apache.ibatis.mapping.BoundSql; |
|||
import org.apache.ibatis.mapping.MappedStatement; |
|||
import org.apache.ibatis.mapping.ResultMap; |
|||
import org.apache.ibatis.mapping.SqlSource; |
|||
import org.apache.ibatis.plugin.*; |
|||
import org.apache.ibatis.reflection.DefaultReflectorFactory; |
|||
import org.apache.ibatis.reflection.MetaObject; |
|||
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; |
|||
import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; |
|||
import org.apache.ibatis.session.ResultHandler; |
|||
import org.apache.ibatis.session.RowBounds; |
|||
|
|||
import java.lang.reflect.InvocationTargetException; |
|||
import java.lang.reflect.Method; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Properties; |
|||
|
|||
/** |
|||
* @description: 查询添加rec_status = 0 |
|||
* @author: wuHuiJuan |
|||
* @create: 2019/12/11 10:58 |
|||
*/ |
|||
@Intercepts({ |
|||
@Signature( |
|||
type = Executor.class, |
|||
method = "query", |
|||
args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} |
|||
) |
|||
}) |
|||
public class MybatisInterceptor implements Interceptor { |
|||
@Override |
|||
public Object intercept(Invocation invocation) throws Throwable { |
|||
|
|||
|
|||
String selectByExample = "selectByExample"; |
|||
String countByExample = "countByExample"; |
|||
String countByExample2 = "selectByExample_COUNT"; |
|||
String selectByPrimaryKey = "selectByPrimaryKey"; |
|||
|
|||
Object[] args = invocation.getArgs(); |
|||
MappedStatement statement = (MappedStatement) args[0]; |
|||
if (statement.getId().endsWith(selectByExample) |
|||
|| statement.getId().endsWith(countByExample) |
|||
|| statement.getId().endsWith(countByExample2)) { |
|||
//XXXExample
|
|||
Object example = args[1]; |
|||
|
|||
addCondition(statement, example); |
|||
|
|||
|
|||
|
|||
|
|||
} else if (statement.getId().endsWith(selectByPrimaryKey)) { |
|||
BoundSql boundSql = statement.getBoundSql(args[1]); |
|||
String sql = boundSql.getSql() + " and rec_status = 0"; |
|||
MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql)); |
|||
MetaObject msObject = MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory()); |
|||
msObject.setValue("sqlSource.boundSql.sql", sql); |
|||
args[0] = newStatement; |
|||
} |
|||
|
|||
return invocation.proceed(); |
|||
} |
|||
|
|||
private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException { |
|||
if (example instanceof Map) { |
|||
example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT"); |
|||
} |
|||
|
|||
|
|||
Method method = example.getClass().getMethod("getOredCriteria", null); |
|||
//获取到条件数组,第一个是Criteria
|
|||
List list = (List) method.invoke(example); |
|||
if (CollectionUtil.isEmpty(list)) { |
|||
Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType(); |
|||
String exampleName = clazz.getName() + "Example"; |
|||
Object paramExample = Class.forName(exampleName).newInstance(); |
|||
Method createCriteria = paramExample.getClass().getMethod("createCriteria"); |
|||
Object criteria = createCriteria.invoke(paramExample); |
|||
Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); |
|||
andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); |
|||
list.add(criteria); |
|||
} else { |
|||
Object criteria = list.get(0); |
|||
Method getCriteria = criteria.getClass().getMethod("getCriteria"); |
|||
List params = (List) getCriteria.invoke(criteria); |
|||
boolean hasDel = false; |
|||
for (Object param : params) { |
|||
Method getCondition = param.getClass().getMethod("getCondition"); |
|||
Object condition = getCondition.invoke(param); |
|||
if ("rec_status =".equals(condition)) { |
|||
hasDel = true; |
|||
} |
|||
} |
|||
if (!hasDel) { |
|||
Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); |
|||
andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Object plugin(Object target) { |
|||
return Plugin.wrap(target, this); |
|||
} |
|||
|
|||
@Override |
|||
public void setProperties(Properties properties) { |
|||
|
|||
} |
|||
|
|||
private MappedStatement newMappedStatement(MappedStatement ms, SqlSource newSqlSource) { |
|||
MappedStatement.Builder builder = |
|||
new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); |
|||
builder.resource(ms.getResource()); |
|||
builder.fetchSize(ms.getFetchSize()); |
|||
builder.statementType(ms.getStatementType()); |
|||
builder.keyGenerator(ms.getKeyGenerator()); |
|||
if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) { |
|||
StringBuilder keyProperties = new StringBuilder(); |
|||
for (String keyProperty : ms.getKeyProperties()) { |
|||
keyProperties.append(keyProperty).append(","); |
|||
} |
|||
keyProperties.delete(keyProperties.length() - 1, keyProperties.length()); |
|||
builder.keyProperty(keyProperties.toString()); |
|||
} |
|||
builder.timeout(ms.getTimeout()); |
|||
builder.parameterMap(ms.getParameterMap()); |
|||
builder.resultMaps(ms.getResultMaps()); |
|||
builder.resultSetType(ms.getResultSetType()); |
|||
builder.cache(ms.getCache()); |
|||
builder.flushCacheRequired(ms.isFlushCacheRequired()); |
|||
builder.useCache(ms.isUseCache()); |
|||
|
|||
return builder.build(); |
|||
} |
|||
|
|||
|
|||
// 定义一个内部辅助类,作用是包装sq
|
|||
class BoundSqlSqlSource implements SqlSource { |
|||
private BoundSql boundSql; |
|||
public BoundSqlSqlSource(BoundSql boundSql) { |
|||
this.boundSql = boundSql; |
|||
} |
|||
@Override |
|||
public BoundSql getBoundSql(Object parameterObject) { |
|||
return boundSql; |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.ccsens.basicserver.util; |
|||
|
|||
import com.ccsens.util.CodeError; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/4 9:44 |
|||
*/ |
|||
public class BasicServerCodeError extends CodeError { |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.ccsens.basicserver.util; |
|||
|
|||
import com.ccsens.util.WebConstant; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/4 9:44 |
|||
*/ |
|||
public class BasicServerConstant extends WebConstant { |
|||
|
|||
/** |
|||
* 汤同伟返回字段 |
|||
*/ |
|||
public static class Tang{ |
|||
|
|||
public static final String NEWS_URL = "http://110.42.221.18:8081/is/bg/getNews"; |
|||
public static final String WEATHER_AND_EPIDEMIC_URL = "http://110.42.221.18:8081/is/bg/getWeatherAndCovid"; |
|||
public static final String ERROR_CODE = "errorCode"; |
|||
public static final String ERROR_MSG = "msg"; |
|||
public static final String DATA = "data"; |
|||
public static final String PAGE_NO = "pageNo"; |
|||
public static final int CURRENT_CODE = 20000; |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
logging: |
|||
level: |
|||
com: |
|||
favorites: DEBUG |
|||
org: |
|||
hibernate: ERROR |
|||
springframework: |
|||
web: DEBUG |
|||
mybatis: |
|||
config-location: classpath:mybatis/mybatis-config.xml |
|||
mapper-locations: classpath*:mapper_*/*.xml |
|||
# type-aliases-package: com.ccsens.mtpro.bean |
|||
#server: |
|||
# tomcat: |
|||
# uri-encoding: UTF-8 |
|||
spring: |
|||
http: |
|||
encoding: |
|||
charset: UTF-8 |
|||
enabled: true |
|||
force: true |
|||
log-request-details: true |
|||
servlet: |
|||
multipart: |
|||
max-file-size: 200MB |
|||
max-request-size: 200MB |
|||
snowflake: |
|||
dataCenterId: 2 |
|||
workerId: 2 |
|||
|
@ -0,0 +1,51 @@ |
|||
server: |
|||
port: 7290 |
|||
servlet: |
|||
context-path: /v1.0 |
|||
spring: |
|||
application: |
|||
name: ptccsens |
|||
datasource: |
|||
type: com.alibaba.druid.pool.DruidDataSource |
|||
# rabbitmq: |
|||
# host: 192.168.0.99 |
|||
# password: 111111 |
|||
# port: 5672 |
|||
# username: admin |
|||
# rabbitmq: |
|||
# host: dd.tall.wiki |
|||
# password: 111111 |
|||
# port: 5672 |
|||
# username: admin |
|||
# redis: |
|||
# database: 0 |
|||
# host: 127.0.0.1 |
|||
# jedis: |
|||
# pool: |
|||
# max-active: 200 |
|||
# max-idle: 10 |
|||
# max-wait: -1ms |
|||
# min-idle: 0 |
|||
# password: '' |
|||
# port: 6379 |
|||
# timeout: 1000ms |
|||
swagger: |
|||
enable: true |
|||
#mybatisCache: |
|||
# database: 1 |
|||
# host: 127.0.0.1 |
|||
# jedis: |
|||
# pool: |
|||
# max-active: 200 |
|||
# max-idle: 10 |
|||
# max-wait: -1 |
|||
# min-idle: 0 |
|||
# password: '' |
|||
# port: 6379 |
|||
# timeout: 1000 |
|||
|
|||
notGatewayUrl: http://101.201.226.163:7320/v1.0 |
|||
file: |
|||
path: /home/cloud/datang/uploads/ |
|||
domain: http://127.0.0.1:7270/v1.0/ |
|||
imgDomain: http://127.0.0.1:7270/v1.0/uploads/ |
@ -0,0 +1,16 @@ |
|||
server: |
|||
port: 7290 |
|||
servlet: |
|||
context-path: /v1.0 |
|||
spring: |
|||
application: |
|||
name: datang |
|||
datasource: |
|||
type: com.alibaba.druid.pool.DruidDataSource |
|||
swagger: |
|||
enable: true |
|||
|
|||
file: |
|||
path: /home/cloud/datang/uploads/ |
|||
domain: http://10.119.190.12:8000/v1.0/ |
|||
imgDomain: http://10.119.190.12:8000/v1.0/uploads/ |
@ -0,0 +1,16 @@ |
|||
server: |
|||
port: 7290 |
|||
servlet: |
|||
context-path: /v1.0 |
|||
spring: |
|||
application: |
|||
name: ptccsens |
|||
datasource: |
|||
type: com.alibaba.druid.pool.DruidDataSource |
|||
swagger: |
|||
enable: true |
|||
|
|||
file: |
|||
path: /home/cloud/datang/uploads/ |
|||
domain: http://test.tall.wiki/datang/v1.0/ |
|||
imgDomain: http://test.tall.wiki/datang/v1.0/uploads/ |
@ -0,0 +1,4 @@ |
|||
spring: |
|||
profiles: |
|||
active: test |
|||
include: common, util-test |
@ -0,0 +1,35 @@ |
|||
spring: |
|||
datasource: |
|||
druid: |
|||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
|||
driverClassName: com.mysql.cj.jdbc.Driver |
|||
dynamicUrl: jdbc:mysql://localhost:3306/${schema} |
|||
filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' |
|||
filterName: druidFilter |
|||
filterProfileEnable: true |
|||
filterUrlPattern: /* |
|||
filters: stat,wall |
|||
initialSize: 5 |
|||
maxActive: 20 |
|||
maxPoolPreparedStatementPerConnectionSize: 20 |
|||
maxWait: 60000 |
|||
minEvictableIdleTimeMillis: 300000 |
|||
minIdle: 5 |
|||
# password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9 |
|||
password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 |
|||
poolPreparedStatements: true |
|||
servletLogSlowSql: true |
|||
servletLoginPassword: 111111 |
|||
servletLoginUsername: druid |
|||
servletName: druidServlet |
|||
servletResetEnable: true |
|||
servletUrlMapping: /druid/* |
|||
testOnBorrow: false |
|||
testOnReturn: false |
|||
testWhileIdle: true |
|||
timeBetweenEvictionRunsMillis: 60000 |
|||
url: jdbc:mysql://test.tall.wiki:3306/datang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true |
|||
username: root |
|||
validationQuery: SELECT 1 FROM DUAL |
|||
# env: CCSENS_GAME |
|||
env: CCSENS_TALL |
@ -0,0 +1,33 @@ |
|||
spring: |
|||
datasource: |
|||
druid: |
|||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
|||
driverClassName: com.mysql.cj.jdbc.Driver |
|||
dynamicUrl: jdbc:mysql://localhost:3306/${schema} |
|||
filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' |
|||
filterName: druidFilter |
|||
filterProfileEnable: true |
|||
filterUrlPattern: /* |
|||
filters: stat,wall |
|||
initialSize: 5 |
|||
maxActive: 20 |
|||
maxPoolPreparedStatementPerConnectionSize: 20 |
|||
maxWait: 60000 |
|||
minEvictableIdleTimeMillis: 300000 |
|||
minIdle: 5 |
|||
password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 |
|||
poolPreparedStatements: true |
|||
servletLogSlowSql: true |
|||
servletLoginPassword: 111111 |
|||
servletLoginUsername: druid |
|||
servletName: druidServlet |
|||
servletResetEnable: true |
|||
servletUrlMapping: /druid/* |
|||
testOnBorrow: false |
|||
testOnReturn: false |
|||
testWhileIdle: true |
|||
timeBetweenEvictionRunsMillis: 60000 |
|||
url: jdbc:mysql://127.0.0.1/datang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true |
|||
username: root |
|||
validationQuery: SELECT 1 FROM DUAL |
|||
env: CCSENS_TALL |
@ -0,0 +1,33 @@ |
|||
spring: |
|||
datasource: |
|||
druid: |
|||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
|||
driverClassName: com.mysql.cj.jdbc.Driver |
|||
dynamicUrl: jdbc:mysql://localhost:3306/${schema} |
|||
filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' |
|||
filterName: druidFilter |
|||
filterProfileEnable: true |
|||
filterUrlPattern: /* |
|||
filters: stat,wall |
|||
initialSize: 5 |
|||
maxActive: 20 |
|||
maxPoolPreparedStatementPerConnectionSize: 20 |
|||
maxWait: 60000 |
|||
minEvictableIdleTimeMillis: 300000 |
|||
minIdle: 5 |
|||
password: |
|||
poolPreparedStatements: true |
|||
servletLogSlowSql: true |
|||
servletLoginPassword: 111111 |
|||
servletLoginUsername: druid |
|||
servletName: druidServlet |
|||
servletResetEnable: true |
|||
servletUrlMapping: /druid/* |
|||
testOnBorrow: false |
|||
testOnReturn: false |
|||
testWhileIdle: true |
|||
timeBetweenEvictionRunsMillis: 60000 |
|||
url: jdbc:mysql://127.0.0.1/datang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true |
|||
username: root |
|||
validationQuery: SELECT 1 FROM DUAL |
|||
env: CCSENS_TALL |
@ -0,0 +1,37 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" |
|||
updateCheck="false" |
|||
name="myEhcache"> |
|||
<diskStore path="java.io.tmpdir/Tmp_EhCache"/> |
|||
<defaultCache eternal="false" |
|||
maxElementsInMemory="1000" |
|||
overflowToDisk="false" |
|||
diskPersistent="false" |
|||
timeToIdleSeconds="0" |
|||
timeToLiveSeconds="600" |
|||
memoryStoreEvictionPolicy="LRU"/> |
|||
<cache name="user" |
|||
eternal="false" |
|||
maxElementsInMemory="10000" |
|||
overflowToDisk="false" |
|||
diskPersistent="false" |
|||
timeToIdleSeconds="0" |
|||
timeToLiveSeconds="0" |
|||
memoryStoreEvictionPolicy="LFU"/> |
|||
<!-- |
|||
缓存配置 |
|||
name: 缓存名称。 |
|||
maxElementsInMemory: 缓存最大个数。 |
|||
eternal: 对象是否永久有效,一但设置了,timeout将不起作用。 |
|||
timeToIdleSeconds: 设置对象在失效前的允许闲置时间(单位:秒)。仅当eternal=false对象不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大。 |
|||
timeToLiveSeconds: 设置对象在失效前允许存活时间(单位:秒)。最大时间介于创建时间和失效时间之间。仅当eternal=false对象不是永久有效时使用,默认是0.,也就是对象存活时间无穷大。 |
|||
overflowToDisk: 当内存中对象数量达到maxElementsInMemory时,Ehcache将会对象写到磁盘中。 |
|||
diskSpoolBufferSizeMB: 这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。 |
|||
maxElementsOnDisk: 硬盘最大缓存个数。 |
|||
diskPersistent: 是否缓存虚拟机重启期数据 Whether the disk store persists between restarts of the Virtual Machine. The default value is false. |
|||
diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒。 |
|||
memoryStoreEvictionPolicy: 当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。 |
|||
clearOnFlush: 内存数量最大时是否清除。 |
|||
--> |
|||
</ehcache> |
@ -0,0 +1,196 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 --> |
|||
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true --> |
|||
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 --> |
|||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 --> |
|||
<configuration scan="true" scanPeriod="10 seconds"> |
|||
|
|||
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />--> |
|||
|
|||
<contextName>logback</contextName> |
|||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 --> |
|||
<property name="log.path" value="/home/cloud/braintraining/log/" /> |
|||
|
|||
<!-- 彩色日志 --> |
|||
<!-- 彩色日志依赖的渲染类 --> |
|||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" /> |
|||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" /> |
|||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" /> |
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
|
|||
<!--输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>info</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
|
|||
<!--输出到文件--> |
|||
|
|||
<!-- 时间滚动输出 level为 DEBUG 日志 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文件的路径及文件名 --> |
|||
<file>${log.path}/log_debug.log</file> |
|||
<!--日志文件输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文件只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 时间滚动输出 level为 INFO 日志 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文件的路径及文件名 --> |
|||
<file>${log.path}/log_info.log</file> |
|||
<!--日志文件输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文件只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 时间滚动输出 level为 WARN 日志 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文件的路径及文件名 --> |
|||
<file>${log.path}/log_warn.log</file> |
|||
<!--日志文件输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文件只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
|
|||
<!-- 时间滚动输出 level为 ERROR 日志 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文件的路径及文件名 --> |
|||
<file>${log.path}/log_error.log</file> |
|||
<!--日志文件输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文件只记录ERROR级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- |
|||
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、 |
|||
以及指定<appender>。<logger>仅有一个name属性, |
|||
一个可选的level和一个可选的addtivity属性。 |
|||
name:用来指定受此logger约束的某一个包或者具体的某一个类。 |
|||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF, |
|||
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。 |
|||
如果未设置此属性,那么当前logger将会继承上级的级别。 |
|||
addtivity:是否向上级logger传递打印信息。默认是true。 |
|||
--> |
|||
<!--<logger name="org.springframework.web" level="info"/>--> |
|||
<!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>--> |
|||
<!-- |
|||
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作: |
|||
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息 |
|||
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别: |
|||
--> |
|||
|
|||
|
|||
<!-- |
|||
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性 |
|||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF, |
|||
不能设置为INHERITED或者同义词NULL。默认是DEBUG |
|||
可以包含零个或多个元素,标识这个appender将会添加到这个logger。 |
|||
--> |
|||
|
|||
<!--开发环境:打印控制台--> |
|||
<springProfile name="dev"> |
|||
<logger name="com.ccsens.ptpro.persist.*" level="debug"/> |
|||
</springProfile> |
|||
|
|||
<root level="info"> |
|||
<appender-ref ref="CONSOLE" /> |
|||
<appender-ref ref="DEBUG_FILE" /> |
|||
<appender-ref ref="INFO_FILE" /> |
|||
<appender-ref ref="WARN_FILE" /> |
|||
<appender-ref ref="ERROR_FILE" /> |
|||
</root> |
|||
|
|||
<!--生产环境:输出到文件--> |
|||
<!--<springProfile name="pro">--> |
|||
<!--<root level="info">--> |
|||
<!--<appender-ref ref="CONSOLE" />--> |
|||
<!--<appender-ref ref="DEBUG_FILE" />--> |
|||
<!--<appender-ref ref="INFO_FILE" />--> |
|||
<!--<appender-ref ref="ERROR_FILE" />--> |
|||
<!--<appender-ref ref="WARN_FILE" />--> |
|||
<!--</root>--> |
|||
<!--</springProfile>--> |
|||
|
|||
</configuration> |
@ -0,0 +1,62 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE configuration |
|||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-config.dtd"> |
|||
|
|||
<configuration> |
|||
<!-- 全局参数 --> |
|||
<settings> |
|||
<!-- 打印SQL语句 --> |
|||
<setting name="logImpl" value="STDOUT_LOGGING" /> |
|||
<!-- 使全局的映射器启用或禁用缓存。 --> |
|||
<setting name="cacheEnabled" value="true"/> |
|||
<!-- 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载。 --> |
|||
<setting name="lazyLoadingEnabled" value="true"/> |
|||
<!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则,每种属性将会按需要加载。 --> |
|||
<setting name="aggressiveLazyLoading" value="true"/> |
|||
<!-- 是否允许单条sql 返回多个数据集 (取决于驱动的兼容性) default:true --> |
|||
<setting name="multipleResultSetsEnabled" value="true"/> |
|||
<!-- 是否可以使用列的别名 (取决于驱动的兼容性) default:true --> |
|||
<setting name="useColumnLabel" value="true"/> |
|||
<!-- 允许JDBC 生成主键。需要驱动器支持。如果设为了true,这个设置将强制使用被生成的主键,有一些驱动器不兼容不过仍然可以执行。 default:false --> |
|||
<setting name="useGeneratedKeys" value="true"/> |
|||
<!-- 指定 MyBatis 如何自动映射 数据基表的列 NONE:不隐射 PARTIAL:部分 FULL:全部 --> |
|||
<setting name="autoMappingBehavior" value="PARTIAL"/> |
|||
<!-- 这是默认的执行类型 (SIMPLE: 简单; REUSE: 执行器可能重复使用prepared statements语句;BATCH: 执行器可以重复执行语句和批量更新) --> |
|||
<setting name="defaultExecutorType" value="SIMPLE"/> |
|||
<!-- 使用驼峰命名法转换字段。 --> |
|||
<setting name="mapUnderscoreToCamelCase" value="true"/> |
|||
<!-- 设置本地缓存范围 session:就会有数据的共享 statement:语句范围 (这样就不会有数据的共享 ) defalut:session --> |
|||
<setting name="localCacheScope" value="SESSION"/> |
|||
<!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型 --> |
|||
<setting name="jdbcTypeForNull" value="NULL"/> |
|||
</settings> |
|||
|
|||
<typeAliases> |
|||
<typeAlias alias="Integer" type="java.lang.Integer" /> |
|||
<typeAlias alias="Long" type="java.lang.Long" /> |
|||
<typeAlias alias="HashMap" type="java.util.HashMap" /> |
|||
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap" /> |
|||
<typeAlias alias="ArrayList" type="java.util.ArrayList" /> |
|||
<typeAlias alias="LinkedList" type="java.util.LinkedList" /> |
|||
<typeAlias alias="String" type="java.lang.String" /> |
|||
</typeAliases> |
|||
|
|||
<plugins> |
|||
<!-- com.github.pagehelper为PageHelper类所在包名 --> |
|||
<plugin interceptor="com.github.pagehelper.PageHelper"> |
|||
<property name="dialect" value="mysql"/> |
|||
<!-- 该参数默认为false --> |
|||
<!-- 设置为true时,会将RowBounds第一个参数offset当成pageNum页码使用 --> |
|||
<!-- 和startPage中的pageNum效果一样--> |
|||
<property name="offsetAsPageNum" value="false"/> |
|||
<!-- 该参数默认为false --> |
|||
<!-- 设置为true时,使用RowBounds分页会进行count查询 --> |
|||
<property name="rowBoundsWithCount" value="false"/> |
|||
<property name="pageSizeZero" value="true"/> |
|||
<property name="reasonable" value="false"/> |
|||
<property name="supportMethodsArguments" value="false"/> |
|||
<property name="returnPageInfo" value="none"/> |
|||
</plugin> |
|||
</plugins> |
|||
</configuration> |
@ -0,0 +1,17 @@ |
|||
package com.ccsens.basicserver; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2022/3/10 11:29 |
|||
*/ |
|||
public class Test01 { |
|||
|
|||
@Test |
|||
public void test01(){ |
|||
System.out.println("山西省州市".indexOf("[州]")); |
|||
System.out.println("黑龙江省 牡丹江市".replaceAll("\\s","")); |
|||
} |
|||
} |
Loading…
Reference in new issue