refactor: ♻️ 框架代码同步

This commit is contained in:
tk 2025-06-03 17:19:55 +08:00 committed by nsnail
parent 2ff146664e
commit fd0218a6fd
18 changed files with 44 additions and 24 deletions

View File

@ -49,13 +49,16 @@ public abstract class RepositoryService<TEntity, TPrimary, TLogger>(BasicReposit
/// 导出实体
/// </summary>
protected static async Task<IActionResult> ExportAsync<TQuery, TExport>( //
Func<QueryReq<TQuery>, ISelect<TEntity>> selector, QueryReq<TQuery> query, string fileName, Expression<Func<TEntity, object>> listExp = null)
Func<QueryReq<TQuery>, ISelect<TEntity>> selector, QueryReq<TQuery> query, string fileName, Expression<Func<TEntity, object>> listExp = null
, Func<object, object> listHandle = null)
where TQuery : DataAbstraction, new()
{
var select = selector(query).WithNoLockNoWait().Take(Numbers.MAX_LIMIT_EXPORT);
object list = listExp == null ? await select.ToListAsync().ConfigureAwait(false) : await select.ToListAsync(listExp).ConfigureAwait(false);
list = listHandle?.Invoke(list) ?? list;
return await GetExportFileStreamAsync<TExport>(fileName, list).ConfigureAwait(false);
}

View File

@ -112,6 +112,14 @@ public record Sys_UserProfile : VersionEntity, IRegister
[JsonIgnore]
public virtual string EmergencyContactName { get; init; }
/// <summary>
/// 性别
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual Genders? Gender { get; init; }
/// <summary>
/// 毕业学校
/// </summary>
@ -201,14 +209,6 @@ public record Sys_UserProfile : VersionEntity, IRegister
[JsonIgnore]
public virtual string RealName { get; init; }
/// <summary>
/// 性别
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual Sexes? Sex { get; init; }
/// <summary>
/// 用户基本信息
/// </summary>

View File

@ -58,6 +58,11 @@ public record CreateUserProfileReq : Sys_UserProfile
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string EmergencyContactName { get; init; }
/// <inheritdoc cref="Sys_UserProfile.Gender" />
[EnumDataType(typeof(Genders), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.性别不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override Genders? Gender { get; init; }
/// <inheritdoc cref="Sys_UserProfile.GraduateSchool" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string GraduateSchool { get; init; }
@ -104,9 +109,4 @@ public record CreateUserProfileReq : Sys_UserProfile
/// <inheritdoc cref="Sys_UserProfile.RealName" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string RealName { get; init; }
/// <inheritdoc cref="Sys_UserProfile.Sex" />
[EnumDataType(typeof(Sexes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.性别不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override Sexes? Sex { get; init; }
}

View File

@ -57,6 +57,10 @@ public sealed record QueryUserProfileRsp : Sys_UserProfile
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string EmergencyContactName { get; init; }
/// <inheritdoc cref="Sys_UserProfile.Gender" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override Genders? Gender { get; init; }
/// <inheritdoc cref="Sys_UserProfile.GraduateSchool" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string GraduateSchool { get; init; }
@ -103,10 +107,6 @@ public sealed record QueryUserProfileRsp : Sys_UserProfile
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string RealName { get; init; }
/// <inheritdoc cref="Sys_UserProfile.Sex" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override Sexes? Sex { get; init; }
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }

View File

@ -4,7 +4,7 @@ namespace NetAdmin.Infrastructure.Enums;
/// 性别
/// </summary>
[Export]
public enum Sexes
public enum Genders
{
/// <summary>
/// 男

View File

@ -121,7 +121,12 @@
</div>
<scContextmenu @command="contextMenuCommand" @visible-change="contextMenuVisibleChange" ref="contextmenu">
<scContextmenuItem
v-for="(menu, index) in contextMenus.filter((x) => x === current.column?.property)"
v-for="(menu, index) in contextMenus.filter((x) => {
if (current.column?.property === x) {
return true
}
return this.contextMulti && !!this.contextMulti[current.column?.property]?.find((y) => y === x)
})"
:command="menu"
:key="index"
:title="`${menu}`">
@ -214,6 +219,7 @@ export default {
contextMenus: { type: Array },
contextOpers: { type: Array, default: ['copy', 'add', 'view', 'edit', 'del'] },
contextAdvs: { type: Array, default: [] },
contextMulti: { type: Object },
tableName: { type: String, default: '' },
beforePost: {
type: Function,

View File

@ -60,6 +60,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'userRegisterConfirm', 'userRegisterDept.name', 'userRegisterRole.name', 'enabled', 'createdTime']"
:context-multi="{ id: ['createdTime'] }"
:export-api="$API.sys_config.export"
:params="query"
:query-api="$API.sys_config.pagedQuery"

View File

@ -67,6 +67,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'name', 'sort', 'enabled', 'createdTime', 'summary']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'sort', order: 'descending' }"
:export-api="$API.sys_dept.export"
:params="query"

View File

@ -74,6 +74,7 @@
<scTable
:before-post="(data) => data.dynamicFilter.filters.length > 0"
:context-menus="['key', 'value', 'enabled', 'createdTime', 'id', 'summary']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_dic.exportContent"
:params="query"

View File

@ -85,6 +85,7 @@
<scTable
:before-post="(data) => data.dynamicFilter.filters.length > 0"
:context-menus="['title', 'enabled', 'createdTime', 'id', 'visibility']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_doc.exportContent"
:params="query"

View File

@ -125,6 +125,7 @@
'createdTime',
'lastDuration',
]"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'lastExecTime', order: 'descending' }"
:export-api="$API.sys_job.export"
:page-size="100"

View File

@ -99,6 +99,7 @@
}
"
:context-menus="['id', 'duration', 'httpMethod', 'requestUrl', 'httpStatusCode', 'createdTime', 'jobId', 'responseBody']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_job.exportRecord"
:params="query"

View File

@ -93,6 +93,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'httpStatusCode', 'loginUserName', 'createdClientIp', 'createdUserAgent', 'createdTime']"
:context-multi="{ id: ['createdTime'] }"
:context-opers="['view']"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_loginlog.export"

View File

@ -119,6 +119,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'httpStatusCode', 'apiPathCrc32', 'ownerId', 'httpMethod', 'duration', 'createdClientIp', 'createdTime']"
:context-multi="{ id: ['createdTime'] }"
:context-opers="[]"
:default-sort="{ prop: 'createdTime', order: 'descending' }"
:export-api="$API.sys_requestlog.export"

View File

@ -58,6 +58,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'createdUserName', 'msgType', 'title', 'summary', 'createdTime']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_sitemsg.export"
:params="query"

View File

@ -115,6 +115,7 @@
<el-main class="nopadding">
<scTable
:context-menus="['id', 'name', 'sort', 'enabled', 'ignorePermissionControl', 'dataScope', 'displayDashboard', 'createdTime']"
:context-multi="{ id: ['createdTime'] }"
:default-sort="{ prop: 'sort', order: 'descending' }"
:export-api="$API.sys_role.export"
:params="query"

View File

@ -93,6 +93,7 @@
<el-col :lg="20">
<scTable
:context-menus="['id', 'userName', 'mobile', 'email', 'enabled', 'createdTime', 'lastLoginTime']"
:context-multi="{ id: ['createdTime'] }"
:context-opers="['view', 'edit']"
:default-sort="{ prop: 'id', order: 'descending' }"
:export-api="$API.sys_user.export"

View File

@ -86,9 +86,9 @@
</el-col>
<el-col :lg="12">
<el-form-item :label="$t('性别')" prop="profile.sex">
<el-select v-model="form.profile.sex" clearable filterable>
<el-option v-for="(item, i) in $GLOBAL.enums.sexes" :key="i" :label="item[1]" :value="i" />
<el-form-item :label="$t('性别')" prop="profile.gender">
<el-select v-model="form.profile.gender" clearable filterable>
<el-option v-for="(item, i) in $GLOBAL.enums.genders" :key="i" :label="item[1]" :value="i" />
</el-select>
</el-form-item>
</el-col>
@ -104,7 +104,7 @@
</el-col>
<el-col :lg="12">
<el-form-item :label="$t('婚姻状况')" prop="profile.sex">
<el-form-item :label="$t('婚姻状况')" prop="profile.gender">
<el-select v-model="form.profile.marriageStatus" clearable filterable>
<el-option v-for="(item, i) in $GLOBAL.enums.marriageStatues" :key="i" :label="item[1]" :value="i" />
</el-select>