From 1544d4d5375d7b9b57f39b125f3b24fd2576839f Mon Sep 17 00:00:00 2001
From: “2926542760@qq.com” <2926542760@qq.com>
Date: Fri, 6 Jan 2023 01:30:50 +0800
Subject: [PATCH] aa
---
antis-ncc-admin/src/views/tbEvaluation/Form.vue | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------
antis-ncc-admin/src/views/tbEvaluation/index.vue | 371 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------
antis-ncc-admin/src/views/tbMemCode/index.vue | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
antis-ncc-admin/src/views/tbPunch/index.vue | 2 +-
antis-ncc-admin/src/views/tbQuestion/Form.vue | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------
antis-ncc-admin/src/views/tbQuestion/index.vue | 376 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------
antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationCrInput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationInfoOutput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListOutput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListQueryInput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/测评信息/Entity/TbEvaluationEntity.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionCrInput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionInfoOutput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListOutput.cs | 33 ++++++++++++++++++++++++++++++---
antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListQueryInput.cs | 6 +++++-
antis-ncc-net-core/ClassLibrary1/题库信息/Entity/TbQuestionEntity.cs | 7 ++++++-
antis-ncc-net-core/NCC.Education/会员码管理/TbMemCodeService.cs | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
antis-ncc-net-core/NCC.Education/打卡记录/TbPunchService.cs | 23 +++++++++++++++++++++++
antis-ncc-net-core/NCC.Education/测评信息/TbEvaluationService.cs | 46 ++++++++++++++++++++++++++++++++++++++++++----
antis-ncc-net-core/NCC.Education/题库信息/TbQuestionService.cs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
20 files changed, 1069 insertions(+), 554 deletions(-)
diff --git a/antis-ncc-admin/src/views/tbEvaluation/Form.vue b/antis-ncc-admin/src/views/tbEvaluation/Form.vue
index 1b789af..643935c 100644
--- a/antis-ncc-admin/src/views/tbEvaluation/Form.vue
+++ b/antis-ncc-admin/src/views/tbEvaluation/Form.vue
@@ -1,38 +1,51 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
+ }
+
diff --git a/antis-ncc-admin/src/views/tbMemCode/index.vue b/antis-ncc-admin/src/views/tbMemCode/index.vue
index 16b519a..c32ce5d 100644
--- a/antis-ncc-admin/src/views/tbMemCode/index.vue
+++ b/antis-ncc-admin/src/views/tbMemCode/index.vue
@@ -37,6 +37,8 @@
新增
导出
批量删除
+ 批量生成
+ 批量修改
@@ -51,7 +53,7 @@
{{ scope.row.type | dynamicText(typeOptions) }}
-
+
@@ -68,6 +70,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
+ }
+
diff --git a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationCrInput.cs b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationCrInput.cs
index cd057af..0d1f590 100644
--- a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationCrInput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationCrInput.cs
@@ -33,6 +33,10 @@ namespace NCC.Education.Entitys.Dto.TbEvaluation
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationInfoOutput.cs b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationInfoOutput.cs
index ba3d089..5ce7a84 100644
--- a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationInfoOutput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationInfoOutput.cs
@@ -38,6 +38,10 @@ namespace NCC.Education.Entitys.Dto.TbEvaluation
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListOutput.cs b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListOutput.cs
index 8441fba..0b0d40c 100644
--- a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListOutput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListOutput.cs
@@ -54,6 +54,10 @@ namespace NCC.Education.Entitys.Dto.TbEvaluation
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListQueryInput.cs b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListQueryInput.cs
index a546279..905a29f 100644
--- a/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListQueryInput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/测评信息/Dto/TbEvaluationListQueryInput.cs
@@ -23,6 +23,10 @@ namespace NCC.Education.Entitys.Dto.TbEvaluation
/// 标题
///
public string title { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/测评信息/Entity/TbEvaluationEntity.cs b/antis-ncc-net-core/ClassLibrary1/测评信息/Entity/TbEvaluationEntity.cs
index ab962da..32ac26d 100644
--- a/antis-ncc-net-core/ClassLibrary1/测评信息/Entity/TbEvaluationEntity.cs
+++ b/antis-ncc-net-core/ClassLibrary1/测评信息/Entity/TbEvaluationEntity.cs
@@ -46,6 +46,10 @@ namespace NCC.Education.Entitys
///
[SugarColumn(ColumnName = "F_LastModifyTime")]
public DateTime? LastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--非默认
+ ///
+ [SugarColumn(ColumnName = "F_Detault")]
+ public string Detault { get; set; }
}
}
\ No newline at end of file
diff --git a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionCrInput.cs b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionCrInput.cs
index c2b2f5a..767cd5e 100644
--- a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionCrInput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionCrInput.cs
@@ -33,6 +33,10 @@ namespace NCC.Education.Entitys.Dto.TbQuestion
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionInfoOutput.cs b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionInfoOutput.cs
index aca32d4..c99ebee 100644
--- a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionInfoOutput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionInfoOutput.cs
@@ -38,6 +38,10 @@ namespace NCC.Education.Entitys.Dto.TbQuestion
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListOutput.cs b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListOutput.cs
index 22cdebd..f04a71f 100644
--- a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListOutput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListOutput.cs
@@ -1,4 +1,9 @@
-using System;
+using Aspose.Words.Lists;
+using NCC.Common.Model;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
namespace NCC.Education.Entitys.Dto.TbQuestion
{
@@ -16,7 +21,9 @@ namespace NCC.Education.Entitys.Dto.TbQuestion
/// 标题
///
public string title { get; set; }
-
+
+ public string editors { get; set; }
+
///
/// 创建时间
///
@@ -26,6 +33,26 @@ namespace NCC.Education.Entitys.Dto.TbQuestion
/// 修改时间
///
public DateTime? lastModifyTime { get; set; }
-
+
+ ///
+ /// 图片信息
+ ///
+ public string img { get; set; }
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
+ public List Img { get
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject>(img);
+ }catch(Exception ex)
+ {
+ return new List();
+ }
+ } }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListQueryInput.cs b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListQueryInput.cs
index fa37bda..388f7e6 100644
--- a/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListQueryInput.cs
+++ b/antis-ncc-net-core/ClassLibrary1/题库信息/Dto/TbQuestionListQueryInput.cs
@@ -23,6 +23,10 @@ namespace NCC.Education.Entitys.Dto.TbQuestion
/// 标题
///
public string title { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--普通
+ ///
+ public string detault { get; set; }
+
}
}
diff --git a/antis-ncc-net-core/ClassLibrary1/题库信息/Entity/TbQuestionEntity.cs b/antis-ncc-net-core/ClassLibrary1/题库信息/Entity/TbQuestionEntity.cs
index ffcd19c..39066e5 100644
--- a/antis-ncc-net-core/ClassLibrary1/题库信息/Entity/TbQuestionEntity.cs
+++ b/antis-ncc-net-core/ClassLibrary1/题库信息/Entity/TbQuestionEntity.cs
@@ -46,6 +46,11 @@ namespace NCC.Education.Entitys
///
[SugarColumn(ColumnName = "F_LastModifyTime")]
public DateTime? LastModifyTime { get; set; }
-
+ ///
+ /// 是否默认 1--默认 2--非默认
+ ///
+ [SugarColumn(ColumnName = "F_Detault")]
+ public string Detault { get; set; }
+
}
}
\ No newline at end of file
diff --git a/antis-ncc-net-core/NCC.Education/会员码管理/TbMemCodeService.cs b/antis-ncc-net-core/NCC.Education/会员码管理/TbMemCodeService.cs
index 22d3468..b6f9201 100644
--- a/antis-ncc-net-core/NCC.Education/会员码管理/TbMemCodeService.cs
+++ b/antis-ncc-net-core/NCC.Education/会员码管理/TbMemCodeService.cs
@@ -25,6 +25,7 @@ using NCC.ClayObject;
using NCC.System.Interfaces.System;
using NCC.System.Entitys.Permission;
using Microsoft.Extensions.Logging;
+using NPOI.HPSF;
namespace NCC.Education.TbMemCode
{
@@ -62,6 +63,91 @@ namespace NCC.Education.TbMemCode
}
///
+ /// 获取时间戳
+ ///
+ ///
+ public static long getTime()
+ {
+ return (long)(DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalMilliseconds;
+ }
+
+ ///
+ /// 批量生成会员码入参
+ ///
+ public class mutineCreateCodeOptions
+ {
+ ///
+ /// 个数
+ ///
+ public int numbers { get; set; }
+ ///
+ /// 过期时间
+ ///
+ public DateTime? expire { get; set; }
+
+ }
+ ///
+ /// 批量生成会员码
+ ///
+ ///
+ [HttpPost("MutinueCreateCode")]
+ public async Task MutinueCreateCode(mutineCreateCodeOptions query)
+ {
+ List list = new List();
+ for(var i=0;i< query.numbers; i++)
+ {
+ list.Add(new TbMemCodeEntity
+ {
+ Id = YitIdHelper.NextId().ToString(),
+ Code =Guid.NewGuid().ToString().Replace("-","").ToLower().Substring(0,10),
+ Expire = query.expire,
+ Type = "2",
+ CreatorTime = DateTime.Now
+ });
+ }
+ var result = _db.Insertable(list).ExecuteCommand();
+ if (!(result > 0)) throw NCCException.Oh($"批量生成失败!");
+ }
+
+ ///
+ /// 批量更改会员截至日期入参
+ ///
+ public class MutineUpdateExpireOptions
+ {
+ ///
+ /// IDS
+ ///
+ public string ids { get; set; }
+ ///
+ /// 会员截至日期
+ ///
+ public DateTime? expire { get; set; }
+ }
+
+ ///
+ /// 批量更改会员截至日期
+ ///
+ ///
+ ///
+ [HttpPost("MutinueUpdateDaysNumber")]
+ public async Task MutinueUpdateDaysNumber(MutineUpdateExpireOptions query)
+ {
+ if (query.ids.IsNullOrEmpty()) throw NCCException.Oh($"参数错误");
+ List list = new List();
+ if (!query.ids.Contains(","))
+ {
+ list.Add(query.ids);
+ }
+ else
+ {
+ list = query.ids.Split(",").ToList();
+ }
+ var result = _db.Updateable().SetColumns(it => new TbMemCodeEntity { Expire = query.expire }).Where(o => list.Contains(o.Id)).ExecuteCommand();
+ if (!(result > 0)) throw NCCException.Oh($"批量更改失败!");
+ }
+
+
+ ///
/// 普通用户根据会员码转会员参数
///
public class ShiftToMemOptions
diff --git a/antis-ncc-net-core/NCC.Education/打卡记录/TbPunchService.cs b/antis-ncc-net-core/NCC.Education/打卡记录/TbPunchService.cs
index 9bda19c..c003c8c 100644
--- a/antis-ncc-net-core/NCC.Education/打卡记录/TbPunchService.cs
+++ b/antis-ncc-net-core/NCC.Education/打卡记录/TbPunchService.cs
@@ -62,6 +62,29 @@ namespace NCC.Education.TbPunch
}
///
+ /// 查询用户会员到期时间
+ ///
+ ///
+ [HttpPost("TaskSchedulerUserType")]
+ public async Task TaskSchedulerUserType()
+ {
+ var list = _db.Queryable().Where(o => o.IsAdministrator == 0).ToList();
+ foreach (var item in list)
+ {
+ if (item.Type == "2" && item.MemDate.ToDate() < DateTime.Now)
+ {
+ item.Type = "1";
+ item.MemDate = null;
+ var result = _db.Updateable(item).ExecuteCommand();
+ _logger.LogInformation($"更改会员用户为普通用户:{result}----{item.ToJson()}");
+ }
+ }
+ }
+
+
+
+
+ ///
/// 每天凌晨过5分判断前一天的时间有那些人没打卡 进行赋值缺卡
///
///
diff --git a/antis-ncc-net-core/NCC.Education/测评信息/TbEvaluationService.cs b/antis-ncc-net-core/NCC.Education/测评信息/TbEvaluationService.cs
index c646030..60c60b4 100644
--- a/antis-ncc-net-core/NCC.Education/测评信息/TbEvaluationService.cs
+++ b/antis-ncc-net-core/NCC.Education/测评信息/TbEvaluationService.cs
@@ -54,7 +54,29 @@ namespace NCC.Education.TbEvaluation
_dataBaseService = dataBaseService;
_userManager = userManager;
}
-
+ ///
+ /// 根据ID设定测评默认
+ ///
+ ///
+ ///
+ [HttpPost("ConfirmEvalDefault")]
+ public async Task ConfirmEvalDefault(string id)
+ {
+ var model = _db.Queryable().Where(o => o.Id == id).First();
+ if (model == null) throw NCCException.Oh($"暂无此数据");
+ try
+ {
+ _db.BeginTran();
+ var result =await _db.Updateable().SetColumns(it => new TbEvaluationEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ model.Detault = "1";
+ var data = await _db.Updateable(model).ExecuteCommandAsync();
+ _db.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ _db.RollbackTran();
+ }
+ }
///
/// 获取测评信息
///
@@ -99,6 +121,8 @@ namespace NCC.Education.TbEvaluation
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title))
+ .WhereIF(!string.IsNullOrEmpty(input.detault), p => p.Detault.Equals(input.detault))
+
.Select(it=> new TbEvaluationListOutput
{
id = it.Id,
@@ -107,6 +131,7 @@ namespace NCC.Education.TbEvaluation
lastModifyTime=it.LastModifyTime,
editors = it.Editors,
img =it.Img,
+ detault=it.Detault,
}).MergeTable().OrderBy(sidx+" "+input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(data);
}
@@ -132,7 +157,12 @@ namespace NCC.Education.TbEvaluation
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt();
entity.Id = YitIdHelper.NextId().ToString();
- entity.CreatorTime = DateTime.Now;
+ entity.CreatorTime = DateTime.Now;
+ if (entity.Detault == "1")
+ {
+ var result = await _db.Updateable().SetColumns(it => new TbEvaluationEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ if (!(result > 0)) throw NCCException.Oh($"更改默认值失败");
+ }
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000);
}
@@ -158,12 +188,15 @@ namespace NCC.Education.TbEvaluation
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title))
+ .WhereIF(!string.IsNullOrEmpty(input.detault), p => p.Detault.Equals(input.detault))
+
.Select(it=> new TbEvaluationListOutput
{
id = it.Id,
title=it.Title,
creatorTime=it.CreatorTime,
lastModifyTime=it.LastModifyTime,
+ detault=it.Detault,
}).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync();
return data;
}
@@ -187,7 +220,7 @@ namespace NCC.Education.TbEvaluation
{
exportData = await this.GetNoPagingList(input);
}
- List paramList = "[{\"value\":\"标题\",\"field\":\"title\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},]".ToList();
+ List paramList = "[{\"value\":\"标题\",\"field\":\"title\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},{\"value\":\"是否默认\",\"field\":\"detault\"},]".ToList();
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "测评信息.xls";
excelconfig.HeadFont = "微软雅黑";
@@ -273,7 +306,12 @@ namespace NCC.Education.TbEvaluation
});
_db.ChangeDatabase(dbLink.Id);
var entity = input.Adapt();
- entity.LastModifyTime = DateTime.Now;
+ entity.LastModifyTime = DateTime.Now;
+ if (entity.Detault == "1")
+ {
+ var result = await _db.Updateable().SetColumns(it => new TbEvaluationEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ if (!(result > 0)) throw NCCException.Oh($"更改默认值失败");
+ }
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
}
diff --git a/antis-ncc-net-core/NCC.Education/题库信息/TbQuestionService.cs b/antis-ncc-net-core/NCC.Education/题库信息/TbQuestionService.cs
index 725b20d..b1215fc 100644
--- a/antis-ncc-net-core/NCC.Education/题库信息/TbQuestionService.cs
+++ b/antis-ncc-net-core/NCC.Education/题库信息/TbQuestionService.cs
@@ -54,6 +54,32 @@ namespace NCC.Education.TbQuestion
_dataBaseService = dataBaseService;
_userManager = userManager;
}
+ ///
+ /// 根据ID设定题库默认
+ ///
+ ///
+ ///
+ [HttpPost("ConfirmDefault")]
+ public async Task ConfirmDefault(string id)
+ {
+ var model = _db.Queryable().Where(o => o.Id == id).First();
+ if (model == null) throw NCCException.Oh($"暂无此数据");
+ try
+ {
+ _db.BeginTran();
+
+ var result =await _db.Updateable().SetColumns(it => new TbQuestionEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ model.Detault = "1";
+ var data =await _db.Updateable(model).ExecuteCommandAsync();
+ _db.CommitTran();
+ }catch(Exception ex)
+ {
+ _db.RollbackTran();
+ }
+ }
+
+
+
///
/// 获取题库信息
@@ -99,12 +125,18 @@ namespace NCC.Education.TbQuestion
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title))
+ .WhereIF(!string.IsNullOrEmpty(input.detault), p => p.Detault.Equals(input.detault))
+
.Select(it=> new TbQuestionListOutput
{
id = it.Id,
title=it.Title,
creatorTime=it.CreatorTime,
+ img=it.Img,
lastModifyTime=it.LastModifyTime,
+ detault = it.Detault,
+ editors= it.Editors,
+
}).MergeTable().OrderBy(sidx+" "+input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(data);
}
@@ -130,7 +162,12 @@ namespace NCC.Education.TbQuestion
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt();
entity.Id = YitIdHelper.NextId().ToString();
- entity.CreatorTime = DateTime.Now;
+ entity.CreatorTime = DateTime.Now;
+ if (entity.Detault == "1")
+ {
+ var result =await _db.Updateable().SetColumns(it => new TbQuestionEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ if (!(result > 0)) throw NCCException.Oh($"更改默认值失败");
+ }
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000);
}
@@ -156,12 +193,16 @@ namespace NCC.Education.TbQuestion
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title))
+ .WhereIF(!string.IsNullOrEmpty(input.detault), p => p.Detault.Equals(input.detault))
+
.Select(it=> new TbQuestionListOutput
{
id = it.Id,
title=it.Title,
creatorTime=it.CreatorTime,
lastModifyTime=it.LastModifyTime,
+ detault = it.Detault,
+
}).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync();
return data;
}
@@ -185,7 +226,7 @@ namespace NCC.Education.TbQuestion
{
exportData = await this.GetNoPagingList(input);
}
- List paramList = "[{\"value\":\"标题\",\"field\":\"title\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},]".ToList();
+ List paramList = "[{\"value\":\"标题\",\"field\":\"title\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},{\"value\":\"是否默认\",\"field\":\"detault\"},]".ToList();
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "题库信息.xls";
excelconfig.HeadFont = "微软雅黑";
@@ -271,7 +312,12 @@ namespace NCC.Education.TbQuestion
});
_db.ChangeDatabase(dbLink.Id);
var entity = input.Adapt();
- entity.LastModifyTime = DateTime.Now;
+ entity.LastModifyTime = DateTime.Now;
+ if (entity.Detault == "1")
+ {
+ var result =await _db.Updateable().SetColumns(it => new TbQuestionEntity { Detault = "2" }).Where(o => o.Detault == "1").ExecuteCommandAsync();
+ if (!(result > 0)) throw NCCException.Oh($"更改默认值失败");
+ }
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
}
--
libgit2 0.21.4