Search in sources :

Example 1 with User

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);
}
Also used : User(org.daijie.mybatis.model.User) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with User

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);
}
Also used : User(org.daijie.mybatis.model.User) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with 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));
}
Also used : User(org.daijie.mybatis.model.User)

Example 4 with 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);
}
Also used : User(org.daijie.mybatis.model.User)

Example 5 with 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());
}
Also used : User(org.daijie.mybatis.model.User) RabbitListener(org.springframework.amqp.rabbit.annotation.RabbitListener) RabbitHandler(org.springframework.amqp.rabbit.annotation.RabbitHandler)

Aggregations

User (org.daijie.mybatis.model.User)7 ApiOperation (io.swagger.annotations.ApiOperation)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)1 RabbitHandler (org.springframework.amqp.rabbit.annotation.RabbitHandler)1 RabbitListener (org.springframework.amqp.rabbit.annotation.RabbitListener)1