use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.
the class RegisterController method register.
@ApiOperation(notes = "注册", value = "注册")
@RequestMapping(value = "/register", method = RequestMethod.POST)
public ModelResult<Object> register(@RequestParam String username, @RequestParam String password) throws Exception {
// 公钥传给客户端
String publicKey = Auth.getPublicKey();
// 客户端调用登录接口时进行公钥加密后传参调用此接口
password = RSAUtil.encryptByPubKey(password, publicKey);
User user = userCloud.getUser(username).getData();
if (user != null) {
return Result.build("该账号已注册", ApiResult.SUCCESS, ResultCode.CODE_200);
}
user = new User();
String salt = PasswordUtil.generateSalt();
String saltPassword = PasswordUtil.generatePassword(password, salt.getBytes());
user.setSalt(salt);
user.setUserName(username);
user.setPassword(saltPassword);
boolean result = userCloud.addUser(user).getData();
if (!result) {
return Result.build("注册失败", ApiResult.SUCCESS, ResultCode.CODE_200);
}
Auth.login(username, password, user.getSalt(), user.getPassword(), "user", user);
return Result.build("注册并登录成功", ApiResult.SUCCESS, ResultCode.CODE_200);
}
use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.
the class UserController method modifyPassword.
@ApiOperation(notes = "修改登录密码", value = "修改登录密码")
@RequestMapping(value = "/modify/password", method = RequestMethod.POST)
public ModelResult<Boolean> modifyPassword(@RequestParam(name = "password") String password) {
User user = Auth.getAuthc(User.class);
user.setPassword(password);
return userCloud.updateUser(user);
}
use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.
the class UserService method getUser.
@Override
public ModelResult<User> getUser(@PathVariable(name = "userName") String userName) {
User user = new User();
user.setUserName(userName);
return Result.build(userMapper.selectOne(user));
}
use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.
the class ProducerTest method send.
public void send() {
User user = new User();
user.setUserName("admin");
rabbitTemplate.convertAndSend("hello", user);
}
use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.
the class ConsumerTest method process.
@RabbitHandler
@RabbitListener(queues = "hello")
public void process(Message message) {
byte[] body = message.getBody();
User user = (User) SerializeUtil.deserialize(body);
System.out.println(user.getUserName());
}
Aggregations