Merge branch 'features/houseprojectinfo'

This commit is contained in:
2021-04-28 18:40:27 +08:00
12 changed files with 277 additions and 203 deletions

View File

@@ -0,0 +1,42 @@
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 AreaId { get; set; }
[Comment("区域名称")]
[MaxLength(500)]
public string AreaName { get; set; }
[Comment("类型")]
[Required]
public int Type { get; set; }
}
}

View File

@@ -1,39 +0,0 @@
using Ewide.Core;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Application
{
/// <summary>
/// 代码生成实体测试EF
/// </summary>
[Table("code_gen_test")]
[Comment("代码生成业务")]
public class CodeGenTest : DEntityBase
{
/// <summary>
/// 名称
/// </summary>
[Comment("名称")]
public string Name { get; set; }
/// <summary>
/// 昵称
/// </summary>
[Comment("昵称")]
public string NickName { get; set; }
/// <summary>
/// 生日
/// </summary>
[Comment("生日")]
public DateTimeOffset Birthday { get; set; }
/// <summary>
/// 年龄
/// </summary>
[Comment("年龄")]
public int Age { get; set; }
}
}

View File

@@ -1,35 +0,0 @@
using SqlSugar;
using System;
namespace Ewide.Application
{
/// <summary>
/// SqlSugar实体
/// </summary>
[SugarTable("Test", TableDescription = "我的业务表")]
public class Test
{
/// <summary>
/// 雪花Id
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(32)")]
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTimeOffset CreateTime { get; set; }
}
}

View File

@@ -4,65 +4,51 @@
<name>Ewide.Application</name> <name>Ewide.Application</name>
</assembly> </assembly>
<members> <members>
<member name="T:Ewide.Application.CodeGenTest"> <member name="T:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService">
<summary> <summary>
代码生成实体测试EF 项目管理相关服务
</summary> </summary>
</member> </member>
<member name="P:Ewide.Application.CodeGenTest.Name"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.AddProject(Ewide.Application.Service.HouseProjectInfo.Dto.AddProjectInput)">
<summary> <summary>
名称 添加项目
</summary> </summary>
<param name="input"></param>
<returns></returns>
</member> </member>
<member name="P:Ewide.Application.CodeGenTest.NickName"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.DeleteProject(Ewide.Application.Service.HouseProjectInfo.Dto.DeleteProjectInput)">
<summary> <summary>
昵称 删除项目
</summary> </summary>
<param name="input"></param>
<returns></returns>
</member> </member>
<member name="P:Ewide.Application.CodeGenTest.Birthday"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.UpdateProject(Ewide.Application.Service.HouseProjectInfo.Dto.AddProjectInput)">
<summary> <summary>
生日 编辑项目
</summary> </summary>
<param name="input"></param>
<returns></returns>
</member> </member>
<member name="P:Ewide.Application.CodeGenTest.Age"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.GetProjectById(System.String)">
<summary> <summary>
年龄 通过ID获取项目
</summary> </summary>
<param name="id"></param>
<returns></returns>
</member> </member>
<member name="T:Ewide.Application.Test"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.QueryProjectPageList(Ewide.Application.Service.HouseProjectInfo.Dto.HouseProjectInfoInput)">
<summary> <summary>
SqlSugar实体 分页查询
</summary> </summary>
<param name="input"></param>
<returns></returns>
</member> </member>
<member name="P:Ewide.Application.Test.Id"> <member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.GetProject(Ewide.Application.Service.HouseProjectInfo.Dto.QueryProjectInput)">
<summary> <summary>
雪花Id
</summary>
</member>
<member name="P:Ewide.Application.Test.Name">
<summary>
名称
</summary>
</member>
<member name="P:Ewide.Application.Test.Age">
<summary>
年龄
</summary>
</member>
<member name="P:Ewide.Application.Test.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="T:Ewide.Application.TestService">
<summary>
业务服务及集成SqlSugar用法事例
</summary>
</member>
<member name="M:Ewide.Application.TestService.GetDescription">
<summary>
测试方法
</summary> </summary>
<param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
</members> </members>

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 : XnInputBase
{
public string Name { get; set; }
public string Note { get; set; }
public int Sort { get; set; }
public string AreaID { get; set; }
public string AreaName { get; set; }
public int Type { get; set; }
public DateTimeOffset? CreatedTime { get; set; }
public DateTimeOffset? UpdatedTime { get; set; }
public string CreatedUserId { get; set; }
public string CreatedUserName { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
}
public class AddProjectInput : HouseProjectInfoInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string ID { get; set; }
}
public class UpdateProjectInput
{
public string ID { get; set; }
public string Note { get; set; }
public int Type { get; set; }
public DateTimeOffset? UpdatedTime { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
}
public class DeleteProjectInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string ID { get; set; }
}
public class QueryProjectInput : AddProjectInput
{
}
}

View File

@@ -0,0 +1,25 @@
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 AreaID { get; set; }
public string AreaName { get; set; }
public int Type { get; set; }
public DateTimeOffset? CreatedTime { get; set; }
public DateTimeOffset? UpdatedTime { get; set; }
public string CreatedUserId { get; set; }
public string CreatedUserName { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
}
}

View File

@@ -0,0 +1,109 @@
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 Mapster;
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.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(AddProjectInput input)
{
var project = input.Adapt<BsHouseProjectInfo>();
await project.UpdateNowAsync();
}
/// <summary>
/// 通过ID获取项目
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/houseProjectInfo/detailById")]
public async Task<BsHouseProjectInfo> GetProjectById([Required] string id)
{
return await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == id);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseProjectInfo/page")]
public async Task<dynamic> QueryProjectPageList([FromQuery] HouseProjectInfoInput input)
{
var areaID = !string.IsNullOrEmpty(input.AreaID);
var projects = await _houseProjectInfoRep.DetachedEntities
.Where(areaID, p => p.AreaId == input.AreaID)
.Select(p => p.Adapt<BsHouseProjectInfo>()).ToPagedListAsync(input.PageNo, input.PageSize);
return XnPageResult<BsHouseProjectInfo>.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;
}
}
}

View File

@@ -0,0 +1,21 @@
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(AddProjectInput input);
Task<BsHouseProjectInfo> GetProjectById([FromRoute] string id);
Task<dynamic> GetProject([FromQuery] QueryProjectInput input);
Task<dynamic> QueryProjectPageList([FromQuery] HouseProjectInfoInput input);
}
}

View File

@@ -1,7 +0,0 @@
namespace Ewide.Application
{
public interface ITestService
{
string GetDescription();
}
}

View File

@@ -1,76 +0,0 @@
using Ewide.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.Snowflake;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Ewide.Application
{
/// <summary>
/// 业务服务及集成SqlSugar用法事例
/// </summary>
public class TestService : ITestService, IDynamicApiController, ITransient
{
//private readonly ISqlSugarRepository<Test> _testRep;
//private readonly SqlSugarClient _db; // SqlSugar对象
public TestService(/*ISqlSugarRepository<Test> sqlSugarRep*/)
{
//_testRep = sqlSugarRep;
//_db = (SqlSugarClient)_testRep.Context;
}
/// <summary>
/// 测试方法
/// </summary>
/// <returns></returns>
[HttpPost("/test")]
public string GetDescription()
{
return "Admin.NET";
}
///// <summary>
///// 增加数据
///// </summary>
///// <returns></returns>
//[HttpPost("/test/add")]
//public async Task AddTestAsync()
//{
// var test = new Test()
// {
// Id = IDGenerator.NextId(),
// Name = "Admin.NET",
// Age = 1,
// CreateTime = DateTimeOffset.Now
// };
// await _testRep.InsertAsync(test);
// // _db.Insertable(test).ExecuteCommand();
//}
///// <summary>
///// 查询所有
///// </summary>
///// <returns></returns>
//[HttpPost("/test/page")]
//public async Task<List<Test>> GetTestListAsync()
//{
// return await _testRep.Entities.ToListAsync();
//}
///// <summary>
///// 查询系统用户
///// </summary>
///// <returns></returns>
//[HttpPost("/test/userPage")]
//public async Task<dynamic> GetUserListAsync()
//{
// return await _db.Queryable<SysUser>().ToListAsync();
//}
}
}

View File

@@ -255,7 +255,7 @@ namespace Ewide.Core.Service
customDataScopeRoleIdList.Add(u.Id); customDataScopeRoleIdList.Add(u.Id);
if ((u.DataScopeType == (int)DataScopeType.AREA || u.DataScopeType == (int)DataScopeType.AREA_WITH_CHILD) && strongerAreaType < u.DataScopeType) if ((u.DataScopeType == (int)DataScopeType.AREA || u.DataScopeType == (int)DataScopeType.AREA_WITH_CHILD) && strongerAreaType < u.DataScopeType)
{ {
strongerDataScopeType = u.DataScopeType; strongerAreaType = u.DataScopeType;
} }
else if (u.DataScopeType <= strongerDataScopeType) else if (u.DataScopeType <= strongerDataScopeType)
strongerDataScopeType = u.DataScopeType; strongerDataScopeType = u.DataScopeType;

View File

@@ -7,17 +7,13 @@ namespace Ewide.Web.Entry.Controllers
[AllowAnonymous] [AllowAnonymous]
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ITestService _testService; public HomeController()
public HomeController(ITestService testService)
{ {
_testService = testService;
} }
public IActionResult Index() public IActionResult Index()
{ {
ViewBag.Description = _testService.GetDescription();
return View(); return View();
} }
} }