diff --git a/Api/Ewide.Application/Entity/BsHouseInfo.cs b/Api/Ewide.Application/Entity/BsHouseInfo.cs index f6f1400..dfe057b 100644 --- a/Api/Ewide.Application/Entity/BsHouseInfo.cs +++ b/Api/Ewide.Application/Entity/BsHouseInfo.cs @@ -2,21 +2,24 @@ 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 { - public class BsHouseInfo : Core.DEntityBase + [Table("bs_house_info")] + [Comment("房屋信息表")] + public class BsHouseInfo : Core.DEntityBase { /// /// HouseCode主键ID /// - [Comment("HouseCode主键ID")] + [Comment("bs_house_code主键Id")] [MaxLength(36)] [Required] - public string NumberId { get; set; } + public string HouseCodeId { get; set; } /// /// 幢名称 diff --git a/Api/Ewide.Application/Entity/BsHouseMemberRelation.cs b/Api/Ewide.Application/Entity/BsHouseMemberRelation.cs new file mode 100644 index 0000000..7b419f8 --- /dev/null +++ b/Api/Ewide.Application/Entity/BsHouseMemberRelation.cs @@ -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.Entity +{ + [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 CodeId { get; set; } + } +} diff --git a/Api/Ewide.Application/Enum/ZoneRole.cs b/Api/Ewide.Application/Enum/ZoneRole.cs new file mode 100644 index 0000000..5085b8f --- /dev/null +++ b/Api/Ewide.Application/Enum/ZoneRole.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application +{ + public enum ZoneRole + { + /// + /// 片区监管员 + /// + ZoneManager, + + /// + /// 房屋安全管理员 + /// + HouseSecurityManager + } +} diff --git a/Api/Ewide.Application/Ewide.Application.xml b/Api/Ewide.Application/Ewide.Application.xml index 4b5757d..5891eef 100644 --- a/Api/Ewide.Application/Ewide.Application.xml +++ b/Api/Ewide.Application/Ewide.Application.xml @@ -4,7 +4,7 @@ Ewide.Application - + HouseCode主键ID @@ -359,6 +359,16 @@ 单位联系人电话 + + + 片区监管员 + + + + + 房屋安全管理员 + + 房屋编码相关 @@ -371,6 +381,90 @@ + + + 分页查询用户 + + + + + + + 增加用户 + + + + + + + 获取角色 + + + + + + + 获取用户拥有角色 + + + + + + + 删除用户 + + + + + + + 更新用户 + + + + + + + 查看用户 + + + + + + + 修改用户状态 + + + + + + + 授权用户数据范围 + + + + + + + 获取用户拥有数据 + + + + + + + 获取当前机构中所创建的默认角色 + 片区中的第一个帐号必定为片区监管员 + + + + + + + 获取可创建的角色列表 + + + 项目管理相关服务 @@ -425,5 +519,15 @@ + + + 选房相关 + + + + + 片区相关 + + diff --git a/Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberInput.cs b/Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberInput.cs deleted file mode 100644 index 80860a1..0000000 --- a/Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberInput.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Ewide.Application.Service.HouseMember.Dto -{ - class HouseMemberInput - { - } -} diff --git a/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs diff --git a/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeOutput.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs diff --git a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs similarity index 92% rename from Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs index 9262a0e..1a6c24a 100644 --- a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs @@ -64,17 +64,14 @@ namespace Ewide.Application.Service.HouseCode } [HttpPost("/houseCode/page")] - [Microsoft.AspNetCore.Authorization.AllowAnonymous] public async Task QueryPage([FromBody] QueryHouseCodeInput input) { var sql = @"SELECT HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,Proj.Name+'('+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) "; -//WHERE HC.Address LIKE @Address AND HC.HouseCode LIKE @HouseCode"; - //return await _dapperRepository.QueryPageData(sql, input, param: new { Address = '%' + input.Address + '%', HouseCode = '%' + input.HouseCode + '%'}); - return await _dapperRepository.QueryPageDataDynamic(sql, input); +LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6) WHERE HC.Address LIKE @Address AND HC.HouseCode LIKE @HouseCode"; + return await _dapperRepository.QueryPageData(sql, input, param: new { Address = '%' + input.Address + '%', HouseCode = '%' + input.HouseCode + '%'}); } /// diff --git a/Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/IHouseCodeService.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseCode/IHouseCodeService.cs diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberInput.cs new file mode 100644 index 0000000..e3634ea --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberInput.cs @@ -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; } + } +} diff --git a/Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberOutput.cs similarity index 51% rename from Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberOutput.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberOutput.cs index eccecb2..73d2395 100644 --- a/Api/Ewide.Application/Service/HouseMember/Dto/HouseMemberOutput.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseMember/Dto/HouseMemberOutput.cs @@ -1,12 +1,13 @@ -using System; +using Ewide.Core.Service; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Ewide.Application.Service.HouseMember.Dto +namespace Ewide.Application.Service { - class HouseMemberOutput + public class HouseMemberOutput { } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs new file mode 100644 index 0000000..1dc5c2e --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs @@ -0,0 +1,302 @@ +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; + +namespace Ewide.Application.Service +{ + [ApiDescriptionSettings(Name = "HouseMember")] + public class HouseMemberService : IHouseMemberService, IDynamicApiController, ITransient + { + private readonly IDapperRepository _dapperRepository; + + private readonly IRepository _sysUserRep; // 用户表仓储 + private readonly IUserManager _userManager; + private readonly ISysUserService _sysUserService; + private readonly ISysEmpService _sysEmpService; + + public HouseMemberService( + IDapperRepository dapperRepository, + IRepository sysUserRep, + IUserManager userManager, + ISysUserService sysUserService, + ISysEmpService sysEmpService + ) + { + _dapperRepository = dapperRepository; + _sysUserRep = sysUserRep; + _userManager = userManager; + _sysUserService = sysUserService; + _sysEmpService = sysEmpService; + } + + /// + /// 分页查询用户 + /// + /// + /// + [HttpPost("/houseMember/page")] + public async Task QueryMemberPageList([FromBody] UserInput input) + { + var dataScopes = await _sysUserService.GetUserDataScopeIdList(_userManager.UserId); + + 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)) + { + sql += " AND (SO.Id = @OrgId OR SO.Pids Like CONCAT('%[', @OrgId, ']%'))"; + 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(sql, input, param); + + foreach (var user in users.Items) + { + user.SysEmpInfo = await _sysEmpService.GetEmpInfo(user.Id); + } + return PageDataResult.PageResult(users); + } + + /// + /// 增加用户 + /// + /// + /// + [HttpPost("/houseMember/add")] + [UnitOfWork] + public async Task AddUser(AddHouseMemberInput input) + { + var id = await _sysUserService.AddUser(input); + var grantRoleInput = input.Adapt(); + grantRoleInput.Id = id; + + // 添加角色 + grantRoleInput.GrantRoleIdList.Add(input.RoleId); + await _sysUserService.GrantUserRole(grantRoleInput); + } + + /// + /// 获取角色 + /// + /// + /// + [HttpGet("/houseMember/defaultRole")] + public async Task DefaultRole([FromQuery] string orgId) + { + return (await GetDefaultRole(orgId)).Adapt(); + } + + /// + /// 获取用户拥有角色 + /// + /// + /// + [HttpGet("/houseMember/ownRole")] + public async Task GetUserOwnRole([FromQuery] QueryUserInput input) + { + return await _sysUserService.GetUserOwnRole(input); + } + + [HttpGet("/houseMember/defaultRoleRange")] + public async Task DefaultRoleRange() + { + return (await GetRoleRange()).Select(p => p.Adapt()).ToList(); + } + + /// + /// 删除用户 + /// + /// + /// + [HttpPost("/houseMember/delete")] + [UnitOfWork] + public async Task DeleteUser(DeleteUserInput input) + { + // 片区监管员在本片区已有安全员的情况下无法删除 + + await _sysUserService.DeleteUser(input); + } + + /// + /// 更新用户 + /// + /// + /// + [HttpPost("/houseMember/edit")] + [UnitOfWork] + public async Task UpdateUser(UpdateUserInput input) + { + /* + * 如果移动组织架构,会产生以下几种逻辑 + * 片区1监管员(无安全员或有其他监管员)=>片区2,直接成功 + * 片区1监管员(有安全员并且无其他监管员)=>片区2,无法移动 + * 片区1安全员=>片区2(有监管员),直接成功 + * 片区1安全员=>片区2(无监管员),无法移动,需要创建监管员 + */ + + await _sysUserService.UpdateUser(input); + } + + /// + /// 查看用户 + /// + /// + /// + [HttpGet("/houseMember/detail")] + public async Task GetUser([FromQuery] QueryUserInput input) + { + return await _sysUserService.GetUser(input); + } + + /// + /// 修改用户状态 + /// + /// + /// + [HttpPost("/houseMember/changeStatus")] + public async Task ChangeUserStatus(UpdateUserInput input) + { + await _sysUserService.ChangeUserStatus(input); + } + + /// + /// 授权用户数据范围 + /// + /// + /// + [HttpPost("/houseMember/grantData")] + public async Task GrantUserData(UpdateUserInput input) + { + await _sysUserService.GrantUserData(input); + } + + /// + /// 获取用户拥有数据 + /// + /// + /// + [HttpGet("/houseMember/ownData")] + public async Task GetUserOwnData([FromQuery] QueryUserInput input) + { + return await _sysUserService.GetUserOwnData(input); + } + + /// + /// 获取当前机构中所创建的默认角色 + /// 片区中的第一个帐号必定为片区监管员 + /// + /// + /// + [NonAction] + private async Task GetDefaultRole(string orgId) + { + var roles = await GetRoleRange(); + if (roles.Count < 2) throw Oops.Oh("未配置正确的角色"); + + var _sysOrgRep = Db.GetRepository(); + var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == orgId); + // 如果当前组织为街道, 则直接返回安全员 + if (org == null || org.Type <= 30) + { + return roles.LastOrDefault(); + } + + var _sysEmpRep = Db.GetRepository(); + var _sysUserRoleRep = Db.GetRepository(); + 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(); + var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == System.Enum.GetName(ZoneRole.ZoneManager).ToUnderScoreCase()); + // 存在片区监管员,返回安全员, 否则返回监管员 + if (isExistZoneManager) + { + return roles.LastOrDefault(); + } + + return roles.FirstOrDefault(); + } + + /// + /// 获取可创建的角色列表 + /// + /// + [NonAction] + private async Task> GetRoleRange() + { + var codes = System.Enum.GetNames(typeof(ZoneRole)).Select(p => p.ToUnderScoreCase()); + + var _sysRoleRep = Db.GetRepository(); + var roles = await _sysRoleRep.DetachedEntities.Where(p => codes.Contains(p.Code)).ToListAsync(); + + return roles; + } + + [HttpGet("/houseMember/test")] + [Microsoft.AspNetCore.Authorization.AllowAnonymous] + public async Task Test([FromQuery] string str) + { + var result1 = str.ToCamelCase(); + var result2 = str.ToUnderScoreCase(); + return result1 + "," + result2; + } + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseMember/IHouseMemberService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseMember/IHouseMemberService.cs new file mode 100644 index 0000000..76ea0f5 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseMember/IHouseMemberService.cs @@ -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 QueryMemberPageList([FromBody] UserInput input); + Task AddUser(AddHouseMemberInput input); + Task DefaultRole([FromQuery] string orgId); + Task DeleteUser(DeleteUserInput input); + Task UpdateUser(UpdateUserInput input); + Task GetUser([FromQuery] QueryUserInput input); + Task ChangeUserStatus(UpdateUserInput input); + Task GetUserOwnRole([FromQuery] QueryUserInput input); + Task GrantUserData(UpdateUserInput input); + Task GetUserOwnData([FromQuery] QueryUserInput input); + Task DefaultRoleRange(); + } +} diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/Dto/HouseProjectInfoInput.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/Dto/HouseProjectInfoInput.cs diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/Dto/HouseProjectOutput.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/Dto/HouseProjectOutput.cs diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/IHouseProjectInfoService.cs similarity index 100% rename from Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/IHouseProjectInfoService.cs diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorInput.cs new file mode 100644 index 0000000..a9f189b --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorInput.cs @@ -0,0 +1,16 @@ +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 HouseSelectorInput + { + [Required(ErrorMessage = "区域编码不可为空")] + [MinLength(9, ErrorMessage = "区域编码长度必须为9位及以上")] + public string AreaCode { get; set; } + } +} diff --git a/Api/Ewide.Application/Service/HouseMember/HouseMemberService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorOutput.cs similarity index 63% rename from Api/Ewide.Application/Service/HouseMember/HouseMemberService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorOutput.cs index d547a77..43fd2e9 100644 --- a/Api/Ewide.Application/Service/HouseMember/HouseMemberService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/Dto/HouseSelectorOutput.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Ewide.Application.Service.HouseMember +namespace Ewide.Application { - class HouseMemberService + public class HouseSelectorOutput { } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs new file mode 100644 index 0000000..6e818ce --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs @@ -0,0 +1,21 @@ +using Ewide.Core; +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Ewide.Application.Service +{ + /// + /// 选房相关 + /// + [ApiDescriptionSettings(Name = "HouseSelector", Order = 180)] + public class HouseSelectorService : IHouseSelectorService, IDynamicApiController, ITransient + { + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/IHouseSelectorService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/IHouseSelectorService.cs new file mode 100644 index 0000000..1b6bd84 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/IHouseSelectorService.cs @@ -0,0 +1,13 @@ +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 + { + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneInput.cs new file mode 100644 index 0000000..4c63c2d --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneInput.cs @@ -0,0 +1,16 @@ +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; } + } +} diff --git a/Api/Ewide.Application/Service/HouseMember/IHouseMemberService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneOutput.cs similarity index 63% rename from Api/Ewide.Application/Service/HouseMember/IHouseMemberService.cs rename to Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneOutput.cs index 43b8343..d95ac21 100644 --- a/Api/Ewide.Application/Service/HouseMember/IHouseMemberService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseZone/Dto/HouseZoneOutput.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Ewide.Application.Service.HouseMember +namespace Ewide.Application { - class IHouseMemberService + class HouseZoneOutput { } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs new file mode 100644 index 0000000..968a8ab --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs @@ -0,0 +1,39 @@ +using Ewide.Core; +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Ewide.Application.Service +{ + /// + /// 片区相关 + /// + [ApiDescriptionSettings(Name = "HouseZone", Order = 180)] + public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient + { + [HttpGet("/houseZone/list")] + public async Task GetHouseZoneList([FromQuery] HouseZoneInput input) + { + var areaCode = input.AreaCode.Substring(0, 9); + var _sysOrgRep = Db.GetRepository(); + 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(); + } + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseZone/IHouseZoneService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseZone/IHouseZoneService.cs new file mode 100644 index 0000000..339734c --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseZone/IHouseZoneService.cs @@ -0,0 +1,14 @@ +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 GetHouseZoneList([FromQuery] HouseZoneInput input); + } +} diff --git a/Api/Ewide.Core/Enum/OrgType.cs b/Api/Ewide.Core/Enum/OrgType.cs new file mode 100644 index 0000000..8955c0a --- /dev/null +++ b/Api/Ewide.Core/Enum/OrgType.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Core +{ + public enum OrgType + { + 市住建部门 = 1, + + 区住建部门 = 11, + + 乡镇街道办事处 = 21, + + 片区 = 31 + } +} diff --git a/Api/Ewide.Core/Ewide.Core.xml b/Api/Ewide.Core/Ewide.Core.xml index 4bcc428..43d95a9 100644 --- a/Api/Ewide.Core/Ewide.Core.xml +++ b/Api/Ewide.Core/Ewide.Core.xml @@ -6794,6 +6794,11 @@ 所在机构名称 + + + 角色编号 + + 角色名称 @@ -7282,5 +7287,20 @@ + + + 下划线转为驼峰 + + + + + + + + 驼峰转为下划线 + + + + diff --git a/Api/Ewide.Core/Service/User/Dto/UserOutput.cs b/Api/Ewide.Core/Service/User/Dto/UserOutput.cs index 384bbb6..2d04bf4 100644 --- a/Api/Ewide.Core/Service/User/Dto/UserOutput.cs +++ b/Api/Ewide.Core/Service/User/Dto/UserOutput.cs @@ -67,6 +67,11 @@ namespace Ewide.Core.Service /// public virtual string OrgName { get; set; } + /// + /// 角色编号 + /// + public virtual string RoleCode { get; set; } + /// /// 角色名称 /// diff --git a/Api/Ewide.Core/Service/User/SysUserService.cs b/Api/Ewide.Core/Service/User/SysUserService.cs index b6eb055..25d66db 100644 --- a/Api/Ewide.Core/Service/User/SysUserService.cs +++ b/Api/Ewide.Core/Service/User/SysUserService.cs @@ -104,7 +104,7 @@ namespace Ewide.Core.Service if (string.IsNullOrEmpty(user.Name)) user.Name = user.Account; if (string.IsNullOrEmpty(user.NickName)) - user.NickName = user.Account; + user.NickName = user.Name; var id = Guid.NewGuid().ToString(); user.Id = id; await _sysUserRep.InsertAsync(user); diff --git a/Api/Ewide.Core/Util/StringExtensions.cs b/Api/Ewide.Core/Util/StringExtensions.cs new file mode 100644 index 0000000..161dced --- /dev/null +++ b/Api/Ewide.Core/Util/StringExtensions.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +public static class StringExtensions +{ + /// + /// 下划线转为驼峰 + /// + /// + /// + /// + public static string ToCamelCase(this string str, char split = '_', bool initialsUppder = true) + { + var _ = string.Join("", + str.Split(split).Select(p => p.Length > 1 ? + p.First().ToString().ToUpper() + p[1..] : p.ToUpper() + ) + ); + + if (!initialsUppder && _.Length > 1) + { + _ = _.First().ToString().ToUpper() + _[1..]; + } + + return _; + } + + /// + /// 驼峰转为下划线 + /// + /// + /// + public static string ToUnderScoreCase(this string str) + { + var _ = new Regex(@"[A-Z]").Replace(str, "_$0"); + + if (_.Length > str.Length) + { + _ = _[1..]; + } + + return _.ToLower(); + } +} diff --git a/Web/src/assets/style/lib/list.less b/Web/src/assets/style/lib/list.less index 89e4a38..98cb08e 100644 --- a/Web/src/assets/style/lib/list.less +++ b/Web/src/assets/style/lib/list.less @@ -4,16 +4,17 @@ background-color: @white; } .yo-list { + @title-color: lighten(@black, 70%); + @value-color: lighten(@black, 30%); &-content--h { display: flex; align-items: center; &--item { - min-width: 120px; margin-left: @padding-xl; >span { line-height: 20px; - color: lighten(@black, 70%); + color: @title-color; } >p { line-height: 22px; @@ -21,11 +22,26 @@ margin-top: @padding-xxs; margin-bottom: 0; - color: lighten(@black, 30%); + color: @value-color; } } } >.ant-pagination { margin: @padding-md 0; } + .ant-descriptions { + .ant-descriptions-item-label { + color: @title-color; + } + .ant-descriptions-item-content { + color: @value-color; + } + .ant-descriptions-row { + &:last-child { + >td { + padding-bottom: 0; + } + } + } + } } diff --git a/Web/src/assets/style/lib/width-height.less b/Web/src/assets/style/lib/width-height.less index caaedcf..3ff2283 100644 --- a/Web/src/assets/style/lib/width-height.less +++ b/Web/src/assets/style/lib/width-height.less @@ -23,4 +23,8 @@ .width-height(@i + 1); } -.width-height(0); \ No newline at end of file +.width-height(0); + +.flex-1 { + flex: 1; +} \ No newline at end of file diff --git a/Web/src/common/api/index.js b/Web/src/common/api/index.js index fbf090e..bb8d45a 100644 --- a/Web/src/common/api/index.js +++ b/Web/src/common/api/index.js @@ -105,13 +105,15 @@ for (let key in urls) { _url = url Object.keys(params).forEach(key => { const value = params[key] - switch (value.constructor) { - case Array: - _params.push(...value.map(p => `${key}=${p}`)) - break - default: - _params.push(`${key}=${value}`) - break + if (value) { + switch (value.constructor) { + case Array: + _params.push(...value.map(p => `${key}=${p}`)) + break + default: + _params.push(`${key}=${value}`) + break + } } }) if (_params.length) { diff --git a/Web/src/common/api/requests/business/houseMember.js b/Web/src/common/api/requests/business/houseMember.js new file mode 100644 index 0000000..78837be --- /dev/null +++ b/Web/src/common/api/requests/business/houseMember.js @@ -0,0 +1,12 @@ +export default { + houseMemberPage: ['/houseMember/page', 'post'], + houseMemberAdd: ['/houseMember/add', 'post'], + houseMemberEdit: ['/houseMember/edit', 'post'], + houseMemberDelete: ['/houseMember/delete', 'post'], + houseMemberOwnRole: ['/houseMember/ownRole', 'get'], + houseMemberOwnData: ['/houseMember/ownData', 'get'], + houseMemberGrantData: ['/houseMember/grantData', 'post'], + houseMemberChangeStatus: ['/houseMember/changeStatus', 'post'], + houseMemberDefaultRole: ['/houseMember/defaultRole', 'get'], + houseMemberDefaultRoleList: ['/houseMember/defaultRoleRange', 'get'] +} \ No newline at end of file diff --git a/Web/src/common/api/requests/business/houseZone.js b/Web/src/common/api/requests/business/houseZone.js new file mode 100644 index 0000000..9e90e3f --- /dev/null +++ b/Web/src/common/api/requests/business/houseZone.js @@ -0,0 +1,3 @@ +export default { + houseZoneList: '/houseZone/list' +} \ No newline at end of file diff --git a/Web/src/common/api/requests/business/index.js b/Web/src/common/api/requests/business/index.js index 45b68b7..f7c2f9a 100644 --- a/Web/src/common/api/requests/business/index.js +++ b/Web/src/common/api/requests/business/index.js @@ -1,7 +1,11 @@ import houseProjectInfo from './houseProjectInfo' +import houseZone from './houseZone' import houseCode from './houseCode' +import houseMember from './houseMember' export default { ...houseProjectInfo, - ...houseCode + ...houseZone, + ...houseCode, + ...houseMember } \ No newline at end of file diff --git a/Web/src/components/yoList/index.js b/Web/src/components/yoList/index.js index 68dd3d1..c95dda1 100644 --- a/Web/src/components/yoList/index.js +++ b/Web/src/components/yoList/index.js @@ -39,9 +39,7 @@ export default { methods: { onLoading() { - this.loading = { - indicator: - } + this.loading = true }, onLoaded() { @@ -80,7 +78,6 @@ export default { render() { const props = { - loading: this.loading, dataSource: this.data, rowKey: record => record.id, ...this.$attrs @@ -100,19 +97,22 @@ export default { - - {Object.keys(this.$slots).map((name) => ( - {this.$slots[name]} - ))} - - { - !!this.data && !!this.data.length && - } + + + + {Object.keys(this.$slots).map((name) => ( + {this.$slots[name]} + ))} + + { + !!this.data && !!this.data.length && + } + ) diff --git a/Web/src/components/yoTable/index.js b/Web/src/components/yoTable/index.js index a698cf9..4955bed 100644 --- a/Web/src/components/yoTable/index.js +++ b/Web/src/components/yoTable/index.js @@ -21,6 +21,10 @@ export default { }, moreQuery: { type: Function + }, + autoLoad: { + type: Boolean, + default: true } }, @@ -52,7 +56,8 @@ export default { }, created() { - this.onLoadData() + if (this.autoLoad) + this.onLoadData() }, methods: { diff --git a/Web/src/pages/business/house/code/form/index.vue b/Web/src/pages/business/house/code/form/index.vue index 92e85e5..3bc8700 100644 --- a/Web/src/pages/business/house/code/form/index.vue +++ b/Web/src/pages/business/house/code/form/index.vue @@ -8,7 +8,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -124,15 +124,6 @@ export default { .then(({ success }) => { if (success) { this.$message.success('保存成功'); - this.$confirm({ - content: '编辑成功,是否继续保留当前页?', - onOk: () => { - this.$refs.forms[0].onProjectChange(); - }, - onCancel: () => { - this.closeContentWindow(); - }, - }); } }) .finally(() => { diff --git a/Web/src/pages/business/house/code/form/part.vue b/Web/src/pages/business/house/code/form/part.vue index 7d2da8b..55488e6 100644 --- a/Web/src/pages/business/house/code/form/part.vue +++ b/Web/src/pages/business/house/code/form/part.vue @@ -93,6 +93,15 @@ {{ item}} + + + {{ item.name }} + + @@ -130,9 +139,6 @@ - - - @@ -142,7 +148,6 @@ const defaultForm = { /* ... */ type: '1', no: '001', - zoneId: 'test', }; export default { @@ -171,6 +176,7 @@ export default { areaCode: [{ required: true, message: '请选择房屋所在区域' }], projectId: [{ required: true, message: '请选择项目' }], no: [{ required: true, message: '请输入房屋序号', trigger: 'blur' }], + zoneId: [{ required: true, message: '请选择片区' }], address: [{ required: true, message: '请输入房屋地址', trigger: 'blur' }], lng: [{ required: true, message: '请在地图中选择坐标' }], lat: [{ required: true, message: '请在地图中选择坐标' }], @@ -189,6 +195,7 @@ export default { options: { areaTree: [], projects: [], + zones: [], }, }; }, @@ -477,22 +484,27 @@ export default { /** * 切换房屋性质 */ - onTypeChange() { + async onTypeChange() { if (this.form.industry) { this.form.industry = undefined; } - this.getProjects(); + this.loading = true; + await this.getProjects(); + this.loading = false; }, /** * 切换区域 */ - onAreaCodeChange(autoChange = false) { + async onAreaCodeChange(autoChange = false) { if (this.form.areaCode.length != 4) { this.form.areaCode = []; } - this.getProjects(autoChange); + this.loading = true; + await this.getProjects(autoChange); + await this.getZones(autoChange); + this.loading = false; }, async getProjects(autoChange = false) { @@ -500,7 +512,6 @@ export default { this.form.projectId = undefined; } if (this.form.areaCode && this.form.areaCode.length === 4) { - this.loading = true; const projects = await this.$api .houseProjectList({ areaCode: this.form.areaCode[3], @@ -510,7 +521,6 @@ export default { return data; }); this.options.projects = projects; - this.loading = false; } }, @@ -529,6 +539,23 @@ export default { this.$set(this.form, 'no', no); this.loading = false; }, + + async getZones(autoChange = false) { + if (this.form.zoneId && !autoChange) { + this.form.zoneId = undefined; + } + if (this.form.areaCode && this.form.areaCode.length === 4) { + const zones = await this.$api + .houseZoneList({ + areaCode: this.form.areaCode[3], + }) + .then(({ data }) => { + return data; + }); + + this.options.zones = zones; + } + }, }, }; \ No newline at end of file diff --git a/Web/src/pages/business/house/code/index.vue b/Web/src/pages/business/house/code/index.vue index 2e8c12b..3078d19 100644 --- a/Web/src/pages/business/house/code/index.vue +++ b/Web/src/pages/business/house/code/index.vue @@ -97,19 +97,13 @@ \ No newline at end of file diff --git a/Web/src/pages/business/house/member/form.vue b/Web/src/pages/business/house/member/form.vue new file mode 100644 index 0000000..d2ebf25 --- /dev/null +++ b/Web/src/pages/business/house/member/form.vue @@ -0,0 +1,323 @@ + + + + + + + + + + + + 角色 + + + + + + {{item.name}} + + + + + + + + + + + + + + + + + + + + + (form.birthday = date ? $moment(date).format('YYYY-MM-DD') : null)" + class="w-100-p" + placeholder="请选择生日" + v-model="form.birthday" + /> + + + + + + 保密 + + + + 男 + + + + 女 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Web/src/pages/business/house/member/index.vue b/Web/src/pages/business/house/member/index.vue new file mode 100644 index 0000000..a0ff18c --- /dev/null +++ b/Web/src/pages/business/house/member/index.vue @@ -0,0 +1,349 @@ + + + + + + 在片区中必须... + + + + + + + + + + + + {{ item.value }} + + + + + 查询 + 重置 + + + + + + + + + 新增用户 + + + + 编辑 + + + + 删除 + + + + 授权额外数据 + + + + {{ record.nickName || record.name }} + + {{ roleName }} + + + {{ record.account }} + + + 选房 + + + + + {{ record.orgName }} + {{ bindCodeValue(record.sex, 'sex') }} + {{ record.phone || '未设置' }} + {{ record.email || '未设置' }} + + + + + onSetUserStatus(record, checked)" + /> + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Web/src/pages/business/house/member/selector/index.vue b/Web/src/pages/business/house/member/selector/index.vue new file mode 100644 index 0000000..8492d00 --- /dev/null +++ b/Web/src/pages/business/house/member/selector/index.vue @@ -0,0 +1,60 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Web/src/pages/business/house/member/selector/selectedList.vue b/Web/src/pages/business/house/member/selector/selectedList.vue new file mode 100644 index 0000000..e5e6a79 --- /dev/null +++ b/Web/src/pages/business/house/member/selector/selectedList.vue @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Web/src/pages/business/house/member/selector/selectorList.vue b/Web/src/pages/business/house/member/selector/selectorList.vue new file mode 100644 index 0000000..5dccbbf --- /dev/null +++ b/Web/src/pages/business/house/member/selector/selectorList.vue @@ -0,0 +1,265 @@ + + + + + + + + + + + + + 全部 + {{item.value}} + + + + + {{item.value}} + + + + + + + + + + + 确认选择 + + + + + {{`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${`000${record.no}`.slice(-3)}`}} + + + {{bindCodeValue(text, 'type') + (text === 2 ? `(${bindCodeValue(record.industry, 'industry')})` : '')}} + + + + + \ No newline at end of file diff --git a/Web/src/pages/system/menu/form.vue b/Web/src/pages/system/menu/form.vue index 21716ec..1697326 100644 --- a/Web/src/pages/system/menu/form.vue +++ b/Web/src/pages/system/menu/form.vue @@ -8,7 +8,7 @@ - 基本信息 + 基本信息 @@ -50,7 +50,7 @@ - 扩展信息 + 扩展信息 diff --git a/Web/src/pages/system/user/index.vue b/Web/src/pages/system/user/index.vue index 79fe981..4132eeb 100644 --- a/Web/src/pages/system/user/index.vue +++ b/Web/src/pages/system/user/index.vue @@ -5,7 +5,12 @@ 2021-04-30 Lufthafen --> - + @@ -15,8 +20,17 @@ - - {{ item.value }} + + {{ item.value }} @@ -65,24 +79,30 @@ {{ record.nickName || record.name }} {{ record.account }} - + + + {{ bindCodeValue(record.sex, 'sex') }} + {{ record.phone || '未设置' }} + {{ record.email || '未设置' }} + - - 性别 - {{ bindCodeValue(record.sex, 'sex') }} - - - 手机 - {{ record.phone || '未设置' }} - - - 邮箱 - {{ record.email || '未设置' }} - - onSetUserStatus(record, checked)" /> + onSetUserStatus(record, checked)" + /> @@ -92,12 +112,24 @@ - + - + @@ -140,7 +172,9 @@ export default { name: '用户', /* 查询条件 */ - query: {}, + query: { + sysEmpParam: {}, + }, /* 表格字段 */ columns: [],
{{ bindCodeValue(record.sex, 'sex') }}
{{ record.phone || '未设置' }}
{{ record.email || '未设置' }}