main主干首次提交,包含用户认证模块

This commit is contained in:
wh
2026-04-23 11:59:31 +08:00
commit cbef58aee5
65 changed files with 2335 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package com.labelsys.backend.dto.request;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
@Schema(description = "修改密码请求")
public record ChangePasswordRequest(
@Schema(description = "旧密码") @NotBlank(message = "不能为空") String oldPassword,
@Schema(description = "新密码") @NotBlank(message = "不能为空") String newPassword,
@Schema(description = "确认新密码") @NotBlank(message = "不能为空") String confirmPassword
) {
}

View File

@@ -0,0 +1,14 @@
package com.labelsys.backend.dto.request;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
@Schema(description = "创建公司管理员请求")
public record CreateCompanyAdminRequest(
@Schema(description = "公司ID") @NotNull(message = "不能为空") Long companyId,
@Schema(description = "手机号") @NotBlank(message = "不能为空") String phone,
@Schema(description = "用户名,前端展示用,可为空", example = "platform-ops") String username,
@Schema(description = "真实姓名") @NotBlank(message = "不能为空") String realName
) {
}

View File

@@ -0,0 +1,11 @@
package com.labelsys.backend.dto.request;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
@Schema(description = "创建公司请求")
public record CreateCompanyRequest(
@Schema(description = "公司编码") @NotBlank(message = "不能为空") String companyCode,
@Schema(description = "公司名称") @NotBlank(message = "不能为空") String companyName
) {
}

View File

@@ -0,0 +1,17 @@
package com.labelsys.backend.dto.request;
import com.labelsys.backend.enums.UserPosition;
import com.labelsys.backend.enums.UserRole;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
@Schema(description = "创建员工请求")
public record CreateUserRequest(
@Schema(description = "手机号") @NotBlank(message = "不能为空") String phone,
@Schema(description = "用户名,前端展示用,可为空", example = "alpha-admin") String username,
@Schema(description = "真实姓名") @NotBlank(message = "不能为空") String realName,
@Schema(description = "角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") @NotNull(message = "不能为空") UserRole role,
@Schema(description = "岗位枚举值UPLOADER上传者、ANNOTATOR标注员、DATA_TRAINER数据训练师、REVIEWER审核员、ADMIN超级管理员") @NotNull(message = "不能为空") UserPosition position
) {
}

View File

@@ -0,0 +1,12 @@
package com.labelsys.backend.dto.request;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
@Schema(description = "登录请求")
public record LoginRequest(
@Schema(description = "手机号") @NotBlank(message = "不能为空") String phone,
@Schema(description = "公司编码") @NotBlank(message = "不能为空") String companyCode,
@Schema(description = "登录密码") @NotBlank(message = "不能为空") String password
) {
}

View File

@@ -0,0 +1,11 @@
package com.labelsys.backend.dto.request;
import com.labelsys.backend.enums.CompanyStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
@Schema(description = "修改公司状态请求")
public record UpdateCompanyStatusRequest(
@Schema(description = "公司状态枚举值ENABLED启用、DISABLED禁用") @NotNull(message = "不能为空") CompanyStatus status
) {
}

View File

@@ -0,0 +1,13 @@
package com.labelsys.backend.dto.request;
import com.labelsys.backend.enums.UserPosition;
import com.labelsys.backend.enums.UserRole;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
@Schema(description = "修改员工角色岗位请求")
public record UpdateUserAssignmentRequest(
@Schema(description = "角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") @NotNull(message = "不能为空") UserRole role,
@Schema(description = "岗位枚举值UPLOADER上传者、ANNOTATOR标注员、DATA_TRAINER数据训练师、REVIEWER审核员、ADMIN超级管理员") @NotNull(message = "不能为空") UserPosition position
) {
}

View File

@@ -0,0 +1,11 @@
package com.labelsys.backend.dto.request;
import com.labelsys.backend.enums.UserStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
@Schema(description = "修改员工状态请求")
public record UpdateUserStatusRequest(
@Schema(description = "用户状态枚举值ENABLED启用、DISABLED禁用") @NotNull(message = "不能为空") UserStatus status
) {
}

View File

@@ -0,0 +1,15 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.entity.SysCompany;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "可登录公司选项")
public record CompanyOptionResponse(
@Schema(description = "公司ID") Long companyId,
@Schema(description = "公司编码") String companyCode,
@Schema(description = "公司名称") String companyName
) {
public static CompanyOptionResponse from(SysCompany company) {
return new CompanyOptionResponse(company.getId(), company.getCompanyCode(), company.getCompanyName());
}
}

View File

@@ -0,0 +1,17 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.entity.SysCompany;
import com.labelsys.backend.enums.CompanyStatus;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "公司响应")
public record CompanyResponse(
@Schema(description = "公司ID") Long companyId,
@Schema(description = "公司编码") String companyCode,
@Schema(description = "公司名称") String companyName,
@Schema(description = "公司状态枚举值ENABLED启用、DISABLED禁用") CompanyStatus status
) {
public static CompanyResponse from(SysCompany company) {
return new CompanyResponse(company.getId(), company.getCompanyCode(), company.getCompanyName(), company.getStatus());
}
}

View File

@@ -0,0 +1,35 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.context.LoginUser;
import com.labelsys.backend.enums.UserPosition;
import com.labelsys.backend.enums.UserRole;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "当前登录用户响应")
public record CurrentUserResponse(
@Schema(description = "用户ID") Long userId,
@Schema(description = "公司ID") Long companyId,
@Schema(description = "公司编码") String companyCode,
@Schema(description = "公司名称") String companyName,
@Schema(description = "手机号") String phone,
@Schema(description = "用户名,可为空", example = "alpha-admin") String username,
@Schema(description = "真实姓名") String realName,
@Schema(description = "角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") UserRole role,
@Schema(description = "岗位枚举值UPLOADER上传者、ANNOTATOR标注员、DATA_TRAINER数据训练师、REVIEWER审核员、ADMIN超级管理员") UserPosition position,
@Schema(description = "是否必须修改密码") boolean mustChangePassword
) {
public static CurrentUserResponse from(LoginUser loginUser) {
return new CurrentUserResponse(
loginUser.userId(),
loginUser.companyId(),
loginUser.companyCode(),
loginUser.companyName(),
loginUser.phone(),
loginUser.username(),
loginUser.realName(),
loginUser.role(),
loginUser.position(),
loginUser.mustChangePassword()
);
}
}

View File

@@ -0,0 +1,24 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.entity.BizDataRecord;
import com.labelsys.backend.enums.UserRole;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "数据记录响应")
public record DataRecordResponse(
@Schema(description = "记录ID") Long id,
@Schema(description = "公司ID") Long companyId,
@Schema(description = "创建人ID") Long creatorId,
@Schema(description = "创建人角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") UserRole creatorRole,
@Schema(description = "记录名称") String recordName
) {
public static DataRecordResponse from(BizDataRecord record) {
return new DataRecordResponse(
record.getId(),
record.getCompanyId(),
record.getCreatorId(),
record.getCreatorRole(),
record.getRecordName()
);
}
}

View File

@@ -0,0 +1,32 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.context.LoginUser;
import com.labelsys.backend.entity.SysCompany;
import com.labelsys.backend.enums.UserPosition;
import com.labelsys.backend.enums.UserRole;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "登录响应")
public record LoginResponse(
@Schema(description = "访问令牌") String token,
@Schema(description = "当前公司信息") CompanyOptionResponse company,
@Schema(description = "手机号") String phone,
@Schema(description = "用户名,可为空", example = "alpha-admin") String username,
@Schema(description = "真实姓名") String realName,
@Schema(description = "角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") UserRole role,
@Schema(description = "岗位枚举值UPLOADER上传者、ANNOTATOR标注员、DATA_TRAINER数据训练师、REVIEWER审核员、ADMIN超级管理员") UserPosition position,
@Schema(description = "是否必须修改密码") boolean mustChangePassword
) {
public static LoginResponse from(String token, LoginUser loginUser, SysCompany company) {
return new LoginResponse(
token,
CompanyOptionResponse.from(company),
loginUser.phone(),
loginUser.username(),
loginUser.realName(),
loginUser.role(),
loginUser.position(),
loginUser.mustChangePassword()
);
}
}

View File

@@ -0,0 +1,16 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.entity.SysMenu;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "菜单响应")
public record MenuResponse(
@Schema(description = "菜单编码") String menuCode,
@Schema(description = "菜单名称") String menuName,
@Schema(description = "菜单路径") String path,
@Schema(description = "排序") Integer sortOrder
) {
public static MenuResponse from(SysMenu menu) {
return new MenuResponse(menu.getMenuCode(), menu.getMenuName(), menu.getPath(), menu.getSortOrder());
}
}

View File

@@ -0,0 +1,34 @@
package com.labelsys.backend.dto.response;
import com.labelsys.backend.entity.SysUser;
import com.labelsys.backend.enums.UserPosition;
import com.labelsys.backend.enums.UserRole;
import com.labelsys.backend.enums.UserStatus;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(description = "用户响应")
public record UserResponse(
@Schema(description = "用户ID") Long userId,
@Schema(description = "公司ID") Long companyId,
@Schema(description = "手机号") String phone,
@Schema(description = "用户名,可为空", example = "alpha-admin") String username,
@Schema(description = "真实姓名") String realName,
@Schema(description = "角色枚举值EMPLOYEE员工、MANAGER部门经理、ENGINEER总工程师") UserRole role,
@Schema(description = "岗位枚举值UPLOADER上传者、ANNOTATOR标注员、DATA_TRAINER数据训练师、REVIEWER审核员、ADMIN超级管理员") UserPosition position,
@Schema(description = "用户状态枚举值ENABLED启用、DISABLED禁用") UserStatus status,
@Schema(description = "是否必须修改密码") boolean mustChangePassword
) {
public static UserResponse from(SysUser user) {
return new UserResponse(
user.getId(),
user.getCompanyId(),
user.getPhone(),
user.getUsername(),
user.getRealName(),
user.getRole(),
user.getPosition(),
user.getStatus(),
Boolean.TRUE.equals(user.getMustChangePassword())
);
}
}