Commit a487f6fc by chamberone

fix: 修复小队接口报错

1 parent 5bf96c89
......@@ -16,6 +16,9 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity,
@Query("select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.status=1")
List<OrgTeamEngineerEntity> findAllByTeamId(String teamId);
@Query("select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.engineerCode=:engineerCode")
OrgTeamEngineerEntity findByTeamIdAndEngineerCode(String teamId, String engineerCode);
@Query("select t from OrgTeamEngineerEntity t where t.teamId in :teamIds and t.status=1")
List<OrgTeamEngineerEntity> findAllByTeamIdIn(List<String> teamIds);
......
......@@ -215,11 +215,19 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
}
// 遍历新的关系映射,创建新的关系
for (OrgTeamEngineerEntity newRelation : newRelationsMap.values()) {
if (!existingRelations.contains(newRelation)) {
orgTeamEngineerDao.save(newRelation);
}
}
for (OrgTeamEngineerEntity newRelation : newRelationsMap.values()) {
if (!existingRelations.contains(newRelation)) {
// 检查是否存在,已经存在的,只需要set status=1就可以了
OrgTeamEngineerEntity exist = orgTeamEngineerDao.findByTeamIdAndEngineerCode(newRelation.getTeamId(),
newRelation.getEngineerCode());
if (null != exist && exist.getId() != null) {
exist.setStatus(1);
orgTeamEngineerDao.save(exist);
} else {
orgTeamEngineerDao.save(newRelation);
}
}
}
}
@Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!