update 项目管理接口
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Ewide.Application
|
||||
{
|
||||
public interface ITestService
|
||||
{
|
||||
string GetDescription();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user