171 lines
5.8 KiB
C#
171 lines
5.8 KiB
C#
using BZPT.Domains.Entity.Sys;
|
||
using BZPT.Domains.IService.Sys;
|
||
using BZPT.Domains.Services.Sys;
|
||
using BZPT.Dto.Sys;
|
||
using DevExtreme.AspNet.Data;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.CodeAnalysis;
|
||
using NPlatform.API;
|
||
using System.ComponentModel.Design;
|
||
using System.Security.Claims;
|
||
using System.Xml.Linq;
|
||
|
||
namespace BZPT.Api.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 工程项目基本信息
|
||
/// </summary>
|
||
[Route("api/[controller]/[action]")]
|
||
public class ProjectInfoController : BaseController
|
||
{
|
||
[Autowired]
|
||
private ILogger<ProjectInfoController> Loger { get; set; }
|
||
/// <summary>
|
||
/// 工程项目基本信息
|
||
/// </summary>
|
||
IProjectInfoService _ProjectInfoService { get; set; }
|
||
public ProjectInfoController(ILogger<ProjectInfoController> loger, IProjectInfoService ProjectInfoService)
|
||
{
|
||
Loger = loger;
|
||
_ProjectInfoService = ProjectInfoService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据获取项目树
|
||
/// </summary>
|
||
/// <param name="setId">用户 ID</param>
|
||
/// <returns>资源树结构</returns>
|
||
[HttpGet]
|
||
public async Task<INPResult> GetUserProjectTree(string setId)
|
||
{
|
||
var treeData = await _ProjectInfoService.GetUserProjectTree(setId);
|
||
return treeData;
|
||
}
|
||
/// <summary>
|
||
/// 根据用户获取项目、标段、施工队、班组树
|
||
/// </summary>
|
||
/// <param name="leve">显示层级,0项目,1标段,2劳务队,3班组</param>
|
||
/// <returns>资源树结构</returns>
|
||
[HttpGet]
|
||
public async Task<INPResult> GetPSTWTree(int leve)
|
||
{
|
||
var treeData = await _ProjectInfoService.GetProjectTree(Context.UserID, leve);
|
||
return treeData;
|
||
}
|
||
/// <summary>
|
||
/// 根据角色获取项目树
|
||
/// </summary>
|
||
/// <param name="setOrg">用户 ID</param>
|
||
/// <param name="leve">层级</param>
|
||
/// <returns>资源树结构</returns>
|
||
[HttpGet]
|
||
public async Task<INPResult> GetOrgProjectTree(string setOrg, int leve = 0)
|
||
{
|
||
var treeData = await _ProjectInfoService.GetOrgProjectTree(setOrg, leve);
|
||
return treeData;
|
||
}
|
||
/// <summary>
|
||
///工程项目基本信息列表分页
|
||
/// </summary>
|
||
/// <param name="dataSourceLoadOptions"></param>
|
||
/// <returns></returns>
|
||
// GET: api/<AccountController>
|
||
[HttpGet]
|
||
public async Task<INPResult> GetPage(DataSourceLoadOptions dataSourceLoadOptions)
|
||
{
|
||
return await _ProjectInfoService.GetPageAsync(dataSourceLoadOptions);
|
||
}
|
||
/// <summary>
|
||
/// 添加工程项目基本信息
|
||
/// </summary>
|
||
/// <param name="resource"></param>
|
||
/// <returns></returns>
|
||
// POST api/<AccountController>
|
||
[HttpPost]
|
||
public async Task<INPResult> Post([FromBody] ProjectInfoDto resource)
|
||
{
|
||
return await _ProjectInfoService.ProjectInfoAdd(resource);
|
||
}
|
||
|
||
///// <summary>
|
||
///// 添加工程项目用户列表
|
||
///// </summary>
|
||
///// <param name="proUser"></param>
|
||
///// <returns></returns>
|
||
//// POST api/<AccountController>
|
||
//[HttpPost]
|
||
//public async Task<INPResult> PostProjectUsers([FromBody] ProjectUserDto proUser)
|
||
//{
|
||
// return await _ProjectInfoService.ProjectUserAdd(proUser);
|
||
//}
|
||
|
||
|
||
///// <summary>
|
||
///// 获取用户列表分页
|
||
///// </summary>
|
||
///// <param name="whereExp"></param>
|
||
///// <returns></returns>
|
||
//// GET: api/<UserController>
|
||
//[HttpGet]
|
||
//public async Task<INPResult> GetProUserPage([FromQuery]string projectId, [FromQuery] DataSourceLoadOptions whereExp)
|
||
//{
|
||
// if (Context.Account != "admin")
|
||
// {
|
||
// whereExp.And(new List<object>{
|
||
// "LoginName","<>","admin" });
|
||
// }
|
||
// return await _ProjectInfoService.GetProUserPage(projectId,whereExp);
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// 编辑工程项目基本信息
|
||
/// </summary>
|
||
/// <param name="resource"></param>
|
||
/// <returns></returns>
|
||
// PUT api/<AccountController>/5
|
||
[HttpPut]
|
||
public async Task<INPResult> Put([FromBody] ProjectInfoDto resource)
|
||
{
|
||
return await _ProjectInfoService.ProjectInfoEdit(resource);
|
||
}
|
||
|
||
///// <summary>
|
||
///// 用户项目
|
||
///// </summary>
|
||
///// <param name="grants">授权数据</param>
|
||
///// <returns></returns>
|
||
//// POST api/<AccountController>
|
||
//[HttpPost]
|
||
//public async Task<INPResult> UserProjectGrant([FromBody] GrantProSectionInput grants)
|
||
//{
|
||
// if (grants == null)
|
||
// {
|
||
// return Fail("授权参数缺失!");
|
||
// }
|
||
// if (grants.GrantId == null)
|
||
// {
|
||
// return Fail("缺少目标用户");
|
||
// }
|
||
// if (grants.GrantId == this.Context.UserID && this.Context.Account != "admin")
|
||
// {
|
||
// return Fail("不能修改自身的权限");
|
||
// }
|
||
// // 调用 BatchAddAsync 方法
|
||
// return await _ProjectInfoService.UserProjectGrant(grants);
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 删除工程项目基本信息
|
||
/// </summary>
|
||
/// <param name="id">工程项目基本信息ID</param>
|
||
/// <returns></returns>
|
||
// DELETE api/<AccountController>/5
|
||
[HttpDelete("{id}")]
|
||
public async Task<INPResult> Delete(string id)
|
||
{
|
||
return await _ProjectInfoService.Delete(id);
|
||
}
|
||
}
|
||
}
|