Compare commits

...

2 Commits

Author SHA1 Message Date
b54e1e314a Merge branch 'refs/heads/master' into master_lz
# Conflicts:
#	wms-module-system/src/main/java/top/wms/admin/auth/AbstractLoginHandler.java
#	wms-module-system/src/main/java/top/wms/admin/auth/handler/SocialLoginHandler.java
2026-03-03 14:21:14 +08:00
3082c24e13 优化 2026-03-03 14:19:20 +08:00
10 changed files with 14 additions and 114 deletions

View File

@@ -38,12 +38,6 @@ public class UserInfoResp implements Serializable {
@Schema(description = "用户名", example = "zhangsan")
private String username;
/**
* 昵称
*/
@Schema(description = "昵称", example = "张三")
private String nickname;
/**
* 性别
*/

View File

@@ -38,7 +38,6 @@ public class UserDO extends BaseDO {
// @FieldEncrypt(encryptor = BCryptEncryptor.class)
private String password;
/*
* 卡号
* */

View File

@@ -25,12 +25,12 @@ public class UserBasicInfoUpdateReq implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 昵称
* 用户名
*/
@Schema(description = "昵称", example = "张三")
@NotBlank(message = "昵称不能为空")
@Schema(description = "用户名", example = "张三")
@NotBlank(message = "用户名不能为空")
@Pattern(regexp = RegexConstants.GENERAL_NAME, message = "昵称长度为 2-30 个字符,支持中文、字母、数字、下划线,短横线")
private String nickname;
private String userName;
/**
* 性别

View File

@@ -38,7 +38,6 @@ public class UserReq implements Serializable {
@Pattern(regexp = RegexConstants.USERNAME, message = "用户名长度为 4-64 个字符,支持大小写字母、数字、下划线,以字母开头")
private String username;
/**
* 密码(加密)
*/

View File

@@ -1,10 +1,6 @@
package top.wms.admin.system.model.resp.user;
import cn.crane4j.annotation.Assemble;
import cn.crane4j.annotation.AssembleMethod;
import cn.crane4j.annotation.ContainerMethod;
import cn.crane4j.annotation.Mapping;
import cn.crane4j.annotation.condition.ConditionOnExpression;
import cn.crane4j.core.executor.handler.ManyToManyAssembleOperationHandler;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@@ -15,8 +11,6 @@ import top.wms.admin.common.constant.ContainerConstants;
import top.wms.admin.common.context.UserContextHolder;
import top.wms.admin.common.enums.DisEnableStatusEnum;
import top.wms.admin.common.enums.GenderEnum;
import top.wms.admin.system.model.resp.DeptResp;
import top.wms.admin.system.service.DeptService;
import top.continew.starter.file.excel.converter.ExcelBaseEnumConverter;
import top.continew.starter.file.excel.converter.ExcelListConverter;
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
@@ -48,13 +42,6 @@ public class UserDetailResp extends BaseDetailResp {
@ExcelProperty(value = "用户名", order = 2)
private String username;
/**
* 昵称
*/
@Schema(description = "昵称", example = "张三")
@ExcelProperty(value = "昵称", order = 3)
private String nickname;
/**
* 状态
*/
@@ -69,22 +56,6 @@ public class UserDetailResp extends BaseDetailResp {
@ExcelProperty(value = "性别", converter = ExcelBaseEnumConverter.class, order = 5)
private GenderEnum gender;
/**
* 部门 ID
*/
@Schema(description = "部门 ID", example = "5")
@ConditionOnExpression("#target.deptName == null")
@AssembleMethod(props = @Mapping(src = "name", ref = "deptName"), targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class))
@ExcelProperty(value = "部门 ID", order = 6)
private Long deptId;
/**
* 所属部门
*/
@Schema(description = "所属部门", example = "测试部")
@ExcelProperty(value = "所属部门", order = 7)
private String deptName;
/**
* 角色 ID 列表
*/
@@ -112,14 +83,6 @@ public class UserDetailResp extends BaseDetailResp {
@ExcelProperty(value = "卡号", order = 11)
private String cardNo;
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "123456789@qq.com")
@ExcelProperty(value = "邮箱", order = 12)
@FieldEncrypt
private String email;
/**
* 是否为系统内置数据
*/

View File

@@ -1,12 +1,10 @@
package top.wms.admin.system.model.resp.user;
import cn.crane4j.annotation.Assemble;
import cn.crane4j.core.executor.handler.ManyToManyAssembleOperationHandler;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Value;
import top.wms.admin.common.model.resp.BaseDetailResp;
import top.wms.admin.common.constant.ContainerConstants;
import top.wms.admin.common.context.UserContextHolder;
@@ -40,18 +38,10 @@ public class UserResp extends BaseDetailResp {
@ExcelProperty(value = "用户名")
private String username;
@Schema(description = "卡号")
@ExcelProperty(value = "卡号")
private String cardNo;
/**
* 昵称
*/
@Schema(description = "昵称", example = "张三")
@ExcelIgnore
private String nickname;
/**
* 性别
*/
@@ -65,14 +55,6 @@ public class UserResp extends BaseDetailResp {
@ExcelIgnore
private String avatar;
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "c*******@126.com")
@JsonMask(MaskType.EMAIL)
@ExcelIgnore
private String email;
/**
* 手机号码
*/
@@ -99,27 +81,6 @@ public class UserResp extends BaseDetailResp {
@Schema(description = "描述", example = "张三描述信息")
private String description;
/**
* 部门 ID
*/
@Schema(description = "部门 ID", example = "5")
@ExcelIgnore
private Long deptId;
/**
* 所属部门
*/
@Schema(description = "所属部门", example = "测试部")
@ExcelIgnore
private String deptName;
/**
* 角色 ID 列表
*/
@Schema(description = "角色 ID 列表", example = "2")
@Assemble(prop = ":roleNames", container = ContainerConstants.USER_ROLE_NAME_LIST, handlerType = ManyToManyAssembleOperationHandler.class)
private List<Long> roleIds;
/**
* 角色名称列表
*/

View File

@@ -24,7 +24,6 @@ import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* 部门业务实现
@@ -87,17 +86,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptRes
@Override
public void beforeDelete(List<Long> ids) {
List<DeptDO> list = baseMapper.lambdaQuery()
.select(DeptDO::getName, DeptDO::getIsSystem)
.in(DeptDO::getId, ids)
.list();
Optional<DeptDO> isSystemData = list.stream().filter(DeptDO::getIsSystem).findFirst();
CheckUtils.throwIf(isSystemData::isPresent, "所选部门 [{}] 是系统内置部门,不允许删除", isSystemData.orElseGet(DeptDO::new)
.getName());
CheckUtils.throwIf(this.countChildren(ids) > 0, "所选部门存在下级部门,不允许删除");
CheckUtils.throwIf(userService.countByDeptIds(ids) > 0, "所选部门存在用户关联,请解除关联后重试");
// 删除角色和部门关联
roleDeptService.deleteByDeptIds(ids);
}
@Override

View File

@@ -158,10 +158,10 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
UserDO oldUser = super.getById(id);
if (Boolean.TRUE.equals(oldUser.getIsSystem())) {
CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, newStatus, "[{}] 是系统内置用户,不允许禁用", oldUser
.getNickname());
.getUsername());
Collection<Long> disjunctionRoleIds = CollUtil.disjunction(req.getRoleIds(), userRoleService
.listRoleIdByUserId(id));
CheckUtils.throwIfNotEmpty(disjunctionRoleIds, "[{}] 是系统内置用户,不允许变更角色", oldUser.getNickname());
CheckUtils.throwIfNotEmpty(disjunctionRoleIds, "[{}] 是系统内置用户,不允许变更角色", oldUser.getUsername());
}
// 更新信息
UserDO newUser = BeanUtil.toBean(req, UserDO.class);
@@ -186,12 +186,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
public void delete(List<Long> ids) {
CheckUtils.throwIf(CollUtil.contains(ids, UserContextHolder.getUserId()), "不允许删除当前用户");
List<UserDO> list = baseMapper.lambdaQuery()
.select(UserDO::getNickname, UserDO::getIsSystem)
.select(UserDO::getUsername, UserDO::getIsSystem)
.in(UserDO::getId, ids)
.list();
Optional<UserDO> isSystemData = list.stream().filter(UserDO::getIsSystem).findFirst();
CheckUtils.throwIf(isSystemData::isPresent, "所选用户 [{}] 是系统内置用户,不允许删除", isSystemData.orElseGet(UserDO::new)
.getNickname());
.getUsername());
// 删除用户和角色关联
userRoleService.deleteByUserIds(ids);
// 删除历史密码
@@ -335,7 +335,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
userDO.setStatus(req.getDefaultStatus());
userDO.setPwdResetTime(LocalDateTime.now());
userDO.setGender(EnumUtil.getBy(GenderEnum::getDescription, row.getGender(), GenderEnum.UNKNOWN));
userDO.setDeptId(deptMap.get(row.getDeptName()));
// 修改 or 新增
if (UPDATE.validate(req.getDuplicateUser(), row.getUsername(), existUsernames)) {
userDO.setId(userMap.get(row.getUsername()));
@@ -396,7 +395,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
public void updateBasicInfo(UserBasicInfoUpdateReq req, Long id) {
super.getById(id);
baseMapper.lambdaUpdate()
.set(UserDO::getNickname, req.getNickname())
.set(UserDO::getUsername, req.getUserName())
.set(UserDO::getGender, req.getGender())
.eq(UserDO::getId, id)
.update();
@@ -467,11 +466,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
@Override
public Long countByDeptIds(List<Long> deptIds) {
if (CollUtil.isEmpty(deptIds)) {
return 0L;
}
return baseMapper.lambdaQuery().in(UserDO::getDeptId, deptIds).count();
}
@Override
protected <E> List<E> list(UserQuery query, SortQuery sortQuery, Class<E> targetClass) {
@@ -742,6 +738,4 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
return null == userDO ? "" : userDO.getUsername();
}
}

View File

@@ -23,7 +23,8 @@ import top.wms.admin.material.service.MaterialInfoService;
@Tag(name = "物料信息管理 API")
@RestController
@RequiredArgsConstructor
@CrudRequestMapping(value = "/admin/meterialInfo", api = {Api.PAGE, Api.DETAIL, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
@CrudRequestMapping(value = "/admin/meterialInfo", api = {Api.PAGE, Api.DETAIL, Api.ADD, Api.UPDATE, Api.DELETE,
Api.EXPORT})
public class MaterialInfoController extends BaseController<MaterialInfoService, MaterialInfoResp, MaterialInfoResp, MaterialInfoQuery, MaterialInfoReq> {
}