|
@@ -11,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;
|
|
@@ -26,7 +27,11 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
#region user 操作
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 查询所有员工(web)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> GetUserList(DtoBase dto)
|
|
@@ -68,7 +73,7 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
else if (dto.PortType == 2)
|
|
|
{
|
|
|
- var companyList = _sysDepRep.QueryDto<Sys_Company, CompanyIView>(a=>a.ToBool(true)).ToList();
|
|
|
+ var companyList = _sysDepRep.QueryDto<Sys_Company, CompanyView>(a=>a.ToBool(true)).ToList();
|
|
|
if (companyList.Count == 0)
|
|
|
{
|
|
|
return Ok(JsonView(false, "暂无数据!"));
|
|
@@ -91,13 +96,103 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 添加企业数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView),StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> AddCompany(AddCompanyDto dto)
|
|
|
{
|
|
|
- Sys_Company _Company = _mapper.Map<Sys_Company>(dto);
|
|
|
- int id = await _syscomRep.AddAsyncReturnId(_Company);
|
|
|
- return Ok(JsonView(0, "成功", _Company));
|
|
|
+ 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
|
|
|
|