|
@@ -1,10 +1,6 @@
|
|
|
|
|
|
-using MySqlX.XDevAPI.Common;
|
|
|
-using OASystem.Domain.Dtos.System;
|
|
|
-using OASystem.Domain.Entities.System;
|
|
|
-using OASystem.Domain.ViewModels.System;
|
|
|
-using OASystem.Infrastructure.Repositories.Login;
|
|
|
-using OASystem.Infrastructure.Repositories.System;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -15,6 +11,7 @@ namespace OASystem.API.Controllers
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
public class SystemController : ControllerBase
|
|
|
{
|
|
|
+
|
|
|
private readonly CompanyRepository _syscomRep;
|
|
|
private readonly DepartmentRepository _sysDepRep;
|
|
|
private readonly UsersRepository _userRep;
|
|
@@ -30,9 +27,13 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
#region user 操作
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 查询所有员工(web)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
- [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> GetUserList(DtoBase dto)
|
|
|
{
|
|
|
try
|
|
@@ -55,46 +56,181 @@ namespace OASystem.API.Controllers
|
|
|
#endregion
|
|
|
|
|
|
#region 企业操作
|
|
|
- [HttpGet]
|
|
|
- [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> getCompanyList()
|
|
|
+ /// <summary>
|
|
|
+ /// 查询企业数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> getCompanyList(DtoBase dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- //var companyList = _sysDepRep.QueryDto<Sys_Company, CompanyView>(c=>c.IsDel!=null).ToList();
|
|
|
- string sqlWhere = "select * from Sys_Company";
|
|
|
- var companyList = _syscomRep.GetListBySqlWithNolock(sqlWhere);
|
|
|
- List<CompanyView> DataList = _mapper.Map<List<CompanyView>>(companyList);
|
|
|
- if (DataList.Count == 0)
|
|
|
+ if (dto.PortType == 1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 2)
|
|
|
+ {
|
|
|
+ var companyList = _sysDepRep.QueryDto<Sys_Company, CompanyView>(a=>a.ToBool(true)).ToList();
|
|
|
+ if (companyList.Count == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(companyList));
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 3)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
return Ok(JsonView(false, "暂无数据!"));
|
|
|
}
|
|
|
- return Ok(JsonView(DataList));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return Ok(JsonView(false, "程序错误!"));
|
|
|
throw;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加企业数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView),StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> AddCompany(AddCompanyDto dto)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(dto.CompanyName) || dto.CreateUserId==0 || !string.IsNullOrWhiteSpace(dto.CompanyCode))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(-1, "请检查信息是否输入完整!", null));
|
|
|
+ }
|
|
|
+ else if (string.IsNullOrWhiteSpace(dto.Tel))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(-1, "请检查联系方式是否输入正确!", null));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sys_Company _Company = _mapper.Map<Sys_Company>(dto);
|
|
|
+ int id = await _syscomRep.AddAsyncReturnId(_Company);
|
|
|
+ if (id == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(-1, "添加失败!", null));
|
|
|
+
|
|
|
+ }
|
|
|
+ return Ok(JsonView(0, "成功", id));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 企业修改
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult>EditCompany(EditCompanyDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(dto.CompanyName) || string.IsNullOrWhiteSpace(dto.CompanyCode) || string.IsNullOrWhiteSpace(dto.Address) || dto.ParentCompanyId == 0 || dto.ContactUserId == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(-1, "请检查信息是否输入完整!", null));
|
|
|
+ }
|
|
|
+ else if (string.IsNullOrWhiteSpace(dto.Tel))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(-1, "请检查联系方式是否输入正确!", null));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bool res = await _syscomRep.UpdateAsync(a => a.Id == dto.Id, a => new Sys_Company
|
|
|
+ {
|
|
|
+ CompanyName = dto.CompanyName,
|
|
|
+ CompanyCode = dto.CompanyCode,
|
|
|
+ Address = dto.Address,
|
|
|
+ ParentCompanyId = dto.ParentCompanyId,
|
|
|
+ Tel = dto.Tel,
|
|
|
+ ContactUserId = dto.ContactUserId,
|
|
|
+ });
|
|
|
+ if (!res) { return Ok(JsonView(-1, "失败", null)); }
|
|
|
+ return Ok(JsonView(0, "成功", null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 企业删除
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> DelCompany(DelCompanyDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bool res = await _syscomRep.SoftDeleteAsync<Sys_Company>(dto.Id.ToString());
|
|
|
+ if (!res) { return Ok(JsonView(-1, "失败", null)); }
|
|
|
+ return Ok(JsonView(0, "成功", null));
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 部门操作
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 查询部门数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
//[Authorize]
|
|
|
[HttpPost]
|
|
|
- [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> QueryDepartmentList(DepartmentDto dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var result = _sysDepRep.QueryDto<Sys_Department, DepartmentView>(s => s.CompanyId == dto.CompanyId).ToList();
|
|
|
- if (result.Count==0)
|
|
|
+ if (dto.PortType==1)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ else if (dto.PortType==2)
|
|
|
+ {
|
|
|
+ var result = _sysDepRep.QueryDto<Sys_Department, DepartmentIView>(s => s.CompanyId == dto.CompanyId).ToList();
|
|
|
+ if (result.Count == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(result));
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 3)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
return Ok(JsonView(false, "暂无数据!"));
|
|
|
}
|
|
|
- return Ok(JsonView(result));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -106,8 +242,13 @@ namespace OASystem.API.Controllers
|
|
|
#endregion
|
|
|
|
|
|
#region 用户操作
|
|
|
+ /// <summary>
|
|
|
+ /// 查询用户数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
- [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> QueryUserList(UserDto dto)
|
|
|
{
|
|
|
try
|