Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Jhipster 4.10.2在注册中添加其他字段_Jhipster - Fatal编程技术网

使用Jhipster 4.10.2在注册中添加其他字段

使用Jhipster 4.10.2在注册中添加其他字段,jhipster,Jhipster,我需要将电话号码添加到注册页面,并需要将其保存在数据库中。我遵循以下链接 但由于Jhister版本发生了变化,代码与上面链接中的代码略有不同。所以我有点困惑。根据链接说明,我更新了ManagedUserVM。之后,我需要帮助,因为代码不同。它确实没有太大变化,逻辑保持不变 registerAccount函数现在应该如下所示: public void registerAccount(@Valid @RequestBody ManagedUserVM managedUserVM) { if

我需要将电话号码添加到注册页面,并需要将其保存在数据库中。我遵循以下链接


但由于Jhister版本发生了变化,代码与上面链接中的代码略有不同。所以我有点困惑。根据链接说明,我更新了ManagedUserVM。之后,我需要帮助,因为代码不同。

它确实没有太大变化,逻辑保持不变

registerAccount函数现在应该如下所示:

public void registerAccount(@Valid @RequestBody ManagedUserVM managedUserVM) {
    if (!checkPasswordLength(managedUserVM.getPassword())) {
        throw new InvalidPasswordException();
    }
    userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase()).ifPresent(u -> {throw new LoginAlreadyUsedException();});
    userRepository.findOneByEmailIgnoreCase(managedUserVM.getEmail()).ifPresent(u -> {throw new EmailAlreadyUsedException();});
    User user = userService.registerUser(managedUserVM, managedUserVM.getPassword(), managedUserVM.getPhone());
    mailService.sendActivationEmail(user);
}
以及UserService中的registerUser函数,它是前createUser的重命名:

请注意,如果使用SQL数据库正确链接User和UserExtra的ID,则可能需要手动更改数据库更改日志,因此如下所示:

<createTable tableName="user_extra">
        <column name="phone" type="varchar(255)">
            <constraints nullable="true" />
        </column>
        <column name="user_id" type="bigint">
            <constraints primaryKey="true" nullable="false" />
        </column>
        <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
    </createTable>
<createTable tableName="user_extra">
        <column name="phone" type="varchar(255)">
            <constraints nullable="true" />
        </column>
        <column name="user_id" type="bigint">
            <constraints primaryKey="true" nullable="false" />
        </column>
        <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
    </createTable>