|
|
@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -82,7 +83,10 @@ public class PsychologistServiceImpl extends BaseServiceImpl<PsychologistDao, Ps |
|
|
|
@Override |
|
|
|
public PsychologistDTO get(String id) { |
|
|
|
PsychologistEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, PsychologistDTO.class); |
|
|
|
PsychologistDTO dto = ConvertUtils.sourceToTarget(entity, PsychologistDTO.class); |
|
|
|
List<String> titles = psychologistTitleRelationDao.selectTitles(id); |
|
|
|
dto.setTitles(titles == null ? new ArrayList<>() : titles); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -104,8 +108,18 @@ public class PsychologistServiceImpl extends BaseServiceImpl<PsychologistDao, Ps |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(PsychologistDTO dto) { |
|
|
|
List<String> relation = dto.getTitles(); |
|
|
|
PsychologistEntity entity = ConvertUtils.sourceToTarget(dto, PsychologistEntity.class); |
|
|
|
updateById(entity); |
|
|
|
boolean updFlag = updateById(entity); |
|
|
|
if (updFlag && relation != null && relation.size() > 0) { |
|
|
|
psychologistTitleRelationDao.clearRelation(entity.getId()); |
|
|
|
relation.forEach(item -> { |
|
|
|
PsychologistTitleRelationEntity psychologistTitleRelationEntity = new PsychologistTitleRelationEntity(); |
|
|
|
psychologistTitleRelationEntity.setPsychologistId(entity.getId()); |
|
|
|
psychologistTitleRelationEntity.setTitleId(item); |
|
|
|
psychologistTitleRelationDao.insert(psychologistTitleRelationEntity); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|