Files
KJD/Store.Product/Models/Product/MainImageCollection.cs
T
2026-09-11 19:11:12 +08:00

35 lines
884 B
C#

using Store.Product.Models.Product.Image;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.Product
{
/// <summary>
/// 主图集合
/// </summary>
public class MainImageCollection : List<ProductImage>
{
/// <summary>
/// 随机排序
/// </summary>
public void RandomSort()
{
Random random = new Random();
List<ProductImage> newList = new List<ProductImage>();
foreach (ProductImage item in this.Take(4))
{
newList.Insert(random.Next(newList.Count + 1), item);
}
if (this.Count == 5)
{
newList.Add(this.Last());
}
this.Clear();
this.AddRange(newList);
}
}
}