Compare commits

..

No commits in common. '80becfa375db9e929243e27ee2e32620f5dae8ab' and 'ff53026f2eaece1754a9dc4e79d313abd2a1a78c' have entirely different histories.

@ -15,18 +15,21 @@
*/ */
package org.opsli.api.wrapper.system.user; package org.opsli.api.wrapper.system.user;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validator.Validator; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validator.ValidatorLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValidatorType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
* - *
* *
* @author Pace * @author Pace
* @date 2020-09-16 17:33 * @date 2020-09-16 17:33
@ -35,6 +38,33 @@ import org.opsli.plugins.excel.annotation.ExcelInfo;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class UserSelfSaveModel extends ApiWrapper { public class UserSelfSaveModel extends ApiWrapper {
/** 登录账户 */
@Schema(description = "登录账户")
@ExcelIgnore
@Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidatorLenMax(32)
@ValidatorLenMin(4)
private String username;
/** 登录密码 */
@Schema(description = "登录密码")
@ExcelIgnore
@ValidatorLenMin(6)
@ValidatorLenMax(50)
private String password;
/** 登录密码强度 */
@Schema(description = "登录密码强度")
@ExcelIgnore
@ValidatorLenMin(1)
@ValidatorLenMax(1)
private String passwordLevel;
/** 是否启用 */
@Schema(description = "是否启用")
@ExcelIgnore
@ValidatorLenMax(1)
private String enable;
/** 真实姓名 */ /** 真实姓名 */
@Schema(description = "真实姓名") @Schema(description = "真实姓名")
@ -44,6 +74,45 @@ public class UserSelfSaveModel extends ApiWrapper {
@ValidatorLenMax(50) @ValidatorLenMax(50)
private String realName; private String realName;
/** 手机 */
@Schema(description = "手机")
@ExcelProperty(value = "手机", order = 2)
@ExcelInfo
private String mobile;
/** 邮箱 */
@Schema(description = "邮箱")
@ExcelProperty(value = "邮箱", order = 3)
@ExcelInfo
private String email;
/** 工号 */
@Schema(description = "工号")
@ExcelProperty(value = "工号", order = 4)
@ExcelInfo
@Validator({ValidatorType.IS_GENERAL})
@ValidatorLenMax(32)
private String no;
/** 头像 */
@Schema(description = "头像")
@ExcelIgnore
@ValidatorLenMax(255)
private String avatar;
/** 最后登陆IP */
@Schema(description = "最后登陆IP")
@ExcelIgnore
@Validator(ValidatorType.IS_IPV4)
private String loginIp;
/** 备注 */
@Schema(description = "备注")
@ExcelProperty(value = "备注", order = 5)
@ExcelInfo
@ValidatorLenMax(255)
private String remark;
/** 签名 */ /** 签名 */
@Schema(description = "签名") @Schema(description = "签名")
@ExcelProperty(value = "签名", order = 5) @ExcelProperty(value = "签名", order = 5)
@ -51,4 +120,38 @@ public class UserSelfSaveModel extends ApiWrapper {
@ValidatorLenMax(255) @ValidatorLenMax(255)
private String sign; private String sign;
/** 多租户字段 */
@Schema(description = "多租户ID")
@ExcelIgnore
@ValidatorLenMax(20)
private String tenantId;
/** 是否租户管理员 */
@Schema(description = "是否租户管理员")
@ExcelIgnore
@ValidatorLenMax(1)
private String izTenantAdmin;
/** 是否存在组织 */
@JsonIgnore
@ExcelIgnore
@ValidatorLenMax(1)
private String izExistOrg;
/** 允许切换租户0 不允许 1 允许) */
@Schema(description = "是否允许切换运营商")
@ExcelIgnore
private String enableSwitchTenant;
/** 切换后的租户id*/
@JsonIgnore
@ExcelIgnore
private String switchTenantId;
/** 切换后的租户管理员*/
@JsonIgnore
@ExcelIgnore
private String switchTenantUserId;
} }

@ -49,11 +49,11 @@ public class SysUser extends BaseEntity {
private String realName; private String realName;
/** 手机 */ /** 手机 */
@TableField(updateStrategy = FieldStrategy.NOT_EMPTY) @TableField(updateStrategy = FieldStrategy.ALWAYS)
private String mobile; private String mobile;
/** 邮箱 */ /** 邮箱 */
@TableField(updateStrategy = FieldStrategy.NOT_EMPTY) @TableField(updateStrategy = FieldStrategy.ALWAYS)
private String email; private String email;
/** 工号 */ /** 工号 */

@ -51,12 +51,6 @@ public interface IUserService extends CrudServiceInterface<SysUser, UserModel> {
*/ */
UserModel queryByEmail(String email); UserModel queryByEmail(String email);
/**
*
* @param userSelfSaveModel model
* @return boolean
*/
boolean updateUserInfo(UserSelfSaveModel userSelfSaveModel);
/** /**
* *

@ -610,7 +610,8 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
// 刷新用户缓存 // 刷新用户缓存
this.clearCache(Collections.singletonList(userModel)); this.clearCache(Collections.singletonList(userModel));
} }
return ret;
return false;
} }
@ -653,7 +654,8 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
// 刷新用户缓存 // 刷新用户缓存
this.clearCache(Collections.singletonList(userModel)); this.clearCache(Collections.singletonList(userModel));
} }
return ret;
return false;
} }
@Override @Override
@ -676,10 +678,12 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
// 修改密码 // 修改密码
boolean ret = mapper.updatePassword(userPassword); boolean ret = mapper.updatePassword(userPassword);
if(ret){ if(ret){
// 刷新用户缓存 // 刷新用户缓存
this.clearCache(Collections.singletonList(userModel)); this.clearCache(Collections.singletonList(userModel));
} }
return ret; return ret;
} }
@ -718,33 +722,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setId(model.getId()); sysUser.setId(model.getId());
sysUser.setAvatar(model.getAvatar()); sysUser.setAvatar(model.getAvatar());
boolean ret = mapper.updateAvatar(sysUser); return mapper.updateAvatar(sysUser);
if(ret){
// 刷新用户缓存
this.clearCache(Collections.singletonList(model));
}
return ret;
}
/**
*
* @param userSelfSaveModel model
* @return boolean
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateUserInfo(UserSelfSaveModel userSelfSaveModel){
UserModel currUser = UserUtil.getUserBySource();
LambdaUpdateWrapper<SysUser> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(SysUser::getRealName, userSelfSaveModel.getRealName())
.set(SysUser::getSign, userSelfSaveModel.getSign())
.eq(SysUser::getId, currUser.getId());
boolean ret = this.update(updateWrapper);
if(ret){
// 刷新用户缓存
this.clearCache(Collections.singletonList(currUser));
}
return ret;
} }

@ -199,10 +199,8 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
UserModel user = UserUtil.getUserBySource(); UserModel user = UserUtil.getUserBySource();
userPassword.setUserId(user.getId()); userPassword.setUserId(user.getId());
IService.updatePasswordByCheckOld(userPassword);
boolean flag = IService.updatePasswordByCheckOld(userPassword); return ResultWrapper.getSuccessResultWrapper();
return flag ? ResultWrapper.getSuccessResultWrapper()
: ResultWrapper.getErrorResultWrapper();
} }
/** /**
@ -231,9 +229,8 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
userPassword.setUserId(userBySource.getId()); userPassword.setUserId(userBySource.getId());
userPassword.setNewPassword(updateUserPasswordByForgetModel.getNewPassword()); userPassword.setNewPassword(updateUserPasswordByForgetModel.getNewPassword());
boolean flag = IService.updatePasswordByNotCheckOld(userPassword); IService.updatePasswordByNotCheckOld(userPassword);
return flag ? ResultWrapper.getSuccessResultWrapper() return ResultWrapper.getSuccessResultWrapper();
: ResultWrapper.getErrorResultWrapper();
} }
/** /**
@ -254,10 +251,9 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
// 验证对象 // 验证对象
ValidatorUtil.verify(updateUserEmailModel); ValidatorUtil.verify(updateUserEmailModel);
// 修改邮箱 // 修改用户邮箱
boolean flag = IService.updateUserEmail(updateUserEmailModel); IService.updateUserEmail(updateUserEmailModel);
return flag ? ResultWrapper.getSuccessResultWrapper() return ResultWrapper.getSuccessResultWrapper();
: ResultWrapper.getErrorResultWrapper();
} }
/** /**
@ -278,10 +274,9 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
// 验证对象 // 验证对象
ValidatorUtil.verify(updateUserMobileModel); ValidatorUtil.verify(updateUserMobileModel);
// 修改手机 // 修改用户邮箱
boolean flag = IService.updateUserMobile(updateUserMobileModel); IService.updateUserMobile(updateUserMobileModel);
return flag ? ResultWrapper.getSuccessResultWrapper() return ResultWrapper.getSuccessResultWrapper();
: ResultWrapper.getErrorResultWrapper();
} }
/** /**
@ -297,9 +292,10 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
UserModel userModel = new UserModel(); UserModel userModel = new UserModel();
userModel.setId(user.getId()); userModel.setId(user.getId());
userModel.setAvatar(userAvatarModel.getImgUrl()); userModel.setAvatar(userAvatarModel.getImgUrl());
boolean flag = IService.updateAvatar(userModel); IService.updateAvatar(userModel);
return flag ? ResultWrapper.getSuccessResultWrapper() // 刷新用户信息
: ResultWrapper.getErrorResultWrapper(); UserUtil.refreshUser(user);
return ResultWrapper.getSuccessResultWrapper();
} }
// ================================================== // ==================================================
@ -539,9 +535,13 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
throw new ServiceException(SystemMsg.EXCEPTION_USER_ILLEGAL_PARAMETER); throw new ServiceException(SystemMsg.EXCEPTION_USER_ILLEGAL_PARAMETER);
} }
boolean flag = IService.updateUserInfo(model); // 防止篡改手机号、邮箱号
return flag ? ResultWrapper.getSuccessResultWrapperByMsg("修改用户信息成功") model.setMobile(null);
: ResultWrapper.getErrorResultWrapper(); model.setEmail(null);
// 调用修改方法
IService.update(Convert.convert(UserModel.class, model));
return ResultWrapper.getSuccessResultWrapperByMsg("修改用户信息成功");
} }
/** /**

Loading…
Cancel
Save