change
This commit is contained in:
		
							parent
							
								
									ee814ac85b
								
							
						
					
					
						commit
						3ae555de41
					
				| 
						 | 
				
			
			@ -103,12 +103,12 @@
 | 
			
		|||
        </profile>
 | 
			
		||||
        <profile>
 | 
			
		||||
            <id>prod</id>
 | 
			
		||||
            <activation>
 | 
			
		||||
                <activeByDefault>true</activeByDefault>
 | 
			
		||||
            </activation>
 | 
			
		||||
            <properties>
 | 
			
		||||
                <spring.profiles.active>prod</spring.profiles.active>
 | 
			
		||||
            </properties>
 | 
			
		||||
            <activation>
 | 
			
		||||
                <activeByDefault>true</activeByDefault>
 | 
			
		||||
            </activation>
 | 
			
		||||
        </profile>
 | 
			
		||||
    </profiles>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
package com.taosdata.example.mybatisplusdemo.config;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
 | 
			
		||||
@Configuration
 | 
			
		||||
public class MybatisPlusConfig {
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    public PaginationInterceptor paginationInnerInterceptor() {
 | 
			
		||||
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
 | 
			
		||||
        // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求  默认false
 | 
			
		||||
        // paginationInterceptor.setOverflow(false);
 | 
			
		||||
        // 设置最大单页限制数量,默认 500 条,-1 不受限制
 | 
			
		||||
        // paginationInterceptor.setLimit(500);
 | 
			
		||||
        // 开启 count 的 join 优化,只针对部分 left join
 | 
			
		||||
//        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
 | 
			
		||||
        return paginationInterceptor;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +1,12 @@
 | 
			
		|||
spring:
 | 
			
		||||
  datasource:
 | 
			
		||||
#    driver-class-name: com.taosdata.jdbc.TSDBDriver
 | 
			
		||||
#    url: jdbc:TAOS://localhost:6030/mp_test
 | 
			
		||||
#    user: root
 | 
			
		||||
#    password: taosdata
 | 
			
		||||
#    charset: UTF-8
 | 
			
		||||
#    locale: en_US.UTF-8
 | 
			
		||||
#    timezone: UTC-8
 | 
			
		||||
 | 
			
		||||
    #    driver-class-name: com.taosdata.jdbc.TSDBDriver
 | 
			
		||||
    #    url: jdbc:TAOS://localhost:6030/mp_test
 | 
			
		||||
    #    user: root
 | 
			
		||||
    #    password: taosdata
 | 
			
		||||
    #    charset: UTF-8
 | 
			
		||||
    #    locale: en_US.UTF-8
 | 
			
		||||
    #    timezone: UTC-8
 | 
			
		||||
    driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
    url:  jdbc:mysql://master:3306/test?useSSL=false
 | 
			
		||||
    username: root
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,3 @@
 | 
			
		|||
spring:
 | 
			
		||||
  profiles:
 | 
			
		||||
    active: @spring.profiles.active@
 | 
			
		||||
    active: "@spring.profiles.active@"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package com.taosdata.example.mybatisplusdemo.mapper;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.taosdata.example.mybatisplusdemo.domain.Weather;
 | 
			
		||||
import org.junit.Assert;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
| 
						 | 
				
			
			@ -37,24 +38,11 @@ public class WeatherMapperTest {
 | 
			
		|||
        weather.setTs(new Timestamp(1605024000000l));
 | 
			
		||||
        weather.setTemperature(random.nextFloat() * 50);
 | 
			
		||||
        weather.setHumidity(random.nextInt(100));
 | 
			
		||||
        weather.setLocation("wangjing");
 | 
			
		||||
        weather.setLocation("望京");
 | 
			
		||||
        int affectRows = mapper.insert(weather);
 | 
			
		||||
        Assert.assertEquals(1, affectRows);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testDelete() {
 | 
			
		||||
        mapper.delete(new QueryWrapper<Weather>().eq("location", "wangjing"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testDeleteByMap() {
 | 
			
		||||
        Map<String, Object> map = new HashMap<>();
 | 
			
		||||
        map.put("location", "wangjing");
 | 
			
		||||
        int affectRows = mapper.deleteByMap(map);
 | 
			
		||||
//        Assert.assertEquals(0, affectRows);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testSelectOne() {
 | 
			
		||||
        QueryWrapper<Weather> wrapper = new QueryWrapper<>();
 | 
			
		||||
| 
						 | 
				
			
			@ -87,5 +75,16 @@ public class WeatherMapperTest {
 | 
			
		|||
        Assert.assertEquals(5, count);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testSelectPage() {
 | 
			
		||||
        Page<Weather> page = new Page<>(1, 2);
 | 
			
		||||
        Page<Weather> weatherPage = mapper.selectPage(page, null);
 | 
			
		||||
        System.out.println("total : " + weatherPage.getTotal());
 | 
			
		||||
        System.out.println("pages : " + weatherPage.getPages());
 | 
			
		||||
        for (Weather weather : weatherPage.getRecords()) {
 | 
			
		||||
            System.out.println(weather);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue