85 lines
3.3 KiB
C#
85 lines
3.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.Json.Serialization;
|
|
using Store.Management.Api.Models;
|
|
|
|
namespace Store.Management.Api.Users;
|
|
|
|
public sealed class UserSearchRequest : PageRequest
|
|
{
|
|
[StringLength(100)] public string? Keyword { get; set; }
|
|
public int? GroupId { get; set; }
|
|
[StringLength(20)] public string? ParentUserName { get; set; }
|
|
}
|
|
|
|
public class UserEditRequest
|
|
{
|
|
public UserGroup? GroupId { get; set; }
|
|
public UserAdminLevel? SaLevel { get; set; }
|
|
[StringLength(50)] public string? OemId { get; set; }
|
|
[StringLength(1000)] public string? Authority { get; set; }
|
|
[StringLength(50)] public string? NickName { get; set; }
|
|
[StringLength(30)] public string? Mobile { get; set; }
|
|
[StringLength(100)] public string? CompanyName { get; set; }
|
|
[StringLength(255)] public string? Notes { get; set; }
|
|
}
|
|
|
|
public sealed class UserCreateRequest : UserEditRequest
|
|
{
|
|
[Required, StringLength(20)] public string UserName { get; set; } = "";
|
|
[Required, StringLength(128, MinimumLength = 6)] public string Password { get; set; } = "";
|
|
[StringLength(20)] public string? ParentUserName { get; set; }
|
|
}
|
|
|
|
public sealed record ChangePasswordRequest(string UserName, string NewPassword, string? OldPassword = null);
|
|
|
|
public enum UserAdminLevel : short
|
|
{
|
|
[System.ComponentModel.Description("普通用户")] Normal = 0,
|
|
[System.ComponentModel.Description("超级管理员")] SuperAdmin = 1
|
|
}
|
|
|
|
public sealed class UserUpdateRequest : UserEditRequest
|
|
{
|
|
[Range(1, int.MaxValue)] public int Id { get; set; }
|
|
}
|
|
|
|
public sealed class UserBillingUpdateRequest
|
|
{
|
|
[Range(1, int.MaxValue)] public int Id { get; init; }
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public int? ShopPointsPerMonth { get; set; }
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public decimal? PostagePerOrder { get; set; }
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public decimal? RefundPostagePerOrder { get; set; }
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public decimal? GiftOemAmountPerOrder { get; set; }
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public decimal? SyncLogisticsPerOrder { get; set; }
|
|
}
|
|
|
|
/// <summary>管理端当前使用的用户资料字段;不接收密码。</summary>
|
|
public sealed class UserInfo
|
|
{
|
|
public int Id { get; init; }
|
|
public string UserName { get; init; } = "";
|
|
public string? NickName { get; init; }
|
|
public string? Mobile { get; init; }
|
|
public string? CompanyName { get; init; }
|
|
public string? Notes { get; init; }
|
|
public string? ParentUserName { get; init; }
|
|
public int GroupId { get; init; }
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
public UserGroup? Group => GroupId is >= byte.MinValue and <= byte.MaxValue ? (UserGroup)GroupId : null;
|
|
public UserAdminLevel? SaLevel { get; init; }
|
|
public string? OemId { get; init; }
|
|
public string? Authority { get; init; }
|
|
public int ShopPointsPerMonth { get; init; }
|
|
public decimal? PostagePerOrder { get; init; }
|
|
public decimal? RefundPostagePerOrder { get; init; }
|
|
public decimal? GiftOemAmountPerOrder { get; init; }
|
|
public decimal? SyncLogisticsPerOrder { get; init; }
|
|
public decimal Points { get; init; }
|
|
public decimal? Balance { get; init; }
|
|
}
|