Comments (11)
Could you provide a reproduce project(maven or gradle project) via GitHub?
from demo-reactive-mybatis.
tomorrow is ok?I am chinese student
from demo-reactive-mybatis.
Of course. Anytime is ok.
from demo-reactive-mybatis.
thank you
from demo-reactive-mybatis.
this is my project webflux
from demo-reactive-mybatis.
@chuntaojun
Probably, it will work fine if you change to use the BodyInserters.fromPublisher
method instead of the BodyInserters.fromObject
method.
Please try it.
from demo-reactive-mybatis.
ok, I'll try now,
from demo-reactive-mybatis.
Additional information:
You should add following configuration in application.properties
for performing a correct result auto-mapping of MyBatis in this application. If it is false
(default is false
), userID
and username
property becomes always null
.
mybatis.configuration.map-underscore-to-camel-case=true
from demo-reactive-mybatis.
how to use fromPublisher()?, I can't use this function in my code, have some error, I saw the fromPublisher is about webclient
WebClient.RequestHeadersSpec requestSpec1 = WebClient .create() .method(HttpMethod.POST) .uri("/resource") .body(BodyInserters.fromPublisher(Mono.just("data")), String.class);
from demo-reactive-mybatis.
ok. I already fix this bug, this is my new code
public class UserAsyncHandlerImpl implements UserAsyncHandler {
@Qualifier(value = "UserLoginService")
@Autowired
private UserLoginService loginService;
/**
* <pre>
* 用户登录 handler
* 用户登录对象为 UserDetails {username, password, scope, client_id, client_secret}
* @success : 返回 {access_token, scope, expires_in, refresh_token}
* @failed : 返回 UserLoginException
* </pre>
* @param request
* @return Mono<ResultData<LinkedHashMap>>
*/
@Override
public Mono<ServerResponse> userLogin(ServerRequest request) {
return request
.bodyToMono(User.class)
.flatMap(user -> ok().body(BodyInserters.fromObject(loginService.login(user))));
}
/**
* @param request
* @return
*/
@Override
public Mono<ServerResponse> userAddInfo(ServerRequest request) {
return ok().body(BodyInserters.empty());
}
/**
* @param request
* @return
*/
@Override
public Mono<ServerResponse> courierAddInfo(ServerRequest request) {
return null;
}
/**
* @param request
* @return
*/
@Override
public Mono<ServerResponse> userOrCourierUpdateInfo(ServerRequest request) {
return null;
}
}
public class UserLoginServiceImpl implements UserLoginService {
private final WxUserMapper userMapper;
public UserLoginServiceImpl(WxUserMapper userMapper) {
this.userMapper = userMapper;
}
@Autowired
private OAuthToken tokenFactory;
/**
* @param user
* @return
*/
@Override
public Flux<ResultData<LinkedHashMap>> login(User user) {
ResultData<LinkedHashMap> token = tokenFactory.init(user, getWxUser(user)).token().build();
return Flux.just(token).zipWith(Flux.interval(Duration.ZERO)).map(Tuple2::getT1).publish();
}
/**
* @param wxUser
* @return
*/
@Override
public Mono<ResultData> register(WxUser wxUser) {
return null;
}
@Override
public Mono<WxUser> test(User user) {
log.info("User info {}", user);
return Flux.just(userMapper.login(user.getUsername())).singleOrEmpty().subscribeOn(Schedulers.elastic());
}
/**
*
* @param user
* @return
*/
private WxUser getWxUser(User user) {
return userMapper.login(user.getUsername());
}
}
but still hava some problem, WxUser.password value always is null, why?
from demo-reactive-mybatis.
this is new Mapp.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.sudi.org.enpity.mapper.WxUserMapper">
<resultMap id="WxUserResult" type="com.sudi.org.enpity.WxUser">
<id column="user_id" property="userID"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
</resultMap>
<select id="login" resultType="com.sudi.org.enpity.WxUser">
select * from WxUser where username=#{username}
</select>
</mapper>
from demo-reactive-mybatis.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from demo-reactive-mybatis.