Commit a487f6fc by chamberone

fix: 修复小队接口报错

1 parent 5bf96c89
...@@ -17,6 +17,9 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity, ...@@ -17,6 +17,9 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity,
@Query("select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.status=1") @Query("select t from OrgTeamEngineerEntity t where t.teamId = :teamId and t.status=1")
List<OrgTeamEngineerEntity> findAllByTeamId(String teamId); 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") @Query("select t from OrgTeamEngineerEntity t where t.teamId in :teamIds and t.status=1")
List<OrgTeamEngineerEntity> findAllByTeamIdIn(List<String> teamIds); List<OrgTeamEngineerEntity> findAllByTeamIdIn(List<String> teamIds);
......
...@@ -217,10 +217,18 @@ public class BusinessTeamServiceImpl implements BusinessTeamService { ...@@ -217,10 +217,18 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
// 遍历新的关系映射,创建新的关系 // 遍历新的关系映射,创建新的关系
for (OrgTeamEngineerEntity newRelation : newRelationsMap.values()) { for (OrgTeamEngineerEntity newRelation : newRelationsMap.values()) {
if (!existingRelations.contains(newRelation)) { 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); orgTeamEngineerDao.save(newRelation);
} }
} }
} }
}
@Override @Override
public Result<?> getTeamDetail(BusinessTeamDetailDTO.Request req) { public Result<?> getTeamDetail(BusinessTeamDetailDTO.Request req) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!