|
@@ -23,6 +23,7 @@ namespace OASystem.API.Controllers
|
|
private readonly DepartmentRepository _sysDepRep;
|
|
private readonly DepartmentRepository _sysDepRep;
|
|
private readonly UsersRepository _userRep;
|
|
private readonly UsersRepository _userRep;
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
|
|
+ private readonly SqlSugarClient _sqlSugar;
|
|
private readonly MessageRepository _messageRep;
|
|
private readonly MessageRepository _messageRep;
|
|
private readonly SetDataRepository _setDataRepository;
|
|
private readonly SetDataRepository _setDataRepository;
|
|
private readonly SystemMenuPermissionRepository _SystemMenuPermissionRepository;
|
|
private readonly SystemMenuPermissionRepository _SystemMenuPermissionRepository;
|
|
@@ -35,7 +36,7 @@ namespace OASystem.API.Controllers
|
|
private readonly UserAuthorityRepository _UserAuthorityRepository;
|
|
private readonly UserAuthorityRepository _UserAuthorityRepository;
|
|
|
|
|
|
public SystemController( CompanyRepository syscom, DepartmentRepository sysDepRep, UsersRepository userRep,
|
|
public SystemController( CompanyRepository syscom, DepartmentRepository sysDepRep, UsersRepository userRep,
|
|
- IMapper mapper, SetDataRepository setDataRepository, CompanyRepository companyRepository,
|
|
|
|
|
|
+ IMapper mapper,SqlSugarClient sqlSugar, SetDataRepository setDataRepository, CompanyRepository companyRepository,
|
|
SystemMenuPermissionRepository systemMenuPermissionRepository, PageFunctionPermissionRepository pageFunctionPermissionRepository,
|
|
SystemMenuPermissionRepository systemMenuPermissionRepository, PageFunctionPermissionRepository pageFunctionPermissionRepository,
|
|
SystemMenuAndFunctionRepository systemMenuAndFunctionRepository, JobPostAuthorityRepository jobPostAuthorityRepository,
|
|
SystemMenuAndFunctionRepository systemMenuAndFunctionRepository, JobPostAuthorityRepository jobPostAuthorityRepository,
|
|
JobPostRepository jobRep,UserAuthorityRepository userAuthorityRepository, MessageRepository messageRep,SetDataTypeRepository setDataTypeRep)
|
|
JobPostRepository jobRep,UserAuthorityRepository userAuthorityRepository, MessageRepository messageRep,SetDataTypeRepository setDataTypeRep)
|
|
@@ -46,6 +47,7 @@ namespace OASystem.API.Controllers
|
|
_messageRep = messageRep;
|
|
_messageRep = messageRep;
|
|
_userRep = userRep;
|
|
_userRep = userRep;
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
|
|
+ _sqlSugar = sqlSugar;
|
|
_setDataRepository = setDataRepository;
|
|
_setDataRepository = setDataRepository;
|
|
_CompanyRepository = companyRepository;
|
|
_CompanyRepository = companyRepository;
|
|
_SystemMenuPermissionRepository = systemMenuPermissionRepository;
|
|
_SystemMenuPermissionRepository = systemMenuPermissionRepository;
|
|
@@ -418,13 +420,13 @@ namespace OASystem.API.Controllers
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Sys_Company _Company = _mapper.Map<Sys_Company>(dto);
|
|
Sys_Company _Company = _mapper.Map<Sys_Company>(dto);
|
|
- int id = await _syscomRep.AddAsyncReturnId(_Company);
|
|
|
|
- if (id == 0)
|
|
|
|
|
|
+ Result data = await _syscomRep.AddCompany(_Company);
|
|
|
|
+ if (data.Code != 0)
|
|
{
|
|
{
|
|
return Ok(JsonView(false, "添加失败!"));
|
|
return Ok(JsonView(false, "添加失败!"));
|
|
|
|
|
|
}
|
|
}
|
|
- return Ok(JsonView(true,"添加成功", new { Id = id }));
|
|
|
|
|
|
+ return Ok(JsonView(true,"添加成功"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
catch (Exception)
|
|
@@ -1056,7 +1058,16 @@ namespace OASystem.API.Controllers
|
|
{
|
|
{
|
|
return Ok(JsonView(false, "参数不能为空!"));
|
|
return Ok(JsonView(false, "参数不能为空!"));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ Sys_Users _Users=_sqlSugar.Queryable<Sys_Users>().First(a=>a.IsDel==0 && a.Id==dto.Id);
|
|
|
|
+ if (_Users != null)
|
|
|
|
+ {
|
|
|
|
+ List<Sys_Users> sys_UsersList=_sqlSugar.Queryable<Sys_Users>().Where(a=>a.IsDel==0 && a.CompanyId==_Users.CompanyId).ToList();
|
|
|
|
+ if (sys_UsersList.Count==1)
|
|
|
|
+ {
|
|
|
|
+ return Ok(JsonView(false, "该人员为公司最后一位,不可删除!"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
|
|
bool res = await _userRep.UpdateAsync<Sys_Users>(a => a.Id == dto.Id, a => new Sys_Users
|
|
{
|
|
{
|
|
IsDel = 1,
|
|
IsDel = 1,
|