@@ -0,0 +1,22 @@ | |||
package com.telpo.dipperposition.annotation; | |||
import java.lang.annotation.*; | |||
/** | |||
* @program: DataPushServer | |||
* @description: mongo数据源切换注解 | |||
* @author: linwl | |||
* @create: 2020-07-11 15:06 | |||
*/ | |||
@Target({ElementType.METHOD}) | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Documented | |||
public @interface MongoSwitch { | |||
/** | |||
* mongo数据库名称 | |||
* | |||
* @return | |||
*/ | |||
String value() default ""; | |||
} |
@@ -22,8 +22,7 @@ import java.util.Map; | |||
public class MongoDbContext { | |||
private static final Map<String, MongoDbFactory> MONGO_CLIENT_DB_FACTORY_MAP = new HashMap<>(); | |||
private static final ThreadLocal<MongoDbFactory> MONGO_DB_FACTORY_THREAD_LOCAL = | |||
new ThreadLocal<>(); | |||
private static final ThreadLocal<MongoDbFactory> MONGO_DB_FACTORY_THREAD_LOCAL = new ThreadLocal<>(); | |||
@Autowired | |||
MongoListProperties mongoListProperties; | |||
@@ -1,5 +1,6 @@ | |||
package com.telpo.dipperposition.mapper; | |||
import com.telpo.dipperposition.annotation.MongoSwitch; | |||
import com.telpo.dipperposition.entity.mongo.IPProvinceEntity; | |||
import db.BaseMongoDbDao; | |||
import org.springframework.stereotype.Repository; | |||
@@ -21,11 +22,13 @@ public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> { | |||
} | |||
@Override | |||
@MongoSwitch("common") | |||
public void save(IPProvinceEntity entity, String collectionName) { | |||
super.save(entity, collectionName); | |||
} | |||
@Override | |||
@MongoSwitch("common") | |||
public void updateFirst(IPProvinceEntity srcObj, IPProvinceEntity targetObj) { | |||
super.updateFirst(srcObj, targetObj); | |||
} | |||
@@ -36,16 +39,19 @@ public class IPProvinceMapper extends BaseMongoDbDao<IPProvinceEntity> { | |||
} | |||
@Override | |||
@MongoSwitch("common") | |||
public List<IPProvinceEntity> queryList(IPProvinceEntity object) { | |||
return super.queryList(object); | |||
} | |||
@Override | |||
@MongoSwitch("common") | |||
public List<IPProvinceEntity> queryList(IPProvinceEntity object, String collectionName) { | |||
return super.queryList(object, collectionName); | |||
} | |||
@Override | |||
@MongoSwitch("common") | |||
public void deleteById(String id) { | |||
super.deleteById(id); | |||
} | |||
@@ -24,7 +24,7 @@ import java.net.InetSocketAddress; | |||
@Slf4j | |||
public class DipperPositionServer { | |||
@Value(value = "${position.serverAddr}") | |||
@Value(value = "${position.server.serverAddr}") | |||
private String serverAddr; | |||
@Value(value = "${position.server.timeAsycPort}") | |||
@@ -29,6 +29,7 @@ pos: | |||
position: | |||
server: | |||
timeAsycPort: | |||
posAsycPort: | |||
starsAsycPort: | |||
serverAddr: 172.16.192.26 | |||
timeAsycPort: 9011 | |||
posAsycPort: 9013 | |||
starsAsycPort: 9012 |