debug
							parent
							
								
									f38513a7d1
								
							
						
					
					
						commit
						b67ea7362f
					
				| @ -1,34 +0,0 @@ | |||||||
| package org.ils.order.config; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| import com.baomidou.mybatisplus.annotation.DbType; |  | ||||||
| import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |  | ||||||
| import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |  | ||||||
| import org.mybatis.spring.annotation.MapperScan; |  | ||||||
| import org.springframework.context.annotation.Bean; |  | ||||||
| import org.springframework.context.annotation.Configuration; |  | ||||||
| import org.springframework.transaction.annotation.EnableTransactionManagement; |  | ||||||
| 
 |  | ||||||
| import java.util.Collections; |  | ||||||
| 
 |  | ||||||
| @EnableTransactionManagement |  | ||||||
| @Configuration |  | ||||||
| @MapperScan("org.ils.order.mapper") |  | ||||||
| public class MyBatisPlusConfig { |  | ||||||
|     @Bean |  | ||||||
|     public PaginationInnerInterceptor paginationInnerInterceptor() { |  | ||||||
|         PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); |  | ||||||
|         // 设置最大单页限制数量,默认 500 条,-1 不受限制
 |  | ||||||
|         paginationInterceptor.setMaxLimit(-1L); |  | ||||||
|         paginationInterceptor.setDbType(DbType.MYSQL); |  | ||||||
|         // 开启 count 的 join 优化,只针对部分 left join
 |  | ||||||
|         paginationInterceptor.setOptimizeJoin(true); |  | ||||||
|         return paginationInterceptor; |  | ||||||
|     } |  | ||||||
|     @Bean |  | ||||||
|     public MybatisPlusInterceptor mybatisPlusInterceptor(){ |  | ||||||
|         MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); |  | ||||||
|         mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor())); |  | ||||||
|         return mybatisPlusInterceptor; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,46 +0,0 @@ | |||||||
| package org.ils.order.config; |  | ||||||
| 
 |  | ||||||
| import com.fasterxml.jackson.annotation.JsonAutoDetect; |  | ||||||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; |  | ||||||
| import com.fasterxml.jackson.annotation.PropertyAccessor; |  | ||||||
| import com.fasterxml.jackson.databind.ObjectMapper; |  | ||||||
| import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; |  | ||||||
| import org.springframework.context.annotation.Bean; |  | ||||||
| import org.springframework.context.annotation.Configuration; |  | ||||||
| import org.springframework.data.redis.connection.RedisConnectionFactory; |  | ||||||
| import org.springframework.data.redis.core.RedisTemplate; |  | ||||||
| import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |  | ||||||
| import org.springframework.data.redis.serializer.StringRedisSerializer; |  | ||||||
| 
 |  | ||||||
| import java.net.UnknownHostException; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * @author chenjf |  | ||||||
|  */ |  | ||||||
| @Configuration |  | ||||||
| public class RedisConfig { |  | ||||||
|     @Bean |  | ||||||
|     public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) |  | ||||||
|             throws UnknownHostException { |  | ||||||
|         RedisTemplate<String, Object> template = new RedisTemplate<>(); |  | ||||||
|         template.setConnectionFactory(redisConnectionFactory); |  | ||||||
|         //Json序列化配置
 |  | ||||||
|         //注意:SpringBoot默认的redis序列化方式是jdk序列化有兴趣可以看默认RedisTemplate源码
 |  | ||||||
|         Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); |  | ||||||
|         ObjectMapper om = new ObjectMapper(); |  | ||||||
|         om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |  | ||||||
|         om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); |  | ||||||
|         jackson2JsonRedisSerializer.setObjectMapper(om); |  | ||||||
|         StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); |  | ||||||
|         //key采用string的序列化方式
 |  | ||||||
|         template.setKeySerializer(stringRedisSerializer); |  | ||||||
|         //hash的key也采用string的序列化方式
 |  | ||||||
|         template.setHashKeySerializer(stringRedisSerializer); |  | ||||||
|         //value序列化方式采用jackson
 |  | ||||||
|         template.setValueSerializer(stringRedisSerializer); |  | ||||||
|         //hash的value序列化方式采用jackson
 |  | ||||||
|         template.setHashValueSerializer(jackson2JsonRedisSerializer); |  | ||||||
|         template.afterPropertiesSet(); |  | ||||||
|         return template; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,61 +0,0 @@ | |||||||
| package org.ils.order.config; |  | ||||||
| 
 |  | ||||||
| import org.apache.http.client.HttpClient; |  | ||||||
| import org.apache.http.client.config.RequestConfig; |  | ||||||
| import org.apache.http.config.Registry; |  | ||||||
| import org.apache.http.config.RegistryBuilder; |  | ||||||
| import org.apache.http.conn.socket.ConnectionSocketFactory; |  | ||||||
| import org.apache.http.conn.socket.PlainConnectionSocketFactory; |  | ||||||
| import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |  | ||||||
| import org.apache.http.impl.client.HttpClientBuilder; |  | ||||||
| import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |  | ||||||
| import org.springframework.context.annotation.Bean; |  | ||||||
| import org.springframework.context.annotation.Configuration; |  | ||||||
| import org.springframework.http.client.ClientHttpRequestFactory; |  | ||||||
| import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |  | ||||||
| 
 |  | ||||||
| import org.springframework.web.client.RestTemplate; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * restTemplate 数据池配置类 |  | ||||||
|  * @author chenjf |  | ||||||
|  */ |  | ||||||
| @Configuration |  | ||||||
| public class RestTemplateConfig { |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public RestTemplate restTemplate() { |  | ||||||
|         return new RestTemplate(httpRequestFactory()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public ClientHttpRequestFactory httpRequestFactory() { |  | ||||||
|         return new HttpComponentsClientHttpRequestFactory(httpClient()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public HttpClient httpClient() { |  | ||||||
|         Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() |  | ||||||
|                 .register("http", PlainConnectionSocketFactory.getSocketFactory()) |  | ||||||
|                 .register("https", SSLConnectionSocketFactory.getSocketFactory()) |  | ||||||
|                 .build(); |  | ||||||
|         PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); |  | ||||||
|         //设置整个连接池最大连接数
 |  | ||||||
|         connectionManager.setMaxTotal(400); |  | ||||||
| 
 |  | ||||||
|         //路由是对maxTotal的细分
 |  | ||||||
|         connectionManager.setDefaultMaxPerRoute(100); |  | ||||||
|         RequestConfig requestConfig = RequestConfig.custom() |  | ||||||
|                 .setSocketTimeout(3000)  //返回数据的超时时间
 |  | ||||||
|                 .setConnectTimeout(2000) //连接上服务器的超时时间
 |  | ||||||
|                 .setConnectionRequestTimeout(1000) //从连接池中获取连接的超时时间
 |  | ||||||
|                 .build(); |  | ||||||
|         return HttpClientBuilder.create() |  | ||||||
|                 .setDefaultRequestConfig(requestConfig) |  | ||||||
|                 .setConnectionManager(connectionManager) |  | ||||||
|                 .build(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,70 +0,0 @@ | |||||||
| package org.ils.order.config; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| import io.swagger.annotations.ApiOperation; |  | ||||||
| import org.springframework.context.annotation.Bean; |  | ||||||
| import org.springframework.context.annotation.Configuration; |  | ||||||
| import org.springframework.web.bind.annotation.RestController; |  | ||||||
| import springfox.documentation.builders.ParameterBuilder; |  | ||||||
| import springfox.documentation.builders.PathSelectors; |  | ||||||
| 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 chenjf |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| @Configuration |  | ||||||
| @EnableSwagger2 |  | ||||||
| public class SwaggerConfig { |  | ||||||
| 
 |  | ||||||
|     //配置了 Swagger 的Docket的bean实例
 |  | ||||||
|     @Bean |  | ||||||
|     public Docket docket(){ |  | ||||||
| 
 |  | ||||||
|         ParameterBuilder ticketPar = new ParameterBuilder(); |  | ||||||
|         List<Parameter> pars = new ArrayList<>(); |  | ||||||
|         ticketPar.name("Authorization").description("token") |  | ||||||
|                 .modelRef(new ModelRef("string")).parameterType("header") |  | ||||||
|                 .required(false).build(); |  | ||||||
|         pars.add(ticketPar.build()); |  | ||||||
| 
 |  | ||||||
|         return new Docket(DocumentationType.SWAGGER_2) |  | ||||||
|                 .apiInfo(apiInfo()) |  | ||||||
|                 .select() |  | ||||||
|                 //RequestHandlerSelectors, 配置要扫描接口的方式
 |  | ||||||
|                 //basePackage:指定要扫描的包
 |  | ||||||
|                 //any():扫描全部
 |  | ||||||
|                 //withClassAnnotation: 扫描类上的注解
 |  | ||||||
|                 //withMethodAnnotation: 扫描方法上的注解
 |  | ||||||
|                 .apis(RequestHandlerSelectors.basePackage("org.ils.order")) |  | ||||||
|                 .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) |  | ||||||
|                 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |  | ||||||
|                 .paths(PathSelectors.any()) |  | ||||||
|                 .build() |  | ||||||
|                 .globalOperationParameters(pars); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     //配置Swagger 信息=apiInfo
 |  | ||||||
|     private ApiInfo apiInfo(){ |  | ||||||
|         return new ApiInfo( |  | ||||||
|                 "ils engine Api", |  | ||||||
|                 "ils 订单服务接口文档", |  | ||||||
|                 "v1.0", |  | ||||||
|                 "127.0.0.1:9097/", |  | ||||||
|                 null,//contact
 |  | ||||||
|                 "Apache 2.0", |  | ||||||
|                 "http://www.apache.org/licenses/LICENSE-2.0", |  | ||||||
|                 new ArrayList() |  | ||||||
|         ); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -0,0 +1,26 @@ | |||||||
|  | package org.ils.order.controller; | ||||||
|  | 
 | ||||||
|  | import io.swagger.annotations.Api; | ||||||
|  | import io.swagger.annotations.ApiOperation; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
|  | import org.ils.order.dto.dto.MainLinePageDto; | ||||||
|  | import org.ils.order.result.Result; | ||||||
|  | import org.ils.order.service.impl.MainLineServiceImpl; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.web.bind.annotation.*; | ||||||
|  | 
 | ||||||
|  | @RestController | ||||||
|  | @RequestMapping("/api/v1/main/line/") | ||||||
|  | @Slf4j | ||||||
|  | @Api(value = "ils 测试接口", tags = {"测试接口"}) | ||||||
|  | public class MainLineController { | ||||||
|  |     @Autowired | ||||||
|  |     private MainLineServiceImpl mainLineService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @ApiOperation("查询列表") | ||||||
|  |     @RequestMapping(value = "list", method = RequestMethod.POST) | ||||||
|  |     public Result list(@RequestBody MainLinePageDto record){ | ||||||
|  |         return (Result) mainLineService.list(record); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -1,45 +1,42 @@ | |||||||
| package org.ils.order; | package org.ils.order; | ||||||
| 
 | 
 | ||||||
| import com.alibaba.fastjson.JSONObject; | import com.z.common.util.RedisUtils; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
|  | import org.ils.order.dto.dto.MainLinePageDto; | ||||||
| import org.ils.order.properties.BaseConfigProperties; | import org.ils.order.properties.BaseConfigProperties; | ||||||
|  | import org.ils.order.result.Result; | ||||||
|  | import org.ils.order.service.impl.MainLineServiceImpl; | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import org.junit.runner.RunWith; | import org.junit.runner.RunWith; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.boot.test.context.SpringBootTest; | import org.springframework.boot.test.context.SpringBootTest; | ||||||
| import org.springframework.http.HttpEntity; |  | ||||||
| import org.springframework.http.HttpHeaders; |  | ||||||
| import org.springframework.http.MediaType; |  | ||||||
| import org.springframework.http.ResponseEntity; |  | ||||||
| import org.springframework.test.context.junit4.SpringRunner; | import org.springframework.test.context.junit4.SpringRunner; | ||||||
| import org.springframework.web.client.RestTemplate; | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| @Slf4j | @Slf4j | ||||||
| @RunWith(SpringRunner.class) | @RunWith(SpringRunner.class) | ||||||
| @SpringBootTest | @SpringBootTest | ||||||
| public  class RestTemplateTest { | public  class RestTemplateTest { | ||||||
|     @Autowired |  | ||||||
|     private RestTemplate restTemplate; |  | ||||||
| 
 | 
 | ||||||
|     @Autowired |     @Autowired | ||||||
|     private BaseConfigProperties baseConfig; |     private BaseConfigProperties baseConfig; | ||||||
|     @Test |  | ||||||
|     public void test(){ |  | ||||||
|         log.info("url :{}", baseConfig.getBaiduUrl()); |  | ||||||
|         String content = restTemplate.getForObject( baseConfig.getBaiduUrl(), String.class); |  | ||||||
|         log.info("get content :{}", content); |  | ||||||
| 
 |  | ||||||
|         JSONObject param = new JSONObject(); |  | ||||||
|         param.put("alarmType", 2); |  | ||||||
|         param.put("optType", 2); |  | ||||||
|         param.put("optDesc", "自动处理"); |  | ||||||
|         HttpHeaders headers = new HttpHeaders(); |  | ||||||
|         headers.add("Content-Type","application/json;charset=UTF-8"); |  | ||||||
|         headers.add("Accept", MediaType.APPLICATION_JSON.toString()); |  | ||||||
|         HttpEntity<String> formEntity = new HttpEntity<String>(param.toString(),headers); |  | ||||||
|         ResponseEntity<JSONObject> response2 =  restTemplate.postForEntity( baseConfig.getBaiduUrl(), formEntity, JSONObject.class); |  | ||||||
|         log.info("response2--->{}",response2.getBody()); |  | ||||||
| 
 | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private MainLineServiceImpl mainLineServiceImpl; | ||||||
| 
 | 
 | ||||||
|  |     public void test(){ | ||||||
|  |         mainLineServiceImpl.test(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void test2(){ | ||||||
|  |         MainLinePageDto mainLinePageDto = new MainLinePageDto(); | ||||||
|  |         mainLinePageDto.setPageNo(1); | ||||||
|  |         mainLinePageDto.setPageSize(10); | ||||||
|  |         mainLinePageDto.setMainLineName("MAI202308021001"); | ||||||
|  |         Result list = mainLineServiceImpl.list(mainLinePageDto); | ||||||
|  |         log.info(list.toString()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
					Loading…
					
					
				
		Reference in New Issue