@ShardStrategy(mapper = UserMapper.class)
public class UserShardStrategy implements SelectionStrategy<User>{
public ShardId selectShardIdForNewObject(User entity) {
if(User.SEX_MALE == entity.getGender()){
return new ShardId(1);
}else if(User.SEX_FEMALE == entity.getGender()){
return new ShardId(2);
}
// 或指向写库
return null;