You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.3 KiB
87 lines
3.3 KiB
3 months ago
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||
|
//
|
||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||
|
|
||
|
using System.ComponentModel;
|
||
|
using Admin.NET.Bodk.Project.Entities;
|
||
|
using Admin.NET.Bodk.Project.Models;
|
||
|
using Admin.NET.Core;
|
||
|
using Furion.DependencyInjection;
|
||
|
using Furion.DynamicApiController;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
||
|
namespace Admin.NET.Bodk.Project.Controllers;
|
||
|
|
||
|
[ApiDescriptionSettings(GroupName = "Bodk Groups", Description = "项目接口服务")]
|
||
|
public class ProjectController : IDynamicApiController, ITransient
|
||
|
{
|
||
|
private readonly SqlSugarRepository<ProjectEntity> _repository;
|
||
|
|
||
|
public ProjectController(SqlSugarRepository<ProjectEntity> repository)
|
||
|
{
|
||
|
_repository = repository;
|
||
|
}
|
||
|
|
||
|
[ApiDescriptionSettings(Name = "GetList"), HttpPost]
|
||
|
[DisplayName("获取项目列表")]
|
||
|
public async Task<SqlSugarPagedList<Project.Models.Project>> GetList(ProjectQueryInput input)
|
||
|
{
|
||
|
return await _repository.AsQueryable()
|
||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Name),
|
||
|
m => input.Name != null && m.Name.Contains(input.Name))
|
||
|
.WhereIF(input.Id is not null, m => m.Id == input.Id)
|
||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Manager),
|
||
|
m => input.Manager != null && m.Manager.Contains(input.Manager))
|
||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Phone),
|
||
|
m => input.Phone != null && m.Phone.Contains(input.Phone))
|
||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Position),
|
||
|
m => input.Position != null && m.Position.Contains(input.Position))
|
||
|
.WhereIF(input.IsDeleted is not null,
|
||
|
m => m.IsDelete == input.IsDeleted)
|
||
|
.Select<Models.Project>((u) => new Models.Project()
|
||
|
{
|
||
|
Id = u.Id,
|
||
|
Name = u.Name,
|
||
|
Manager = u.Manager,
|
||
|
Position = u.Position,
|
||
|
Phone = u.Phone,
|
||
|
IsDeleted = u.IsDelete,
|
||
|
CreateTime = u.CreateTime,
|
||
|
})
|
||
|
.ToPagedListAsync(input.Page, input.PageSize);
|
||
|
}
|
||
|
|
||
|
[ApiDescriptionSettings(Name = "Add"), HttpPost]
|
||
|
[DisplayName("新增项目")]
|
||
|
public async Task AddProject(ProjectInput project)
|
||
|
{
|
||
|
await _repository.InsertAsync(new ProjectEntity()
|
||
|
{
|
||
|
Name = project.Name,
|
||
|
Position = project.Position,
|
||
|
Manager = project.Manager,
|
||
|
Phone = project.Phone
|
||
|
});
|
||
|
}
|
||
|
|
||
|
[ApiDescriptionSettings(Name = "Delete"), HttpPost]
|
||
|
[DisplayName("删除项目")]
|
||
|
public async Task DeleteProject(long id)
|
||
|
{
|
||
|
var project = await _repository.GetSingleAsync(d => d.Id == id);
|
||
|
project.IsDelete = true;
|
||
|
await _repository.UpdateAsync(project);
|
||
|
}
|
||
|
|
||
|
[ApiDescriptionSettings(Name = "Update"), HttpPost]
|
||
|
[DisplayName("修改项目")]
|
||
|
public async Task UpdateProject(ProjectInput projectInput)
|
||
|
{
|
||
|
var project = await _repository.GetSingleAsync(d => d.Id == projectInput.Id);
|
||
|
project.Manager = projectInput.Manager;
|
||
|
project.Name = projectInput.Name;
|
||
|
project.Phone = projectInput.Phone;
|
||
|
project.Position = projectInput.Position;
|
||
|
await _repository.UpdateAsync(project);
|
||
|
}
|
||
|
}
|