From fc2b3fedec7560c5157b309da0f13799aebaa023 Mon Sep 17 00:00:00 2001 From: zpc Date: Sat, 13 Sep 2025 01:12:15 +0800 Subject: [PATCH] 32 --- CoreCms.Net.Configuration/GlobalConstVars.cs | 2 +- .../SQ/ISQReservationReputationRepository.cs | 103 +++ .../SQ/ISQReservationReputationServices.cs | 99 +++ .../Entities/SQ/SQReservationReputation.cs | 116 ++++ .../SQ/SQReservationReputationRepository.cs | 242 +++++++ .../SQ/SQReservationReputationServices.cs | 137 ++++ .../SQ/SQReservationReputationController.cs | 628 ++++++++++++++++++ CoreCms.Net.Web.Admin/Doc.xml | 83 +++ .../sq/sqreservationreputation/create.html | 89 +++ .../sq/sqreservationreputation/details.html | 90 +++ .../sq/sqreservationreputation/edit.html | 89 +++ .../sq/sqreservationreputation/index.html | 399 +++++++++++ .../Controllers/SQController.cs | 28 +- 13 files changed, 2102 insertions(+), 3 deletions(-) create mode 100644 CoreCms.Net.IRepository/SQ/ISQReservationReputationRepository.cs create mode 100644 CoreCms.Net.IServices/SQ/ISQReservationReputationServices.cs create mode 100644 CoreCms.Net.Model/Entities/SQ/SQReservationReputation.cs create mode 100644 CoreCms.Net.Repository/SQ/SQReservationReputationRepository.cs create mode 100644 CoreCms.Net.Services/SQ/SQReservationReputationServices.cs create mode 100644 CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationReputationController.cs create mode 100644 CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/create.html create mode 100644 CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/details.html create mode 100644 CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/edit.html create mode 100644 CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/index.html diff --git a/CoreCms.Net.Configuration/GlobalConstVars.cs b/CoreCms.Net.Configuration/GlobalConstVars.cs index b34d230..144201f 100644 --- a/CoreCms.Net.Configuration/GlobalConstVars.cs +++ b/CoreCms.Net.Configuration/GlobalConstVars.cs @@ -284,7 +284,7 @@ public const string CacheSQReservationParticipants = "CacheSQReservationParticipants"; public const string CacheCoreCmsUserBlacklist = "CacheCoreCmsUserBlacklist"; public const string CacheSQReservationEvaluate = "CacheSQReservationEvaluate"; - + public const string CacheSQReservationReputation = "CacheSQReservationReputation"; diff --git a/CoreCms.Net.IRepository/SQ/ISQReservationReputationRepository.cs b/CoreCms.Net.IRepository/SQ/ISQReservationReputationRepository.cs new file mode 100644 index 0000000..4568bfc --- /dev/null +++ b/CoreCms.Net.IRepository/SQ/ISQReservationReputationRepository.cs @@ -0,0 +1,103 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.IRepository +{ + /// + /// 工厂接口 + /// + public interface ISQReservationReputationRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + new Task InsertAsync(SQReservationReputation entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(SQReservationReputation entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(List entity); + + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + new Task DeleteByIdAsync(object id); + + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + new Task DeleteByIdsAsync(int[] ids); + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + /// + /// 更新cache + /// + Task> UpdateCaChe(); + + #endregion + + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + } +} diff --git a/CoreCms.Net.IServices/SQ/ISQReservationReputationServices.cs b/CoreCms.Net.IServices/SQ/ISQReservationReputationServices.cs new file mode 100644 index 0000000..5997c9b --- /dev/null +++ b/CoreCms.Net.IServices/SQ/ISQReservationReputationServices.cs @@ -0,0 +1,99 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.IServices +{ + /// + /// 声誉工厂接口 + /// + public interface ISQReservationReputationServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + new Task InsertAsync(SQReservationReputation entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(SQReservationReputation entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + new Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + new Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + new Task DeleteByIdsAsync(int[] ids); + + #endregion + + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + /// + /// 更新cache + /// + Task> UpdateCaChe(); + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + new Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + #endregion + } +} diff --git a/CoreCms.Net.Model/Entities/SQ/SQReservationReputation.cs b/CoreCms.Net.Model/Entities/SQ/SQReservationReputation.cs new file mode 100644 index 0000000..6c8aad9 --- /dev/null +++ b/CoreCms.Net.Model/Entities/SQ/SQReservationReputation.cs @@ -0,0 +1,116 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// + /// + public partial class SQReservationReputation + { + /// + /// 构造函数 + /// + public SQReservationReputation() + { + } + + /// + /// 主键 + /// + [Display(Name = "主键")] + + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 id { get; set; } + + + /// + /// 用户id + /// + [Display(Name = "用户id")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 user_id { get; set; } + + + /// + /// 变化值 + /// + [Display(Name = "变化值")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Decimal reputation_value { get; set; } + + + /// + /// 预约id + /// + [Display(Name = "预约id")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 reservation_id { get; set; } + + + /// + /// 创建时间 + /// + [Display(Name = "创建时间")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.DateTime created_at { get; set; } + + + /// + /// 修改时间 + /// + [Display(Name = "修改时间")] + + + + + + public System.DateTime? updated_at { get; set; } + + + /// + /// 备注 + /// + [Display(Name = "备注")] + + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + + public System.String remark { get; set; } + + + } +} diff --git a/CoreCms.Net.Repository/SQ/SQReservationReputationRepository.cs b/CoreCms.Net.Repository/SQ/SQReservationReputationRepository.cs new file mode 100644 index 0000000..b295cd2 --- /dev/null +++ b/CoreCms.Net.Repository/SQ/SQReservationReputationRepository.cs @@ -0,0 +1,242 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Caching.Manual; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.Repository +{ + /// + /// 接口实现 + /// + public class SQReservationReputationRepository : BaseRepository, ISQReservationReputationRepository + { + private readonly IUnitOfWork _unitOfWork; + public SQReservationReputationRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public new async Task InsertAsync(SQReservationReputation entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0; + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public new async Task UpdateAsync(SQReservationReputation entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await DbClient.Queryable().In(entity.id).SingleAsync(); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + //事物处理过程开始 + oldModel.id = entity.id; + oldModel.user_id = entity.user_id; + oldModel.reputation_value = entity.reputation_value; + oldModel.reservation_id = entity.reservation_id; + oldModel.created_at = entity.created_at; + oldModel.updated_at = entity.updated_at; + oldModel.remark = entity.remark; + + //事物处理过程结束 + var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public new async Task UpdateAsync(List entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public new async Task DeleteByIdAsync(object id) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable(id).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public new async Task DeleteByIdsAsync(int[] ids) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + if (bl) + { + await UpdateCaChe(); + } + + return jm; + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + var cache = ManualDataCache.Instance.Get>(GlobalConstVars.CacheSQReservationReputation); + if (cache != null) + { + return cache; + } + return await UpdateCaChe(); + } + + /// + /// 更新cache + /// + public async Task> UpdateCaChe() + { + var list = await DbClient.Queryable().With(SqlWith.NoLock).ToListAsync(); + ManualDataCache.Instance.Set(GlobalConstVars.CacheSQReservationReputation, list); + return list; + } + + #endregion + + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + RefAsync totalCount = 0; + List page; + if (blUseNoLock) + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new SQReservationReputation + { + id = p.id, + user_id = p.user_id, + reputation_value = p.reputation_value, + reservation_id = p.reservation_id, + created_at = p.created_at, + updated_at = p.updated_at, + remark = p.remark, + + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new SQReservationReputation + { + id = p.id, + user_id = p.user_id, + reputation_value = p.reputation_value, + reservation_id = p.reservation_id, + created_at = p.created_at, + updated_at = p.updated_at, + remark = p.remark, + + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } +} diff --git a/CoreCms.Net.Services/SQ/SQReservationReputationServices.cs b/CoreCms.Net.Services/SQ/SQReservationReputationServices.cs new file mode 100644 index 0000000..65fd4b1 --- /dev/null +++ b/CoreCms.Net.Services/SQ/SQReservationReputationServices.cs @@ -0,0 +1,137 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.Services +{ + /// + /// 接口实现 + /// + public class SQReservationReputationServices : BaseServices, ISQReservationReputationServices + { + private readonly ISQReservationReputationRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public SQReservationReputationServices(IUnitOfWork unitOfWork, ISQReservationReputationRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public new async Task InsertAsync(SQReservationReputation entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public new async Task UpdateAsync(SQReservationReputation entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public new async Task UpdateAsync(List entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public new async Task DeleteByIdAsync(object id) + { + return await _dal.DeleteByIdAsync(id); + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public new async Task DeleteByIdsAsync(int[] ids) + { + return await _dal.DeleteByIdsAsync(ids); + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + return await _dal.GetCaChe(); + } + + /// + /// 更新cache + /// + public async Task> UpdateCaChe() + { + return await _dal.UpdateCaChe(); + } + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public new async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + } + #endregion + + } +} diff --git a/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationReputationController.cs b/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationReputationController.cs new file mode 100644 index 0000000..c7ada44 --- /dev/null +++ b/CoreCms.Net.Web.Admin/Controllers/SQ/SQReservationReputationController.cs @@ -0,0 +1,628 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/9/13 1:02:35 + * Description: 暂无 + ***********************************************************************/ + + +using System; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.Entities.Expression; +using CoreCms.Net.Model.FromBody; +using CoreCms.Net.Model.ViewModels.UI; +using CoreCms.Net.Filter; +using CoreCms.Net.Loging; +using CoreCms.Net.IServices; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.Utility.Extensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using NPOI.HSSF.UserModel; +using SqlSugar; +using CoreCms.Net.Web.Admin.Infrastructure; + +namespace CoreCms.Net.Web.Admin.Controllers +{ + /// + /// + /// + [Description("")] + [Route("api/[controller]/[action]")] + [ApiController] + [RequiredErrorForAdmin] + [Authorize] + public class SQReservationReputationController : ControllerBase + { + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly ISQReservationReputationServices _SQReservationReputationServices; + + /// + /// 构造函数 + /// + public SQReservationReputationController(IWebHostEnvironment webHostEnvironment + ,ISQReservationReputationServices SQReservationReputationServices + ) + { + _webHostEnvironment = webHostEnvironment; + _SQReservationReputationServices = SQReservationReputationServices; + } + + #region 获取列表============================================================ + // POST: Api/SQReservationReputation/GetPageList + /// + /// 获取列表 + /// + /// + [HttpPost] + [Description("获取列表")] + public async Task GetPageList() + { + var jm = new AdminUiCallBack(); + var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); + var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); + var where = PredicateBuilder.True(); + //获取排序字段 + var orderField = Request.Form["orderField"].FirstOrDefault(); + + Expression> orderEx = orderField switch + { + "id" => p => p.id,"user_id" => p => p.user_id,"reputation_value" => p => p.reputation_value,"reservation_id" => p => p.reservation_id,"created_at" => p => p.created_at,"updated_at" => p => p.updated_at,"remark" => p => p.remark, + _ => p => p.id + }; + + //设置排序方式 + var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); + var orderBy = orderDirection switch + { + "asc" => OrderByType.Asc, + "desc" => OrderByType.Desc, + _ => OrderByType.Desc + }; + //查询筛选 + + //主键 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //用户id int + var user_id = Request.Form["user_id"].FirstOrDefault().ObjectToInt(0); + if (user_id > 0) + { + where = where.And(p => p.user_id == user_id); + } + //变化值 decimal + var reputation_value = Request.Form["reputation_value"].FirstOrDefault().ObjectToDecimal(0); + if (reputation_value > 0) + { + where = where.And(p => p.reputation_value == reputation_value); + } + //预约id int + var reservation_id = Request.Form["reservation_id"].FirstOrDefault().ObjectToInt(0); + if (reservation_id > 0) + { + where = where.And(p => p.reservation_id == reservation_id); + } + //创建时间 datetime + var created_at = Request.Form["created_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(created_at)) + { + if (created_at.Contains("到")) + { + var dts = created_at.Split("到"); + var dtStart = dts[0].Trim().ObjectToDate(); + where = where.And(p => p.created_at > dtStart); + var dtEnd = dts[1].Trim().ObjectToDate(); + where = where.And(p => p.created_at < dtEnd); + } + else + { + var dt = created_at.ObjectToDate(); + where = where.And(p => p.created_at > dt); + } + } + //修改时间 datetime + var updated_at = Request.Form["updated_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(updated_at)) + { + if (updated_at.Contains("到")) + { + var dts = updated_at.Split("到"); + var dtStart = dts[0].Trim().ObjectToDate(); + where = where.And(p => p.updated_at > dtStart); + var dtEnd = dts[1].Trim().ObjectToDate(); + where = where.And(p => p.updated_at < dtEnd); + } + else + { + var dt = updated_at.ObjectToDate(); + where = where.And(p => p.updated_at > dt); + } + } + //备注 nvarchar + var remark = Request.Form["remark"].FirstOrDefault(); + if (!string.IsNullOrEmpty(remark)) + { + where = where.And(p => p.remark.Contains(remark)); + } + //获取数据 + var list = await _SQReservationReputationServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); + //返回数据 + jm.data = list; + jm.code = 0; + jm.count = list.TotalCount; + jm.msg = "数据调用成功!"; + return jm; + } + #endregion + + #region 首页数据============================================================ + // POST: Api/SQReservationReputation/GetIndex + /// + /// 首页数据 + /// + /// + [HttpPost] + [Description("首页数据")] + public AdminUiCallBack GetIndex() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建数据============================================================ + // POST: Api/SQReservationReputation/GetCreate + /// + /// 创建数据 + /// + /// + [HttpPost] + [Description("创建数据")] + public AdminUiCallBack GetCreate() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建提交============================================================ + // POST: Api/SQReservationReputation/DoCreate + /// + /// 创建提交 + /// + /// + /// + [HttpPost] + [Description("创建提交")] + public async Task DoCreate([FromBody]SQReservationReputation entity) + { + var jm = await _SQReservationReputationServices.InsertAsync(entity); + return jm; + } + #endregion + + #region 编辑数据============================================================ + // POST: Api/SQReservationReputation/GetEdit + /// + /// 编辑数据 + /// + /// + /// + [HttpPost] + [Description("编辑数据")] + public async Task GetEdit([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationReputationServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 编辑提交============================================================ + // POST: Api/SQReservationReputation/Edit + /// + /// 编辑提交 + /// + /// + /// + [HttpPost] + [Description("编辑提交")] + public async Task DoEdit([FromBody]SQReservationReputation entity) + { + var jm = await _SQReservationReputationServices.UpdateAsync(entity); + return jm; + } + #endregion + + #region 删除数据============================================================ + // POST: Api/SQReservationReputation/DoDelete/10 + /// + /// 单选删除 + /// + /// + /// + [HttpPost] + [Description("单选删除")] + public async Task DoDelete([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationReputationServices.ExistsAsync(p => p.id == entity.id, true); + if (!model) + { + jm.msg = GlobalConstVars.DataisNo; + return jm; + } + jm = await _SQReservationReputationServices.DeleteByIdAsync(entity.id); + + return jm; + } + #endregion + + #region 批量删除============================================================ + // POST: Api/SQReservationReputation/DoBatchDelete/10,11,20 + /// + /// 批量删除 + /// + /// + /// + [HttpPost] + [Description("批量删除")] + public async Task DoBatchDelete([FromBody]FMArrayIntIds entity) + { + var jm = await _SQReservationReputationServices.DeleteByIdsAsync(entity.id); + return jm; + } + + #endregion + + #region 预览数据============================================================ + // POST: Api/SQReservationReputation/GetDetails/10 + /// + /// 预览数据 + /// + /// + /// + [HttpPost] + [Description("预览数据")] + public async Task GetDetails([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _SQReservationReputationServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 选择导出============================================================ + // POST: Api/SQReservationReputation/SelectExportExcel/10 + /// + /// 选择导出 + /// + /// + /// + [HttpPost] + [Description("选择导出")] + public async Task SelectExportExcel([FromBody]FMArrayIntIds entity) + { + var jm = new AdminUiCallBack(); + + //创建Excel文件的对象 + var book = new HSSFWorkbook(); + //添加一个sheet + var mySheet = book.CreateSheet("Sheet1"); + //获取list数据 + var listModel = await _SQReservationReputationServices.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id, OrderByType.Asc, true); + //给sheet1添加第一行的头部标题 + var headerRow = mySheet.CreateRow(0); + var headerStyle = ExcelHelper.GetHeaderStyle(book); + + var cell0 = headerRow.CreateCell(0); + cell0.SetCellValue("主键"); + cell0.CellStyle = headerStyle; + mySheet.SetColumnWidth(0, 10 * 256); + + var cell1 = headerRow.CreateCell(1); + cell1.SetCellValue("用户id"); + cell1.CellStyle = headerStyle; + mySheet.SetColumnWidth(1, 10 * 256); + + var cell2 = headerRow.CreateCell(2); + cell2.SetCellValue("变化值"); + cell2.CellStyle = headerStyle; + mySheet.SetColumnWidth(2, 10 * 256); + + var cell3 = headerRow.CreateCell(3); + cell3.SetCellValue("预约id"); + cell3.CellStyle = headerStyle; + mySheet.SetColumnWidth(3, 10 * 256); + + var cell4 = headerRow.CreateCell(4); + cell4.SetCellValue("创建时间"); + cell4.CellStyle = headerStyle; + mySheet.SetColumnWidth(4, 10 * 256); + + var cell5 = headerRow.CreateCell(5); + cell5.SetCellValue("修改时间"); + cell5.CellStyle = headerStyle; + mySheet.SetColumnWidth(5, 10 * 256); + + var cell6 = headerRow.CreateCell(6); + cell6.SetCellValue("备注"); + cell6.CellStyle = headerStyle; + mySheet.SetColumnWidth(6, 10 * 256); + + headerRow.Height = 30 * 20; + var commonCellStyle = ExcelHelper.GetCommonStyle(book); + + //将数据逐步写入sheet1各个行 + for (var i = 0; i < listModel.Count; i++) + { + var rowTemp = mySheet.CreateRow(i + 1); + + var rowTemp0 = rowTemp.CreateCell(0); + rowTemp0.SetCellValue(listModel[i].id.ToString()); + rowTemp0.CellStyle = commonCellStyle; + + var rowTemp1 = rowTemp.CreateCell(1); + rowTemp1.SetCellValue(listModel[i].user_id.ToString()); + rowTemp1.CellStyle = commonCellStyle; + + var rowTemp2 = rowTemp.CreateCell(2); + rowTemp2.SetCellValue(listModel[i].reputation_value.ToString()); + rowTemp2.CellStyle = commonCellStyle; + + var rowTemp3 = rowTemp.CreateCell(3); + rowTemp3.SetCellValue(listModel[i].reservation_id.ToString()); + rowTemp3.CellStyle = commonCellStyle; + + var rowTemp4 = rowTemp.CreateCell(4); + rowTemp4.SetCellValue(listModel[i].created_at.ToString()); + rowTemp4.CellStyle = commonCellStyle; + + var rowTemp5 = rowTemp.CreateCell(5); + rowTemp5.SetCellValue(listModel[i].updated_at.ToString()); + rowTemp5.CellStyle = commonCellStyle; + + var rowTemp6 = rowTemp.CreateCell(6); + rowTemp6.SetCellValue(listModel[i].remark.ToString()); + rowTemp6.CellStyle = commonCellStyle; + + } + // 导出excel + string webRootPath = _webHostEnvironment.WebRootPath; + string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; + string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SQReservationReputation导出(选择结果).xls"; + string filePath = webRootPath + tpath; + DirectoryInfo di = new DirectoryInfo(filePath); + if (!di.Exists) + { + di.Create(); + } + FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); + book.Write(fileHssf); + fileHssf.Close(); + + jm.code = 0; + jm.msg = GlobalConstVars.ExcelExportSuccess; + jm.data = tpath + fileName; + + return jm; + } + #endregion + + #region 查询导出============================================================ + // POST: Api/SQReservationReputation/QueryExportExcel/10 + /// + /// 查询导出 + /// + /// + [HttpPost] + [Description("查询导出")] + public async Task QueryExportExcel() + { + var jm = new AdminUiCallBack(); + + var where = PredicateBuilder.True(); + //查询筛选 + + //主键 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //用户id int + var user_id = Request.Form["user_id"].FirstOrDefault().ObjectToInt(0); + if (user_id > 0) + { + where = where.And(p => p.user_id == user_id); + } + //变化值 decimal + var reputation_value = Request.Form["reputation_value"].FirstOrDefault().ObjectToDecimal(0); + if (reputation_value > 0) + { + where = where.And(p => p.reputation_value == reputation_value); + } + //预约id int + var reservation_id = Request.Form["reservation_id"].FirstOrDefault().ObjectToInt(0); + if (reservation_id > 0) + { + where = where.And(p => p.reservation_id == reservation_id); + } + //创建时间 datetime + var created_at = Request.Form["created_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(created_at)) + { + var dt = created_at.ObjectToDate(); + where = where.And(p => p.created_at > dt); + } + //修改时间 datetime + var updated_at = Request.Form["updated_at"].FirstOrDefault(); + if (!string.IsNullOrEmpty(updated_at)) + { + var dt = updated_at.ObjectToDate(); + where = where.And(p => p.updated_at > dt); + } + //备注 nvarchar + var remark = Request.Form["remark"].FirstOrDefault(); + if (!string.IsNullOrEmpty(remark)) + { + where = where.And(p => p.remark.Contains(remark)); + } + //获取数据 + //创建Excel文件的对象 + var book = new HSSFWorkbook(); + //添加一个sheet + var mySheet = book.CreateSheet("Sheet1"); + //获取list数据 + var listModel = await _SQReservationReputationServices.QueryListByClauseAsync(where, p => p.id, OrderByType.Asc, true); + //给sheet1添加第一行的头部标题 + var headerRow = mySheet.CreateRow(0); + var headerStyle = ExcelHelper.GetHeaderStyle(book); + + var cell0 = headerRow.CreateCell(0); + cell0.SetCellValue("主键"); + cell0.CellStyle = headerStyle; + mySheet.SetColumnWidth(0, 10 * 256); + + var cell1 = headerRow.CreateCell(1); + cell1.SetCellValue("用户id"); + cell1.CellStyle = headerStyle; + mySheet.SetColumnWidth(1, 10 * 256); + + var cell2 = headerRow.CreateCell(2); + cell2.SetCellValue("变化值"); + cell2.CellStyle = headerStyle; + mySheet.SetColumnWidth(2, 10 * 256); + + var cell3 = headerRow.CreateCell(3); + cell3.SetCellValue("预约id"); + cell3.CellStyle = headerStyle; + mySheet.SetColumnWidth(3, 10 * 256); + + var cell4 = headerRow.CreateCell(4); + cell4.SetCellValue("创建时间"); + cell4.CellStyle = headerStyle; + mySheet.SetColumnWidth(4, 10 * 256); + + var cell5 = headerRow.CreateCell(5); + cell5.SetCellValue("修改时间"); + cell5.CellStyle = headerStyle; + mySheet.SetColumnWidth(5, 10 * 256); + + var cell6 = headerRow.CreateCell(6); + cell6.SetCellValue("备注"); + cell6.CellStyle = headerStyle; + mySheet.SetColumnWidth(6, 10 * 256); + + + headerRow.Height = 30 * 20; + var commonCellStyle = ExcelHelper.GetCommonStyle(book); + + //将数据逐步写入sheet1各个行 + for (var i = 0; i < listModel.Count; i++) + { + var rowTemp = mySheet.CreateRow(i + 1); + + + var rowTemp0 = rowTemp.CreateCell(0); + rowTemp0.SetCellValue(listModel[i].id.ToString()); + rowTemp0.CellStyle = commonCellStyle; + + + + var rowTemp1 = rowTemp.CreateCell(1); + rowTemp1.SetCellValue(listModel[i].user_id.ToString()); + rowTemp1.CellStyle = commonCellStyle; + + + + var rowTemp2 = rowTemp.CreateCell(2); + rowTemp2.SetCellValue(listModel[i].reputation_value.ToString()); + rowTemp2.CellStyle = commonCellStyle; + + + + var rowTemp3 = rowTemp.CreateCell(3); + rowTemp3.SetCellValue(listModel[i].reservation_id.ToString()); + rowTemp3.CellStyle = commonCellStyle; + + + + var rowTemp4 = rowTemp.CreateCell(4); + rowTemp4.SetCellValue(listModel[i].created_at.ToString()); + rowTemp4.CellStyle = commonCellStyle; + + + + var rowTemp5 = rowTemp.CreateCell(5); + rowTemp5.SetCellValue(listModel[i].updated_at.ToString()); + rowTemp5.CellStyle = commonCellStyle; + + + + var rowTemp6 = rowTemp.CreateCell(6); + rowTemp6.SetCellValue(listModel[i].remark.ToString()); + rowTemp6.CellStyle = commonCellStyle; + + + } + // 写入到excel + string webRootPath = _webHostEnvironment.WebRootPath; + string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; + string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SQReservationReputation导出(查询结果).xls"; + string filePath = webRootPath + tpath; + DirectoryInfo di = new DirectoryInfo(filePath); + if (!di.Exists) + { + di.Create(); + } + FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create); + book.Write(fileHssf); + fileHssf.Close(); + + jm.code = 0; + jm.msg = GlobalConstVars.ExcelExportSuccess; + jm.data = tpath + fileName; + + return jm; + } + #endregion + + + + } +} diff --git a/CoreCms.Net.Web.Admin/Doc.xml b/CoreCms.Net.Web.Admin/Doc.xml index 7891380..e5ba0b8 100644 --- a/CoreCms.Net.Web.Admin/Doc.xml +++ b/CoreCms.Net.Web.Admin/Doc.xml @@ -3824,6 +3824,89 @@ + + + + + + + + 构造函数 + + + + + 获取列表 + + + + + + 首页数据 + + + + + + 创建数据 + + + + + + 创建提交 + + + + + + + 编辑数据 + + + + + + + 编辑提交 + + + + + + + 单选删除 + + + + + + + 批量删除 + + + + + + + 预览数据 + + + + + + + 选择导出 + + + + + + + 查询导出 + + + 预约表 diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/create.html new file mode 100644 index 0000000..e4d863b --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/create.html @@ -0,0 +1,89 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/details.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/details.html new file mode 100644 index 0000000..65750b9 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/details.html @@ -0,0 +1,90 @@ + + \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/edit.html new file mode 100644 index 0000000..578a7be --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/edit.html @@ -0,0 +1,89 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/index.html new file mode 100644 index 0000000..45acec2 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/sq/sqreservationreputation/index.html @@ -0,0 +1,399 @@ + + +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + diff --git a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs index df66c38..4872c99 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/SQController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/SQController.cs @@ -47,7 +47,7 @@ public class SQController : ControllerBase private readonly IHttpContextUser _user; private readonly SqlSugarScope _dbBase; private readonly ICoreCmsUserBlacklistServices _coreCmsUserBlacklistServices; - + private readonly ISQReservationReputationServices _sQReservationReputationServices; private readonly ISQReservationEvaluateServices _sQReservationEvaluateServices; /// @@ -66,6 +66,8 @@ public class SQController : ControllerBase , ICoreCmsUserBlacklistServices coreCmsUserBlacklistServices , ISQReservationEvaluateServices sQReservationEvaluateServices + , +ISQReservationReputationServices sQReservationReputationServices ) { @@ -81,6 +83,7 @@ ISQReservationEvaluateServices sQReservationEvaluateServices _dbBase = unitOfWork.GetDbClient(); _coreCmsUserBlacklistServices = coreCmsUserBlacklistServices; _sQReservationEvaluateServices = sQReservationEvaluateServices; + _sQReservationReputationServices = sQReservationReputationServices; } @@ -248,7 +251,7 @@ ISQReservationEvaluateServices sQReservationEvaluateServices /// - /// + /// 评价用户 /// /// /// @@ -328,4 +331,25 @@ ISQReservationEvaluateServices sQReservationEvaluateServices Msg = "评价成功" }; } + /// + /// 获取我的声誉记录 + /// + /// + /// + /// + [HttpGet] + [Authorize] + public async Task GetReputationByUser([FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 20) + { + var list = await _sQReservationReputationServices.QueryPageAsync(it => it.user_id == _user.ID, it => it.created_at, OrderByType.Desc, pageIndex, pageSize, true); + return new WebApiDto() + { + Code = 0, + Data = list, + Msg = "ok", + }; + } + + + }