格式化代码。
parent
e34efdfc56
commit
c4e7b8fd26
|
@ -14,7 +14,8 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import static xyz.zhouxy.plusone.domain.ValidatableStringRecord.getValueOrNull;
|
import xyz.zhouxy.plusone.commons.domain.ValidatableStringRecord;
|
||||||
|
import xyz.zhouxy.plusone.commons.util.OptionalUtil;
|
||||||
import xyz.zhouxy.plusone.jdbc.JdbcRepositorySupport;
|
import xyz.zhouxy.plusone.jdbc.JdbcRepositorySupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,23 +197,35 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final SqlParameterSource generateParamSource(Long id, @Nonnull Account entity) {
|
protected final SqlParameterSource generateParamSource(Long id, @Nonnull Account entity) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
final LocalDateTime now = LocalDateTime.now();
|
||||||
AccountInfo accountInfo = entity.getAccountInfo();
|
final AccountInfo accountInfo = entity.getAccountInfo();
|
||||||
|
final Optional<String> email = entity.getEmail().map(ValidatableStringRecord::value);
|
||||||
|
final Optional<String> mobilePhone = entity.getMobilePhone().map(ValidatableStringRecord::value);
|
||||||
|
final String username = entity.getUsername().value();
|
||||||
|
final String password = entity.getPassword().value();
|
||||||
|
final String salt = entity.getPassword().getSalt();
|
||||||
|
final Optional<String> avatar = accountInfo.getAvatar().map(Object::toString);
|
||||||
|
final int sex = accountInfo.getSex().getId();
|
||||||
|
final Optional<String> nickname = accountInfo.getNickname().map(ValidatableStringRecord::value);
|
||||||
|
final int status = entity.getStatus().getId();
|
||||||
|
final Optional<Long> createdBy = entity.getCreatedBy();
|
||||||
|
final Optional<Long> updatedBy = entity.getUpdatedBy();
|
||||||
|
final long version = entity.getVersion();
|
||||||
return new MapSqlParameterSource()
|
return new MapSqlParameterSource()
|
||||||
.addValue("id", id)
|
.addValue("id", id)
|
||||||
.addValue("email", getValueOrNull(entity.getEmail()))
|
.addValue("email", OptionalUtil.orElseNull(email))
|
||||||
.addValue("mobilePhone", getValueOrNull(entity.getMobilePhone()))
|
.addValue("mobilePhone", OptionalUtil.orElseNull(mobilePhone))
|
||||||
.addValue("username", entity.getUsername().value())
|
.addValue("username", username)
|
||||||
.addValue("password", entity.getPassword().value())
|
.addValue("password", password)
|
||||||
.addValue("salt", entity.getPassword().getSalt())
|
.addValue("salt", salt)
|
||||||
.addValue("avatar", accountInfo.getAvatar().toString())
|
.addValue("avatar", OptionalUtil.orElseNull(avatar))
|
||||||
.addValue("sex", accountInfo.getSex().getId())
|
.addValue("sex", sex)
|
||||||
.addValue("nickname", getValueOrNull(accountInfo.getNickname()))
|
.addValue("nickname", OptionalUtil.orElseNull(nickname))
|
||||||
.addValue("status", entity.getStatus().getId())
|
.addValue("status", status)
|
||||||
.addValue("createdBy", entity.getCreatedBy())
|
.addValue("createdBy", OptionalUtil.orElseNull(createdBy))
|
||||||
.addValue("createTime", now)
|
.addValue("createTime", now)
|
||||||
.addValue("updatedBy", entity.getUpdatedBy())
|
.addValue("updatedBy", OptionalUtil.orElseNull(updatedBy))
|
||||||
.addValue("updateTime", now)
|
.addValue("updateTime", now)
|
||||||
.addValue("version", entity.getVersion());
|
.addValue("version", version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue