|
@@ -10,6 +10,7 @@ import com.persagy.fm.common.constant.enums.ValidEnum;
|
|
import com.persagy.fm.common.context.DefaultAppContext;
|
|
import com.persagy.fm.common.context.DefaultAppContext;
|
|
import com.persagy.fm.common.model.vo.SimpleObjVO;
|
|
import com.persagy.fm.common.model.vo.SimpleObjVO;
|
|
import com.persagy.fm.common.utils.ListUtil;
|
|
import com.persagy.fm.common.utils.ListUtil;
|
|
|
|
+import com.persagy.fm.department.model.Department;
|
|
import com.persagy.fm.department.model.vo.DepSimpleObjVO;
|
|
import com.persagy.fm.department.model.vo.DepSimpleObjVO;
|
|
import com.persagy.fm.department.service.IDepartmentService;
|
|
import com.persagy.fm.department.service.IDepartmentService;
|
|
import com.persagy.fm.person.dao.PersonMapper;
|
|
import com.persagy.fm.person.dao.PersonMapper;
|
|
@@ -508,7 +509,6 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
* @param updatePerson4FrontEndDTO 更新人员入参
|
|
* @param updatePerson4FrontEndDTO 更新人员入参
|
|
* @param personId 人员id
|
|
* @param personId 人员id
|
|
* @return 更新后的人员对象
|
|
* @return 更新后的人员对象
|
|
- * @throws
|
|
|
|
* @author lixing
|
|
* @author lixing
|
|
* @version V1.0 2021/4/9 7:30 下午
|
|
* @version V1.0 2021/4/9 7:30 下午
|
|
*/
|
|
*/
|
|
@@ -516,9 +516,7 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
Person person = getById(personId);
|
|
Person person = getById(personId);
|
|
// 直接上级不能选择自己
|
|
// 直接上级不能选择自己
|
|
Long leaderAfterChange = updatePerson4FrontEndDTO.getLeader();
|
|
Long leaderAfterChange = updatePerson4FrontEndDTO.getLeader();
|
|
- if (leaderAfterChange != null && personId.equals(leaderAfterChange.toString())) {
|
|
|
|
- throw new IllegalArgumentException("不能选择自己作为直接上级");
|
|
|
|
- }
|
|
|
|
|
|
+ checkLeader(leaderAfterChange, person);
|
|
person = ConvertPersonTool.INSTANCE.convertUpdateDto2Entity(person, updatePerson4FrontEndDTO);
|
|
person = ConvertPersonTool.INSTANCE.convertUpdateDto2Entity(person, updatePerson4FrontEndDTO);
|
|
person.setNamePinyin(PinyinUtil.getPinyin(person.getName(), ""));
|
|
person.setNamePinyin(PinyinUtil.getPinyin(person.getName(), ""));
|
|
List<String> professions = updatePerson4FrontEndDTO.getProfessions();
|
|
List<String> professions = updatePerson4FrontEndDTO.getProfessions();
|
|
@@ -533,6 +531,32 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 校验直接上级
|
|
|
|
+ *
|
|
|
|
+ * @param leaderId 直接上级id
|
|
|
|
+ * @param person 人员对象
|
|
|
|
+ * @author lixing
|
|
|
|
+ * @version V1.0 2021/4/22 11:43 上午
|
|
|
|
+ */
|
|
|
|
+ private void checkLeader(Long leaderId, Person person) {
|
|
|
|
+ if (leaderId == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String personId = person.getId();
|
|
|
|
+ if (personId.equals(leaderId.toString())) {
|
|
|
|
+ throw new IllegalArgumentException("不能选择自己作为直接上级");
|
|
|
|
+ }
|
|
|
|
+ // 不能选择直接上级是自己的员工作为上级
|
|
|
|
+ List<Person> people = queryByLeader(leaderId);
|
|
|
|
+ people.forEach(tmpPerson -> {
|
|
|
|
+ String tmpPersonId = tmpPerson.getId();
|
|
|
|
+ if (tmpPersonId.equals(leaderId.toString())) {
|
|
|
|
+ throw new IllegalArgumentException("不能选择自己的下级作为直接上级");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 重置账号与角色的关联关系
|
|
* 重置账号与角色的关联关系
|
|
*
|
|
*
|
|
* @param updatePerson4FrontEndDTO 更新人员入参
|
|
* @param updatePerson4FrontEndDTO 更新人员入参
|
|
@@ -1189,10 +1213,31 @@ public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public List<Person> queryByLeader(Long leaderId) {
|
|
|
|
+ if (leaderId == null) {
|
|
|
|
+ throw new IllegalArgumentException("根据直接上级查询人员,直接上级id不可为空");
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<Person> personLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ personLambdaQueryWrapper.
|
|
|
|
+ eq(Person::getLeader, leaderId).
|
|
|
|
+ eq(Person::getValid, ValidEnum.TRUE.getType());
|
|
|
|
+ return list(personLambdaQueryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public IPage<ResponsePersonListItemVO> pageQueryByNameOrUserName(PageQueryPersonByNameOrUserNameDTO pageQueryPersonDTO) {
|
|
public IPage<ResponsePersonListItemVO> pageQueryByNameOrUserName(PageQueryPersonByNameOrUserNameDTO pageQueryPersonDTO) {
|
|
List<Person> people = personMapper.queryPersonListByNameOrUserName(pageQueryPersonDTO);
|
|
List<Person> people = personMapper.queryPersonListByNameOrUserName(pageQueryPersonDTO);
|
|
int total = personMapper.queryCountByNameOrUserName(pageQueryPersonDTO);
|
|
int total = personMapper.queryCountByNameOrUserName(pageQueryPersonDTO);
|
|
|
|
|
|
return packagePageResult(people, total);
|
|
return packagePageResult(people, total);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<ResponsePersonListItemVO> queryByUserName(QueryByUserNameDTO queryByUserNameDTO) {
|
|
|
|
+ QueryWrapper<Person> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(Person.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
|
+ queryWrapper.eq(Person.PROP_USERNAME, queryByUserNameDTO.getUsername());
|
|
|
|
+ List<Person> result = list(queryWrapper);
|
|
|
|
+ return packagePageResult(result, result.size());
|
|
|
|
+ }
|
|
}
|
|
}
|