用户编辑密码加密修改

This commit is contained in:
176yunxuan 2024-01-15 22:55:32 +08:00
parent 6e37a89f23
commit 3f243f5c9c
3 changed files with 17 additions and 11 deletions

View File

@ -1,10 +1,12 @@
package com.jsl.oa.model.voData;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@Setter
@Getter
public class UserEditProfile {
private Long id;

View File

@ -10,6 +10,7 @@ import com.jsl.oa.utils.BaseResponse;
import com.jsl.oa.utils.ErrorCode;
import com.jsl.oa.utils.ResultUtil;
import lombok.RequiredArgsConstructor;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
@Service
@ -44,6 +45,9 @@ public class UserServiceImpl implements UserService {
@Override
public BaseResponse userEditProfile(UserEditProfile userEditProfile) {
if(userDAO.isExistUser(userEditProfile.getId())) {
if(userEditProfile.getPassword()!=null){
userEditProfile.setPassword(BCrypt.hashpw(userEditProfile.getPassword(), BCrypt.gensalt()));
}
userDAO.userEditProfile(userEditProfile);
return ResultUtil.success("修改成功");
}else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);

View File

@ -7,37 +7,37 @@
<update id="userEditProfile">
update organize_oa.oa_user
<set>
<if test="username != null">
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null">
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="address != null">
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="phone != null">
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="email != null">
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="age != null">
<if test="age != null and age != ''">
age = #{age},
</if>
<if test="signature != null">
<if test="signature != null and signature != ''">
signature = #{signature},
</if>
<if test="sex != null">
<if test="sex != null and sex != ''">
sex = #{sex},
</if>
<if test="avatar != null">
<if test="avatar != null and avatar != ''">
avatar = #{avatar},
</if>
<if test="nickname != null">
<if test="nickname != null and nickname != ''">
nickname = #{nickname},
</if>
<if test="description != null">
<if test="description != null and description != ''">
description = #{description}
</if>
</set>