提交
This commit is contained in:
32
api_v1/Appointment.Repository/Appointment.Repository.csproj
Normal file
32
api_v1/Appointment.Repository/Appointment.Repository.csproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>Appointment.Repository.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ApptRepoJNC - 复制.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Log4NetCore" Version="1.0.0" />
|
||||
<PackageReference Include="sqlSugarCore" Version="5.0.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Appointment.Entity\Appointment.Entity.csproj" />
|
||||
<ProjectReference Include="..\Appointment.IRepository\Appointment.IRepository.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Appointment.Repository.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
423
api_v1/Appointment.Repository/Appointment.Repository.xml
Normal file
423
api_v1/Appointment.Repository/Appointment.Repository.xml
Normal file
@@ -0,0 +1,423 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Appointment.Repository</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Appointment.Repository.ApptRepo">
|
||||
<summary>
|
||||
标准预订业务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.UsableMeetingList(Appointment.Entity.MeetingReq)">
|
||||
<summary>
|
||||
可用会议室资源列表
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.UsableMeeting(Appointment.Entity.UsableMeetingReq)">
|
||||
<summary>
|
||||
当天可用会议室资源
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.UsableRoom(Appointment.Entity.UsableRoomReq)">
|
||||
<summary>
|
||||
可用客房资源列表
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.UsableRoomMin(Appointment.Entity.UsableRoomReq)">
|
||||
<summary>
|
||||
根据时间段获取房类最小可用数
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.RemarkList">
|
||||
<summary>
|
||||
备注列表项
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.Add(Appointment.Entity.ApptSummaryReq)">
|
||||
<summary>
|
||||
创建暂定单
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.DeleteAppt(Appointment.Entity.AuditDeleteReq)">
|
||||
<summary>
|
||||
删除预定
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.ApptAudit(Appointment.Entity.ApptAuditReq)">
|
||||
<summary>
|
||||
预订审批
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.CancelAudit(Appointment.Entity.ApptAuditReq)">
|
||||
<summary>
|
||||
取消预订
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.TransferAudit(Appointment.Entity.TransferAuditReq)">
|
||||
<summary>
|
||||
转审批
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.ApptSend(Appointment.Entity.ApptSendReq)">
|
||||
<summary>
|
||||
抄送
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.GetModel(System.Int32)">
|
||||
<summary>
|
||||
获取实体
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.MyApptApplyPageReq(Appointment.Entity.MyApptApplyPageReq)">
|
||||
<summary>
|
||||
我发起的预订列表
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.MyPartakePage(Appointment.Entity.MyApptAuditPageReq)">
|
||||
<summary>
|
||||
和我关联的预订(我审核的、我有权审核的、我抄送的、抄送给我的)
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.AuditorLogTree(Appointment.Entity.CommIntReq)">
|
||||
<summary>
|
||||
获取预订审核记录表
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.InAppt(System.Int32)">
|
||||
<summary>
|
||||
预订信息入正式表
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.SetMsgAuditing(System.Int32,System.Int32,System.String)">
|
||||
<summary>
|
||||
向审核人员发送审核消息
|
||||
</summary>
|
||||
<param name="apptId"></param>
|
||||
<param name="auditorId"></param>
|
||||
<param name="hotelid">酒店id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.TransferAuditMsg(System.Int32,System.String,System.String)">
|
||||
<summary>
|
||||
转审批
|
||||
</summary>
|
||||
<param name="wxSericeOpenId"></param>
|
||||
<param name="auditorId"></param>
|
||||
<param name="hotelid"></param>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.SetMsgaudited(System.String,Appointment.Entity.EnumAuditorStatus,System.String,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
审核通过向提交人发送信息
|
||||
</summary>
|
||||
<param name="wxSericeOpenId"></param>
|
||||
<param name="auditorStatus"></param>
|
||||
<param name="hotelid"></param>
|
||||
<param name="title"></param>
|
||||
<param name="reason"></param>
|
||||
<param name="auditer"></param>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepo.SetCopyMsg(System.String)">
|
||||
<summary>
|
||||
抄送 消息模板
|
||||
</summary>
|
||||
<param name="wxSericeOpenId">接收人程序openid</param>
|
||||
</member>
|
||||
<member name="T:Appointment.Repository.ApptRepoJNC">
|
||||
<summary>
|
||||
江南春模式
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Appointment.Repository.ApptRepoJNC.JncAuditor">
|
||||
<summary>
|
||||
"预定部", "销售经理", "财务经理", "财务总监", "总经理"
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.AddApptSummary(Appointment.Entity.AddSummaryJncReq)">
|
||||
<summary>
|
||||
创建暂订单
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.UpdateSummary(Appointment.Entity.UpdateSummaryReq)">
|
||||
<summary>
|
||||
修改暂订单
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.ApplyOrder(Appointment.Entity.ApplyOrderReq)">
|
||||
<summary>
|
||||
申请审核单
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.Cancel(Appointment.Entity.ApplyOrderReq)">
|
||||
<summary>
|
||||
取消OA单
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
<remarks>
|
||||
未占用资源时,只有发起人可以取消;
|
||||
未用资源后,只有预定部可以取消;
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.AuditorSummary(Appointment.Entity.ApplyOrderReq)">
|
||||
<summary>
|
||||
审核通过
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.RejectSummary(Appointment.Entity.ApplyOrderReq)">
|
||||
<summary>
|
||||
被驳回
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.ManualCopy(Appointment.Entity.ApptSendReq)">
|
||||
<summary>
|
||||
手动抄送
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.AddReply(Appointment.Entity.AddMsgReq)">
|
||||
<summary>
|
||||
信息回复
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.GetSummaryModel(Appointment.Entity.SummaryJncModelReq)">
|
||||
<summary>
|
||||
根据订单主键获取实体
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.AuditorLogTree(Appointment.Entity.SummaryJncModelReq)">
|
||||
<summary>
|
||||
获取审批流程
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.Disparity(Appointment.Entity.SummaryJncModelReq)">
|
||||
<summary>
|
||||
订单数据差异
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
<remarks>
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.GetReplyPicList(Appointment.Entity.SummaryJncModelReq)">
|
||||
<summary>
|
||||
返回回复中的图片列表
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.ApprovedByAuditor(Appointment.Entity.ApplyOrderReq)">
|
||||
<summary>
|
||||
预定部对预定单进行审批通过 【新的订单替换原来的订单】
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.PostMsg(Appointment.Entity.ApptSummary)">
|
||||
<summary>
|
||||
实时计算机发送消息模板
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.SetCopyMsg(System.String,System.String,System.String,System.Boolean,System.String)">
|
||||
<summary>
|
||||
抄送消息推送
|
||||
</summary>
|
||||
<param name="createUserName">发起人姓名</param>
|
||||
<param name="buyerTitle">订单标题</param>
|
||||
<param name="wxSericeOpenId">接收人程序openid</param>
|
||||
<param name="autoCopy">自动手动,true-自动,false-手动</param>
|
||||
<param name="remark">手动自动备注</param>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.AotoCopy(System.Int32)">
|
||||
<summary>
|
||||
自动抄送
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.ApptRepoJNC.GetReplyList(System.Collections.Generic.List{Appointment.Entity.UcLogin},System.Int32)">
|
||||
<summary>
|
||||
封装手工回复信息
|
||||
</summary>
|
||||
<param name="allUser">所有人员</param>
|
||||
<param name="id">要查看的回复的主键</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.BaseRepo.DECLoginInfo(System.String)">
|
||||
<summary>
|
||||
解释用户信息
|
||||
</summary>
|
||||
<param name="encode"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.BaseRepo.FormatApptSummaryReq(System.Collections.Generic.List{Appointment.Entity.ApptSummaryReq})">
|
||||
<summary>
|
||||
格式转化
|
||||
</summary>
|
||||
<param name="_summarys"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Appointment.Repository.DbContext">
|
||||
<summary>
|
||||
数据库操作
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.InsertReturnId``1(``0,System.Boolean)">
|
||||
<summary>
|
||||
插入数据并返回主键
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="t"></param>
|
||||
<param name="isCheck"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.InsertRange``1(System.Collections.Generic.List{``0},System.Boolean)">
|
||||
<summary>
|
||||
批量插入
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="list"></param>
|
||||
<param name="isCheck"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.DeleteById``1(System.Object)">
|
||||
<summary>
|
||||
根据主键删除
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.DeleteRange``1(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
批量删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.Update``1(``0,System.Boolean)">
|
||||
<summary>
|
||||
更新
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="t"></param>
|
||||
<param name="isCheck"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.UpdateRange``1(System.Collections.Generic.List{``0},System.Boolean)">
|
||||
<summary>
|
||||
批量更新
|
||||
</summary>
|
||||
<param name="list"></param>
|
||||
<param name="isCheck">是否数据校验</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetById``1(System.Object)">
|
||||
<summary>
|
||||
根据主键获取实体
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetSingle``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
||||
<summary>
|
||||
根据条件获取实体,如果多条获取第一条
|
||||
</summary>
|
||||
<param name="whereExpression"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetList``1">
|
||||
<summary>
|
||||
获取所有
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetList``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
||||
<summary>
|
||||
根据条件查询
|
||||
</summary>
|
||||
<param name="whereExpression">Lambd表达式</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetIn``1(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
IN 查询
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.DbContext.GetPageList``1(System.Int32,System.Int32,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},SqlSugar.OrderByType)">
|
||||
<summary>
|
||||
单表分页获取数据列表
|
||||
</summary>
|
||||
<param name="pageIndex">当前页</param>
|
||||
<param name="pageSize">页大小</param>
|
||||
<param name="whereExpression">Lambd表达式</param>
|
||||
<param name="orderByExpression">排序字段,</param>
|
||||
<param name="orderByType">排序方式</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.UserRepo.UserNameLogin(System.String,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
账号与密码登录
|
||||
</summary>
|
||||
<param name="userName">账号</param>
|
||||
<param name="userPwd">密码</param>
|
||||
<param name="code">公众号Code</param>
|
||||
<param name="hotelid">酒店Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Appointment.Repository.UserRepo.GetTransferAuditUserList(Appointment.Entity.BindUserReq)">
|
||||
<summary>
|
||||
当前用户角色是否具有转审权限
|
||||
</summary>
|
||||
<param name="req"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
134
api_v1/Appointment.Repository/ApptAuditorRepo.cs
Normal file
134
api_v1/Appointment.Repository/ApptAuditorRepo.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.IRepository;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class ApptAuditorRepo : DbContext, IApptAuditorRepo
|
||||
{
|
||||
private List<ApptAuditor> cache = null;
|
||||
|
||||
IApptLogRepo _ApptLogRepo;
|
||||
public ApptAuditorRepo(IApptLogRepo apptLogRepo)
|
||||
{
|
||||
_ApptLogRepo = apptLogRepo;
|
||||
}
|
||||
|
||||
public ApiResult<ApptAuditor> Add(ApptAuditor req)
|
||||
{
|
||||
var apptType = Db.Queryable<ApptType>()
|
||||
.Where(t => t.Id == req.ApptTypeId)
|
||||
.Any();
|
||||
if (!apptType) return ApiResult<ApptAuditor>.Failed($"操作失败,预订类型无效!");
|
||||
|
||||
var groupAny = Db.Queryable<UcGroup>()
|
||||
.Where(t => t.OpGroup == req.OpGroup.Trim() && t.Descript == req.OpDescript.Trim())
|
||||
.Any();
|
||||
if (!groupAny) return ApiResult<ApptAuditor>.Failed($"操作失败,组别无效!");
|
||||
|
||||
cache = Db.Queryable<ApptAuditor>().Where(t => t.ApptTypeId == req.ApptTypeId).ToList();
|
||||
if (req.Pid > 0)
|
||||
{
|
||||
var rootEntity = cache.Where(t => t.Id == req.Pid).FirstOrDefault();
|
||||
if (rootEntity == null) return ApiResult<ApptAuditor>.Failed($"操作失败,上级审核组无效!");
|
||||
}
|
||||
var auditorAny = cache.Where(t => t.Pid == req.Pid).FirstOrDefault();
|
||||
if (auditorAny != null) return ApiResult<ApptAuditor>.Failed($"操作失败,当前位置已经配置了审核组!");
|
||||
|
||||
var result = InsertReturnId(req);
|
||||
if (!result.IsSuccess) return ApiResult<ApptAuditor>.Failed(result.Msg);
|
||||
|
||||
req.Id = result.Info;
|
||||
return ApiResult<ApptAuditor>.Success(string.Empty, req);
|
||||
}
|
||||
|
||||
public ApiResult Delete(int id)
|
||||
{
|
||||
var childData = Db.Queryable<ApptAuditor>().Where(t => t.Pid == id).Any();
|
||||
if (childData) return ApiResult.Failed("操作失败,请先删除子级数据!");
|
||||
|
||||
var apptAuditor = GetById<ApptAuditor>(id);
|
||||
if (apptAuditor == null) return ApiResult.Success(string.Empty);
|
||||
|
||||
var ls = Db.Queryable<ApptSummary>().Where(
|
||||
t => t.ApptTypeId == apptAuditor.ApptTypeId && t.AuditorId == apptAuditor.Id
|
||||
&& t.AuditorStatus == (int)EnumAuditorStatus.审核中)
|
||||
.Select(t => t.Id).ToList();
|
||||
if (ls.Count > 0) return ApiResult.Failed($"操作失败,有待审核的预订[{string.Join(",", ls)}],请审核后再删除!");
|
||||
|
||||
|
||||
_ApptLogRepo.SetLog("ppt_auditor", apptAuditor.Id.ToString(), JsonConvert.SerializeObject(apptAuditor), null, null, 1);
|
||||
DeleteById<ApptSummary>(id);
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
public ApiResult<ApptAuditor> GetModel(int id)
|
||||
{
|
||||
var entity = GetById<ApptAuditor>(id);
|
||||
|
||||
return ApiResult<ApptAuditor>.Success(string.Empty, entity);
|
||||
}
|
||||
|
||||
public ApiResult<List<ApptAuditor>> GetList(ApptAuditor req)
|
||||
{
|
||||
var ls = Db.Queryable<ApptAuditor>()
|
||||
.Where(t => req.Pid == 0)
|
||||
.WhereIF(req.Id > 0, t => t.Id == req.Id)
|
||||
.WhereIF(req.ApptTypeId > 0, t => t.ApptTypeId == req.ApptTypeId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(req.OpGroup), t => t.OpGroup == req.OpGroup)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(req.OpDescript), t => t.OpDescript.Contains(req.OpDescript))
|
||||
.WhereIF(req.Pid > 0, t => t.Pid == req.Pid)
|
||||
.ToList();
|
||||
|
||||
|
||||
return ApiResult<List<ApptAuditor>>.Success(string.Empty, ls);
|
||||
}
|
||||
|
||||
public ApiResult<PagerData<ApptAuditor>> Page(CommPageReq req)
|
||||
{
|
||||
int total = 0;
|
||||
var ls = Db.Queryable<ApptAuditor>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(req.Keywords), t => t.OpDescript.Contains(req.Keywords))
|
||||
.ToPageList(req.PageIndex, req.PageSize, ref total);
|
||||
|
||||
|
||||
PagerData<ApptAuditor> result = new PagerData<ApptAuditor>()
|
||||
{
|
||||
PageIndex = req.PageIndex,
|
||||
PageSize = req.PageSize,
|
||||
Total = total,
|
||||
Data = ls
|
||||
};
|
||||
|
||||
return ApiResult<PagerData<ApptAuditor>>.Success(string.Empty, result);
|
||||
}
|
||||
|
||||
public ApiResult<ApptAuditor> AuditorLine(int apptTypeId)
|
||||
{
|
||||
cache = Db.Queryable<ApptAuditor>().Where(t => t.ApptTypeId == apptTypeId).ToList();
|
||||
if (cache.Count == 0) return ApiResult<ApptAuditor>.Success(string.Empty, null);
|
||||
|
||||
ApptAuditor apptAuditor = cache.Where(t => t.ApptTypeId == apptTypeId && t.Pid == 0).FirstOrDefault();
|
||||
|
||||
if (apptAuditor == null) return ApiResult<ApptAuditor>.Success(string.Empty, null);
|
||||
|
||||
apptAuditor = GetRecursion(apptAuditor);
|
||||
|
||||
return ApiResult<ApptAuditor>.Success(string.Empty, apptAuditor);
|
||||
}
|
||||
|
||||
private ApptAuditor GetRecursion(ApptAuditor req)
|
||||
{
|
||||
var entity = cache.Where(t => t.Pid == req.Id).FirstOrDefault();
|
||||
if (entity == null) return req;
|
||||
|
||||
req.Child = GetRecursion(entity);
|
||||
|
||||
return req;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
api_v1/Appointment.Repository/ApptLogRepo.cs
Normal file
26
api_v1/Appointment.Repository/ApptLogRepo.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.IRepository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class ApptLogRepo : DbContext, IApptLogRepo
|
||||
{
|
||||
public ApiResult<int> SetLog(string tableName, string keyId, string oldData, string newData, string userId, int systemUser = 0)
|
||||
{
|
||||
var model = new ApptLog()
|
||||
{
|
||||
TableName = tableName,
|
||||
KeyId = keyId,
|
||||
OldData = oldData,
|
||||
NewData = newData,
|
||||
CreateTime = DateTime.Now,
|
||||
UserId = userId,
|
||||
SystemUser = systemUser
|
||||
};
|
||||
return InsertReturnId(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
1902
api_v1/Appointment.Repository/ApptRepo.cs
Normal file
1902
api_v1/Appointment.Repository/ApptRepo.cs
Normal file
File diff suppressed because it is too large
Load Diff
4191
api_v1/Appointment.Repository/ApptRepoJNC.cs
Normal file
4191
api_v1/Appointment.Repository/ApptRepoJNC.cs
Normal file
File diff suppressed because it is too large
Load Diff
104
api_v1/Appointment.Repository/ApptTypeRepo.cs
Normal file
104
api_v1/Appointment.Repository/ApptTypeRepo.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.IRepository;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class ApptTypeRepo : DbContext, IApptTypeRepo
|
||||
{
|
||||
IApptLogRepo _ApptLog;
|
||||
public ApptTypeRepo(IApptLogRepo apptLog)
|
||||
{
|
||||
_ApptLog = apptLog;
|
||||
}
|
||||
|
||||
public ApiResult<ApptType> Add(ApptTypeAddReq req)
|
||||
{
|
||||
if (req == null || string.IsNullOrEmpty(req.ApptName)) return ApiResult<ApptType>.Failed($"操作失败,缺少参数!");
|
||||
req.ApptName = req.ApptName.Trim();
|
||||
var oldData = Db.Queryable<ApptType>().Where(t => t.ApptName == req.ApptName).Any();
|
||||
if (oldData) return ApiResult<ApptType>.Failed($"操作失败,名称 [{req.ApptName}] 被占用!");
|
||||
|
||||
var re = new ApptType()
|
||||
{
|
||||
ApptName = req.ApptName,
|
||||
Remark = req.Remark
|
||||
};
|
||||
|
||||
var result = InsertReturnId(re);
|
||||
if (!result.IsSuccess) return ApiResult<ApptType>.Failed(result.Msg);
|
||||
|
||||
re.Id = result.Info;
|
||||
return ApiResult<ApptType>.Success(string.Empty, re);
|
||||
}
|
||||
|
||||
public ApiResult Delete(int id)
|
||||
{
|
||||
if (id < 1) return ApiResult.Failed("操作失败,参数无效");
|
||||
|
||||
var model = GetById<ApptType>(id);
|
||||
if (model == null) return ApiResult.Success();
|
||||
|
||||
_ApptLog.SetLog("appt_type", model.Id.ToString(), JsonConvert.SerializeObject(model), null, null, 1);
|
||||
DeleteById<ApptType>(id);
|
||||
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
public ApiResult<ApptType> Update(ApptType req)
|
||||
{
|
||||
if (req == null || string.IsNullOrEmpty(req.ApptName)) return ApiResult<ApptType>.Failed($"操作失败,缺少参数!");
|
||||
req.ApptName = req.ApptName.Trim();
|
||||
|
||||
var model = GetById<ApptType>(req.Id);
|
||||
if (model == null) return ApiResult<ApptType>.Failed("操作失败,未获取有效的数据");
|
||||
string oldData = JsonConvert.SerializeObject(model);
|
||||
|
||||
model.ApptName = req.ApptName;
|
||||
model.Remark = req.Remark;
|
||||
var result = Update(model);
|
||||
if (!result.IsSuccess) return ApiResult<ApptType>.Failed(result.Msg);
|
||||
string newData = JsonConvert.SerializeObject(model);
|
||||
_ApptLog.SetLog("appt_type", model.Id.ToString(), oldData, newData, null, 1);
|
||||
|
||||
return ApiResult<ApptType>.Success(string.Empty, model);
|
||||
}
|
||||
|
||||
public ApiResult<ApptType> GetModel(int id)
|
||||
{
|
||||
var entity = Db.Queryable<ApptType>().Where(t => t.Id == id).First();
|
||||
return ApiResult<ApptType>.Success(string.Empty, entity);
|
||||
}
|
||||
|
||||
public ApiResult<List<ApptType>> GetList(ApptType req)
|
||||
{
|
||||
var ls = Db.Queryable<ApptType>()
|
||||
.WhereIF(req.Id > 0, t => t.Id == req.Id)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(req.ApptName), t => t.ApptName.Contains(req.ApptName))
|
||||
.ToList();
|
||||
|
||||
return ApiResult<List<ApptType>>.Success(string.Empty, ls);
|
||||
}
|
||||
|
||||
public ApiResult<PagerData<ApptType>> Page(CommPageReq req)
|
||||
{
|
||||
int total = 0;
|
||||
var ls = Db.Queryable<ApptType>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(req.Keywords), t => t.ApptName.Contains(req.Keywords))
|
||||
.ToPageList(req.PageIndex, req.PageSize, ref total);
|
||||
|
||||
PagerData<ApptType> result = new PagerData<ApptType>()
|
||||
{
|
||||
PageIndex = req.PageIndex,
|
||||
PageSize = req.PageSize,
|
||||
Total = total,
|
||||
Data = ls
|
||||
};
|
||||
|
||||
return ApiResult<PagerData<ApptType>>.Success(string.Empty, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
api_v1/Appointment.Repository/BaseRepo.cs
Normal file
188
api_v1/Appointment.Repository/BaseRepo.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using Appointment.Entity;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class BaseRepo : DbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 解释用户信息
|
||||
/// </summary>
|
||||
/// <param name="encode"></param>
|
||||
/// <returns></returns>
|
||||
public static ApiResult<LoginUserRes> DECLoginInfo(string encode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(encode)) return ApiResult<LoginUserRes>.Failed("操作失败,未获取到当前用户账号!");
|
||||
var jsonStr = CryptoHelper.DES_Decode(encode);
|
||||
if (string.IsNullOrWhiteSpace(jsonStr)) return ApiResult<LoginUserRes>.Failed("操作失败,当前用户信息不正确!");
|
||||
LoginUserRes loginUserRes = JsonConvert.DeserializeObject<LoginUserRes>(jsonStr);
|
||||
if (loginUserRes == null) return ApiResult<LoginUserRes>.Failed("操作失败,未获取到当前用户账号!");
|
||||
return ApiResult<LoginUserRes>.Success(string.Empty, loginUserRes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式转化
|
||||
/// </summary>
|
||||
/// <param name="_summarys"></param>
|
||||
/// <returns></returns>
|
||||
public List<ApptSummaryReq> FormatApptSummaryReq(List<ApptSummaryReq> _summarys)
|
||||
{
|
||||
if (_summarys == null || _summarys.Count == 0) return new List<ApptSummaryReq>();
|
||||
|
||||
var apptIds = _summarys.Select(t => t.Id).ToList();
|
||||
|
||||
var apptMeetingsCache = Db.Queryable<ApptMeeting>()
|
||||
.In(t => t.ApptId, apptIds).ToList();
|
||||
var apptRoomsCache = Db.Queryable<ApptRoom>()
|
||||
.In(t => t.ApptId, apptIds).ToList();
|
||||
var apptCateringsCache = Db.Queryable<ApptCatering>()
|
||||
.In(t => t.ApptId, apptIds).ToList();
|
||||
var apptSpringsCache = Db.Queryable<ApptSpring>()
|
||||
.In(t => t.ApptId, apptIds).ToList();
|
||||
|
||||
var apptRemarksCache = Db.Queryable<ApptRemark>()
|
||||
.In(t => t.ApptId, apptIds).ToList();
|
||||
|
||||
foreach (var item in _summarys)
|
||||
{
|
||||
var apptMeetingList = apptMeetingsCache.Where(t => t.ApptId == item.Id).OrderBy(t => t.Id).ToList();
|
||||
if (apptMeetingList.Count > 0)
|
||||
{
|
||||
item.ApptMeetingList = new List<ApptMeetingReq>();
|
||||
foreach (var _item in apptMeetingList)
|
||||
{
|
||||
var model = item.ApptMeetingList.Where(t => t.MeetingTime == _item.MeetingTime).FirstOrDefault();
|
||||
if (model == null)
|
||||
{
|
||||
item.ApptMeetingList.Add(new ApptMeetingReq()
|
||||
{
|
||||
Id = _item.Id.Value,
|
||||
MeetingTime = _item.MeetingTime,
|
||||
//MeetingGroup = new int[] { _item.MeetingGroup },
|
||||
MeetingRoom = _item.MeetingRoom,
|
||||
MeetingCode = _item.MeetingCode,
|
||||
MeetingRostrum = _item.MeetingRostrum,
|
||||
MeetingShape = _item.MeetingShape,
|
||||
MeetingNum = _item.MeetingNum,
|
||||
MeetingPrice = _item.MeetingPrice,
|
||||
MeetingTitle = _item.MeetingTitle,
|
||||
Remark = _item.Remark
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
List<int> _arr = model.MeetingGroup.ToList();
|
||||
//_arr.Add(_item.MeetingGroup);
|
||||
_arr.Sort();
|
||||
model.MeetingGroup = _arr.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var apptRoomList = apptRoomsCache.Where(t => t.ApptId == item.Id).OrderBy(t => t.Id).ToList();
|
||||
if (apptRoomList.Count > 0)
|
||||
{
|
||||
item.ApptRoomList = new List<ApptRoomReq>();
|
||||
foreach (var _item in apptRoomList)
|
||||
{
|
||||
item.ApptRoomList.Add(new ApptRoomReq()
|
||||
{
|
||||
Id = _item.Id.Value,
|
||||
RoomIn = _item.RoomIn,
|
||||
RoomOut = _item.RoomOut,
|
||||
RoomGroup = _item.RoomGroup,
|
||||
RooomCode = _item.RoomCode,
|
||||
RoomNum = _item.RoomNum,
|
||||
RoomPrice = _item.RoomPrice,
|
||||
BreakfastNum = _item.BreakfastNum,
|
||||
LongDistance = _item.LongDistance,
|
||||
MinShop = _item.MinShop,
|
||||
RoomRemark = _item.RoomRemark
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var apptCateringList = apptCateringsCache.Where(t => t.ApptId == item.Id).OrderBy(t => t.Id).ToList();
|
||||
if (apptCateringList.Count > 0)
|
||||
{
|
||||
item.ApptCateringList = new List<ApptCateringReq>();
|
||||
foreach (var _item in apptCateringList)
|
||||
{
|
||||
var model = item.ApptCateringList.Where(t => t.CateringTime == _item.CateringTime).FirstOrDefault();
|
||||
if (model == null)
|
||||
{
|
||||
item.ApptCateringList.Add(new ApptCateringReq()
|
||||
{
|
||||
Id = _item.Id.Value,
|
||||
CateringTime = _item.CateringTime,
|
||||
//CateringGroup = new int[] { _item.CateringGroup },
|
||||
CateringRoom = _item.CateringRoom,
|
||||
CateringCode = _item.CateringCode,
|
||||
CateringType = _item.CateringType,
|
||||
CateringNum = _item.CateringNum,
|
||||
CateringPrice = _item.CateringPrice,
|
||||
CateringTable = _item.CateringTable,
|
||||
Wine = _item.Wine,
|
||||
Remark = _item.Remark
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
List<int> _arr = model.CateringGroup.ToList();
|
||||
//_arr.Add(_item.CateringGroup);
|
||||
_arr.Sort();
|
||||
model.CateringGroup = _arr.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var apptSpringList = apptSpringsCache.Where(t => t.ApptId == item.Id).OrderBy(t => t.Id).ToList();
|
||||
if (apptSpringList.Count > 0)
|
||||
{
|
||||
item.ApptSpringList = new List<ApptSpringReq>();
|
||||
foreach (var _item in apptSpringList)
|
||||
{
|
||||
item.ApptSpringList.Add(new ApptSpringReq()
|
||||
{
|
||||
Id = _item.Id.Value,
|
||||
SpringTime = _item.SpringTime,
|
||||
PeopleNum = _item.PeopleNum,
|
||||
SpringMen = _item.SpringMen,
|
||||
SpringWomen = _item.SpringWomen,
|
||||
Consume = _item.Consume,
|
||||
SpringPrice = _item.SpringPrice,
|
||||
Remark = _item.Remark
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var ls = Db.Queryable<SysCode>()
|
||||
.Where(t => t.Class == EnumSysCodeClass.apptremark.ToString())
|
||||
.OrderBy(t => t.Id, OrderByType.Asc)
|
||||
.Select(t => t.Descript1).ToList().Replace();
|
||||
if (ls != null && ls.Count > 0)
|
||||
{
|
||||
item.Remarks = new List<RemarkReq>();
|
||||
foreach (var _item in ls)
|
||||
{
|
||||
string info = string.Empty;
|
||||
var model = apptRemarksCache.Where(t => t.ApptId == item.Id && t.Title == _item).FirstOrDefault();
|
||||
if (model != null) info = model.Info;
|
||||
item.Remarks.Add(new RemarkReq()
|
||||
{
|
||||
RemarkName = _item,
|
||||
RemarkContent = info,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _summarys;
|
||||
}
|
||||
}
|
||||
}
|
||||
280
api_v1/Appointment.Repository/DbContext.cs
Normal file
280
api_v1/Appointment.Repository/DbContext.cs
Normal file
@@ -0,0 +1,280 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.Entity.Utility;
|
||||
using Appointment.Entity.ValidateAttribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库操作
|
||||
/// </summary>
|
||||
public class DbContext
|
||||
{
|
||||
static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DbContext));
|
||||
|
||||
public SqlSugarClient Db;
|
||||
|
||||
public DbContext()
|
||||
{
|
||||
string conn = BaseConfig.App(new string[] { "ConnectionString" });
|
||||
if (string.IsNullOrWhiteSpace(conn)) throw new Exception("未获取到数据库连接信息");
|
||||
Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = conn,
|
||||
DbType = DbType.SqlServer,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
});
|
||||
|
||||
Db.Aop.OnError = (exp) =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(exp.Sql))
|
||||
{
|
||||
string spar = string.Empty;
|
||||
if (exp.Parametres != null)
|
||||
{
|
||||
SugarParameter[] parss = (SugarParameter[])exp.Parametres;
|
||||
if (parss.Length > 0)
|
||||
{
|
||||
foreach (SugarParameter item in parss)
|
||||
{
|
||||
spar += $"{item.ParameterName}={item.Value.ToString()},";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Error($"sql语句:{exp.Sql} 参数:{spar}");
|
||||
log.Error($"错误信息:{exp.Message}");
|
||||
|
||||
throw new Exception("操作失败,出现异常请联系管理员!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ----- 插入
|
||||
|
||||
/// <summary>
|
||||
/// 插入数据并返回主键
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="isCheck"></param>
|
||||
/// <returns></returns>
|
||||
public virtual ApiResult<int> InsertReturnId<T>(T t, bool isCheck = true) where T : class, new()
|
||||
{
|
||||
if (isCheck)
|
||||
{
|
||||
var resultValidate = t.Validate();
|
||||
if (!resultValidate.IsSuccess) return ApiResult<int>.Failed(resultValidate.Msg);
|
||||
}
|
||||
int id = new SimpleClient<T>(Db).InsertReturnIdentity(t);
|
||||
return ApiResult<int>.Success("", id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="isCheck"></param>
|
||||
/// <returns></returns>
|
||||
public virtual ApiResult InsertRange<T>(List<T> list, bool isCheck = true) where T : class, new()
|
||||
{
|
||||
if (list == null || list.Count <= 0) return ApiResult.Success("没有可提交的数据");
|
||||
if (isCheck)
|
||||
{
|
||||
var resultValidate = ApiResult.Success();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
resultValidate = list[i].Validate();
|
||||
if (!resultValidate.IsSuccess) return ApiResult.Failed(resultValidate.Msg);
|
||||
}
|
||||
}
|
||||
int rows = Db.Insertable(list.ToArray()).ExecuteCommand();
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
// ----- 删除
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool DeleteById<T>(dynamic id) where T : class, new()
|
||||
{
|
||||
return new SimpleClient<T>(Db).DeleteById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool DeleteRange<T>(List<int> ids) where T : class, new()
|
||||
{
|
||||
List<dynamic> ls = new List<dynamic>();
|
||||
ids.ForEach(p => ls.Add(p));
|
||||
|
||||
return new SimpleClient<T>(Db).DeleteByIds(ls.ToArray());
|
||||
}
|
||||
|
||||
// ----- 更新
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="isCheck"></param>
|
||||
/// <returns></returns>
|
||||
public virtual ApiResult Update<T>(T t, bool isCheck = true) where T : class, new()
|
||||
{
|
||||
if (isCheck)
|
||||
{
|
||||
var resultValidate = t.Validate();
|
||||
if (!resultValidate.IsSuccess) ApiResult.Failed(resultValidate.Msg);
|
||||
}
|
||||
new SimpleClient<T>(Db).Update(t);
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="isCheck">是否数据校验</param>
|
||||
/// <returns></returns>
|
||||
public virtual ApiResult UpdateRange<T>(List<T> list, bool isCheck = true) where T : class, new()
|
||||
{
|
||||
if (list == null || list.Count <= 0) return ApiResult.Success("没有可修改的数据");
|
||||
if (isCheck)
|
||||
{
|
||||
var resultValidate = ApiResult.Success();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
resultValidate = list[i].Validate();
|
||||
if (!resultValidate.IsSuccess) return ApiResult.Failed(resultValidate.Msg);
|
||||
}
|
||||
}
|
||||
new SimpleClient<T>(Db).UpdateRange(list.ToArray());
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
// ----- 查询单条
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取实体
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetById<T>(dynamic id) where T : class, new()
|
||||
{
|
||||
return new SimpleClient<T>(Db).GetById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件获取实体,如果多条获取第一条
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetSingle<T>(Expression<Func<T, bool>> whereExpression) where T : class, new()
|
||||
{
|
||||
var simple = new SimpleClient<T>(Db);
|
||||
try
|
||||
{
|
||||
return simple.GetSingle(whereExpression);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return simple.GetList(whereExpression).FirstOrDefault();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string t = ex.Message;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// ----- 查询多条
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual List<T> GetList<T>() where T : class, new()
|
||||
{
|
||||
return new SimpleClient<T>(Db).GetList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询
|
||||
/// </summary>
|
||||
/// <param name="whereExpression">Lambd表达式</param>
|
||||
/// <returns></returns>
|
||||
public virtual List<T> GetList<T>(Expression<Func<T, bool>> whereExpression) where T : class, new()
|
||||
{
|
||||
return new SimpleClient<T>(Db).GetList(whereExpression);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IN 查询
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public virtual List<T> GetIn<T>(List<int> ids) where T : class, new()
|
||||
{
|
||||
return Db.Queryable<T>().In(ids.ToArray()).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单表分页获取数据列表
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">当前页</param>
|
||||
/// <param name="pageSize">页大小</param>
|
||||
/// <param name="whereExpression">Lambd表达式</param>
|
||||
/// <param name="orderByExpression">排序字段,</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <returns></returns>
|
||||
public virtual PagerData<T> GetPageList<T>(int pageIndex, int pageSize, Expression<Func<T, bool>> whereExpression, Expression<Func<T, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) where T : class, new()
|
||||
{
|
||||
if (pageIndex <= 1) pageIndex = 1;
|
||||
if (pageSize <= 1) pageSize = 10;
|
||||
|
||||
PagerData<T> pagerData = new PagerData<T>();
|
||||
|
||||
PageModel page = new PageModel()
|
||||
{
|
||||
PageIndex = pageIndex,
|
||||
PageSize = pageSize
|
||||
};
|
||||
|
||||
if (whereExpression == null)
|
||||
{
|
||||
var exp = Expressionable.Create<T>();
|
||||
whereExpression = exp.ToExpression();
|
||||
}
|
||||
|
||||
List<T> ls = new SimpleClient<T>(Db).GetPageList(whereExpression, page, orderByExpression, orderByType);
|
||||
|
||||
if (ls != null && ls.Count > 0)
|
||||
{
|
||||
pagerData.Data = ls;
|
||||
}
|
||||
else
|
||||
{
|
||||
pagerData.Data = null;
|
||||
}
|
||||
pagerData.PageIndex = page.PageIndex;
|
||||
pagerData.PageSize = page.PageSize;
|
||||
pagerData.Total = page.PageCount;
|
||||
|
||||
return pagerData;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
api_v1/Appointment.Repository/ManageGroup.cs
Normal file
27
api_v1/Appointment.Repository/ManageGroup.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.Entity.Utility;
|
||||
using Appointment.IRepository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class ManagerGroup : DbContext, IManagerGroup
|
||||
{
|
||||
public ApiResult<List<UcGroup>> GetAll()
|
||||
{
|
||||
var list = Db.Queryable<UcGroup>().AS("uc_group").ToList();
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.OpGroup = item.OpGroup?.Trim();
|
||||
item.Descript = item.Descript?.Trim();
|
||||
item.OpFunc = item.OpFunc?.Trim();
|
||||
}
|
||||
}
|
||||
return ApiResult<List<UcGroup>>.Success("", list);
|
||||
}
|
||||
}
|
||||
}
|
||||
193
api_v1/Appointment.Repository/UserRepo.cs
Normal file
193
api_v1/Appointment.Repository/UserRepo.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using Appointment.Entity;
|
||||
using Appointment.IRepository;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Appointment.Repository
|
||||
{
|
||||
public class UserRepo : DbContext, IUserRepo
|
||||
{
|
||||
static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(UserRepo));
|
||||
|
||||
IApptLogRepo _ApptLog;
|
||||
IApptRepo _ApptRepo;
|
||||
public UserRepo(IApptLogRepo apptLog, IApptRepo apptRepo)
|
||||
{
|
||||
_ApptLog = apptLog;
|
||||
_ApptRepo = apptRepo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 账号与密码登录
|
||||
/// </summary>
|
||||
/// <param name="userName">账号</param>
|
||||
/// <param name="userPwd">密码</param>
|
||||
/// <param name="code">公众号Code</param>
|
||||
/// <param name="hotelid">酒店Id</param>
|
||||
/// <returns></returns>
|
||||
public ApiResult<UserInfoRes> UserNameLogin(string userName, string userPwd, string code, string hotelid)
|
||||
{
|
||||
var user = Db.Queryable<UcLogin>()
|
||||
.Where(t => t.OpId == userName && t.Password == userPwd).First();
|
||||
if (user == null) return ApiResult<UserInfoRes>.Failed("登录失败,用户不存在!");
|
||||
user = user.Replace();
|
||||
if (user.Locked == "T") return ApiResult<UserInfoRes>.Failed("登录失败,账号锁定!");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(code))
|
||||
{
|
||||
ApiResult<WeChatLoginRes> resultOpen = new WechatHelper().Code2Session(code);
|
||||
if (!resultOpen.IsSuccess) return ApiResult<UserInfoRes>.Failed(resultOpen.Msg);
|
||||
|
||||
if (user.WxOpenId != resultOpen.Info.Openid)
|
||||
{
|
||||
user.WxOpenId = resultOpen.Info.Openid;
|
||||
var update = Db.Updateable(user)
|
||||
.UpdateColumns(t => new { t.WxOpenId, t.OpId, t.Password })
|
||||
.WhereColumns(t => new { t.OpId, t.Password }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
var role = Db.Queryable<ApptAuditor>().Where(t => t.OpGroup == user.OpGroup && t.ApptTypeId == 2).Any();
|
||||
|
||||
int bindStatus = string.IsNullOrWhiteSpace(user.WxServiceId) ? 0 : 1;
|
||||
string sJson = JsonConvert.SerializeObject(new LoginUserRes()
|
||||
{
|
||||
UserAccount = user.OpId,
|
||||
UserName = user.OpName,
|
||||
UserGroup = user.OpGroup,
|
||||
Hotelid = hotelid
|
||||
});
|
||||
var userToken = CryptoHelper.DES_Encode(sJson);
|
||||
|
||||
var wxmpAppid = BaseConfig.App(new string[] { "WeChatService", "AppId" });
|
||||
|
||||
return ApiResult<UserInfoRes>.Success(string.Empty, new UserInfoRes()
|
||||
{
|
||||
BindStatus = bindStatus,
|
||||
UserAccount = user.OpId,
|
||||
Token = wxmpAppid,
|
||||
Role = role ? 1 : 0,
|
||||
AccountDES = userToken
|
||||
});
|
||||
}
|
||||
|
||||
public ApiResult<UserInfoRes> WxLogin(string code, string hotelid)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(code)) return ApiResult<UserInfoRes>.Failed("未获取有效的微信信息");
|
||||
|
||||
ApiResult<WeChatLoginRes> resultOpen = new WechatHelper().Code2Session(code);
|
||||
if (!resultOpen.IsSuccess) return ApiResult<UserInfoRes>.Failed(resultOpen.Msg);
|
||||
|
||||
var user = Db.Queryable<UcLogin>()
|
||||
.Where(t => t.WxOpenId == resultOpen.Info.Openid).First();
|
||||
if (user == null) return ApiResult<UserInfoRes>.Failed("登录失败,该微信未绑定,可以通过工号登录实现绑定!");
|
||||
user = user.Replace();
|
||||
if (user.Locked == "T") return ApiResult<UserInfoRes>.Failed("登录失败,账号锁定!");
|
||||
|
||||
var role = Db.Queryable<ApptAuditor>().Where(t => t.OpGroup == user.OpGroup && t.ApptTypeId == 2).Any();
|
||||
|
||||
int bindStatus = string.IsNullOrWhiteSpace(user.WxServiceId) ? 0 : 1;
|
||||
string sJson = JsonConvert.SerializeObject(new LoginUserRes()
|
||||
{
|
||||
UserAccount = user.OpId,
|
||||
UserName = user.OpName,
|
||||
UserGroup = user.OpGroup,
|
||||
Hotelid = hotelid
|
||||
});
|
||||
var userToken = CryptoHelper.DES_Encode(sJson);
|
||||
|
||||
var wxmpAppid = BaseConfig.App(new string[] { "WeChatService", "AppId" });
|
||||
|
||||
return ApiResult<UserInfoRes>.Success(string.Empty, new UserInfoRes()
|
||||
{
|
||||
BindStatus = bindStatus,
|
||||
UserAccount = user.OpId,
|
||||
Token = wxmpAppid,
|
||||
Role = role ? 1 : 0,
|
||||
AccountDES = userToken
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public ApiResult WxServiceSet(WxServiceSetRes req)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(req.UserAccount)) return ApiResult.Failed("添加失败,未获取到当前用户账号!");
|
||||
|
||||
var user = Db.Queryable<UcLogin>().Where(t => t.OpId == req.UserAccount && t.Locked == "F").First();
|
||||
if (user == null) return ApiResult.Failed("操作失败,用户不存在或被冻结!");
|
||||
user = user.Replace();
|
||||
|
||||
string oldData = JsonConvert.SerializeObject(user);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(user.WxServiceId))
|
||||
{
|
||||
string accessTokenMode = BaseConfig.App(new string[] { "AccessTokenMode" });
|
||||
if (string.IsNullOrWhiteSpace(accessTokenMode))
|
||||
{
|
||||
log.Error("配置文件中未获取有效的AccessTokenMode");
|
||||
return ApiResult.Failed("配置文件中未获取有效的AccessTokenMode");
|
||||
}
|
||||
var openResult = AizhuhotelHelper.GetWxSericeOpenId(req.Code);
|
||||
if (!openResult.IsSuccess) return ApiResult.Failed(openResult.Msg);
|
||||
|
||||
string serviceOpen = openResult.Info;
|
||||
var anyM = Db.Queryable<UcLogin>().Where(t => t.OpId != req.UserAccount && t.WxServiceId == serviceOpen).First();
|
||||
if (anyM != null)
|
||||
{
|
||||
return ApiResult.Failed($"当前微信已绑定了账号{anyM.OpId}");
|
||||
}
|
||||
|
||||
|
||||
user.WxServiceId = openResult.Info;
|
||||
Update(user);
|
||||
|
||||
string newData = JsonConvert.SerializeObject(user);
|
||||
|
||||
return ApiResult.Success();
|
||||
}
|
||||
return ApiResult.Success();
|
||||
}
|
||||
|
||||
|
||||
public ApiResult<List<LoginUserRes>> GetSendUserList(BindUserReq req)
|
||||
{
|
||||
ApiResult<LoginUserRes> loginUserRes = null;
|
||||
if (req != null && !string.IsNullOrEmpty(req.AccountDES))
|
||||
{
|
||||
loginUserRes = BaseRepo.DECLoginInfo(req.AccountDES);
|
||||
if (!loginUserRes.IsSuccess) return ApiResult<List<LoginUserRes>>.Failed(loginUserRes.Msg);
|
||||
}
|
||||
var ls = Db.Queryable<UcLogin>()
|
||||
.Where(t => t.Apptsend == "T" && t.Locked == "F")
|
||||
.WhereIF(loginUserRes != null, t => t.OpId != loginUserRes.Info.UserAccount)
|
||||
.Select(t => new LoginUserRes { UserAccount = t.OpId, UserName = t.OpName, UserGroup = t.OpGroup }).ToList().Replace();
|
||||
return ApiResult<List<LoginUserRes>>.Success(string.Empty, ls);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户角色是否具有转审权限
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public ApiResult<List<LoginUserRes>> GetTransferAuditUserList(BindUserReq req)
|
||||
{
|
||||
List<LoginUserRes> loginUseList = new List<LoginUserRes>();
|
||||
var loginUserRes = BaseRepo.DECLoginInfo(req.AccountDES);
|
||||
if (!loginUserRes.IsSuccess) return ApiResult<List<LoginUserRes>>.Failed(loginUserRes.Msg);
|
||||
|
||||
loginUseList = Db.Queryable<UcLogin>()
|
||||
.Where(t => t.Appttrans == "T" && !SqlFunc.IsNullOrEmpty(t.WxOpenId) && !SqlFunc.IsNullOrEmpty(t.WxServiceId) && t.Locked == "F" && t.OpId != loginUserRes.Info.UserAccount)
|
||||
.Select(t => new LoginUserRes()
|
||||
{
|
||||
UserAccount = t.OpId,
|
||||
UserName = t.OpName
|
||||
}).ToList();
|
||||
loginUseList = loginUseList.Replace();
|
||||
return ApiResult<List<LoginUserRes>>.Success(string.Empty, loginUseList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user