为什么都没了

This commit is contained in:
路 范
2021-09-24 12:59:34 +08:00
parent a975b3bdee
commit a66921f0f4
962 changed files with 252792 additions and 0 deletions

9
framework/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
bin/
obj/
*.user
/Publish
/packages
.vs
Logs/
Upload
dbsettings.Development.json

3
framework/.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "Api/Furion"]
path = Api/Furion
url = https://gitee.com/dotnetchina/Furion.git

View File

@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Application
{
[Table("bs_house_code")]
[Comment("房屋编码表")]
public class BsHouseCode : Core.DEntityBase
{
[Comment("系统中唯一的房屋编码,生成即不再变更")]
[MaxLength(50)]
[Required]
public string HouseCode { get; set; }
[Comment("编号")]
[MaxLength(3)]
[Required]
public int No { get; set; }
[Comment("项目ID")]
[MaxLength(36)]
[Required]
public string ProjectId { get; set; }
[Comment("片区ID")]
[MaxLength(36)]
[Required]
public string ZoneId { get; set; }
[Comment("详细地址")]
[MaxLength(500)]
[Required]
public string Address { get; set; }
[Comment("性质")]
[Required]
public int Type { get; set; }
[Comment("所属行业")]
[Required]
public int Industry { get; set; }
[Comment("坐标-经度")]
[MaxLength(50)]
public string Lng { get; set; }
[Comment("坐标-纬度")]
[MaxLength(50)]
public string Lat { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
[Table("bs_house_company")]
[Comment("房屋相关单位表")]
public class BsHouseCompany : Core.DEntityBase
{
/// <summary>
/// 单位类型,多选
/// </summary>
[Comment("单位类型,多选")]
[MaxLength(20)]
public string Type { get; set; }
/// <summary>
/// 单位名称
/// </summary>
[Comment("单位名称")]
[MaxLength(200)]
public string Name { get; set; }
/// <summary>
/// 信息
/// </summary>
[Comment("信息")]
public string Info { get; set; }
}
}

View File

@@ -0,0 +1,378 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
[Table("bs_house_info")]
[Comment("房屋信息表")]
public class BsHouseInfo : Core.DEntityBase
{
/// <summary>
/// HouseCode主键ID
/// </summary>
[Comment("bs_house_code主键Id")]
[MaxLength(36)]
[Required]
public string HouseCodeId { get; set; }
/// <summary>
/// 幢名称
/// </summary>
[Comment("幢名称")]
[MaxLength(255)]
public string BuildingName { get; set; }
/// <summary>
/// 土地性质
/// </summary>
[Comment("土地性质")]
public int? LandAttribute { get; set; }
/// <summary>
/// 结构类型
/// </summary>
[Comment("结构类型")]
public int? StructureType { get; set; }
/// <summary>
/// 基础情况
/// </summary>
[Comment("基础情况")]
public int? BaseInfo { get; set; }
/// <summary>
/// 抗震等级
/// </summary>
[Comment("抗震等级")]
public int? SeismicGrade { get; set; }
/// <summary>
/// 竣工日期
/// </summary>
[Comment("竣工日期")]
public DateTime? CompletedDate { get; set; }
/// <summary>
/// 设计使用年限
/// </summary>
[Comment("设计使用年限")]
public int? UsefulYear { get; set; }
/// <summary>
/// 总层数
/// </summary>
[Comment("总层数")]
public int? TotalFloor { get; set; }
/// <summary>
/// 地上层数
/// </summary>
[Comment("地上层数")]
public int? LandFloorCount { get; set; }
/// <summary>
/// 地上商业层数开始
/// </summary>
[Comment("地上商业层数开始")]
public int? LandBsFloorStart { get; set; }
/// <summary>
/// 地上商业层数结束
/// </summary>
[Comment("地上商业层数结束")]
public int? LandBsFloorEnd { get; set; }
/// <summary>
/// 地上车棚层开始
/// </summary>
[Comment("地上车棚层开始")]
public int? LandBikeFloorStart { get; set; }
/// <summary>
/// 地上住宅层开始
/// </summary>
[Comment("地上住宅层开始")]
public int? LandResidenceFloorStart { get; set; }
/// <summary>
/// 地上住宅层结束
/// </summary>
[Comment("地上住宅层结束")]
public int? LandResidenceFloorEnd { get; set; }
/// <summary>
/// 地下层数
/// </summary>
[Comment("地下层数")]
public int? UnderFloorCount { get; set; }
/// <summary>
/// 总建筑面积
/// </summary>
[Comment("总建筑面积")]
public float? TotalArea { get; set; }
/// <summary>
/// 有无建筑幕墙
/// </summary>
[Comment("有无建筑幕墙")]
public int? CurtainWall { get; set; }
/// <summary>
/// 有无面砖
/// </summary>
[Comment("有无面砖")]
public int? FaceBrick { get; set; }
/// <summary>
/// 有无涂料
/// </summary>
[Comment("有无涂料")]
public int? Coating { get; set; }
/// <summary>
/// 有无粉刷
/// </summary>
[Comment("有无粉刷")]
public int? Painting { get; set; }
/// <summary>
/// 电梯
/// </summary>
[Comment("电梯")]
[MaxLength(20)]
public string Elevator { get; set; }
/// <summary>
/// 总户数(户)
/// </summary>
[Comment("总户数(户)")]
public int? HouseHolds { get; set; }
/// <summary>
/// 房屋单元数
/// </summary>
[Comment("房屋单元数")]
public int? Units { get; set; }
/// <summary>
/// 各单元每层户数(户)
/// </summary>
[Comment("各单元每层户数(户)")]
public int? UnitFloorHolds { get; set; }
/// <summary>
/// 建设单位ID
/// </summary>
[Comment("建设单位ID")]
[MaxLength(36)]
public string BuildingUnitId { get; set; }
/// <summary>
/// 设计单位ID
/// </summary>
[Comment("设计单位ID")]
[MaxLength(36)]
public string DesingerUnitId { get; set; }
/// <summary>
/// 施工单位ID
/// </summary>
[Comment("施工单位ID")]
[MaxLength(36)]
public string ConstructionUnitId { get; set; }
/// <summary>
/// 监理单位ID
/// </summary>
[Comment("监理单位ID")]
[MaxLength(36)]
public string MonitorUnitId { get; set; }
/// <summary>
/// 产权性质
/// </summary>
[Comment("产权性质")]
[MaxLength(100)]
public string PropertyRights { get; set; }
/// <summary>
/// 总共套数
/// </summary>
[Comment("总共套数")]
public int? HouseCount { get; set; }
/// <summary>
/// 直管公房套数
/// </summary>
[Comment("直管公房套数")]
public int? StraightHouseCount { get; set; }
/// <summary>
/// 自管公房套数
/// </summary>
[Comment("自管公房套数")]
public int? SelfHouseCount { get; set; }
/// <summary>
/// 私房套数
/// </summary>
[Comment("私房套数")]
public int? PrivateHouseCount { get; set; }
/// <summary>
/// 商品房套数
/// </summary>
[Comment("商品房套数")]
public int? BusinessCount { get; set; }
/// <summary>
/// 房改房套数
/// </summary>
[Comment("房改房套数")]
public int? ChangeHouseCount { get; set; }
/// <summary>
/// 拆迁安置房套数
/// </summary>
[Comment("拆迁安置房套数")]
public int? ResettlementHouseCount { get; set; }
/// <summary>
/// 其它套数
/// </summary>
[Comment("其它套数")]
public int? OtherCount { get; set; }
/// <summary>
/// 产权单位ID
/// </summary>
[Comment("产权单位ID")]
[MaxLength(36)]
public string PropertyUnitId { get; set; }
/// <summary>
/// 物业单位ID
/// </summary>
[Comment("物业单位ID")]
[MaxLength(36)]
public string WuYeUnitId { get; set; }
/// <summary>
/// 图纸资料存档处
/// </summary>
[Comment("图纸资料存档处")]
[MaxLength(50)]
public string DrawingMaterial { get; set; }
/// <summary>
/// 其他图纸存档
/// </summary>
[Comment("其他图纸存档")]
[MaxLength(100)]
public string DrawingMaterialText { get; set; }
/// <summary>
/// 立项文件
/// </summary>
[Comment("立项文件")]
[MaxLength(2000)]
public string AnEntryDocument { get; set; }
/// <summary>
/// 规划许可
/// </summary>
[Comment("规划许可")]
[MaxLength(2000)]
public string PlanningPermission { get; set; }
/// <summary>
/// 竣工验收备案
/// </summary>
[Comment("竣工验收备案")]
[MaxLength(2000)]
public string CompletionRecord { get; set; }
/// <summary>
/// 监理资料
/// </summary>
[Comment("监理资料")]
[MaxLength(2000)]
public string MonitorDocument { get; set; }
/// <summary>
/// 鉴定报告
/// </summary>
[Comment("鉴定报告")]
[MaxLength(2000)]
public string IdentificationReport { get; set; }
/// <summary>
/// 其它资料
/// </summary>
[Comment("其它资料")]
[MaxLength(2000)]
public string OtherDocument { get; set; }
/// <summary>
/// 外立面照片
/// </summary>
[Comment("外立面照片")]
[MaxLength(2000)]
public string FacadePhoto { get; set; }
/// <summary>
/// 房屋等级 1,2,3,4,C,d
/// </summary>
[Comment("房屋等级 1,2,3,4,C,d")]
public int? HouseGrade { get; set; }
/// <summary>
/// 房屋使用状态
/// </summary>
[Comment("房屋使用状态")]
public int? HouseUsedStatus { get; set; }
/// <summary>
/// -1 退回(审核被退回的数据) 1、待建档需要建档的数据未暂存未保存的2、暂存点击了暂存的数据3、待提交点击了保存的数据 5、审核中6、审核通过
/// </summary>
[Comment("-1 退回(审核被退回的数据) 1、待建档需要建档的数据未暂存未保存的2、暂存点击了暂存的数据3、待提交点击了保存的数据 5、审核中6、审核通过")]
[Required]
public int State { get; set; }
/// <summary>
/// 调查登记机构
/// </summary>
[Comment("调查登记机构")]
[MaxLength(100)]
public string InvestigateAgency { get; set; }
/// <summary>
/// 纸质资料调查人
/// </summary>
[Comment("纸质资料调查人")]
[MaxLength(50)]
public string InvestigateUser { get; set; }
/// <summary>
/// 纸质资料审核人
/// </summary>
[Comment("纸质资料审核人")]
[MaxLength(50)]
public string OfflineAuditor { get; set; }
/// <summary>
/// 主管部门
/// </summary>
[Comment("主管部门")]
[MaxLength(50)]
public string CompetentDepartment { get; set; }
}
}

View File

@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
[Table("bs_house_log")]
[Comment("房屋流转日志")]
public class BsHouseLog : Core.DEntityBase
{
[Comment("房屋编码Id")]
[MaxLength(36)]
public string HouseCodeId { get; set; }
[Comment("目标处理人Id可多个")]
public string TargetUserIds { get; set; }
[Comment("步骤类型")]
public HouseLogType Type { get; set; }
[Comment("状态")]
public HouseLogStatus Status { get; set; }
[Comment("备注信息")]
public string Remark { get; set; }
[Comment("完成时间")]
public DateTime? FinishedTime { get; set; }
[Comment("完成者Id")]
[MaxLength(36)]
public string FinishedUserId { get; set; }
[Comment("完成者名称")]
[MaxLength(20)]
public string FinishedUserName { get; set; }
[Comment("排序")]
public int Sort { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
[Table("bs_house_member_relation")]
[Comment("房屋与人员关联表")]
public class BsHouseMemberRelation : Core.DEntityBase
{
[Comment("sys_user主键Id")]
[MaxLength(36)]
[Required]
public string SysUserId { get; set; }
[Comment("bs_house_code主键Id")]
[MaxLength(36)]
[Required]
public string HouseCodeId { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Entity
{
[Table("bs_house_projectinfo")]
[Comment("项目表")]
public class BsHouseProjectInfo : Core.DEntityBase
{
[Comment("名称")]
[MaxLength(100)]
[Required]
public string Name { get; set; }
[Comment("备注")]
[MaxLength(1000)]
public string Note { get; set; }
[Comment("排序")]
[Required]
public int Sort { get; set; }
[Comment("区域ID")]
[MaxLength(36)]
[Required]
public string AreaCode { get; set; }
[Comment("类型")]
[Required]
public int Type { get; set; }
}
}

View File

@@ -0,0 +1,266 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Application
{
[Table("bs_house_task")]
[Comment("房屋巡查任务表")]
public class BsHouseTask : Core.DEntityBase
{
/// <summary>
/// bs_house_code主键Id
/// </summary>
[Comment("bs_house_code主键Id")]
[MaxLength(36)]
[Required]
public string HouseCodeId { get; set; }
/// <summary>
/// 巡查日期
/// </summary>
[Comment("巡查日期")]
public DateTime? PatrolDate { get; set; }
/// <summary>
/// 巡查人姓名
/// </summary>
[Comment("巡查人姓名")]
[MaxLength(50)]
public string PatrolUser { get; set; }
/// <summary>
/// 沉降倾斜
/// </summary>
[Comment("沉降倾斜")]
[MaxLength(1000)]
public string SettlementTilt { get; set; }
/// <summary>
/// 沉降倾斜附件
/// </summary>
[Comment("沉降倾斜附件")]
[MaxLength(2000)]
public string SettlementTiltFiles { get; set; }
/// <summary>
/// 其他情况
/// </summary>
[Comment("其他情况")]
[MaxLength(1000)]
public string OtherInfo { get; set; }
/// <summary>
/// 其他情况附件
/// </summary>
[Comment("其他情况附件")]
[MaxLength(2000)]
public string OtherInfoFiles { get; set; }
/// <summary>
/// 初始等级
/// </summary>
[Comment("初始等级")]
public int? InitGrade { get; set; }
/// <summary>
/// 损坏等级
/// </summary>
[Comment("损坏等级")]
public int? DamageGrade { get; set; }
/// <summary>
/// 综合等级
/// </summary>
[Comment("综合等级")]
public int? ComprehensiveGrade { get; set; }
/// <summary>
/// 房屋场地
/// </summary>
[Comment("房屋场地")]
[MaxLength(100)]
public string HouseSite { get; set; }
/// <summary>
/// 相邻施工
/// </summary>
[Comment("相邻施工")]
[MaxLength(100)]
public string AdjacentConstruction { get; set; }
/// <summary>
/// 化学侵蚀
/// </summary>
[Comment("化学侵蚀")]
[MaxLength(100)]
public string ChemicalErosion { get; set; }
/// <summary>
/// 结构拆改
/// </summary>
[Comment("结构拆改")]
public int? StructuralDismantling { get; set; }
/// <summary>
/// 加层改造
/// </summary>
[Comment("加层改造")]
public int? AddingLayer { get; set; }
/// <summary>
/// 修缮加固
/// </summary>
[Comment("修缮加固")]
[MaxLength(100)]
public string RepairAndReinforce { get; set; }
/// <summary>
/// 历史灾害
/// </summary>
[Comment("历史灾害")]
[MaxLength(100)]
public string HistoricalCalamity { get; set; }
/// <summary>
/// 使用功能变更
/// </summary>
[Comment("使用功能变更")]
[MaxLength(100)]
public string FunctionalChange { get; set; }
/// <summary>
/// 其他调查内容
/// </summary>
[Comment("其他调查内容")]
[MaxLength(1000)]
public string OtherContents { get; set; }
/// <summary>
/// 主要安全隐患综述
/// </summary>
[Comment("主要安全隐患综述")]
[MaxLength(1000)]
public string MainSafety { get; set; }
/// <summary>
/// 处理意见
/// </summary>
[Comment("处理意见")]
public int? HandlingOpinion { get; set; }
/// <summary>
/// 处理意见备注
/// </summary>
[Comment("处理意见备注")]
[MaxLength(1000)]
public string HandlingOpinionRemark { get; set; }
/// <summary>
/// 整改情况
/// </summary>
[Comment("整改情况")]
public int? RectifyAndReform { get; set; }
/// <summary>
/// 整改情况备注
/// </summary>
[Comment("整改情况备注")]
[MaxLength(1000)]
public string RectifyAndReformRemark { get; set; }
/// <summary>
/// 巡查结果1正常,-1异常
/// </summary>
[Comment("巡查结果1正常,-1异常")]
public int? PatrolResult { get; set; }
/// <summary>
/// 巡查异常描述
/// </summary>
[Comment("巡查异常描述")]
[MaxLength(1000)]
public string PatrolResultRemark { get; set; }
/// <summary>
/// 任务人员ID
/// </summary>
[Comment("任务人员ID")]
[MaxLength(36)]
public string UserID { get; set; }
/// <summary>
/// 任务截止时间
/// </summary>
[Comment("任务截止时间")]
public DateTime? EndTime { get; set; }
/// <summary>
/// 是否过期
/// </summary>
[Comment("是否过期")]
public bool? IsDelay { get; set; }
/// <summary>
/// -1退回0待处理1保存待提交2待审核3审核通过
/// </summary>
[Comment("-1退回0待处理1保存待提交2待审核6审核通过")]
public int Status { get; set; } = 0;
/// <summary>
/// 0建档任务1系统派发的巡查任务2主动巡查任务
/// </summary>
[Comment("0建档任务1系统派发的巡查任务2主动巡查任务")]
public int? TaskType { get; set; }
/// <summary>
/// 上报街道
/// </summary>
[Comment("上报街道")]
public int? ReportRoad { get; set; }
/// <summary>
/// 上报街道时间
/// </summary>
[Comment("上报街道时间")]
public DateTime? ReportRoadTime { get; set; }
/// <summary>
/// 上报区住建
/// </summary>
[Comment("上报区住建")]
public int? ReportArea { get; set; }
/// <summary>
/// 上报区住建时间
/// </summary>
[Comment("上报区住建时间")]
public DateTime? ReportAreaTime { get; set; }
/// <summary>
/// 上报备注
/// </summary>
[Comment("上报备注")]
[MaxLength(1000)]
public string ReportRemark { get; set; }
/// <summary>
/// 提交时间
/// </summary>
[Comment("提交时间")]
public DateTime? SubmitTime { get; set; }
/// <summary>
/// 最后提交时间
/// </summary>
[Comment("最后提交时间")]
public DateTime? LastSubmitTime { get; set; }
/// <summary>
/// 是否有效
/// </summary>
[Comment("是否有效")]
public bool IsEnabled { get; set; } = true;
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Ewide.Application
{
[Table("bs_house_task_check_record")]
[Comment("房屋任务审核记录表")]
public class BsHouseTaskCheckRecord : Core.DEntityBase
{
/// <summary>
/// 任务Id
/// </summary>
[Comment("任务Id")]
[MaxLength(36)]
public string TaskId { get; set; }
/// <summary>
/// 通过1退回-1
/// </summary>
[Comment("通过3退回-1")]
public int PassOrBack { get; set; }
/// <summary>
/// 审核内容
/// </summary>
[Comment("审核内容")]
[MaxLength(500)]
public string Content { get; set; }
}
}

View File

@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Application
{
[Table("bs_house_task_options")]
[Comment("房屋巡查任务选项表")]
public class BsHouseTaskOptions : Core.DEntityBase
{
/// <summary>
/// bs_house_code主键Id
/// </summary>
[Comment("bs_house_code主键Id")]
[MaxLength(36)]
[Required]
public string TaskId { get; set; }
/// <summary>
/// 字典类型
/// </summary>
[Comment("字典类型")]
[MaxLength(50)]
public string DictType { get; set; }
/// <summary>
/// 字典code
/// </summary>
[Comment("字典code")]
[MaxLength(50)]
public string DictCode { get; set; }
/// <summary>
/// 字典值
/// </summary>
[Comment("字典值")]
[MaxLength(100)]
public string DictValue { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
[MaxLength(500)]
public string Remark { get; set; }
/// <summary>
/// 附件
/// </summary>
[Comment("附件")]
[MaxLength(2000)]
public string File { get; set; }
/// <summary>
/// 是否选中
/// </summary>
[Comment("是否选中")]
public bool? Checked { get; set; }
}
}

View File

@@ -0,0 +1 @@
/** 您的业务实体文件写在此文件夹下面 **/

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public enum DataStatus
{
/// <summary>
/// 审核退回
/// </summary>
[Description("审核退回")]
Back = -1,
/// <summary>
/// 初始未处理
/// </summary>
[Description("初始未处理")]
Init = 0,
/// <summary>
/// 暂存
/// </summary>
[Description("暂存")]
TempSaved = 1,
/// <summary>
/// 已保存,待提交
/// </summary>
[Description("已保存,待提交")]
Saved = 2,
/// <summary>
/// 已提交,待审核
/// </summary>
[Description("已提交,待审核")]
Submited = 3,
/// <summary>
/// 审核通过
/// </summary>
[Description("审核通过")]
Passed = 6
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public enum HouseLogType
{
[Description("创建房屋编码")]
CreateCode = 1,
[Description("人员选房")]
SelectMember = 2,
[Description("房屋建档")]
CreateInfo = 3,
[Description("审核")]
Check = 4,
[Description("审核通过")]
Agree = 5,
[Description("审核退回")]
Disagree = 6
}
public enum HouseLogStatus
{
[Description("待处理")]
Handle = 0,
[Description("正在处理")]
Handling = 1,
[Description("已处理")]
Handled = 2,
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public enum HouseManagerRole
{
/// <summary>
/// 市住建部门
/// </summary>
CityManager,
/// <summary>
/// 区住建部门
/// </summary>
AreaManager,
/// <summary>
/// 街道管理员
/// </summary>
RoadManager,
/// <summary>
/// 片区监管员
/// </summary>
ZoneManager,
/// <summary>
/// 房屋安全管理员
/// </summary>
HouseSecurityManager
}
}

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>1701;1702;1591</NoWarn>
<DocumentationFile>Ewide.Application.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="applicationsettings.json" />
<None Remove="Ewide.Application.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="applicationsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ewide.Core\Ewide.Core.csproj" />
<ProjectReference Include="..\Ewide.EntityFramework.Core\Ewide.EntityFramework.Core.csproj" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
1、原则上服务应该放在Application层次考虑将咱自己的业务层直接写在Application里面好些后续升级后咱大家直接升级就行了减少冲突
2、系统默认ORM为EF Core如果觉得不趁手可以自行更换
3、在此应用层默认集成了SqlSugar,其他ORM类同可以多个ORM并行开发熟悉哪个用哪个

View File

@@ -0,0 +1,65 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseCodeInput
{
}
public class AddHouseCodeInput : PageInputBase
{
public string HouseCode { get; set; }
[Required(ErrorMessage = "行政区域编码不能为空")]
public string AreaCode { get; set; }
[Required(ErrorMessage = "项目Id不能为空")]
public string ProjectId { get; set; }
[Required(ErrorMessage = "房屋编号不能为空")]
public int No { get; set; }
[Required(ErrorMessage = "片区Id不能为空")]
public string ZoneId { get; set; }
[Required(ErrorMessage = "房屋地址不能为空")]
public string Address { get; set; }
[Required(ErrorMessage = "房屋性质不能为空")]
public int Type { get; set; }
[Required(ErrorMessage = "所属行业不能为空")]
public int Industry { get; set; }
[Required(ErrorMessage = "经度不能为空")]
public string Lng { get; set; }
[Required(ErrorMessage = "纬度不能为空")]
public string Lat { get; set; }
}
public class EditHouseCodeInput : AddHouseCodeInput
{
[Required(ErrorMessage = "房屋编码Id不能为空")]
public string Id { get; set; }
}
public class DeleteHouseCodeInput
{
[Required(ErrorMessage = "房屋编码ID不可为空")]
public string Id { get; set; }
}
public class QueryHouseCodeInput : PageInputBase
{
public string HouseCode { get; set; }
public int? No { get; set; }
public string Address { get; set; }
public string ProjectId { get; set; }
public string ZoonId { get; set; }
public int Type { get; set; }
}
public class GetHouseCodeInput
{
[Required(ErrorMessage = "房屋编码ID不可为空")]
public string Id { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseCodeOutput
{
public string Id { get; set; }
public string Address { get; set; }
public string ProjectId { get; set; }
public string ZoneId { get; set; }
public int Type { get; set; }
public string AreaName { get; set; }
public string RoadName { get; set; }
public string CommName { get; set; }
public string ZoneName { get; set; }
public string ProjectNote { get; set; }
public string FullProjName { get; set; }
public string HouseCode { get; set; }
public int No { get; set; }
public string Lng { get; set; }
public string Lat { get; set; }
}
public class GetHouseCodeOutput
{
public string Id { get; set; }
public string HouseCode { get; set; }
public int Type { get; set; }
public int Industry { get; set; }
public string AreaCode { get; set; }
public string ProjectId { get; set; }
public int No { get; set; }
public string ZoneId { get; set; }
public string Address { get; set; }
public string Lng { get; set; }
public string Lat { get; set; }
}
}

View File

@@ -0,0 +1,123 @@
using Ewide.Application.Entity;
using Ewide.Core;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
using Dapper;
using Ewide.Core.Extension;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Collections.Generic;
namespace Ewide.Application.Service.HouseCode
{
/// <summary>
/// 房屋编码相关
/// </summary>
[ApiDescriptionSettings(Name = "HouseCode", Order = 180)]
public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseCode> _houseCodeRep;
private readonly IDapperRepository _dapperRepository;
private readonly IUserManager _userManager;
private readonly IHouseLogService _houseLogService;
public HouseCodeService(IRepository<BsHouseCode> HouseCodeRep, IDapperRepository dapperRepository, IUserManager userManager, IHouseLogService houseLogService)
{
_houseCodeRep = HouseCodeRep;
_dapperRepository = dapperRepository;
_userManager = userManager;
_houseLogService = houseLogService;
}
[HttpPost("/houseCode/add")]
[UnitOfWork]
public async Task AddHouseCode(AddHouseCodeInput input)
{
var houseProjectInfoRep = Db.GetRepository<BsHouseProjectInfo>();
var houseProject = await houseProjectInfoRep.FirstOrDefaultAsync(p => p.Id == input.ProjectId);
if (houseProject == null) throw Oops.Oh("项目参数有误,添加失败");
var areaCodeRep = Db.GetRepository<SysAreaCode>();
var areaCode = await areaCodeRep.DetachedEntities.FirstOrDefaultAsync(a => a.Code == input.AreaCode && a.LevelType == 4);
if(areaCode == null) throw Oops.Oh("区域编码有误,添加失败");
input.HouseCode = areaCode.AdCode + houseProject.Sort.ToString().PadLeft(3, '0') + input.No.ToString().PadLeft(3, '0');
var id = System.Guid.NewGuid().ToString().ToLower();
var houseCode = input.Adapt<BsHouseCode>();
houseCode.Id = id;
var isExist = await _houseCodeRep.AnyAsync(p => p.HouseCode == houseCode.HouseCode);
if (isExist) throw Oops.Oh("房屋编码已存在,不可重复添加");
await houseCode.InsertAsync();
// 添加到流转日志
var sort = await _houseLogService.AddThenDone(id, _userManager.User, HouseLogType.CreateCode);
sort = await _houseLogService.Add(id, _userManager.User, HouseLogType.SelectMember, sort: sort);
}
[HttpPost("/houseCode/edit")]
public async Task EditHouseCode(EditHouseCodeInput input)
{
var houseCode = input.Adapt<BsHouseCode>();
await houseCode.UpdateExcludeAsync(new[] { nameof(BsHouseCode.HouseCode) }, true);
}
[HttpPost("/houseCode/delete")]
public async Task DeleteHouseCode(DeleteHouseCodeInput input)
{
var houseCode = _houseCodeRep.FirstOrDefault(p => p.Id == input.Id);
await houseCode.DeleteNowAsync();
}
[HttpPost("/houseCode/page")]
public async Task<dynamic> QueryPage([FromBody] QueryHouseCodeInput input)
{
var sql = @"SELECT
HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,CONCAT(Proj.`Name`, IFNULL(CONCAT('(',Proj.Note,')'), '')) FullProjName
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6) ";
return await _dapperRepository.QueryPageDataDynamic(sql, input, filterFields: new string[] {"Type", "Address", "HouseCode","AreaCode"});
}
[HttpGet("/houseCode/detail")]
public async Task<dynamic> GetHouserCode([FromQuery] GetHouseCodeInput input)
{
var houseCode = await _houseCodeRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
var areaCode = (await Db.GetRepository<BsHouseProjectInfo>().DetachedEntities.FirstOrDefaultAsync(p => p.Id == houseCode.ProjectId)).AreaCode;
var result = houseCode.Adapt<GetHouseCodeOutput>();
result.AreaCode = areaCode;
return result;
}
/// <summary>
/// 获取同一区域下的下一个编号
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
[HttpGet("/houseCode/getNextNoByCode")]
public async Task<dynamic> GetNextNoByFullNumber([Required] string projectId)
{
var areaCodeRep = Db.GetRepository<SysAreaCode>();
var houseProjectInfoRep = Db.GetRepository<BsHouseProjectInfo>();
var houseProject = await houseProjectInfoRep.FirstOrDefaultAsync(p => p.Id == projectId);
if(houseProject == null) throw Oops.Oh("项目参数有误,房屋编码生成失败");
//取到社区编码
var commAreaCode = await areaCodeRep.FirstOrDefaultAsync(a => a.Code == houseProject.AreaCode && a.LevelType == 4);
if(commAreaCode == null) throw Oops.Oh("项目区域编码有误,房屋编码生成失败");
var maxNo = await _houseCodeRep.DetachedEntities
.Where(h => h.HouseCode.Contains(commAreaCode.AdCode + houseProject.Sort.ToString().PadLeft(3, '0')))
.MaxAsync(h => (int?)h.No);
return maxNo.GetValueOrDefault(0) + 1;
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseCode
{
public interface IHouseCodeService
{
Task AddHouseCode(AddHouseCodeInput input);
}
}

View File

@@ -0,0 +1,61 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseCompanyInput
{
[Required(ErrorMessage = "Id不能为空")]
public string Id { get; set; }
}
public class HouseCompanyInfoInput
{
[Required(ErrorMessage = "信息名称不能为空")]
public string Name { get; set; }
[Required(ErrorMessage = "信息内容不能为空")]
public string Value { get; set; }
}
public class HouseCompanyPageInput : PageInputBase {}
public class HouseCompanyAddInput
{
[Required(ErrorMessage = "名称不能为空")]
public virtual string Name { get; set; }
private string _Type { get; set; }
[Required(ErrorMessage = "类型不能为空")]
public virtual string Type
{
get
{
return _Type;
}
set
{
_Type = String.Join(",", value.Split(',').Select(p => $"[{p}]"));
}
}
public virtual List<HouseCompanyInfoInput> Info { get; set; }
}
public class HouseCompanyEditInput : HouseCompanyAddInput
{
[Required(ErrorMessage = "Id不能为空")]
public string Id { get; set; }
}
public class HouseCompanyListInput
{
[Required(ErrorMessage = "类型不能为空")]
public string Type { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseCompanyInfoOutput
{
public string Name { get; set; }
public string Value { get; set; }
}
public class HouseCompanyDetailOutput
{
public string Id { get; set; }
public string Name { get; set; }
private string _Type { get; set; }
public string Type
{
get
{
return _Type;
}
set
{
_Type = String.Join(",", value.Split(',').Select(p => p.Replace("[", "").Replace("]", "")));
}
}
public List<HouseCompanyInfoOutput> Info { get; set; }
}
}

View File

@@ -0,0 +1,101 @@
using Ewide.Core.Extension;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
[ApiDescriptionSettings(Name = "HouseCompany")]
public class HouseCompanyService : IHouseCompanyService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseCompany> _bsHouseCompanyRep;
public HouseCompanyService(IRepository<BsHouseCompany> bsHouseCompanyRep)
{
_bsHouseCompanyRep = bsHouseCompanyRep;
}
[HttpPost("/houseCompany/page")]
public async Task<dynamic> Page([FromBody] HouseCompanyPageInput input)
{
var config = new TypeAdapterConfig().ForType<BsHouseCompany, HouseCompanyDetailOutput>()
.Map(target => target.Info, src => JsonConvert.DeserializeObject<List<HouseCompanyInfoOutput>>(src.Info))
.Config;
return await _bsHouseCompanyRep.DetachedEntities.ToPageData<BsHouseCompany, HouseCompanyDetailOutput>(input, config);
}
[HttpPost("/houseCompany/add")]
public async Task Add([FromBody] HouseCompanyAddInput input)
{
var info = JsonConvert.SerializeObject(input.Info);
var config = new TypeAdapterConfig().ForType<HouseCompanyAddInput, BsHouseCompany>()
.Map(target => target.Info, src => JsonConvert.SerializeObject(src.Info))
.Config;
var company = input.Adapt<BsHouseCompany>(config);
await company.InsertAsync();
}
[HttpPost("/houseCompany/edit")]
public async Task Edit([FromBody] HouseCompanyEditInput input)
{
var config = new TypeAdapterConfig().ForType<HouseCompanyEditInput, BsHouseCompany>()
.Map(target => target.Info, src => JsonConvert.SerializeObject(src.Info))
.Config;
var company = input.Adapt<BsHouseCompany>(config);
await company.UpdateAsync();
}
[HttpPost("/houseCompany/delete")]
public async Task Delete([FromBody] HouseCompanyInput input)
{
var company = await _bsHouseCompanyRep.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
await company.DeleteAsync();
}
[HttpGet("/houseCompany/detail")]
public async Task<HouseCompanyDetailOutput> Detail([FromQuery] HouseCompanyInput input)
{
var company = await _bsHouseCompanyRep.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
var config = new TypeAdapterConfig().ForType<BsHouseCompany, HouseCompanyDetailOutput>()
.Map(target => target.Info, src => JsonConvert.DeserializeObject<List<HouseCompanyInfoOutput>>(src.Info))
.Config;
var output = company.Adapt<HouseCompanyDetailOutput>(config);
return output;
}
[HttpGet("/houseCompany/list")]
public async Task<dynamic> List([FromQuery] HouseCompanyListInput input)
{
var types = input.Type.Split(',');
var result = new List<HouseCompanyDetailOutput>();
var config = new TypeAdapterConfig().ForType<BsHouseCompany, HouseCompanyDetailOutput>()
.Map(target => target.Info, src => JsonConvert.DeserializeObject<List<HouseCompanyInfoOutput>>(src.Info))
.Config;
foreach (var type in types)
{
var list = (await _bsHouseCompanyRep.DetachedEntities
.Where(p => EF.Functions.Like(p.Type, $"%[{type.Trim()}]%"))
.OrderBy(p => p.Name)
.ToListAsync())
.Select(p =>
{
var output = p.Adapt<HouseCompanyDetailOutput>(config);
return output;
});
result.AddRange(list);
}
return result.Distinct();
}
}
}

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseCompanyService
{
Task<dynamic> Page([FromBody] HouseCompanyPageInput input);
Task Add([FromBody] HouseCompanyAddInput input);
Task Edit([FromBody] HouseCompanyEditInput input);
Task Delete([FromBody] HouseCompanyInput input);
Task<HouseCompanyDetailOutput> Detail([FromQuery] HouseCompanyInput input);
Task<dynamic> List([FromQuery] HouseCompanyListInput input);
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseInfoInput
{
#region building
public string BuildingName { get; set; }
public int? LandAttribute { get; set; }
public int? StructureType { get; set; }
public int? SeismicGrade { get; set; }
public int? BaseInfo { get; set; }
public string InsulationMaterial { get; set; }
public string WallMaterial { get; set; }
public string FireproofGrade { get; set; }
public int? CurtainWall { get; set; }
public int? FaceBrick { get; set; }
public int? WhiteWash { get; set; }
public int? Coating { get; set; }
public string Elevator { get; set; }
public DateTime? CompletedDate { get; set; }
public int? UsefulYear { get; set; }
/// <summary>
/// 总建筑面积
/// </summary>
public float? TotalArea { get; set; }
/// <summary>
/// 总户数(户)
/// </summary>
public int? HouseHolds { get; set; }
/// <summary>
/// 房屋单元数
/// </summary>
public int? Units { get; set; }
/// <summary>
/// 各单元每层户数(户)
/// </summary>
public int? UnitFloorHolds { get; set; }
/// <summary>
/// 总层数
/// </summary>
public int? TotalFloor { get; set; }
/// <summary>
/// 地上层数
/// </summary>
public int? LandFloorCount { get; set; }
/// <summary>
/// 地上商业层数开始
/// </summary>
public int? LandBsFloorStart { get; set; }
/// <summary>
/// 地上商业层数结束
/// </summary>
public int? LandBsFloorEnd { get; set; }
/// <summary>
/// 地上车棚层开始
/// </summary>
public int? LandBikeFloorStart { get; set; }
/// <summary>
/// 地上住宅层开始
/// </summary>
public int? LandResidenceFloorStart { get; set; }
/// <summary>
/// 地上住宅层结束
/// </summary>
public int? LandResidenceFloorEnd { get; set; }
/// <summary>
/// 地下层数
/// </summary>
public int? UnderFloorCount { get; set; }
#endregion
#region ownership
/// <summary>
/// 产权性质
/// </summary>
public string PropertyRights { get; set; }
/// <summary>
/// 总共套数
/// </summary>
public int? HouseCount { get; set; }
/// <summary>
/// 直管公房套数
/// </summary>
public int? StraightHouseCount { get; set; }
/// <summary>
/// 自管公房套数
/// </summary>
public int? SelfHouseCount { get; set; }
/// <summary>
/// 私房套数
/// </summary>
public int? PrivateHouseCount { get; set; }
/// <summary>
/// 商品房套数
/// </summary>
public int? BusinessCount { get; set; }
/// <summary>
/// 房改房套数
/// </summary>
public int? ChangeHouseCount { get; set; }
/// <summary>
/// 拆迁安置房套数
/// </summary>
public int? ResettlementHouseCount { get; set; }
/// <summary>
/// 其它套数
/// </summary>
public int? OtherCount { get; set; }
#endregion
#region manager
#endregion
#region identification
/// <summary>
/// 房屋等级 1,2,3,4,C,d
/// </summary>
public int? HouseGrade { get; set; }
/// <summary>
/// 房屋使用状态
/// </summary>
public int? HouseUsedStatus { get; set; }
#endregion
#region drawing
/// <summary>
/// 图纸资料存档处
/// </summary>
public string DrawingMaterial { get; set; }
/// <summary>
/// 其他图纸存档
/// </summary>
public string DrawingMaterialText { get; set; }
#endregion
#region attachments
/// <summary>
/// 立项文件
/// </summary>
public string AnEntryDocument { get; set; }
/// <summary>
/// 规划许可
/// </summary>
public string PlanningPermission { get; set; }
/// <summary>
/// 竣工验收备案
/// </summary>
public string CompletionRecord { get; set; }
/// <summary>
/// 监理资料
/// </summary>
public string MonitorDocument { get; set; }
/// <summary>
/// 鉴定报告
/// </summary>
public string IdentificationReport { get; set; }
/// <summary>
/// 其它资料
/// </summary>
public string OtherDocument { get; set; }
#endregion
#region aspect
/// <summary>
/// 外立面照片
/// </summary>
public string FacadePhoto { get; set; }
#endregion
#region unit
/// <summary>
/// 调查登记机构
/// </summary>
public string InvestigateAgency { get; set; }
/// <summary>
/// 纸质资料调查人
/// </summary>
public string InvestigateUser { get; set; }
/// <summary>
/// 纸质资料审核人
/// </summary>
public string OfflineAuditor { get; set; }
/// <summary>
/// 主管部门
/// </summary>
public string CompetentDepartment { get; set; }
#endregion
public int State { get; set; }
}
public class HouseInfoInputSave
{
public HouseCodeOutput houseCode { get; set; }
public HouseInfoInput houseInfo { get; set; }
public EditHouseTaskInput PatrolInfo { get; set; }
public HouseTaskCheckRecordInput TaskCheckRecord { get; set; }
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseInfoOutput
{
#region building
public string BuildingName { get; set; }
public int? LandAttribute { get; set; }
public int? StructureType { get; set; }
public int? SeismicGrade { get; set; }
public int? BaseInfo { get; set; }
public string InsulationMaterial { get; set; }
public string WallMaterial { get; set; }
public string FireproofGrade { get; set; }
public int? CurtainWall { get; set; }
public int? FaceBrick { get; set; }
public int? WhiteWash { get; set; }
public int? Coating { get; set; }
public string Elevator { get; set; }
public DateTime? CompletedDate { get; set; }
public int? UsefulYear { get; set; }
/// <summary>
/// 总建筑面积
/// </summary>
public float? TotalArea { get; set; }
/// <summary>
/// 总户数(户)
/// </summary>
public int? HouseHolds { get; set; }
/// <summary>
/// 房屋单元数
/// </summary>
public int? Units { get; set; }
/// <summary>
/// 各单元每层户数(户)
/// </summary>
public int? UnitFloorHolds { get; set; }
/// <summary>
/// 总层数
/// </summary>
public int? TotalFloor { get; set; }
/// <summary>
/// 地上层数
/// </summary>
public int? LandFloorCount { get; set; }
/// <summary>
/// 地上商业层数开始
/// </summary>
public int? LandBsFloorStart { get; set; }
/// <summary>
/// 地上商业层数结束
/// </summary>
public int? LandBsFloorEnd { get; set; }
/// <summary>
/// 地上车棚层开始
/// </summary>
public int? LandBikeFloorStart { get; set; }
/// <summary>
/// 地上住宅层开始
/// </summary>
public int? LandResidenceFloorStart { get; set; }
/// <summary>
/// 地上住宅层结束
/// </summary>
public int? LandResidenceFloorEnd { get; set; }
/// <summary>
/// 地下层数
/// </summary>
public int? UnderFloorCount { get; set; }
#endregion
#region ownership
/// <summary>
/// 产权性质
/// </summary>
public string PropertyRights { get; set; }
/// <summary>
/// 总共套数
/// </summary>
public int? HouseCount { get; set; }
/// <summary>
/// 直管公房套数
/// </summary>
public int? StraightHouseCount { get; set; }
/// <summary>
/// 自管公房套数
/// </summary>
public int? SelfHouseCount { get; set; }
/// <summary>
/// 私房套数
/// </summary>
public int? PrivateHouseCount { get; set; }
/// <summary>
/// 商品房套数
/// </summary>
public int? BusinessCount { get; set; }
/// <summary>
/// 房改房套数
/// </summary>
public int? ChangeHouseCount { get; set; }
/// <summary>
/// 拆迁安置房套数
/// </summary>
public int? ResettlementHouseCount { get; set; }
/// <summary>
/// 其它套数
/// </summary>
public int? OtherCount { get; set; }
#endregion
#region manager
#endregion
#region identification
/// <summary>
/// 房屋等级 1,2,3,4,C,d
/// </summary>
public int? HouseGrade { get; set; }
/// <summary>
/// 房屋使用状态
/// </summary>
public int? HouseUsedStatus { get; set; }
#endregion
#region drawing
/// <summary>
/// 图纸资料存档处
/// </summary>
public string DrawingMaterial { get; set; }
/// <summary>
/// 其他图纸存档
/// </summary>
public string DrawingMaterialText { get; set; }
#endregion
#region attachments
/// <summary>
/// 立项文件
/// </summary>
public string AnEntryDocument { get; set; }
/// <summary>
/// 规划许可
/// </summary>
public string PlanningPermission { get; set; }
/// <summary>
/// 竣工验收备案
/// </summary>
public string CompletionRecord { get; set; }
/// <summary>
/// 监理资料
/// </summary>
public string MonitorDocument { get; set; }
/// <summary>
/// 鉴定报告
/// </summary>
public string IdentificationReport { get; set; }
/// <summary>
/// 其它资料
/// </summary>
public string OtherDocument { get; set; }
#endregion
#region aspect
/// <summary>
/// 外立面照片
/// </summary>
public string FacadePhoto { get; set; }
#endregion
public int State { get; set; }
#region unit
/// <summary>
/// 调查登记机构
/// </summary>
public string InvestigateAgency { get; set; }
/// <summary>
/// 纸质资料调查人
/// </summary>
public string InvestigateUser { get; set; }
/// <summary>
/// 纸质资料审核人
/// </summary>
public string OfflineAuditor { get; set; }
/// <summary>
/// 主管部门
/// </summary>
public string CompetentDepartment { get; set; }
#endregion
}
public class HouseInfoOutputForDetailPage
{
#region header
public HouseCodeOutput HouseCode { get; set; }
#endregion
public HouseInfoOutput HouseInfo { get; set; }
public HouseTaskOutput PatrolInfo { get; set; }
}
}

View File

@@ -0,0 +1,208 @@
using Dapper;
using Ewide.Core;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseSafety.HouseInfo
{
/// <summary>
/// 房屋详细信息
/// </summary>
[ApiDescriptionSettings(Name = "HouseInfo", Order = 200)]
public class HouseInfoService : IHouseInfoService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseCode> _houseCodeRep;
private readonly IRepository<BsHouseInfo> _houseInfoRep;
private readonly IRepository<BsHouseTask> _houseTaskRep;
private readonly IRepository<SysUser> _sysUserRep;
private readonly IUserManager _userManager;
private readonly IDapperRepository _dapperRepository;
private readonly IHouseLogService _houseLogService;
public HouseInfoService(
IRepository<BsHouseCode> HouseCodeRep,
IRepository<BsHouseInfo> HouseInfoRep,
IRepository<BsHouseTask> HouseTaskRep,
IRepository<SysUser> sysUserRep,
IUserManager userManager, IDapperRepository dapperRepository, IHouseLogService houseLogService)
{
_houseCodeRep = HouseCodeRep;
_houseInfoRep = HouseInfoRep;
_houseTaskRep = HouseTaskRep;
_sysUserRep = sysUserRep;
_userManager = userManager;
_dapperRepository = dapperRepository;
_houseLogService = houseLogService;
}
[HttpPost("/houseInfo/save")]
[UnitOfWork]
[AllowAnonymous]
public async Task Save([FromBody] HouseInfoInputSave input)
{
await InputDataProcess(input, DataStatus.Saved);
}
[HttpPost("/houseInfo/submitToCheck")]
[UnitOfWork]
[AllowAnonymous]
public async Task SubmitToCheck([FromBody] HouseInfoInputSave input)
{
await InputDataProcess(input,DataStatus.Submited);
}
[HttpPost("/houseInfo/check")]
[UnitOfWork]
public async Task Check([FromBody] HouseInfoInputSave input)
{
await InputDataProcess(input, input.TaskCheckRecord.PassOrBackDataStatus );
}
[HttpGet("/houseInfo/getByTaskId")]
[UnitOfWork]
public async Task<HouseInfoOutputForDetailPage> GetByTaskId([Required] string taskId)
{
//获取任务实体
var houseTask = await _houseTaskRep.DetachedEntities.FirstOrDefaultAsync(t=>t.Id == taskId);
if(houseTask == null) throw Oops.Oh("任务不存在");
//获取房屋编码信息
var houseCodeOutputAsync = await _dapperRepository.QueryAsync<HouseCodeOutput>(
@"SELECT
HC.Id,HC.Address,HC.ProjectId,HC.ZoneId,HC.Type,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,O.Name ZoneName,Proj.Note ProjectNote,CONCAT(Proj.`Name`, IFNULL(CONCAT('(',Proj.Note,')'), '')) FullProjName,HC.HouseCode,HC.Lng,HC.Lat,HC.No
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_org O ON HC.ZoneId = O.Id
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
WHERE HC.Id=@HouseCodeId", new { houseTask.HouseCodeId }
);
var houseCodeOutput= houseCodeOutputAsync.SingleOrDefault();
if (houseCodeOutput == null) throw Oops.Oh("任务已失效:房屋编码不存在,请重新加载任务列表");
//获取当前登录账号
var currentUser = await _userManager.CheckUserAsync();
//查询房屋详细信息是否存在
var houseInfo = await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(h => h.HouseCodeId == houseTask.HouseCodeId);
var houseInfoOutputForDetailPage = new HouseInfoOutputForDetailPage
{
HouseCode = houseCodeOutput
};
var taskOutput = houseTask.Adapt<HouseTaskOutput>();
taskOutput.PatrolDate = houseTask.PatrolDate.GetValueOrDefault(DateTime.Now);
taskOutput.PatrolUser = String.IsNullOrEmpty(houseTask.PatrolUser) ? currentUser.Name : houseTask.PatrolUser;
houseInfoOutputForDetailPage.PatrolInfo = taskOutput;
if (houseInfo == null || houseInfo.State <= (int)DataStatus.Submited)
{
// 未建档或者当前数据未提交时打开,标记为已读
await _houseLogService.Read(houseCodeOutput.Id);
}
if (houseInfo == null)
{
houseInfoOutputForDetailPage.HouseInfo = new HouseInfoOutput();
return houseInfoOutputForDetailPage;
}
var houseInfoOutput = (await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.HouseCodeId == houseTask.HouseCodeId)).Adapt<HouseInfoOutput>();
houseInfoOutputForDetailPage.HouseInfo = houseInfoOutput;
return houseInfoOutputForDetailPage;
}
[NonAction]
[UnitOfWork]
public async Task InputDataProcess(HouseInfoInputSave input,DataStatus dataStatus = DataStatus.Init)
{
//房屋编码地址/坐标单独更新
var houseCode = input.houseCode.Adapt<BsHouseCode>();
await houseCode.UpdateIncludeAsync(new[] { nameof(BsHouseCode.Address), nameof(BsHouseCode.Lng), nameof(BsHouseCode.Lat) }, true);
//获取房屋详情实体,判断是新增还是更新
var houseEntity = await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(h => h.HouseCodeId == input.houseCode.Id);
//建档审核通过的房屋数据修改时对应的建档任务Task不处理
var houseTask = await _houseTaskRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.PatrolInfo.Id);
if (houseEntity == null || houseEntity.State != 6)
{
var _houseTask = input.PatrolInfo.Adapt<BsHouseTask>();
_houseTask.HouseCodeId = input.houseCode.Id;
//任务没有暂存状态其他状态与HouseInfo的State一致
_houseTask.Status = dataStatus == DataStatus.TempSaved ? (int)DataStatus.Saved : (int)dataStatus;
await _houseTask.UpdateExcludeAsync(new string[] { nameof(BsHouseTask.TaskType) }, ignoreNullValues: true);
}
//判断房屋建档状态
//dataStatus == DataStatus.Saved 若是保存操作 则判断是新增/更新
//判断是新增/更新 根据传入参数dataStatus确定
input.houseInfo.State = dataStatus == DataStatus.Saved ? (houseEntity == null ? (int)DataStatus.Saved : houseEntity.State) : (int)dataStatus;
var houseInfo = input.houseInfo.Adapt<BsHouseInfo>();
houseInfo.HouseCodeId = input.houseCode.Id;
if (houseEntity == null)
{
houseInfo.Id = Guid.NewGuid().ToString();
await houseInfo.InsertAsync();
}
else
{
houseInfo.Id = houseEntity.Id;
await houseInfo.UpdateExcludeAsync(new[] { nameof(BsHouseInfo.HouseGrade) }, true);
}
int? logSort = null;
if (dataStatus == DataStatus.Submited)
{
await _houseLogService.Done(input.houseCode.Id);
var org = await _userManager.GetUserOrgInfo();
var _sysEmpRep = Db.GetRepository<SysEmp>();
var _sysUserRoleRep = Db.GetRepository<SysUserRole>();
var _sysRoleRep = Db.GetRepository<SysRole>();
var zoneManagerList = await (from u in _sysUserRep.DetachedEntities
join e in _sysEmpRep.DetachedEntities on u.Id equals e.Id
join ur in _sysUserRoleRep.DetachedEntities on u.Id equals ur.SysUserId
join r in _sysRoleRep.DetachedEntities on ur.SysRoleId equals r.Id
where e.OrgId == org.Id && r.Code == Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase()
select u).ToListAsync();
logSort = await _houseLogService.Add(input.houseCode.Id, zoneManagerList, HouseLogType.Check);
}
//审核操作则新增一条审核记录
if (dataStatus == DataStatus.Back || dataStatus == DataStatus.Passed)
{
var checkRecord = input.TaskCheckRecord.Adapt<BsHouseTaskCheckRecord>();
await checkRecord.InsertAsync();
await _houseLogService.Done(input.houseCode.Id);
logSort = await _houseLogService.AddThenDone(input.houseCode.Id, _userManager.User, dataStatus == DataStatus.Passed ? HouseLogType.Agree : HouseLogType.Disagree, remark: checkRecord.Content, sort: logSort);
if (dataStatus == DataStatus.Back)
{
var user = await _sysUserRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(houseTask.UserID));
logSort = await _houseLogService.Add(input.houseCode.Id, user, HouseLogType.CreateInfo, sort: logSort);
}
}
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseInfoService
{
Task<HouseInfoOutputForDetailPage> GetByTaskId(string taskId);
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseLogInput
{
[Required(ErrorMessage = "Id不能为空")]
public string Id { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseLogOutput
{
public string Id { get; set; }
public string TargetUserNames { get; set; }
public int Type { get; set; }
public int Status { get; set; }
public string Remark { get; set; }
public DateTime? FinishedTime { get; set; }
public string FinishedUserId { get; set; }
public string FinishedUserName { get; set; }
}
}

View File

@@ -0,0 +1,209 @@
using Dapper;
using Ewide.Core;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
/// <summary>
/// 房屋流转日志
/// </summary>
[ApiDescriptionSettings(Name = "HouseLog", Order = 210)]
public class HouseLogService : IHouseLogService, IDynamicApiController, ITransient
{
private readonly IDapperRepository _dapperRep;
private readonly IUserManager _userManager;
private readonly IRepository<BsHouseLog> _bsHouseLogRep;
public HouseLogService(IDapperRepository dapperRep, IUserManager userManager, IRepository<BsHouseLog> bsHouseLogRep)
{
_dapperRep = dapperRep;
_userManager = userManager;
_bsHouseLogRep = bsHouseLogRep;
}
[NonAction]
[UnitOfWork]
public async Task<int> Add(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null)
{
return await Add(houseCodeId, new List<SysUser> { targetUser }, type, remark, sort);
}
[NonAction]
[UnitOfWork]
public async Task<int> Add(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null)
{
if (!sort.HasValue)
{
sort = await _bsHouseLogRep.DetachedEntities.Where(p => p.HouseCodeId.Equals(houseCodeId)).MaxAsync(p => p.Sort);
}
var _sort = sort.GetValueOrDefault(1) + 1;
await new BsHouseLog
{
Id = Guid.NewGuid().ToString(),
HouseCodeId = houseCodeId,
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
Type = type,
Status = HouseLogStatus.Handle,
Remark = remark,
Sort = _sort
}.InsertAsync();
return _sort;
}
[NonAction]
[UnitOfWork]
public async Task Read(string houseCodeId)
{
var log = await _bsHouseLogRep
.Where(p => p.HouseCodeId.Equals(houseCodeId) && p.Status.Equals(HouseLogStatus.Handle))
.OrderByDescending(p => p.CreatedTime)
.FirstOrDefaultAsync();
if (log != null)
{
log.Status = HouseLogStatus.Handling;
await log.UpdateAsync();
}
}
[NonAction]
[UnitOfWork]
public async Task Done(string houseCodeId)
{
var log = await _bsHouseLogRep
.Where(p => p.HouseCodeId.Equals(houseCodeId) && !p.Status.Equals(HouseLogStatus.Handled))
.OrderByDescending(p => p.CreatedTime)
.FirstOrDefaultAsync();
if (log != null)
{
log.Status = HouseLogStatus.Handled;
log.FinishedTime = DateTime.Now;
log.FinishedUserId = _userManager.UserId;
log.FinishedUserName = _userManager.User.Account;
await log.UpdateAsync();
}
}
[NonAction]
[UnitOfWork]
public async Task<int> AddThenRead(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null)
{
return await AddThenRead(houseCodeId, new List<SysUser> { targetUser }, type, remark, sort);
}
[NonAction]
[UnitOfWork]
public async Task<int> AddThenRead(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null)
{
if (!sort.HasValue)
{
sort = await _bsHouseLogRep.DetachedEntities.Where(p => p.HouseCodeId.Equals(houseCodeId)).MaxAsync(p => p.Sort);
}
var _sort = sort.GetValueOrDefault(1) + 1;
await new BsHouseLog
{
Id = Guid.NewGuid().ToString(),
HouseCodeId = houseCodeId,
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
Type = type,
Status = HouseLogStatus.Handling,
Remark = remark,
Sort = _sort
}.InsertAsync();
return _sort;
}
[NonAction]
[UnitOfWork]
public async Task<int> AddThenDone(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null)
{
return await AddThenDone(houseCodeId, new List<SysUser> { targetUser }, type, remark, sort);
}
[NonAction]
[UnitOfWork]
public async Task<int> AddThenDone(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null)
{
if (!sort.HasValue)
{
sort = await _bsHouseLogRep.DetachedEntities.Where(p => p.HouseCodeId.Equals(houseCodeId)).MaxAsync(p => p.Sort);
}
var _sort = sort.GetValueOrDefault(1) + 1;
await new BsHouseLog
{
Id = Guid.NewGuid().ToString(),
HouseCodeId = houseCodeId,
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
Type = type,
Status = HouseLogStatus.Handled,
Remark = remark,
FinishedTime = DateTime.Now,
FinishedUserId = _userManager.UserId,
FinishedUserName = _userManager.User.Account,
Sort = _sort
}.InsertAsync();
return _sort;
}
[HttpGet("/houseLog/list")]
public async Task<dynamic> List([FromQuery] HouseLogInput input)
{
var sql = @"SELECT
HL.Id,
HL.Type,
HL.`Status`,
HL.Remark,
HL.FinishedTime,
HL.FinishedUserId,
IFNULL(NickName, `Name`) FinishedUserName,
(SELECT GROUP_CONCAT(IFNULL(NickName,`Name`)) FROM sys_user
WHERE Id IN (
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(_HL.TargetUserIds,',',HT.help_topic_id + 1),',',-1)
FROM bs_house_log _HL
JOIN mysql.help_topic HT ON HT.help_topic_id < (LENGTH(_HL.TargetUserIds) - LENGTH(REPLACE(_HL.TargetUserIds,',','')) + 1)
WHERE _HL.Id = HL.Id
)
) TargetUserNames
FROM bs_house_log HL
LEFT JOIN sys_user SU ON HL.FinishedUserId = SU.Id
WHERE HouseCodeId = @HouseCodeId
ORDER BY Sort DESC";
return await _dapperRep.QueryAsync<HouseLogOutput>(sql, new { houseCodeId = input.Id });
}
[HttpGet("/houseLog/listByInfoId")]
public async Task<dynamic> ListByInfoId([FromQuery] HouseLogInput input)
{
var info = await Db.GetRepository<BsHouseInfo>().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
return await List(new HouseLogInput
{
Id = info.HouseCodeId
});
}
[HttpGet("/houseLog/listByTaskId")]
public async Task<dynamic> ListByTaskId([FromQuery] HouseLogInput input)
{
var task = await Db.GetRepository<BsHouseTask>().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
return await List(new HouseLogInput
{
Id = task.HouseCodeId
});
}
}
}

View File

@@ -0,0 +1,24 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseLogService
{
Task<int> Add(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null);
Task<int> Add(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null);
Task Read(string houseCodeId);
Task Done(string houseCodeId);
Task<int> AddThenRead(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null);
Task<int> AddThenRead(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null);
Task<int> AddThenDone(string houseCodeId, SysUser targetUser, HouseLogType type, string remark = null, int? sort = null);
Task<int> AddThenDone(string houseCodeId, List<SysUser> targetUsers, HouseLogType type, string remark = null, int? sort = null);
Task<dynamic> List(HouseLogInput input);
Task<dynamic> ListByInfoId(HouseLogInput input);
Task<dynamic> ListByTaskId(HouseLogInput input);
}
}

View File

@@ -0,0 +1,16 @@
using Ewide.Core.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public class AddHouseMemberInput : AddUserInput
{
[Required(ErrorMessage = "角色不能为空")]
public string RoleId { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using Ewide.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public class HouseMemberOutput
{
}
}

View File

@@ -0,0 +1,326 @@
using Dapper;
using Ewide.Core;
using Ewide.Core.Extension;
using Ewide.Core.Service;
using Furion.DatabaseAccessor;
using Furion.DataEncryption;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System;
namespace Ewide.Application.Service
{
[ApiDescriptionSettings(Name = "HouseMember")]
public class HouseMemberService : IHouseMemberService, IDynamicApiController, ITransient
{
private readonly IDapperRepository _dapperRepository;
private readonly IRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly IUserManager _userManager;
private readonly ISysUserService _sysUserService;
private readonly ISysEmpService _sysEmpService;
public HouseMemberService(
IDapperRepository dapperRepository,
IRepository<SysUser> sysUserRep,
IUserManager userManager,
ISysUserService sysUserService,
ISysEmpService sysEmpService
)
{
_dapperRepository = dapperRepository;
_sysUserRep = sysUserRep;
_userManager = userManager;
_sysUserService = sysUserService;
_sysEmpService = sysEmpService;
}
/// <summary>
/// 分页查询用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/page")]
public async Task<dynamic> QueryMemberPageList([FromBody] UserInput input)
{
var dataScopes = await _userManager.GetUserAllDataScopeList();
var sql = @"SELECT
SU.*,
SO.Name OrgName,
SUR.RoleName,
SUR.RoleCode
FROM sys_user SU
LEFT JOIN sys_emp SE ON SU.Id = SE.Id
LEFT JOIN sys_org SO ON SE.OrgId = SO.Id
LEFT JOIN (
SELECT
SUR.SysUserId,
GROUP_CONCAT(SR.Name) RoleName,
GROUP_CONCAT(SR.Code) RoleCode
FROM sys_user_role SUR
LEFT JOIN sys_role SR ON SUR.SysRoleId = SR.Id
GROUP BY SUR.SysUserId
) SUR ON SU.Id = SUR.SysUserId
WHERE 1=1";
var param = new DynamicParameters();
if (!string.IsNullOrEmpty(input.SearchValue))
{
sql += @" AND (SU.Account Like @SearchValue
OR SU.Name Like @SearchValue
OR SU.Phone Like @SearchValue)";
param.Add("SearchValue", "%" + input.SearchValue + "%");
}
if (!string.IsNullOrEmpty(input.SysEmpParam.OrgId))
{
var filter = " AND (SO.Id = @OrgId {0}) ";
filter = String.Format(filter, input.TreeNodeDataScope.GetValueOrDefault(1) == 2 ? " OR SO.Pids Like CONCAT('%[', @OrgId, ']%') " : "");
sql += filter;
param.Add("OrgId", input.SysEmpParam.OrgId);
}
if (input.SearchStatus >= 0)
{
sql += " AND SU.Status = @Status";
param.Add("Status", input.SearchStatus);
}
if (!_userManager.SuperAdmin)
{
sql += " AND SU.AdminType <> @AdminType";
param.Add("AdminType", AdminType.SuperAdmin);
sql += " AND SU.Id <> @UserId";
param.Add("UserId", _userManager.UserId);
if (dataScopes.Count > 0)
{
sql += " AND SO.Id IN @OrgIds";
param.Add("OrgIds", dataScopes.ToArray());
}
}
var users = await _dapperRepository.QueryPageData<UserOutput>(sql, input, param);
//foreach (var user in users.Items)
//{
// user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id);
//}
return PageDataResult<UserOutput>.PageResult(users);
}
/// <summary>
/// 增加用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/add")]
[UnitOfWork]
public async Task AddUser(AddHouseMemberInput input)
{
var id = await _sysUserService.AddUser(input);
var grantRoleInput = input.Adapt<UpdateUserInput>();
grantRoleInput.Id = id;
// 添加角色
grantRoleInput.GrantRoleIdList.Add(input.RoleId);
await _sysUserService.GrantUserRole(grantRoleInput);
}
/// <summary>
/// 获取角色
/// </summary>
/// <param name="orgId"></param>
/// <returns></returns>
[HttpGet("/houseMember/defaultRole")]
public async Task<dynamic> DefaultRole([FromQuery] string orgId)
{
return (await GetDefaultRole(orgId)).Adapt<RoleOutput>();
}
/// <summary>
/// 获取用户拥有角色
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseMember/ownRole")]
public async Task<dynamic> GetUserOwnRole([FromQuery] QueryUserInput input)
{
return await _sysUserService.GetUserOwnRole(input);
}
[HttpGet("/houseMember/defaultRoleRange")]
public async Task<dynamic> DefaultRoleRange()
{
return (await GetRoleRange()).Select(p => p.Adapt<RoleOutput>()).ToList();
}
/// <summary>
/// 删除用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/delete")]
[UnitOfWork]
public async Task DeleteUser(DeleteUserInput input)
{
/*
* 未处理逻辑
* 片区监管员在本片区已有安全员的情况下无法删除
*/
await _sysUserService.DeleteUser(input);
}
/// <summary>
/// 更新用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/edit")]
[UnitOfWork]
public async Task UpdateUser(UpdateUserInput input)
{
/*
* 未处理逻辑
* 如果移动组织架构,会产生以下几种逻辑
* 片区1监管员(无安全员或有其他监管员)=>片区2,直接成功
* 片区1监管员(有安全员并且无其他监管员)=>片区2,无法移动
* 片区1安全员=>片区2(有监管员),直接成功
* 片区1安全员=>片区2(无监管员),无法移动,需要创建监管员
*/
await _sysUserService.UpdateUser(input);
}
/// <summary>
/// 查看用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseMember/detail")]
public async Task<dynamic> GetUser([FromQuery] QueryUserInput input)
{
var sql = @"SELECT
SU.*,
SO.Name OrgName,
SUR.RoleName,
SUR.RoleCode
FROM sys_user SU
LEFT JOIN sys_emp SE ON SU.Id = SE.Id
LEFT JOIN sys_org SO ON SE.OrgId = SO.Id
LEFT JOIN (
SELECT
SUR.SysUserId,
GROUP_CONCAT(SR.Name) RoleName,
GROUP_CONCAT(SR.Code) RoleCode
FROM sys_user_role SUR
LEFT JOIN sys_role SR ON SUR.SysRoleId = SR.Id
GROUP BY SUR.SysUserId
) SUR ON SU.Id = SUR.SysUserId
WHERE SU.Id=@Id";
var user = (await _dapperRepository.QueryAsync<UserOutput>(sql, new { input.Id })).SingleOrDefault();
if (user != null)
{
user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id);
}
return user;
}
/// <summary>
/// 修改用户状态
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/changeStatus")]
public async Task ChangeUserStatus(UpdateUserInput input)
{
await _sysUserService.ChangeUserStatus(input);
}
/// <summary>
/// 授权用户数据范围
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseMember/grantData")]
public async Task GrantUserData(UpdateUserInput input)
{
await _sysUserService.GrantUserData(input);
}
/// <summary>
/// 获取用户拥有数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseMember/ownData")]
public async Task<dynamic> GetUserOwnData([FromQuery] QueryUserInput input)
{
return await _sysUserService.GetUserOwnData(input);
}
/// <summary>
/// 获取当前机构中所创建的默认角色
/// 片区中的第一个帐号必定为片区监管员
/// </summary>
/// <param name="orgId"></param>
/// <returns></returns>
[NonAction]
private async Task<SysRole> GetDefaultRole(string orgId)
{
var roles = await GetRoleRange();
if (roles.Count < 2) throw Oops.Oh("未配置正确的角色");
var _sysOrgRep = Db.GetRepository<SysOrg>();
var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == orgId);
// 如果当前组织为街道, 则直接返回安全员
if (org == null || org.Type <= (int)OrgType.)
{
return roles.LastOrDefault();
}
var _sysEmpRep = Db.GetRepository<SysEmp>();
var _sysUserRoleRep = Db.GetRepository<SysUserRole>();
var userIds = await _sysEmpRep.DetachedEntities.Where(p => p.OrgId == orgId).Select(p => p.Id).ToListAsync();
var roleIds = await _sysUserRoleRep.DetachedEntities.Where(p => userIds.Contains(p.SysUserId)).Select(p => p.SysRoleId).ToListAsync();
var _sysRoleRep = Db.GetRepository<SysRole>();
var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase());
// 存在片区监管员,返回安全员, 否则返回监管员
if (isExistZoneManager)
{
return roles.LastOrDefault();
}
return roles.FirstOrDefault();
}
/// <summary>
/// 获取可创建的角色列表
/// </summary>
/// <returns></returns>
[NonAction]
private async Task<List<SysRole>> GetRoleRange()
{
var codes = (new[] {
Enum.GetName(HouseManagerRole.ZoneManager),
Enum.GetName(HouseManagerRole.HouseSecurityManager),
}).Select(p => p.ToUnderScoreCase());
var _sysRoleRep = Db.GetRepository<SysRole>();
var roles = await _sysRoleRep.DetachedEntities.Where(p => codes.Contains(p.Code)).ToListAsync();
return roles;
}
}
}

View File

@@ -0,0 +1,22 @@
using Ewide.Core.Service;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseMemberService
{
Task<dynamic> QueryMemberPageList([FromBody] UserInput input);
Task AddUser(AddHouseMemberInput input);
Task<dynamic> DefaultRole([FromQuery] string orgId);
Task DeleteUser(DeleteUserInput input);
Task UpdateUser(UpdateUserInput input);
Task<dynamic> GetUser([FromQuery] QueryUserInput input);
Task ChangeUserStatus(UpdateUserInput input);
Task<dynamic> GetUserOwnRole([FromQuery] QueryUserInput input);
Task GrantUserData(UpdateUserInput input);
Task<dynamic> GetUserOwnData([FromQuery] QueryUserInput input);
Task<dynamic> DefaultRoleRange();
}
}

View File

@@ -0,0 +1,52 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseProjectInfo.Dto
{
public class HouseProjectInfoInput : InputBase
{
public string Name { get; set; }
public string Note { get; set; }
public int Sort { get; set; }
public string AreaCode { get; set; }
public int Type { get; set; }
}
public class AddProjectInput : HouseProjectInfoInput
{
}
public class UpdateProjectInput : HouseProjectInfoInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string Id { get; set; }
}
public class DeleteProjectInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string Id { get; set; }
}
public class QueryProjectInput : UpdateProjectInput
{
}
public class PageProjectInput: HouseProjectInfoInput
{
public string pid { get; set; }
}
public class ListHouseProjectInfoInput
{
[Required(ErrorMessage = "区域编码不可为空")]
public string AreaCode { get; set; }
[Required(ErrorMessage = "性质不可为空")]
public int Type { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseProjectInfo.Dto
{
public class HouseProjectOutput
{
public string Id { get; set; }
public string Name { get; set; }
public string Note { get; set; }
public int Sort { get; set; }
public string AreaCode { get; set; }
public string AreaName { get; set; }
public int Type { get; set; }
}
}

View File

@@ -0,0 +1,147 @@
using Ewide.Application.Entity;
using Ewide.Application.Service.HouseProjectInfo.Dto;
using Ewide.Core;
using Ewide.Core.Service;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseProjectInfo
{
/// <summary>
/// 项目管理相关服务
/// </summary>
[ApiDescriptionSettings(Name = "HouseProjectInfo", Order = 170)]
public class HouseProjectInfoService : IHouseProjectInfoService, ITransient, IDynamicApiController
{
private readonly IRepository<BsHouseProjectInfo> _houseProjectInfoRep;
public HouseProjectInfoService(IRepository<BsHouseProjectInfo> houseProjectInfoRep)
{
_houseProjectInfoRep = houseProjectInfoRep;
}
/// <summary>
/// 添加项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseProjectInfo/add")]
public async Task AddProject(AddProjectInput input)
{
await _houseProjectInfoRep.InsertNowAsync(input.Adapt<BsHouseProjectInfo>());
}
/// <summary>
/// 删除项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseProjectInfo/delete")]
public async Task DeleteProject(DeleteProjectInput input)
{
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id);
await project.DeleteNowAsync();
}
/// <summary>
/// 编辑项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseProjectInfo/edit")]
public async Task UpdateProject(UpdateProjectInput input)
{
var project = input.Adapt<BsHouseProjectInfo>();
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaCode) }, true);
}
/// <summary>
/// 通过ID获取项目
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
[HttpGet("/houseProjectInfo/getById")]
public async Task<BsHouseProjectInfo> GetById([Required] string projectId)
{
return await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == projectId);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseProjectInfo/page")]
public async Task<dynamic> QueryProjectPageList([FromBody] PageProjectInput input)
{
var areaCodeRep = Db.GetRepository<SysAreaCode>();
var projects = await _houseProjectInfoRep.DetachedEntities
.Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name })
.Where(input.Type>0, x => x.p.Type == input.Type)
.Where(!string.IsNullOrEmpty(input.Name), x => x.p.Name.Contains(input.Name))
.Where(!string.IsNullOrEmpty(input.Note), x => x.p.Note.Contains(input.Note))
.Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode)
.Where(!string.IsNullOrEmpty(input.pid) , x=> x.p.AreaCode.Contains(input.pid))
.Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaCode, x.AreaName, x.p.Type }.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageIndex, input.PageSize);
return PageDataResult<HouseProjectOutput>.PageResult(projects);
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseProjectInfo/detail")]
public async Task<dynamic> GetProject([FromQuery] QueryProjectInput input)
{
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
var userDto = user.Adapt<UserOutput>();
return userDto;
}
[HttpGet("/houseProjectInfo/nextSort")]
public async Task<int> GetNextProjectSortByAreaCode([FromQuery] ListHouseProjectInfoInput input)
{
//var projects = await _houseProjectInfoRep.DetachedEntities
// .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
// .Select(p => p.Sort)
// .DefaultIfEmpty()
// .MaxAsync();
if (input.Type > 2 || input.Type < 1)
{
throw Oops.Oh("类型参数异常");
}
var p = await _houseProjectInfoRep.DetachedEntities
.Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
.MaxAsync(p => (int?)p.Sort);
return p.GetValueOrDefault(0) + 1;
}
/// <summary>
/// 获取项目下拉列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("houseProjectInfo/list")]
public async Task<dynamic> GetProjectList([FromQuery] ListHouseProjectInfoInput input)
{
return await _houseProjectInfoRep.DetachedEntities
.Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
.OrderBy(p => p.Sort)
.ToListAsync();
}
}
}

View File

@@ -0,0 +1,24 @@
using Ewide.Application.Entity;
using Ewide.Application.Service.HouseProjectInfo.Dto;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseProjectInfo
{
public interface IHouseProjectInfoService
{
Task AddProject(AddProjectInput input);
Task DeleteProject(DeleteProjectInput input);
Task UpdateProject(UpdateProjectInput input);
Task<BsHouseProjectInfo> GetById([FromRoute] string projectId);
Task<dynamic> GetProject([FromQuery] QueryProjectInput input);
Task<dynamic> QueryProjectPageList([FromQuery] PageProjectInput input);
Task<int> GetNextProjectSortByAreaCode([FromQuery] ListHouseProjectInfoInput input);
Task<dynamic> GetProjectList([FromQuery] ListHouseProjectInfoInput input);
}
}

View File

@@ -0,0 +1,21 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseQueryInput: PageInputBase
{
}
public class HouseQueryDetailInput
{
[Required(ErrorMessage = "Id不能为空")]
public string Id { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseQueryOutput
{
}
}

View File

@@ -0,0 +1,110 @@
using Dapper;
using Ewide.Core.Extension;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseSafety.HouseQuery
{
/// <summary>
/// 住宅查询
/// </summary>
[ApiDescriptionSettings(Name = "HouseQuery", Order = 210)]
public class HouseQueryService : IHouseQueryService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseCode> _houseCodeRep;
private readonly IRepository<BsHouseInfo> _houseInfoRep;
private readonly IRepository<BsHouseTask> _houseTaskRep;
private readonly IDapperRepository _dapperRepository;
public HouseQueryService(IRepository<BsHouseCode> HouseCodeRep, IRepository<BsHouseInfo> HouseInfoRep, IRepository<BsHouseTask> HouseTaskRep, IDapperRepository dapperRepository)
{
_houseCodeRep = HouseCodeRep;
_houseInfoRep = HouseInfoRep;
_houseTaskRep = HouseTaskRep;
_dapperRepository = dapperRepository;
}
[HttpPost("/houseQuery/page")]
public async Task<dynamic> QueryPage([FromBody] HouseQueryInput input)
{
var sql = @"SELECT
HC.ID,
HC.HouseCode,
AA.Name AreaName,
RA.Name RoadName,
CA.Name CommName,
Proj.AreaCode,
Proj.Note,
Proj.Name,
CONCAT(Proj.Name,'(',Proj.Note,')') FullProjName,
HC.Address,
IFNULL(HI.BuildingName,'') BuildingName,
IFNULL(HI.TotalFloor,0) TotalFloor,
IFNULL(HI.TotalArea,0) TotalArea,
HI.LandAttribute,
IFNULL(HI.HouseGrade,0) HouseGrade,
HC.Type,
HC.No,
HI.State,
HI.CompletedDate,
HI.CreatedTime
FROM bs_house_code HC
LEFT JOIN bs_house_info HI ON HI.HouseCodeId = HC.Id
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
WHERE 1=1";
return await _dapperRepository.QueryPageDataDynamic(sql, input, filterFields: new string[] {
"HouseCode",
"Address",
"BuildingName",
"State",
"AreaCode",
"LandAttribute",
"HouseGrade",
"CompletedDate",
"CreatedTime",
"TotalArea",
"TotalFloor"
});
}
[HttpGet("/houseQuery/detail")]
public async Task<dynamic> Detail([FromQuery] HouseQueryDetailInput input)
{
var houseCodeOutputAsync = await _dapperRepository.QueryAsync<HouseCodeOutput>(
@"SELECT HC.Id,HC.Address,HC.ProjectId,HC.ZoneId,HC.Type,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,O.Name ZoneName,Proj.Note ProjectNote,CONCAT(Proj.Name,'(',Proj.Note,')') ProjectFullName,HC.HouseCode,HC.Lng,HC.Lat,HC.No FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_org O ON HC.ZoneId = O.Id
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
WHERE HC.Id=@Id", new { input.Id }
);
var houseCodeOutput = houseCodeOutputAsync.SingleOrDefault();
var houseInfoOutputForDetailPage = new HouseInfoOutputForDetailPage
{
HouseCode = houseCodeOutput
};
var houseInfoOutput = (await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.HouseCodeId == houseCodeOutput.Id)).Adapt<HouseInfoOutput>();
houseInfoOutputForDetailPage.HouseInfo = houseInfoOutput;
return houseInfoOutputForDetailPage;
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseSafety.HouseQuery
{
public interface IHouseQueryService
{
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseSelectInput
{
[Required(ErrorMessage = "用户Id不能为空")]
public string UserId { get; set; }
[Required(ErrorMessage = "房屋编码Id不能为空")]
public string[] Ids { get; set; }
}
public class QueryHouseSelectorInput : QueryHouseCodeInput
{
[Required(ErrorMessage = "用户Id不能为空")]
public string UserId { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseSelectorOutput
{
}
}

View File

@@ -0,0 +1,225 @@
using Dapper;
using Ewide.Core;
using Ewide.Core.Extension;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
/// <summary>
/// 选房相关
/// </summary>
[ApiDescriptionSettings(Name = "HouseSelector", Order = 180)]
public class HouseSelectorService : IHouseSelectorService, IDynamicApiController, ITransient
{
private readonly IUserManager _userManager;
private readonly IDapperRepository _dapperRep;
private readonly IRepository<BsHouseMemberRelation> _bsHouseMemberRelationRep;
private readonly IRepository<BsHouseCode> _bsHouseCodeRep;
private readonly IRepository<BsHouseTask> _bsHouseTaskRep;
private readonly IRepository<SysUser> _sysUserRep;
private readonly IHouseZoneService _houseZoneService;
private readonly IHouseLogService _houseLogService;
public HouseSelectorService(
IUserManager userManager,
IDapperRepository dapperRep,
IRepository<BsHouseMemberRelation> bsHouseMemberRelationRep,
IRepository<BsHouseCode> bsHouseCodeRep,
IRepository<BsHouseTask> bsHouseTaskRep,
IRepository<SysUser> sysUserRep,
IHouseZoneService houseZoneService,
IHouseLogService houseLogService
)
{
_userManager = userManager;
_dapperRep = dapperRep;
_bsHouseMemberRelationRep = bsHouseMemberRelationRep;
_bsHouseCodeRep = bsHouseCodeRep;
_bsHouseTaskRep = bsHouseTaskRep;
_sysUserRep = sysUserRep;
_houseZoneService = houseZoneService;
_houseLogService = houseLogService;
}
/// <summary>
/// 获取人员允许绑定的房屋编码列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseSelector/selectorPage")]
public async Task<dynamic> HouseSelectorList([FromBody] QueryHouseSelectorInput input)
{
var sql = @"SELECT
HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,CONCAT(Proj.`Name`, IFNULL(CONCAT('(',Proj.Note,')'), '')) FullProjName
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
LEFT JOIN bs_house_member_relation HM ON HC.Id = HM.HouseCodeId
INNER JOIN (SELECT * FROM sys_emp WHERE Id = @UserId) E ON HC.ZoneId = E.OrgId
WHERE HM.Id IS NULL";
return await _dapperRep.QueryPageDataDynamic(sql, input, param: new
{
input.UserId
}, filterFields: new[] {
nameof(BsHouseCode.Address) ,
nameof(BsHouseCode.CreatedTime)
});
}
/// <summary>
/// 获取人员已经绑定的房屋编码列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseSelector/selectedPage")]
public async Task<dynamic> HouseSelectedList([FromBody] QueryHouseSelectorInput input)
{
var sql = @"SELECT
HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,CONCAT(Proj.`Name`, IFNULL(CONCAT('(',Proj.Note,')'), '')) FullProjName
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
INNER JOIN (SELECT * FROM bs_house_member_relation WHERE SysUserId = @UserId) HM ON HC.Id = HM.HouseCodeId";
return await _dapperRep.QueryPageDataDynamic(sql, input, param: new
{
input.UserId
}, filterFields: new[] {
nameof(BsHouseCode.Address) ,
nameof(BsHouseCode.CreatedTime)
});
}
/// <summary>
/// 从人员选择房屋
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseSelector/select")]
[UnitOfWork]
public async Task Select([FromBody] HouseSelectInput input)
{
#region
var ids = input.Ids.Distinct().ToList();
if (ids.Count == 0) throw Oops.Oh("没有选中任何房屋");
// 验证当前用户是否安全员 **须补充
// 已经被选中的房屋,从ids中剔除
var houseSelected = await _bsHouseMemberRelationRep.DetachedEntities
.Where(p => ids.Contains(p.HouseCodeId))
.Select(p => p.HouseCodeId)
.ToListAsync();
if (houseSelected.Count > 0)
{
houseSelected.ForEach(p =>
{
var index = ids.IndexOf(p);
if (index > -1)
{
ids.RemoveAt(index);
}
});
}
if (ids.Count == 0) throw Oops.Oh("当前房屋在此之前已经全部被选中,请确认");
var selectedUser = await _sysUserRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.UserId));
// 从用户所在片区中过滤房屋
var zoneId = await _houseZoneService.GetZoneByUser(selectedUser.Id);
var house = await _bsHouseCodeRep.DetachedEntities.Where(p => ids.Contains(p.Id) && p.ZoneId == zoneId).Select(p => p.Id).ToListAsync();
if (house.Count == 0) throw Oops.Oh("选中的房屋错误");
#endregion
// 选定房屋
house.ForEach(async p =>
{
var originalTask = _bsHouseTaskRep.DetachedEntities.FirstOrDefault(t => t.HouseCodeId == p && t.TaskType == 0 && t.IsEnabled);
if (originalTask == null)
{
new BsHouseTask
{
Id = System.Guid.NewGuid().ToString(),
HouseCodeId = p,
UserID = selectedUser.Id,
EndTime = System.DateTime.Now.AddMonths(1),
Status = 0,
TaskType = 0
}.Insert();
await _houseLogService.Done(p);
await _houseLogService.Add(p, selectedUser, HouseLogType.CreateInfo);
}
else
{
var sort = await _houseLogService.AddThenDone(p, _userManager.User, HouseLogType.SelectMember);
if (originalTask.Status != 6)//建档未完成生成新建档任务分配给新的人员原建档任务数据保留有效性设置为false取消巡查关系
{
var newTask = originalTask.Adapt<BsHouseTask>();
newTask.Id = System.Guid.NewGuid().ToString();
newTask.UserID = input.UserId;
newTask.EndTime = System.DateTime.Now.AddMonths(1);
newTask.Insert();
originalTask.IsEnabled = false;
originalTask.Update();
sort = await _houseLogService.Add(p, selectedUser, HouseLogType.CreateInfo, sort: sort);
}//已建档完成,不再分配建档任务,仅更换巡查关系
else
{
var originalRelation = _bsHouseMemberRelationRep.DetachedEntities.FirstOrDefault(r => r.HouseCodeId == p && r.SysUserId == originalTask.UserID);
originalRelation.Delete();
}
}
new BsHouseMemberRelation
{
SysUserId = selectedUser.Id,
HouseCodeId = p
}.Insert();
});
}
[HttpPost("/houseSelector/revoke")]
[UnitOfWork]
public async Task Revoke([FromBody] HouseSelectInput input)
{
var ids = input.Ids.Distinct().ToList();
if (ids.Count == 0) throw Oops.Oh("没有选中任何房屋");
var selected = await _bsHouseMemberRelationRep.Where(p => ids.Contains(p.HouseCodeId) && p.SysUserId == input.UserId).ToListAsync();
selected.ForEach(p =>
{
p.Delete();
});
}
public async Task SelectMember()
{
}
}
}

View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseSelectorService
{
Task<dynamic> HouseSelectorList([FromQuery] QueryHouseSelectorInput input);
Task<dynamic> HouseSelectedList([FromQuery] QueryHouseSelectorInput input);
Task Select([FromBody] HouseSelectInput input);
Task Revoke([FromBody] HouseSelectInput input);
Task SelectMember();
}
}

View File

@@ -0,0 +1,171 @@
using Ewide.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseTaskInput
{
[Required(ErrorMessage = "巡查日期不能为空")]
public DateTime PatrolDate { get; set; }
[Required(ErrorMessage = "巡查人员/单位不能为空")]
public string PatrolUser { get; set; }
/// <summary>
/// 沉降倾斜
/// </summary>
public string SettlementTilt { get; set; }
/// <summary>
/// 沉降倾斜附件
/// </summary>
public string SettlementTiltFiles { get; set; }
/// <summary>
/// 其他情况
/// </summary>
public string OtherInfo { get; set; }
/// <summary>
/// 其他情况附件
/// </summary>
public string OtherInfoFiles { get; set; }
//[Required(ErrorMessage = "巡查初始等级不能为空")]
public int InitGrade { get; set; }
//[Required(ErrorMessage = "巡查损坏等级不能为空")]
public int DamageGrade { get; set; }
//[Required(ErrorMessage = "巡查综合等级不能为空")]
public int ComprehensiveGrade { get; set; }
#region investigation
/// <summary>
/// 房屋场地
/// </summary>
public string HouseSite { get; set; }
/// <summary>
/// 相邻施工
/// </summary>
public string AdjacentConstruction { get; set; }
/// <summary>
/// 化学侵蚀
/// </summary>
public string ChemicalErosion { get; set; }
/// <summary>
/// 结构拆改
/// </summary>
public int? StructuralDismantling { get; set; }
/// <summary>
/// 加层改造
/// </summary>
public int? AddingLayer { get; set; }
/// <summary>
/// 修缮加固
/// </summary>
public string RepairAndReinforce { get; set; }
/// <summary>
/// 历史灾害
/// </summary>
public string HistoricalCalamity { get; set; }
/// <summary>
/// 使用功能变更
/// </summary>
public string FunctionalChange { get; set; }
/// <summary>
/// 其他调查内容
/// </summary>
public string OtherContents { get; set; }
#endregion
/// <summary>
/// 主要安全隐患综述
/// </summary>
public string MainSafety { get; set; }
/// <summary>
/// 处理意见
/// </summary>
public int? HandlingOpinion { get; set; }
/// <summary>
/// 处理意见备注
/// </summary>
public string HandlingOpinionRemark { get; set; }
/// <summary>
/// 整改情况
/// </summary>
public int? RectifyAndReform { get; set; }
/// <summary>
/// 整改情况备注
/// </summary>
public string RectifyAndReformRemark { get; set; }
/// <summary>
/// 巡查结果1正常,-1异常
/// </summary>
//[Required(ErrorMessage = "巡查结果不能为空")]
public int PatrolResult { get; set; }
public string PatrolResultRemark { get; set; }
/// <summary>
/// 上报街道
/// </summary>
public int? ReportRoad { get; set; }
/// <summary>
/// 上报街道时间
/// </summary>
public DateTime? ReportRoadTime { get; set; }
/// <summary>
/// 上报区住建
/// </summary>
public int? ReportArea { get; set; }
/// <summary>
/// 上报区住建时间
/// </summary>
public DateTime? ReportAreaTime { get; set; }
/// <summary>
/// 上报备注
/// </summary>
public string ReportRemark { get; set; }
}
public class AddHouseTaskInput : HouseTaskInput
{
}
public class EditHouseTaskInput : HouseTaskInput
{
[Required(ErrorMessage = "任务Id不能为空")]
public string Id { get; set; }
}
public class SubmitHouseTaskInput
{
[Required(ErrorMessage = "任务Id不能为空")]
public string TaskId { get; set; }
}
public class QueryHouseTaskInput : PageInputBase
{
}
}

View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseTaskOutput
{
public DateTime? PatrolDate { get; set; }
public string PatrolUser { get; set; }
/// <summary>
/// 沉降倾斜
/// </summary>
public string SettlementTilt { get; set; }
/// <summary>
/// 沉降倾斜附件
/// </summary>
public string SettlementTiltFiles { get; set; }
/// <summary>
/// 其他情况
/// </summary>
public string OtherInfo { get; set; }
/// <summary>
/// 其他情况附件
/// </summary>
public string OtherInfoFiles { get; set; }
/// <summary>
/// 初始等级
/// </summary>
public int? InitGrade { get; set; }
/// <summary>
/// 损坏等级
/// </summary>
public int? DamageGrade { get; set; }
/// <summary>
/// 综合等级
/// </summary>
public int? ComprehensiveGrade { get; set; }
#region investigation
/// <summary>
/// 房屋场地
/// </summary>
public string HouseSite { get; set; }
/// <summary>
/// 相邻施工
/// </summary>
public string AdjacentConstruction { get; set; }
/// <summary>
/// 化学侵蚀
/// </summary>
public string ChemicalErosion { get; set; }
/// <summary>
/// 结构拆改
/// </summary>
public int? StructuralDismantling { get; set; }
/// <summary>
/// 加层改造
/// </summary>
public int? AddingLayer { get; set; }
/// <summary>
/// 修缮加固
/// </summary>
public string RepairAndReinforce { get; set; }
/// <summary>
/// 历史灾害
/// </summary>
public string HistoricalCalamity { get; set; }
/// <summary>
/// 使用功能变更
/// </summary>
public string FunctionalChange { get; set; }
/// <summary>
/// 其他调查内容
/// </summary>
public string OtherContents { get; set; }
#endregion
/// <summary>
/// 主要安全隐患综述
/// </summary>
public string MainSafety { get; set; }
/// <summary>
/// 处理意见
/// </summary>
public int? HandlingOpinion { get; set; }
/// <summary>
/// 处理意见备注
/// </summary>
public string HandlingOpinionRemark { get; set; }
/// <summary>
/// 整改情况
/// </summary>
public int? RectifyAndReform { get; set; }
/// <summary>
/// 整改情况备注
/// </summary>
public string RectifyAndReformRemark { get; set; }
/// <summary>
/// 巡查结果1正常,-1异常
/// </summary>
public int? PatrolResult { get; set; }
/// <summary>
/// 巡查异常描述
/// </summary>
public string PatrolResultRemark { get; set; }
/// <summary>
/// 上报街道
/// </summary>
public int? ReportRoad { get; set; }
/// <summary>
/// 上报街道时间
/// </summary>
public DateTime? ReportRoadTime { get; set; }
/// <summary>
/// 上报区住建
/// </summary>
public int? ReportArea { get; set; }
/// <summary>
/// 上报区住建时间
/// </summary>
public DateTime? ReportAreaTime { get; set; }
/// <summary>
/// 上报备注
/// </summary>
public string ReportRemark { get; set; }
public int Status { get; set; }
/// <summary>
/// 提交时间
/// </summary>
public DateTime? SubmitTime { get; set; }
/// <summary>
/// 最后提交时间
/// </summary>
public DateTime? LastSubmitTime { get; set; }
/// <summary>
/// 是否有效
/// </summary>
public bool IsEnabled { get; set; }
}
}

View File

@@ -0,0 +1,102 @@
using Dapper;
using Ewide.Core;
using Ewide.Core.Extension;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
/// <summary>
/// 房屋任务(巡查任务/建档任务)
/// </summary>
[ApiDescriptionSettings(Name = "HouseTask", Order = 190)]
public class HouseTaskService : IHouseTaskService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseTask> _houseTaskRep;
private readonly IRepository<BsHouseInfo> _houseInfoRep;
private readonly IDapperRepository _dapperRepository;
private readonly IUserManager _userManager;
private readonly IHouseLogService _houseLogService;
public HouseTaskService(IRepository<BsHouseTask> HouseTaskRep, IRepository<BsHouseInfo> HouseInfoRep, IDapperRepository dapperRepository, IUserManager userManager, IHouseLogService houseLogService)
{
_houseTaskRep = HouseTaskRep;
_houseInfoRep = HouseInfoRep;
_dapperRepository = dapperRepository;
_userManager = userManager;
_houseLogService = houseLogService;
}
[HttpPost("/houseTask/page")]
public async Task<dynamic> QueryPage([FromBody] QueryHouseTaskInput input)
{
var sql = @"SELECT T.Id,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,Proj.Name,CONCAT(Proj.`Name`, IFNULL(CONCAT('(',Proj.Note,')'), '')) FullProjName,HC.HouseCode,HC.Address,T.EndTime,HC.Type,HC.Industry,HC.No,T.Status,IFNULL(HI.State,0) State FROM `bs_house_task` T
LEFT JOIN bs_house_code HC ON T.HouseCodeId = HC.Id
LEFT JOIN bs_house_info HI ON HI.HouseCodeId = T.HouseCodeId
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
WHERE T.IsEnabled = 1 {0}";
var user = await _userManager.CheckUserAsync();
if (user == null) throw Oops.Oh("登录信息丢失");
var userRoles = await _userManager.GetUserRoleList();
var userOrg = await _userManager.GetUserOrgInfo();
var param = new DynamicParameters();
if (userRoles.Where(r => r.Code == Enum.GetName(HouseManagerRole.HouseSecurityManager).ToUnderScoreCase()).Any())
{
sql = String.Format(sql, " AND T.UserID=@UserID ");
param.Add("UserID", user.Id);
}
if (userRoles.Where(r => r.Code == Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase()).Any())
{
sql = String.Format(sql, " AND (T.Status=3 OR T.Status=6) AND HC.ZoneId = @ZoneId ");
param.Add("ZoneId", userOrg.Id);
}
return await _dapperRepository.QueryPageDataDynamic(sql, input, param, filterFields: new string[] { "Type", "Address", "HouseCode", "Status","State" });
}
[HttpPost("/houseTask/submit")]
[UnitOfWork]
[AllowAnonymous]
public async Task Submit([FromBody] SubmitHouseTaskInput input)
{
//获取任务实体
var houseTask = await _houseTaskRep.DetachedEntities.FirstOrDefaultAsync(t => t.Id == input.TaskId);
if (houseTask == null) throw Oops.Oh("任务不存在");
houseTask.Status = 2;
houseTask.LastSubmitTime = DateTime.Now;
if (!houseTask.SubmitTime.HasValue) houseTask.SubmitTime = houseTask.LastSubmitTime;
await houseTask.UpdateExcludeAsync(new string[] { nameof(BsHouseTask.TaskType) }, ignoreNullValues: true);
if(houseTask.TaskType == 0)
{
var houseInfo = await _houseInfoRep.DetachedEntities.FirstOrDefaultAsync(h => h.HouseCodeId == houseTask.HouseCodeId);
if (houseInfo == null) throw Oops.Oh("提交审核失败:请先保存后再提交");
houseInfo.State = 5;
await houseInfo.UpdateExcludeAsync(new[] { nameof(BsHouseInfo.HouseGrade) }, true);
}
// 提交时流转日志
await _houseLogService.Done(houseTask.HouseCodeId);
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseTaskService
{
Task<dynamic> QueryPage(QueryHouseTaskInput input);
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseTaskCheckRecordInput
{
/// <summary>
/// 任务Id
/// </summary>
[Required(ErrorMessage = "任务参数有误")]
public string TaskId { get; set; }
/// <summary>
/// 通过3退回-1
/// </summary>
[Required(ErrorMessage = "审核结果不能为空")]
public int PassOrBack { get; set; }
public DataStatus PassOrBackDataStatus
{
get
{
return PassOrBack switch
{
-1 => DataStatus.Back,
1 => DataStatus.TempSaved,
2 => DataStatus.Saved,
3 => DataStatus.Submited,
6 => DataStatus.Passed,
_ => DataStatus.Init,
};
}
}
/// <summary>
/// 审核内容
/// </summary>
[Required(ErrorMessage = "审核内容不能为空")]
public string Content { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseSafety.HouseTaskCheckRecord.Dto
{
public class HouseTaskCheckRecordOutput
{
}
}

View File

@@ -0,0 +1,41 @@
using Ewide.Core.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
public class HouseZoneInput
{
[Required(ErrorMessage = "区域编码不可为空")]
[MinLength(9, ErrorMessage = "区域编码长度必须为9位及以上")]
public string AreaCode { get; set; }
}
public class AddHouseZoneInput : OrgInput
{
/// <summary>
/// 所属街道
/// </summary>
[Required(ErrorMessage = "所属街道不能为空")]
public override string Pid { get; set; }
/// <summary>
/// 名称
/// </summary>
[Required(ErrorMessage = "片区名称不能为空")]
public override string Name { get; set; }
}
public class UpdateHouseZoneInput : AddHouseZoneInput
{
/// <summary>
/// 机构Id
/// </summary>
[Required(ErrorMessage = "片区Id不能为空")]
public string Id { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application
{
class HouseZoneOutput
{
}
}

View File

@@ -0,0 +1,175 @@
using Ewide.Core;
using Ewide.Core.Extension;
using Ewide.Core.Service;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
/// <summary>
/// 片区相关
/// </summary>
[ApiDescriptionSettings(Name = "HouseZone", Order = 180)]
public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient
{
private readonly IUserManager _userManager;
private readonly IRepository<SysOrg> _sysOrgRep;
private readonly IRepository<SysEmp> _sysEmpRep;
private readonly ISysOrgService _sysOrgService;
public HouseZoneService(
IUserManager userManager,
IRepository<SysOrg> sysOrgRep,
IRepository<SysEmp> sysEmpRep,
ISysOrgService sysOrgService
)
{
_userManager = userManager;
_sysOrgRep = sysOrgRep;
_sysEmpRep = sysEmpRep;
_sysOrgService = sysOrgService;
}
/// <summary>
/// 获取片区列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseZone/list")]
public async Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input)
{
var areaCode = input.AreaCode.Substring(0, 9);
var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == areaCode);
if (road == null) throw Oops.Oh("未在组织机构中配置街道");
return await _sysOrgRep.DetachedEntities
.Where(p => p.Pid == road.Id)
.Where(p => p.Type == (int)OrgType.)
.OrderBy(p => p.Sort)
.Select(p => new
{
p.Id,
p.Name
})
.ToListAsync();
}
[HttpGet("/houseZone/getById")]
public async Task<dynamic> GetById([Required] string zoneId)
{
return await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == zoneId);
}
/// <summary>
/// 分页查询片区
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseZone/page")]
public async Task<dynamic> QueryZonePageList([FromBody] PageOrgInput input)
{
var dataScopeList = _sysOrgService.GetDataScopeList(await _userManager.GetUserAllDataScopeList());
var name = !string.IsNullOrEmpty(input.Name?.Trim());
var id = !string.IsNullOrEmpty(input.Id?.Trim());
var pId = !string.IsNullOrEmpty(input.Pid?.Trim());
var orgs = await _sysOrgRep.DetachedEntities
.Where((name, u => EF.Functions.Like(u.Name, $"%{input.Name.Trim()}%")), // 根据机构名称模糊查询
(id, u => u.Id == input.Id.Trim()), // 根据机构id查询
(pId, u => EF.Functions.Like(u.Pids, $"%[{input.Pid.Trim()}]%")
|| u.Id == input.Pid.Trim())) // 根据父机构id查询
.Where(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) // 非管理员范围限制
.Where(u => u.Status != CommonStatus.DELETED)
.Where(u => u.Type == (int)OrgType.)
.OrderBy(u => u.Sort)
.ToPageData<SysOrg, OrgOutput>(input);
return PageDataResult<OrgOutput>.PageResult(orgs);
}
/// <summary>
/// 根据用户Id获取所在片区的Id
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet("/houseZone/getByUser")]
public async Task<string> GetZoneByUser([FromQuery][Required(ErrorMessage = "用户Id不能为空")] string userId)
{
var data = await _sysEmpRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == userId);
if(data == null) throw Oops.Oh("用户不在组织机构中");
var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == data.OrgId && p.Type == (int)OrgType.);
if(org == null) throw Oops.Oh("用户不在片区中");
return org.Id;
}
[HttpGet("/houseZone/autoIncrement")]
public async Task<dynamic> AutoIncrement([FromQuery] string roadId)
{
var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == roadId && p.Type == 3);
if (road == null) throw Oops.Oh("组织机构错误");
return await AutoIncrement(road);
}
[NonAction]
public async Task<dynamic> AutoIncrement(SysOrg road)
{
var maxZone = (await _sysOrgRep.DetachedEntities.Where(p => p.Pid == road.Id && p.Type == (int)OrgType.).MaxAsync(p => p.Code)) ?? "000";
return Convert.ToInt32(maxZone[^3..]) + 1;
}
[HttpPost("/houseZone/add")]
public async Task AddZone(AddHouseZoneInput input)
{
/*
* 区县市限定所属区域/上级机构是否为当前区
* 街道自动获取所属区域/上级机构
* 自动生成唯一编码, 街道Code+三位编号
*
* 机构类型默认为片区
*/
var org = await _userManager.GetUserOrgInfo();
var areaManager = Enum.GetName(HouseManagerRole.AreaManager).ToUnderScoreCase();
var roadManager = Enum.GetName(HouseManagerRole.RoadManager).ToUnderScoreCase();
var roles = await _userManager.GetUserRoleList();
if (roles.Any(p => p.Code == areaManager))
{
var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Pid);
if (!road.Pids.Contains(org.Id)) throw Oops.Oh("当前用户组织机构错误");
input.AreaCode = road.AreaCode;
input.Code = road.Code + (await AutoIncrement(road)).ToString().PadLeft(3, '0');
}
else if (roles.Any(p => p.Code == roadManager))
{
input.AreaCode = org.AreaCode;
input.Code = org.Code + (await AutoIncrement(org)).ToString().PadLeft(3, '0');
}
input.Type = (int)OrgType.;
AddOrgInput addOrgInput = input.Adapt<AddOrgInput>();
await _sysOrgService.AddOrg(addOrgInput);
}
[HttpPost("/houseZone/edit")]
public async Task EditZone(UpdateHouseZoneInput input)
{
var zone = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(z => z.Id == input.Id);
if(zone == null) throw Oops.Oh("修改失败:数据有误,刷新列表后再尝试修改");
zone.Remark = input.Remark;
await zone.UpdateIncludeAsync(new[] { nameof(SysOrg.Remark) }, true);
}
}
}

View File

@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service
{
public interface IHouseZoneService
{
Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input);
Task<string> GetZoneByUser([FromQuery] string userId);
}
}

View File

@@ -0,0 +1,30 @@
using Furion;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
namespace Ewide.Application
{
public class Startup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
//services.AddSqlSugar(new ConnectionConfig
//{
// ConnectionString = App.Configuration["ConnectionStrings:DefaultConnection"],
// DbType = DbType.Sqlite,
// IsAutoCloseConnection = true,
// InitKeyType = InitKeyType.Attribute
//},
//db =>
//{
// // db.DbMaintenance.CreateDatabase();
// // db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Test));
// db.Aop.OnLogExecuting = (sql, pars) =>
// {
// App.PrintToMiniProfiler("SqlSugar", "Info", sql + "\r\n" + string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value)));
// };
//});
}
}
}

View File

@@ -0,0 +1,3 @@
{
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Core.Attributes
{
public class OpAttribute : Attribute
{
private readonly LogOpType logOpType;
public OpAttribute(LogOpType logOpType)
{
this.logOpType = logOpType;
}
public int OpType { get => (int)logOpType; }
}
}

View File

@@ -0,0 +1,33 @@
using Furion.ConfigurableOptions;
namespace Ewide.Core
{
/// <summary>
/// 缓存配置
/// </summary>
public class CacheOptions : IConfigurableOptions
{
/// <summary>
/// 缓存类型
/// </summary>
public CacheType CacheType { get; set; }
/// <summary>
/// Redis配置
/// </summary>
public string RedisConnectionString { get; set; }
}
public enum CacheType
{
/// <summary>
/// 内存缓存
/// </summary>
MemoryCache,
/// <summary>
/// Redis缓存
/// </summary>
RedisCache
}
}

View File

@@ -0,0 +1,107 @@
using System;
using System.Threading.Tasks;
namespace Ewide.Core
{
/// <summary>
/// 缓存接口
/// </summary>
public interface ICache
{
/// <summary>
/// 用于在 key 存在时删除 key
/// </summary>
/// <param name="key">键</param>
long Del(params string[] key);
/// <summary>
/// 用于在 key 存在时删除 key
/// </summary>
/// <param name="key">键</param>
/// <returns></returns>
Task<long> DelAsync(params string[] key);
/// <summary>
/// 用于在 key 模板存在时删除
/// </summary>
/// <param name="pattern">key模板</param>
/// <returns></returns>
Task<long> DelByPatternAsync(string pattern);
/// <summary>
/// 检查给定 key 是否存在
/// </summary>
/// <param name="key">键</param>
/// <returns></returns>
bool Exists(string key);
/// <summary>
/// 检查给定 key 是否存在
/// </summary>
/// <param name="key">键</param>
/// <returns></returns>
Task<bool> ExistsAsync(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <param name="key">键</param>
/// <returns></returns>
string Get(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <typeparam name="T">byte[] 或其他类型</typeparam>
/// <param name="key">键</param>
/// <returns></returns>
T Get<T>(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <param name="key">键</param>
/// <returns></returns>
Task<string> GetAsync(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <typeparam name="T">byte[] 或其他类型</typeparam>
/// <param name="key">键</param>
/// <returns></returns>
Task<T> GetAsync<T>(string key);
/// <summary>
/// 设置指定 key 的值所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
bool Set(string key, object value);
/// <summary>
/// 设置指定 key 的值所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="expire">有效期</param>
bool Set(string key, object value, TimeSpan expire);
/// <summary>
/// 设置指定 key 的值所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns></returns>
Task<bool> SetAsync(string key, object value);
/// <summary>
/// 设置指定 key 的值所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="expire">有效期</param>
/// <returns></returns>
Task<bool> SetAsync(string key, object value, TimeSpan expire);
}
}

View File

@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Furion.DependencyInjection;
using Microsoft.Extensions.Caching.Memory;
namespace Ewide.Core
{
/// <summary>
/// 内存缓存
/// </summary>
public class MemoryCache : ICache, ISingleton
{
private readonly IMemoryCache _memoryCache;
public MemoryCache(IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
}
public long Del(params string[] key)
{
foreach (var k in key)
{
_memoryCache.Remove(k);
}
return key.Length;
}
public Task<long> DelAsync(params string[] key)
{
foreach (var k in key)
{
_memoryCache.Remove(k);
}
return Task.FromResult((long)key.Length);
}
public async Task<long> DelByPatternAsync(string pattern)
{
if (string.IsNullOrEmpty(pattern))
return default;
//pattern = Regex.Replace(pattern, @"\{*.\}", "(.*)");
var keys = GetAllKeys().Where(k => k.StartsWith(pattern));
if (keys != null && keys.Any())
return await DelAsync(keys.ToArray());
return default;
}
public bool Exists(string key)
{
return _memoryCache.TryGetValue(key, out _);
}
public Task<bool> ExistsAsync(string key)
{
return Task.FromResult(_memoryCache.TryGetValue(key, out _));
}
public string Get(string key)
{
return _memoryCache.Get(key)?.ToString();
}
public T Get<T>(string key)
{
return _memoryCache.Get<T>(key);
}
public Task<string> GetAsync(string key)
{
return Task.FromResult(Get(key));
}
public Task<T> GetAsync<T>(string key)
{
return Task.FromResult(Get<T>(key));
}
public bool Set(string key, object value)
{
_memoryCache.Set(key, value);
return true;
}
public bool Set(string key, object value, TimeSpan expire)
{
_memoryCache.Set(key, value, expire);
return true;
}
public Task<bool> SetAsync(string key, object value)
{
Set(key, value);
return Task.FromResult(true);
}
public Task<bool> SetAsync(string key, object value, TimeSpan expire)
{
Set(key, value, expire);
return Task.FromResult(true);
}
private List<string> GetAllKeys()
{
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
var entries = _memoryCache.GetType().GetField("_entries", flags).GetValue(_memoryCache);
var cacheItems = entries.GetType().GetProperty("Keys").GetValue(entries) as ICollection<object>; //entries as IDictionary;
var keys = new List<string>();
if (cacheItems == null) return keys;
return cacheItems.Select(u => u.ToString()).ToList();
//foreach (DictionaryEntry cacheItem in cacheItems)
//{
// keys.Add(cacheItem.Key.ToString());
//}
//return keys;
}
}
}

View File

@@ -0,0 +1,95 @@
using Furion.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Ewide.Core
{
/// <summary>
/// Redis缓存
/// </summary>
public class RedisCache : ICache, ISingleton
{
public RedisCache(IOptions<CacheOptions> cacheOptions)
{
var csredis = new CSRedis.CSRedisClient(cacheOptions.Value.RedisConnectionString);
RedisHelper.Initialization(csredis);
}
public long Del(params string[] key)
{
return RedisHelper.Del(key);
}
public Task<long> DelAsync(params string[] key)
{
return RedisHelper.DelAsync(key);
}
public async Task<long> DelByPatternAsync(string pattern)
{
if (string.IsNullOrEmpty(pattern))
return default;
//pattern = Regex.Replace(pattern, @"\{.*\}", "*");
var keys = (await RedisHelper.KeysAsync(pattern));
if (keys != null && keys.Length > 0)
{
return await RedisHelper.DelAsync(keys);
}
return default;
}
public bool Exists(string key)
{
return RedisHelper.Exists(key);
}
public Task<bool> ExistsAsync(string key)
{
return RedisHelper.ExistsAsync(key);
}
public string Get(string key)
{
return RedisHelper.Get(key);
}
public T Get<T>(string key)
{
return RedisHelper.Get<T>(key);
}
public Task<string> GetAsync(string key)
{
return RedisHelper.GetAsync(key);
}
public Task<T> GetAsync<T>(string key)
{
return RedisHelper.GetAsync<T>(key);
}
public bool Set(string key, object value)
{
return RedisHelper.Set(key, value);
}
public bool Set(string key, object value, TimeSpan expire)
{
return RedisHelper.Set(key, value, expire);
}
public Task<bool> SetAsync(string key, object value)
{
return RedisHelper.SetAsync(key, value);
}
public Task<bool> SetAsync(string key, object value, TimeSpan expire)
{
return RedisHelper.SetAsync(key, value, expire);
}
}
}

View File

@@ -0,0 +1,227 @@
using Furion;
using Furion.DependencyInjection;
using Furion.DistributedIDGenerator;
using Furion.JsonSerialization;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
namespace Ewide.Core
{
/// <summary>
/// 点选验证码
/// </summary>
public class ClickWordCaptcha : IClickWordCaptcha, ITransient
{
private readonly IMemoryCache _memoryCache;
public ClickWordCaptcha(IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
}
/// <summary>
/// 生成验证码图片
/// </summary>
/// <param name="code"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public ClickWordCaptchaResult CreateCaptchaImage(string code, int width, int height)
{
var rtnResult = new ClickWordCaptchaResult();
// 变化点: 3个字
int rightCodeLength = 3;
Bitmap bitmap = null;
Graphics g = null;
MemoryStream ms = null;
Random random = new Random();
Color[] colorArray = { Color.Black, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple };
string bgImagesDir = Path.Combine(App.WebHostEnvironment.WebRootPath, "Captcha/Image");
string[] bgImagesFiles = Directory.GetFiles(bgImagesDir);
//if (bgImagesFiles == null || bgImagesFiles.Length == 0)
// throw Oops.Oh("背景图片文件丢失");
// 字体来自https://www.zcool.com.cn/special/zcoolfonts/
string fontsDir = Path.Combine(App.WebHostEnvironment.WebRootPath, "Captcha/Font");
string[] fontFiles = new DirectoryInfo(fontsDir)?.GetFiles()
?.Where(m => m.Extension.ToLower() == ".ttf")
?.Select(m => m.FullName).ToArray();
//if (fontFiles == null || fontFiles.Length == 0)
// throw Oops.Oh("字体文件丢失");
int imgIndex = random.Next(bgImagesFiles.Length);
string randomImgFile = bgImagesFiles[imgIndex];
var imageStream = Image.FromFile(randomImgFile);
bitmap = new Bitmap(imageStream, width, height);
imageStream.Dispose();
g = Graphics.FromImage(bitmap);
Color[] penColor = { Color.Red, Color.Green, Color.Blue };
int code_length = code.Length;
List<string> words = new List<string>();
for (int i = 0; i < code_length; i++)
{
int colorIndex = random.Next(colorArray.Length);
int fontIndex = random.Next(fontFiles.Length);
Font f = LoadFont(fontFiles[fontIndex], 15, FontStyle.Regular);
Brush b = new SolidBrush(colorArray[colorIndex]);
int _y = random.Next(height);
if (_y > (height - 30))
_y = _y - 60;
int _x = width / (i + 1);
if ((width - _x) < 50)
{
_x = width - 60;
}
string word = code.Substring(i, 1);
if (rtnResult.repData.point.Count < rightCodeLength)
{
// (int, int) percentPos = ToPercentPos((width, height), (_x, _y));
// 添加正确答案 位置数据
rtnResult.repData.point.Add(new PointPosModel()
{
X = _x, //percentPos.Item1,
Y = _y //percentPos.Item2,
});
words.Add(word);
}
g.DrawString(word, f, b, _x, _y);
}
rtnResult.repData.wordList = words;
ms = new MemoryStream();
bitmap.Save(ms, ImageFormat.Jpeg);
g.Dispose();
bitmap.Dispose();
ms.Dispose();
rtnResult.repData.originalImageBase64 = Convert.ToBase64String(ms.GetBuffer()); //"data:image/jpg;base64," +
rtnResult.repData.token = IDGen.NextID().ToString();
// 缓存验证码正确位置集合
var cacheOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(30));
_memoryCache.Set(CommonConst.CACHE_KEY_CODE + rtnResult.repData.token, rtnResult.repData.point, cacheOptions);
rtnResult.repData.point = null; // 清空位置信息
return rtnResult;
}
/// <summary>
/// 转换为相对于图片的百分比单位
/// </summary>
/// <param name="widthAndHeight">图片宽高</param>
/// <param name="xAndy">相对于图片的绝对尺寸</param>
/// <returns>(int:xPercent, int:yPercent)</returns>
private (int, int) ToPercentPos((int, int) widthAndHeight, (int, int) xAndy)
{
(int, int) rtnResult = (0, 0);
// 注意: int / int = int (小数部分会被截断)
rtnResult.Item1 = (int)(((double)xAndy.Item1) / ((double)widthAndHeight.Item1) * 100);
rtnResult.Item2 = (int)(((double)xAndy.Item2) / ((double)widthAndHeight.Item2) * 100);
return rtnResult;
}
/// <summary>
/// 加载字体
/// </summary>
/// <param name="path">字体文件路径,包含字体文件名和后缀名</param>
/// <param name="size">大小</param>
/// <param name="fontStyle">字形(常规/粗体/斜体/粗斜体)</param>
private Font LoadFont(string path, int size, FontStyle fontStyle)
{
var pfc = new System.Drawing.Text.PrivateFontCollection();
pfc.AddFontFile(path);// 字体文件路径
Font myFont = new Font(pfc.Families[0], size, fontStyle);
return myFont;
}
/// <summary>
/// 随机绘制字符串
/// </summary>
/// <param name="number"></param>
/// <returns></returns>
public string RandomCode(int number)
{
var str = "左怀军天地玄黄宇宙洪荒日月盈昃辰宿列张寒来暑往秋收冬藏闰余成岁律吕调阳云腾致雨露结为霜金生丽水玉出昆冈剑号巨阙珠称夜光果珍李柰菜重芥姜海咸河淡鳞潜羽翔龙师火帝鸟官人皇始制文字乃服衣裳推位让国有虞陶唐吊民伐罪周发殷汤坐朝问道垂拱平章爱育黎首臣伏戎羌遐迩体率宾归王";
char[] str_char_arrary = str.ToArray();
Random rand = new Random();
HashSet<string> hs = new HashSet<string>();
bool randomBool = true;
while (randomBool)
{
if (hs.Count == number)
break;
int rand_number = rand.Next(str_char_arrary.Length);
hs.Add(str_char_arrary[rand_number].ToString());
}
return string.Join("", hs);
}
/// <summary>
/// 验证码验证
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public dynamic CheckCode(ClickWordCaptchaInput input)
{
var res = new ClickWordCaptchaResult();
var rightVCodePos = _memoryCache.Get(CommonConst.CACHE_KEY_CODE + input.Token) as List<PointPosModel>;
if (rightVCodePos == null)
{
res.repCode = "6110";
res.repMsg = "验证码已失效,请重新获取";
return res;
}
var userVCodePos = JSON.GetJsonSerializer().Deserialize<List<PointPosModel>>(input.PointJson);
if (userVCodePos == null || userVCodePos.Count < rightVCodePos.Count)
{
res.repCode = "6111";
res.repMsg = "验证码无效";
return res;
}
int allowOffset = 20; // 允许的偏移量(点触容错)
for (int i = 0; i < userVCodePos.Count; i++)
{
var xOffset = userVCodePos[i].X - rightVCodePos[i].X;
var yOffset = userVCodePos[i].Y - rightVCodePos[i].Y;
xOffset = Math.Abs(xOffset); // x轴偏移量
yOffset = Math.Abs(yOffset); // y轴偏移量
// 只要有一个点的任意一个轴偏移量大于allowOffset则验证不通过
if (xOffset > allowOffset || yOffset > allowOffset)
{
res.repCode = "6112";
res.repMsg = "验证码错误";
return res;
}
}
_memoryCache.Remove(CommonConst.CACHE_KEY_CODE + input.Token);
res.repCode = "0000";
res.repMsg = "验证成功";
return res;
}
}
/// <summary>
/// 记录正确位置
/// </summary>
public class PointPosModel
{
public int X { get; set; }
public int Y { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
using Furion.DependencyInjection;
using System.ComponentModel.DataAnnotations;
namespace Ewide.Core
{
/// <summary>
/// 点击验证码输入参数
/// </summary>
[SuppressSniffer]
public class ClickWordCaptchaInput
{
/// <summary>
/// 验证码类型
/// </summary>
[Required(ErrorMessage = "验证码类型")]
public string CaptchaType { get; set; }
/// <summary>
/// 坐标点集合
/// </summary>
[Required(ErrorMessage = "坐标点集合不能为空")]
public string PointJson { get; set; }
/// <summary>
/// Token
/// </summary>
public string Token { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using Furion.DependencyInjection;
using System.Collections.Generic;
namespace Ewide.Core
{
/// <summary>
/// 验证码输出参数
/// </summary>
[SuppressSniffer]
public class ClickWordCaptchaResult
{
public string repCode { get; set; } = "0000";
public string repMsg { get; set; }
public RepData repData { get; set; } = new RepData();
public bool error { get; set; }
public bool success { get; set; } = true;
}
[SuppressSniffer]
public class RepData
{
public string captchaId { get; set; }
public string projectCode { get; set; }
public string captchaType { get; set; }
public string captchaOriginalPath { get; set; }
public string captchaFontType { get; set; }
public string captchaFontSize { get; set; }
public string secretKey { get; set; }
public string originalImageBase64 { get; set; }
public List<PointPosModel> point { get; set; } = new List<PointPosModel>();
public string jigsawImageBase64 { get; set; }
public List<string> wordList { get; set; } = new List<string>();
public string pointList { get; set; }
public string pointJson { get; set; }
public string token { get; set; }
public bool result { get; set; }
public string captchaVerification { get; set; }
}
[SuppressSniffer]
public class WordList
{
}
}

View File

@@ -0,0 +1,9 @@
namespace Ewide.Core
{
public interface IClickWordCaptcha
{
dynamic CheckCode(ClickWordCaptchaInput input);
ClickWordCaptchaResult CreateCaptchaImage(string code, int width, int height);
string RandomCode(int number);
}
}

View File

@@ -0,0 +1,130 @@
using Furion.DependencyInjection;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
namespace Ewide.Core
{
/// <summary>
/// 常规验证码
/// </summary>
public class GeneralCaptcha : IGeneralCaptcha, ITransient
{
private readonly IMemoryCache _memoryCache;
public GeneralCaptcha(IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
}
/// <summary>
/// 生成验证码图片
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
public string CreateCaptchaImage(int length = 4)
{
return Convert.ToBase64String(Draw(length));
}
private string GenerateRandom(int length)
{
var chars = new StringBuilder();
// 验证码的字符集,去掉了一些容易混淆的字符
char[] character = { '2', '3', '4', '5', '6', '8', '9', 'a', 'b', 'd', 'e', 'f', 'h', 'k', 'm', 'n', 'r', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };
Random rnd = new Random();
// 生成验证码字符串
for (int i = 0; i < length; i++)
{
chars.Append(character[rnd.Next(character.Length)]);
}
return chars.ToString();
}
private byte[] Draw(int length = 4)
{
int codeW = 110;
int codeH = 36;
int fontSize = 22;
// 颜色列表,用于验证码、噪线、噪点
Color[] color = { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Brown, Color.Brown, Color.DarkBlue };
// 字体列表,用于验证码
string[] fonts = new[] { "Times New Roman", "Verdana", "Arial", "Gungsuh", "Impact" };
var code = GenerateRandom(length); // 随机字符串集合
using (Bitmap bmp = new Bitmap(codeW, codeH))
using (Graphics g = Graphics.FromImage(bmp))
using (MemoryStream ms = new MemoryStream())
{
g.Clear(Color.White);
Random rnd = new Random();
// 画噪线
for (int i = 0; i < 1; i++)
{
int x1 = rnd.Next(codeW);
int y1 = rnd.Next(codeH);
int x2 = rnd.Next(codeW);
int y2 = rnd.Next(codeH);
var clr = color[rnd.Next(color.Length)];
g.DrawLine(new Pen(clr), x1, y1, x2, y2);
}
// 画验证码字符串
string fnt;
Font ft;
for (int i = 0; i < code.Length; i++)
{
fnt = fonts[rnd.Next(fonts.Length)];
ft = new Font(fnt, fontSize);
var clr = color[rnd.Next(color.Length)];
g.DrawString(code[i].ToString(), ft, new SolidBrush(clr), (float)i * 24 + 2, (float)0);
}
// 缓存验证码正确集合
var cacheOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(30));
_memoryCache.Set(CommonConst.CACHE_KEY_CODE + Guid.NewGuid().ToString("N"), code, cacheOptions);
// 将验证码图片写入内存流
bmp.Save(ms, ImageFormat.Png);
return ms.ToArray();
}
}
/// <summary>
/// 验证码验证
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public dynamic CheckCode(GeneralCaptchaInput input)
{
var res = new ClickWordCaptchaResult();
var code = _memoryCache.Get(CommonConst.CACHE_KEY_CODE + input.Token);
if (code == null)
{
res.repCode = "6110";
res.repMsg = "验证码已失效,请重新获取";
return res;
}
if (input.CaptchaCode != (string)code)
{
res.repCode = "6112";
res.repMsg = "验证码错误";
return res;
}
_memoryCache.Remove(CommonConst.CACHE_KEY_CODE + input.Token);
res.repCode = "0000";
res.repMsg = "验证成功";
return res;
}
}
}

View File

@@ -0,0 +1,29 @@
using Furion.DependencyInjection;
using System.ComponentModel.DataAnnotations;
namespace Ewide.Core
{
/// <summary>
/// 常规验证码输入
/// </summary>
[SuppressSniffer]
public class GeneralCaptchaInput
{
/// <summary>
/// 验证码类型
/// </summary>
[Required(ErrorMessage = "验证码类型")]
public string CaptchaType { get; set; }
/// <summary>
/// 验证码字符
/// </summary>
[Required(ErrorMessage = "验证码字符不能为空")]
public string CaptchaCode { get; set; }
/// <summary>
/// Token
/// </summary>
public string Token { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Ewide.Core
{
public interface IGeneralCaptcha
{
dynamic CheckCode(GeneralCaptchaInput input);
string CreateCaptchaImage(int length = 4);
}
}

View File

@@ -0,0 +1,26 @@
namespace Ewide.Core
{
public class ClaimConst
{
/// <summary>
/// 用户Id
/// </summary>
public const string CLAINM_USERID = "UserId";
/// <summary>
/// 账号
/// </summary>
public const string CLAINM_ACCOUNT = "Account";
/// <summary>
/// 名称
/// </summary>
public const string CLAINM_NAME = "Name";
/// <summary>
/// 是否超级管理
/// </summary>
public const string CLAINM_SUPERADMIN = "SuperAdmin";
}
}

View File

@@ -0,0 +1,49 @@
namespace Ewide.Core
{
public class CommonConst
{
/// <summary>
/// 默认密码
/// </summary>
public const string DEFAULT_PASSWORD = "123456";
/// <summary>
/// 用户缓存
/// </summary>
public const string CACHE_KEY_USER = "user_";
/// <summary>
/// 菜单缓存
/// </summary>
public const string CACHE_KEY_MENU = "menu_";
/// <summary>
/// 权限缓存
/// </summary>
public const string CACHE_KEY_PERMISSION = "permission_";
/// <summary>
/// 数据范围缓存
/// </summary>
public const string CACHE_KEY_DATASCOPE = "datascope_";
/// <summary>
/// 验证码缓存
/// </summary>
public const string CACHE_KEY_CODE = "vercode_";
/// <summary>
/// 区域缓存
/// </summary>
public const string CACHE_AREA_CODE = "areaCode";
/// <summary>
/// 所有缓存关键字集合
/// </summary>
public const string CACHE_KEY_ALL = "allkey";
/// <summary>
/// 定时任务缓存
/// </summary>
public const string CACHE_KEY_TIMER_JOB = "timerjob";
}
}

View File

@@ -0,0 +1,91 @@
using Ewide.Core.Service;
using Ewide.Core.Service.Area;
using Ewide.Core.Service.Area.Dto;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Core.Controller
{
/// <summary>
/// 区域代码相关服务
/// </summary>
[ApiDescriptionSettings(Name = "AreaCode", Order = 160)]
public class AreaCodeController : IDynamicApiController
{
private readonly IAreaCodeService _areaCodeService;
private readonly IUserManager _userManager;
private readonly ISysUserService _sysUserService;
public AreaCodeController(IAreaCodeService areaCodeService, IUserManager userManager, ISysUserService sysUserService)
{
_areaCodeService = areaCodeService;
_userManager = userManager;
_sysUserService = sysUserService;
}
/// <summary>
/// 查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/sysArea/page")]
public async Task<dynamic> QueryAreaCodePageList([FromBody] AreaCodeInput input)
{
return (await _areaCodeService.QueryAreaCodePageList(input));
}
/// <summary>
///
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet("/sysArea/{code}")]
public async Task<AreaCodeOutput> GetAreaCode([FromRoute]string code)
{
return (await _areaCodeService.GetAreaCode(code)).Adapt<AreaCodeOutput>();
}
/// <summary>
/// 添加区域信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/sysArea/add")]
public async Task AddAreaCode(AreaCodeInput input)
{
await _areaCodeService.AddAreaCode(input);
}
/// <summary>
/// 更新区域信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/sysArea/edit")]
public async Task UpdateAreaCode(AreaCodeInput input)
{
await _areaCodeService.UpdateAreaCode(input);
}
/// <summary>
/// 删除区域
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/sysArea/delete")]
public async Task DeleteAreaCode(DeleteAreaCodeInput input)
{
await _areaCodeService.DeleteAreaCode(input);
}
/// <summary>
/// 获取目录树
/// </summary>
/// <returns></returns>
[HttpGet("/sysArea/tree")]
public async Task<List<AreaTreeNode>> GetAreaCodeTree([FromQuery]int? level)
{
return await _areaCodeService.GetAreaCodeTree(level);
}
}
}

View File

@@ -0,0 +1,72 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 自定义实体基类
/// </summary>
public abstract class DEntityBase : IEntity
{
/// <summary>
/// 主键Id
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Comment("Id主键")]
[Column("Id", TypeName = "varchar(36)")]
public virtual string Id { get; set; } = String.Empty;
/// <summary>
/// 创建时间
/// </summary>
[Comment("创建时间")]
public virtual DateTime? CreatedTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Comment("更新时间")]
public virtual DateTime? UpdatedTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
[Comment("创建者Id")]
[Column("CreatedUserId", TypeName = "varchar(36)")]
public virtual string CreatedUserId { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
[Comment("创建者名称")]
[MaxLength(20)]
public virtual string CreatedUserName { get; set; }
/// <summary>
/// 修改者Id
/// </summary>
[Comment("修改者Id")]
[Column("UpdatedUserId", TypeName = "varchar(36)")]
public virtual string UpdatedUserId { get; set; }
/// <summary>
/// 修改者名称
/// </summary>
[Comment("修改者名称")]
[MaxLength(20)]
public virtual string UpdatedUserName { get; set; }
/// <summary>
/// 软删除
/// </summary>
[JsonIgnore]
[Comment("软删除标记")]
[Column("IsDeleted", TypeName = "bit")]
public virtual bool IsDeleted { get; set; } = false;
}
}

View File

@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 系统应用表
/// </summary>
[Table("sys_app")]
[Comment("系统应用表")]
public class SysApp : DEntityBase
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 图标
/// </summary>
[Comment("图标")]
public string Icon { get; set; }
/// <summary>
/// 图标颜色
/// </summary>
[Comment("图标颜色")]
public string Color { get; set; }
/// <summary>
/// 是否默认激活Y-是N-否),只能有一个系统默认激活
/// 用户登录后默认展示此系统菜单
/// </summary>
[Comment("是否默认激活")]
[Column("Active", TypeName = "bit")]
public bool Active { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
}
}

View File

@@ -0,0 +1,83 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace Ewide.Core
{
[Table("sys_area_code")]
[Comment("区域表")]
public class SysAreaCode: IEntity
{
[Key]
[Comment("系统使用的区域编码")]
[MaxLength(50)]
public string Code { get; set; }
[Comment("区域的行政编码")]
[MaxLength(50)]
public string AdCode { get; set; }
[Comment("名称")]
[Required]
[MaxLength(100)]
public string Name { get; set; }
[Comment("备注")]
[MaxLength(1000)]
public string Note { get; set; }
[Comment("类别")]
[Required]
public int LevelType { get; set; }
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 父节点就是去掉后面两位
/// </summary>
public string ParentCode => LevelType switch
{
// 市级 => 没有父级 3302
1 => string.Empty,
// 区级 => 6位取4位得到市级 330201
2 => Code[0..(Code.Length - 2)],
// 其他 => 去除后3位得到上级 330201001
_ => Code[0..(Code.Length - 3)],
};
/// <summary>
/// 多个区域有多个用户绑定自定义数据
/// </summary>
[XmlIgnore]
public ICollection<SysUser> SysUsers { get; set; }
/// <summary>
/// 中间表
/// </summary>
[XmlIgnore]
public List<SysUserArea> SysUserAreas { get; set; }
/// <summary>
/// 多个区域有多个角色绑定权限数据
/// </summary>
[XmlIgnore]
public ICollection<SysRole> SysRoles { get; set; }
/// <summary>
/// 中间表
/// </summary>
[XmlIgnore]
public List<SysRoleArea> SysRoleAreas { get; set; }
/// <summary>
/// 一个区域有多个组织
/// </summary>
[XmlIgnore]
public ICollection<SysOrg> SysOrgs { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 代码生成表
/// </summary>
[Table("sys_code_gen")]
[Comment("代码生成表")]
public class SysCodeGen : DEntityBase
{
/// <summary>
/// 作者姓名
/// </summary>
[Comment("作者姓名")]
public string AuthorName { get; set; }
/// <summary>
/// 是否移除表前缀
/// </summary>
[Comment("是否移除表前缀")]
public string TablePrefix { get; set; }
/// <summary>
/// 生成方式
/// </summary>
[Comment("生成方式")]
public string GenerateType { get; set; }
/// <summary>
/// 数据库表名
/// </summary>
[Comment("数据库表名")]
public string TableName { get; set; }
/// <summary>
/// 命名空间
/// </summary>
[Comment("命名空间")]
public string NameSpace { get; set; }
/// <summary>
/// 业务名
/// </summary>
[Comment("业务名")]
public string BusName { get; set; }
}
}

View File

@@ -0,0 +1,104 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 代码生成字段配置表
/// </summary>
[Table("sys_code_gen_config")]
[Comment("代码生成字段配置表")]
public class SysCodeGenConfig : DEntityBase
{
/// <summary>
/// 代码生成主表ID
/// </summary>
[Comment("代码生成主表ID")]
[Column("CodeGenId", TypeName = "varchar(36)")]
public string CodeGenId { get; set; }
/// <summary>
/// 数据库字段名
/// </summary>
[Comment("数据库字段名")]
public string ColumnName { get; set; }
/// <summary>
/// 字段描述
/// </summary>
[Comment("字段描述")]
public string ColumnComment { get; set; }
/// <summary>
/// .NET数据类型
/// </summary>
[Comment(".NET数据类型")]
public string NetType { get; set; }
/// <summary>
/// 作用类型(字典)
/// </summary>
[Comment("作用类型")]
public string EffectType { get; set; }
/// <summary>
/// 字典code
/// </summary>
[Comment("字典Code")]
public string DictTypeCode { get; set; }
/// <summary>
/// 列表是否缩进(字典)
/// </summary>
[Comment("列表是否缩进")]
public string WhetherRetract { get; set; }
/// <summary>
/// 是否必填(字典)
/// </summary>
[Comment("是否必填")]
public string WhetherRequired { get; set; }
/// <summary>
/// 是否是查询条件
/// </summary>
[Comment("是否是查询条件")]
public string QueryWhether { get; set; }
/// <summary>
/// 查询方式
/// </summary>
[Comment("查询方式")]
public string QueryType { get; set; }
/// <summary>
/// 列表显示
/// </summary>
[Comment("列表显示")]
public string WhetherTable { get; set; }
/// <summary>
/// 增改
/// </summary>
[Comment("增改")]
public string WhetherAddUpdate { get; set; }
/// <summary>
/// 主外键
/// </summary>
[Comment("主外键")]
public string ColumnKey { get; set; }
/// <summary>
/// 数据库中类型(物理类型)
/// </summary>
[Comment("数据库中类型")]
public string DataType { get; set; }
/// <summary>
/// 是否通用字段
/// </summary>
[Comment("是否通用字段")]
public string WhetherCommon { get; set; }
}
}

View File

@@ -0,0 +1,73 @@
using Ewide.Core.Service;
using Furion;
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 参数配置表
/// </summary>
[Table("sys_config")]
[Comment("参数配置表")]
public class SysConfig : DEntityBase, IEntityChangedListener<SysConfig>
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 属性值
/// </summary>
[Comment("属性值")]
public string Value { get; set; }
/// <summary>
/// 是否是系统参数Y-是N-否)
/// </summary>
[Comment("是否是系统参数")]
public string SysFlag { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 常量所属分类的编码,来自于“常量的分类”字典
/// </summary>
[Comment("常量所属分类的编码")]
public string GroupCode { get; set; }
/// <summary>
/// 监听实体更改之后
/// </summary>
/// <param name="newEntity"></param>
/// <param name="oldEntity"></param>
/// <param name="dbContext"></param>
/// <param name="dbContextLocator"></param>
/// <param name="state"></param>
public void OnChanged(SysConfig newEntity, SysConfig oldEntity, DbContext dbContext, Type dbContextLocator, EntityState state)
{
// 刷新配置缓存
App.GetService<ISysConfigService>().UpdateConfigCache(newEntity.Code, newEntity.Value);
}
}
}

View File

@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 字典值表
/// </summary>
[Table("sys_dict_data")]
[Comment("字典值表")]
public class SysDictData : DEntityBase
{
/// <summary>
/// 字典类型Id
/// </summary>
[Comment("字典类型Id")]
[Column("TypeId", TypeName = "varchar(36)")]
public string TypeId { get; set; }
/// <summary>
/// 值
/// </summary>
[Comment("值")]
public string Value { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
[Comment("扩展编码以json形式存储")]
public string ExtCode { get; set; }
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 所属类型
/// </summary>
[XmlIgnore]
public SysDictType SysDictType { get; set; }
}
}

View File

@@ -0,0 +1,73 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 字典类型表
/// </summary>
[Table("sys_dict_type")]
[Comment("字典类型表")]
public class SysDictType : DEntityBase, IEntityTypeBuilder<SysDictType>
{
/// <summary>
/// 父Id
/// </summary>
[Comment("父Id")]
[Column("Pid", TypeName = "varchar(36)")]
public string Pid { get; set; }
/// <summary>
/// 父Ids
/// </summary>
[Comment("父Ids")]
public string Pids { get; set; }
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 字典数据
/// </summary>
[XmlIgnore]
public ICollection<SysDictData> SysDictDatas { get; set; }
public void Configure(EntityTypeBuilder<SysDictType> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasMany(x => x.SysDictDatas)
.WithOne(x => x.SysDictType)
.HasForeignKey(x => x.TypeId);
}
}
}

View File

@@ -0,0 +1,74 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 员工表
/// </summary>
[Table("sys_emp")]
[Comment("员工表")]
public class SysEmp : IEntity, IEntityTypeBuilder<SysEmp>
{
/// <summary>
/// 用户Id
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Comment("用户Id")]
[Column("Id", TypeName = "varchar(36)")]
public string Id { get; set; }
/// <summary>
/// 工号
/// </summary>
[Comment("工号")]
public string JobNum { get; set; }
/// <summary>
/// 机构Id
/// </summary>
[Comment("机构Id")]
[Column("OrgId", TypeName = "varchar(36)")]
public string OrgId { get; set; }
/// <summary>
/// 机构名称
/// </summary>
[Comment("机构名称")]
public string OrgName { get; set; }
/// <summary>
/// 多对多(职位)
/// </summary>
[XmlIgnore]
public ICollection<SysPos> SysPos { get; set; }
/// <summary>
/// 多对多中间表(员工-职位)
/// </summary>
[XmlIgnore]
public List<SysEmpPos> SysEmpPos { get; set; }
/// <summary>
/// 多对多配置关系
/// </summary>
/// <param name="entityBuilder"></param>
/// <param name="dbContext"></param>
/// <param name="dbContextLocator"></param>
public void Configure(EntityTypeBuilder<SysEmp> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasMany(p => p.SysPos).WithMany(p => p.SysEmps).UsingEntity<SysEmpPos>(
u => u.HasOne(c => c.SysPos).WithMany(c => c.SysEmpPos).HasForeignKey(c => c.SysPosId),
u => u.HasOne(c => c.SysEmp).WithMany(c => c.SysEmpPos).HasForeignKey(c => c.SysEmpId),
u =>
{
u.HasKey(c => new { c.SysEmpId, c.SysPosId });
});
}
}
}

View File

@@ -0,0 +1,74 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 员工附属机构职位表
/// </summary>
[Table("sys_emp_ext_org_pos")]
[Comment("员工附属机构职位表")]
public class SysEmpExtOrgPos : IEntity, IEntityTypeBuilder<SysEmpExtOrgPos>
{
/// <summary>
/// 员工Id
/// </summary>
[Comment("员工Id")]
[Column("SysEmpId", TypeName = "varchar(36)")]
public string SysEmpId { get; set; }
/// <summary>
/// 一对一引用(员工)
/// </summary>
[XmlIgnore]
public SysEmp SysEmp { get; set; }
/// <summary>
/// 机构Id
/// </summary>
[Comment("机构Id")]
[Column("SysOrgId", TypeName = "varchar(36)")]
public string SysOrgId { get; set; }
/// <summary>
/// 一对一引用(机构)
/// </summary>
[XmlIgnore]
public SysOrg SysOrg { get; set; }
/// <summary>
/// 职位Id
/// </summary>
[Comment("职位Id")]
[Column("SysPosId", TypeName = "varchar(36)")]
public string SysPosId { get; set; }
/// <summary>
/// 一对一引用(职位)
/// </summary>
[XmlIgnore]
public SysPos SysPos { get; set; }
public void Configure(EntityTypeBuilder<SysEmpExtOrgPos> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasKey(c => new { c.SysEmpId, c.SysOrgId, c.SysPosId });
}
//public IEnumerable<SysEmpExtOrgPos> HasData(DbContext dbContext, Type dbContextLocator)
//{
// return new[]
// {
// new SysEmpExtOrgPos { SysEmpId = "d0ead3dc-5096-4e15-bc6d-f640be5301ec", SysOrgId = "12d888de-f55d-4c88-b0a0-7c3510664d97", SysPosId = "269236c4-d74e-4e54-9d50-f6f61580a197" },
// new SysEmpExtOrgPos { SysEmpId = "d0ead3dc-5096-4e15-bc6d-f640be5301ec", SysOrgId = "8a2271d6-5bda-4544-bdd3-27e53a8b418e", SysPosId = "46c68a62-f119-4ff7-b621-0bbd77504538" },
// new SysEmpExtOrgPos { SysEmpId = "d0ead3dc-5096-4e15-bc6d-f640be5301ec", SysOrgId = "127c0a5d-43ac-4370-b313-082361885aca", SysPosId = "5bd8c466-2bca-4386-a551-daac78e3cee8" },
// new SysEmpExtOrgPos { SysEmpId = "d0ead3dc-5096-4e15-bc6d-f640be5301ec", SysOrgId = "f236ab2d-e1b5-4e9d-844f-a59ec32c20e4", SysPosId = "d89a3afe-e6ba-4018-bdae-3c98bb47ad66" },
// new SysEmpExtOrgPos { SysEmpId = "16a74726-e156-499f-9942-0e0e24ad0c3f", SysOrgId = "f236ab2d-e1b5-4e9d-844f-a59ec32c20e4", SysPosId = "269236c4-d74e-4e54-9d50-f6f61580a197" }
// };
//}
}
}

View File

@@ -0,0 +1,41 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 员工职位表
/// </summary>
[Table("sys_emp_pos")]
[Comment("员工职位表")]
public class SysEmpPos : IEntity
{
/// <summary>
/// 员工Id
/// </summary>
[Comment("员工Id")]
[Column("SysEmpId", TypeName = "varchar(36)")]
public string SysEmpId { get; set; }
/// <summary>
/// 一对一引用(员工)
/// </summary>
[XmlIgnore]
public SysEmp SysEmp { get; set; }
/// <summary>
/// 职位Id
/// </summary>
[Comment("职位Id")]
[Column("SysPosId", TypeName = "varchar(36)")]
public string SysPosId { get; set; }
/// <summary>
/// 一对一引用(职位)
/// </summary>
[XmlIgnore]
public SysPos SysPos { get; set; }
}
}

View File

@@ -0,0 +1,61 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 文件信息表
/// </summary>
[Table("sys_file")]
[Comment("文件信息表")]
public class SysFile : DEntityBase
{
/// <summary>
/// 文件存储位置1:阿里云2:腾讯云3:minio4:本地)
/// </summary>
[Comment("文件存储位置")]
public int FileLocation { get; set; }
/// <summary>
/// 文件仓库
/// </summary>
[Comment("文件仓库")]
public string FileBucket { get; set; }
/// <summary>
/// 文件名称(上传时候的文件名)
/// </summary>
[Comment("文件名称")]
public string FileOriginName { get; set; }
/// <summary>
/// 文件后缀
/// </summary>
[Comment("文件后缀")]
public string FileSuffix { get; set; }
/// <summary>
/// 文件大小kb
/// </summary>
[Comment("文件大小kb")]
public long FileSizeKb { get; set; }
/// <summary>
/// 文件大小信息,计算后的
/// </summary>
[Comment("文件大小信息")]
public string FileSizeInfo { get; set; }
/// <summary>
/// 存储到bucket的名称文件唯一标识id
/// </summary>
[Comment("存储到bucket的名称")]
public string FileObjectName { get; set; }
/// <summary>
/// 存储路径
/// </summary>
[Comment("存储路径")]
public string FilePath { get; set; }
}
}

View File

@@ -0,0 +1,64 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 系统操作/审计日志表
/// </summary>
[Table("sys_log_audit")]
[Comment("审计日志表")]
public class SysLogAudit : EntityBase
{
/// <summary>
/// 表名
/// </summary>
[Comment("表名")]
public string TableName { get; set; }
/// <summary>
/// 列名
/// </summary>
[Comment("列名")]
public string ColumnName { get; set; }
/// <summary>
/// 新值
/// </summary>
[Comment("新值")]
public string NewValue { get; set; }
/// <summary>
/// 旧值
/// </summary>
[Comment("旧值")]
public string OldValue { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[Comment("操作时间")]
public DateTime CreatedTime { get; set; }
/// <summary>
/// 操作人Id
/// </summary>
[Comment("操作人Id")]
[Column("UserId", TypeName = "varchar(36)")]
public string UserId { get; set; }
/// <summary>
/// 操作人名称
/// </summary>
[Comment("操作人名称")]
public string UserName { get; set; }
/// <summary>
/// 操作方式:新增、更新、删除
/// </summary>
[Comment("操作方式")]
public string Operate { get; set; }
}
}

View File

@@ -0,0 +1,117 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 操作日志表
/// </summary>
[Table("sys_log_op")]
[Comment("操作日志表")]
public class SysLogOp : EntityBase
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 操作类型0其他 1增加 2删除 3编辑见LogAnnotionOpTypeEnum
/// </summary>
[Comment("操作类型")]
public int? OpType { get; set; }
/// <summary>
/// 是否执行成功Y-是N-否)
/// </summary>
[Comment("是否执行成功")]
public bool? Success { get; set; }
/// <summary>
/// 具体消息
/// </summary>
[Comment("具体消息")]
public string Message { get; set; }
/// <summary>
/// IP
/// </summary>
[Comment("IP")]
public string Ip { get; set; }
/// <summary>
/// 地址
/// </summary>
[Comment("地址")]
public string Location { get; set; }
/// <summary>
/// 浏览器
/// </summary>
[Comment("浏览器")]
public string Browser { get; set; }
/// <summary>
/// 操作系统
/// </summary>
[Comment("操作系统")]
public string Os { get; set; }
/// <summary>
/// 请求地址
/// </summary>
[Comment("请求地址")]
public string Url { get; set; }
/// <summary>
/// 类名称
/// </summary>
[Comment("类名称")]
public string ClassName { get; set; }
/// <summary>
/// 方法名称
/// </summary>
[Comment("方法名称")]
public string MethodName { get; set; }
/// <summary>
/// 请求方式GET POST PUT DELETE)
/// </summary>
[Comment("请求方式")]
public string ReqMethod { get; set; }
/// <summary>
/// 请求参数
/// </summary>
[Comment("请求参数")]
public string Param { get; set; }
/// <summary>
/// 返回结果
/// </summary>
[Comment("返回结果")]
public string Result { get; set; }
/// <summary>
/// 耗时(毫秒)
/// </summary>
[Comment("耗时")]
public long ElapsedTime { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[Comment("操作时间")]
public DateTime OpTime { get; set; }
/// <summary>
/// 操作人
/// </summary>
[Comment("操作人")]
public string Account { get; set; }
}
}

View File

@@ -0,0 +1,75 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 访问日志表
/// </summary>
[Table("sys_log_vis")]
[Comment("访问日志表")]
public class SysLogVis : EntityBase
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 是否执行成功Y-是N-否)
/// </summary>
[Comment("是否执行成功")]
public bool Success { get; set; }
/// <summary>
/// 具体消息
/// </summary>
[Comment("具体消息")]
public string Message { get; set; }
/// <summary>
/// IP
/// </summary>
[Comment("IP")]
public string Ip { get; set; }
/// <summary>
/// 地址
/// </summary>
[Comment("地址")]
public string Location { get; set; }
/// <summary>
/// 浏览器
/// </summary>
[Comment("浏览器")]
public string Browser { get; set; }
/// <summary>
/// 操作系统
/// </summary>
[Comment("操作系统")]
public string Os { get; set; }
/// <summary>
/// 访问类型(字典 1登入 2登出
/// </summary>
[Comment("访问类型")]
public int? VisType { get; set; }
/// <summary>
/// 访问时间
/// </summary>
[Comment("访问时间")]
public DateTime VisTime { get; set; }
/// <summary>
/// 访问人
/// </summary>
[Comment("访问人")]
public string Account { get; set; }
}
}

View File

@@ -0,0 +1,142 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 菜单表
/// </summary>
[Table("sys_menu")]
[Comment("菜单表")]
public class SysMenu : DEntityBase
{
/// <summary>
/// 父Id
/// </summary>
[Comment("父Id")]
[Column("Pid", TypeName = "varchar(36)")]
public string Pid { get; set; }
/// <summary>
/// 父Ids
/// </summary>
[Comment("父Ids")]
public string Pids { get; set; }
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 菜单类型(字典 0目录 1菜单 2按钮
/// </summary>
[Comment("菜单类型")]
public int Type { get; set; }
/// <summary>
/// 图标
/// </summary>
[Comment("图标")]
public string Icon { get; set; }
/// <summary>
/// 路由地址
/// </summary>
[Comment("路由地址")]
public string Router { get; set; }
/// <summary>
/// 组件地址
/// </summary>
[Comment("组件地址")]
public string Component { get; set; }
/// <summary>
/// 权限标识
/// </summary>
[Comment("权限标识")]
public string Permission { get; set; }
/// <summary>
/// 应用分类(应用编码)
/// </summary>
[Comment("应用分类")]
public string Application { get; set; }
/// <summary>
/// 打开方式(字典 0无 1组件 2内链 3外链
/// </summary>
[Comment("打开方式")]
public int OpenType { get; set; } = 0;
/// <summary>
/// 是否可见Y-是N-否)
/// </summary>
[Comment("是否可见")]
[Column("Visible", TypeName = "bit")]
public bool Visible { get; set; } = true;
/// <summary>
/// 内链地址
/// </summary>
[Comment("内链地址")]
public string Link { get; set; }
/// <summary>
/// 重定向地址
/// </summary>
[Comment("重定向地址")]
public string Redirect { get; set; }
/// <summary>
/// 权重(字典 1系统权重 2业务权重
/// </summary>
[Comment("权重")]
public int Weight { get; set; } = 2;
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; } = 100;
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 关联上级菜单显示 0表示不需要关联菜单 1表示关联 仅按钮有效
/// </summary>
[Comment("关联菜单显示")]
[Column("VisibleParent", TypeName = "bit")]
public bool VisibleParent { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 多对多(角色)
/// </summary>
[XmlIgnore]
public ICollection<SysRole> SysRoles { get; set; }
/// <summary>
/// 多对多中间表(用户角色)
/// </summary>
[XmlIgnore]
public List<SysRoleMenu> SysRoleMenus { get; set; }
}
}

View File

@@ -0,0 +1,81 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 通知公告表
/// </summary>
[Table("sys_notice")]
[Comment("通知公告表")]
public class SysNotice : DEntityBase
{
/// <summary>
/// 标题
/// </summary>
[Comment("标题")]
public string Title { get; set; }
/// <summary>
/// 内容
/// </summary>
[Comment("内容")]
public string Content { get; set; }
/// <summary>
/// 类型(字典 1通知 2公告
/// </summary>
[Comment("类型")]
public int Type { get; set; }
/// <summary>
/// 发布人Id
/// </summary>
[Comment("发布人Id")]
[Column("PublicUserId", TypeName = "varchar(36)")]
public string PublicUserId { get; set; }
/// <summary>
/// 发布人姓名
/// </summary>
[Comment("发布人姓名")]
public string PublicUserName { get; set; }
/// <summary>
/// 发布机构Id
/// </summary>
[Comment("发布机构Id")]
[Column("PublicOrgId", TypeName = "varchar(36)")]
public string PublicOrgId { get; set; }
/// <summary>
/// 发布机构名称
/// </summary>
[Comment("发布机构名称")]
public string PublicOrgName { get; set; }
/// <summary>
/// 发布时间
/// </summary>
[Comment("发布时间")]
public DateTime? PublicTime { get; set; }
/// <summary>
/// 撤回时间
/// </summary>
[Comment("撤回时间")]
public DateTime? CancelTime { get; set; }
/// <summary>
/// 状态(字典 0草稿 1发布 2撤回 3删除
/// </summary>
[Comment("状态")]
public int Status { get; set; }
/// <summary>
/// 上传文件ids
/// </summary>
[Comment("上传文件id集合")]
public string Attachments { set; get; }
}
}

View File

@@ -0,0 +1,47 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// 通知公告用户表
/// </summary>
[Table("sys_notice_user")]
[Comment("通知公告用户表")]
public class SysNoticeUser : DEntityBase
{
/// <summary>
/// 通知公告Id
/// </summary>
[Comment("通知公告Id")]
[Column("NoticeId", TypeName = "varchar(36)")]
public string NoticeId { get; set; }
/// <summary>
/// 用户Id
/// </summary>
[Comment("用户Id")]
[Column("UserId", TypeName = "varchar(36)")]
public string UserId { get; set; }
/// <summary>
/// 阅读时间
/// </summary>
[Comment("阅读时间")]
public DateTime? ReadTime { get; set; }
/// <summary>
/// 状态(字典 0未读 1已读
/// </summary>
[Comment("状态")]
public int ReadStatus { get; set; }
public void Configure(EntityTypeBuilder<SysNoticeUser> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasNoKey();
}
}
}

View File

@@ -0,0 +1,85 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Core
{
/// <summary>
/// Oauth登录用户表
/// </summary>
[Table("sys_oauth_user")]
[Comment("Oauth登录用户表")]
public class SysOauthUser : DEntityBase
{
/// <summary>
/// 第三方平台的用户唯一Id
/// </summary>
[Comment("UUID")]
public string Uuid { get; set; }
/// <summary>
/// 用户授权的token
/// </summary>
[Comment("Token")]
public string AccessToken { get; set; }
/// <summary>
/// 昵称
/// </summary>
[Comment("昵称")]
public string NickName { get; set; }
/// <summary>
/// 头像
/// </summary>
[Comment("头像")]
public string Avatar { get; set; }
/// <summary>
/// 性别
/// </summary>
[Comment("性别")]
public string Gender { get; set; }
/// <summary>
/// 电话
/// </summary>
[Comment("电话")]
public string Phone { get; set; }
/// <summary>
/// 邮箱
/// </summary>
[Comment("邮箱")]
public string Email { get; set; }
/// <summary>
/// 位置
/// </summary>
[Comment("位置")]
public string Location { get; set; }
/// <summary>
/// 用户网址
/// </summary>
[Comment("用户网址")]
public string Blog { get; set; }
/// <summary>
/// 所在公司
/// </summary>
[Comment("所在公司")]
public string Company { get; set; }
/// <summary>
/// 用户来源
/// </summary>
[Comment("用户来源")]
public string Source { get; set; }
/// <summary>
/// 用户备注(各平台中的用户个人介绍)
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
}
}

View File

@@ -0,0 +1,112 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 组织机构表
/// </summary>
[Table("sys_org")]
[Comment("组织机构表")]
public class SysOrg : DEntityBase
{
/// <summary>
/// 父Id
/// </summary>
[Comment("父Id")]
[Column("Pid", TypeName = "varchar(36)")]
public string Pid { get; set; }
/// <summary>
/// 父Ids
/// </summary>
[Comment("Pids")]
public string Pids { get; set; }
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
[MaxLength(20)]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 机构类型
/// </summary>
[Comment("机构类型")]
public int Type { get; set; }
/// <summary>
/// 联系人
/// </summary>
[Comment("联系人")]
public string Contacts { get; set; }
/// <summary>
/// 电话
/// </summary>
[Comment("电话")]
public string Tel { get; set; }
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string AreaCode { get; set; }
/// <summary>
/// 一对一 一个组织对应一个区域代码
/// </summary>
[XmlIgnore]
public SysAreaCode Area { get; set; }
/// <summary>
/// 多对多(用户)
/// </summary>
[XmlIgnore]
public ICollection<SysUser> SysUsers { get; set; }
/// <summary>
/// 多对多中间表(用户数据范围)
/// </summary>
[XmlIgnore]
public List<SysUserDataScope> SysUserDataScopes { get; set; }
/// <summary>
/// 多对多(角色)
/// </summary>
[XmlIgnore]
public ICollection<SysRole> SysRoles { get; set; }
/// <summary>
/// 多对多中间表(角色数据范围)
/// </summary>
[XmlIgnore]
public List<SysRoleDataScope> SysRoleDataScopes { get; set; }
}
}

View File

@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 职位表
/// </summary>
[Table("sys_pos")]
[Comment("职位表")]
public class SysPos : DEntityBase
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 多对多(员工)
/// </summary>
[XmlIgnore]
public ICollection<SysEmp> SysEmps { get; set; }
/// <summary>
/// 多对多中间表(员工职位)
/// </summary>
[XmlIgnore]
public List<SysEmpPos> SysEmpPos { get; set; }
}
}

View File

@@ -0,0 +1,133 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
namespace Ewide.Core
{
/// <summary>
/// 角色表
/// </summary>
[Table("sys_role")]
[Comment("角色表")]
public class SysRole : DEntityBase, IEntityTypeBuilder<SysRole>
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 排序
/// </summary>
[Comment("排序")]
public int Sort { get; set; }
/// <summary>
/// 数据范围类型(字典 1全部数据 2本部门及以下数据 3本部门数据 4仅本人数据 5自定义数据
/// </summary>
[Comment("数据范围类型")]
public int DataScopeType { get; set; }
/// <summary>
/// 备注
/// </summary>
[Comment("备注")]
public string Remark { get; set; }
/// <summary>
/// 状态(字典 0正常 1停用 2删除
/// </summary>
[Comment("状态")]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 多对多(用户)
/// </summary>
[XmlIgnore]
public ICollection<SysUser> SysUsers { get; set; }
/// <summary>
/// 多对多中间表(用户角色)
/// </summary>
[XmlIgnore]
public List<SysUserRole> SysUserRoles { get; set; }
/// <summary>
/// 多对多(机构)
/// </summary>
[XmlIgnore]
public ICollection<SysOrg> SysOrgs { get; set; }
/// <summary>
/// 多对多中间表(角色-机构 数据范围)
/// </summary>
[XmlIgnore]
public List<SysRoleDataScope> SysRoleDataScopes { get; set; }
[XmlIgnore]
public ICollection<SysAreaCode> AreaCodes { get; set; }
[XmlIgnore]
public List<SysRoleArea> SysRoleAreas { get; set; }
/// <summary>
/// 多对多(菜单)
/// </summary>
[XmlIgnore]
public ICollection<SysMenu> SysMenus { get; set; }
/// <summary>
/// 多对多中间表(角色-菜单)
/// </summary>
[XmlIgnore]
public List<SysRoleMenu> SysRoleMenus { get; set; }
/// <summary>
/// 配置多对多关系
/// </summary>
/// <param name="entityBuilder"></param>
/// <param name="dbContext"></param>
/// <param name="dbContextLocator"></param>
public void Configure(EntityTypeBuilder<SysRole> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasMany(p => p.SysOrgs)
.WithMany(p => p.SysRoles)
.UsingEntity<SysRoleDataScope>(
u => u.HasOne(c => c.SysOrg).WithMany(c => c.SysRoleDataScopes).HasForeignKey(c => c.SysOrgId),
u => u.HasOne(c => c.SysRole).WithMany(c => c.SysRoleDataScopes).HasForeignKey(c => c.SysRoleId),
u =>
{
u.HasKey(c => new { c.SysRoleId, c.SysOrgId });
});
entityBuilder.HasMany(p => p.AreaCodes)
.WithMany(p => p.SysRoles)
.UsingEntity<SysRoleArea>(
u => u.HasOne(c => c.Area).WithMany(c => c.SysRoleAreas).HasForeignKey(c => c.AreaCode),
u => u.HasOne(c => c.SysRole).WithMany(c => c.SysRoleAreas).HasForeignKey(c => c.SysRoleId),
u =>
{
u.HasKey(c => new { c.SysRoleId, c.AreaCode });
});
entityBuilder.HasMany(p => p.SysMenus)
.WithMany(p => p.SysRoles)
.UsingEntity<SysRoleMenu>(
u => u.HasOne(c => c.SysMenu).WithMany(c => c.SysRoleMenus).HasForeignKey(c => c.SysMenuId),
u => u.HasOne(c => c.SysRole).WithMany(c => c.SysRoleMenus).HasForeignKey(c => c.SysRoleId),
u =>
{
u.HasKey(c => new { c.SysRoleId, c.SysMenuId });
});
}
}
}

Some files were not shown because too many files have changed in this diff Show More