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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user