- 添加 UserScore20250801 相关实体、DTO 和 API 控制器 - 实现用户评分列表、专家列表和提交评分的功能- 添加前端页面以展示和提交评分数据 - 优化评分计算逻辑,处理最高分和最低分
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
public static class StringExtensions
|
|
{
|
|
/// <summary>
|
|
/// 下划线转为驼峰
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <param name="initialsUppder"></param>
|
|
/// <returns></returns>
|
|
public static string ToCamelCase(this string str, char split = '_', bool initialsUppder = true)
|
|
{
|
|
var _ = string.Join("",
|
|
str.Split(split).Select(p => p.Length > 1 ? p.First().ToString().ToUpper() + p[1..] : p.ToUpper()
|
|
)
|
|
);
|
|
|
|
if (!initialsUppder && _.Length > 1)
|
|
{
|
|
_ = _.First().ToString().ToUpper() + _[1..];
|
|
}
|
|
|
|
return _;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 驼峰转为下划线
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <returns></returns>
|
|
public static string ToUnderScoreCase(this string str)
|
|
{
|
|
var _ = new Regex(@"[A-Z]").Replace(str, "_$0");
|
|
|
|
if (_.Length > str.Length)
|
|
{
|
|
_ = _[1..];
|
|
}
|
|
|
|
return _.ToLower();
|
|
}
|
|
|
|
public static DateTime GetNow(this DateTime timestamp)
|
|
{
|
|
return DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(8)).DateTime;
|
|
}
|
|
} |