Search in sources :

Example 6 with User

use of org.daijie.mybatis.model.User in project daijie-example by daijiejay.

the class LoginController method login.

@ApiOperation(notes = "登录", value = "登录")
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ModelResult<Object> login(@RequestParam String username, @RequestParam String password) throws Exception {
    // 公钥传给客户端
    String publicKey = Auth.getPublicKey();
    // 客户端调用登录接口时进行公钥加密后传参调用此接口
    password = RSAUtil.encryptByPubKey(password, publicKey);
    // 以下正式走登录流程
    User user = userCloud.getUser(username).getData();
    Auth.login(username, password, user.getSalt(), user.getPassword(), user);
    // 加入角色权限
    Auth.refreshRoles(new ArrayList<String>());
    ArrayList<String> permissions = new ArrayList<String>();
    permissions.add("USER");
    Auth.refreshPermissions(permissions);
    Auth.getPermissions();
    return Result.build("登录成功", ApiResult.SUCCESS, ResultCode.CODE_200);
}
Also used : User(org.daijie.mybatis.model.User) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 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)

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