-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】…
…部门员工管理
- Loading branch information
zhuoda
committed
Jul 15, 2024
1 parent
8fdcf13
commit e0c2b5a
Showing
505 changed files
with
59,748 additions
and
1,111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ava/net/lab1024/sa/admin/module/system/employee/domain/form/EmployeeUpdateAvatarForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.lab1024.sa.admin.module.system.employee.domain.form; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
import net.lab1024.sa.base.common.util.SmartVerificationUtil; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Pattern; | ||
|
||
/** | ||
* 修改登录人头像 | ||
* | ||
* @Author 1024创新实验室: 善逸 | ||
* @Date 2024年6月30日00:26:35 | ||
* @Wechat zhuoda1024 | ||
* @Email [email protected] | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
*/ | ||
@Data | ||
public class EmployeeUpdateAvatarForm { | ||
|
||
@Schema(hidden = true) | ||
private Long employeeId; | ||
|
||
@Schema(description = "头像") | ||
@NotBlank(message = "头像不能为空哦") | ||
private String avatar; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
import net.lab1024.sa.admin.module.system.employee.domain.form.*; | ||
import net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO; | ||
import net.lab1024.sa.admin.module.system.employee.manager.EmployeeManager; | ||
import net.lab1024.sa.admin.module.system.login.service.LoginService; | ||
import net.lab1024.sa.admin.module.system.position.dao.PositionDao; | ||
import net.lab1024.sa.admin.module.system.position.domain.entity.PositionEntity; | ||
import net.lab1024.sa.admin.module.system.role.dao.RoleEmployeeDao; | ||
import net.lab1024.sa.admin.module.system.role.domain.vo.RoleEmployeeVO; | ||
import net.lab1024.sa.base.common.code.UserErrorCode; | ||
|
@@ -24,6 +27,7 @@ | |
import net.lab1024.sa.base.module.support.securityprotect.service.ProtectPasswordService; | ||
import org.apache.commons.codec.digest.DigestUtils; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.Resource; | ||
|
@@ -37,7 +41,7 @@ | |
* @Date 2021-12-29 21:52:46 | ||
* @Wechat zhuoda1024 | ||
* @Email [email protected] | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
*/ | ||
@Service | ||
public class EmployeeService { | ||
|
@@ -62,14 +66,20 @@ public class EmployeeService { | |
@Resource | ||
private ProtectPasswordService protectPasswordService; | ||
|
||
@Resource | ||
@Lazy | ||
private LoginService loginService; | ||
|
||
@Resource | ||
private PositionDao positionDao; | ||
|
||
public EmployeeEntity getById(Long employeeId) { | ||
return employeeDao.selectById(employeeId); | ||
} | ||
|
||
|
||
/** | ||
* 查询员工列表 | ||
* | ||
*/ | ||
public ResponseDTO<PageResult<EmployeeVO>> queryEmployee(EmployeeQueryForm employeeQueryForm) { | ||
employeeQueryForm.setDeletedFlag(false); | ||
|
@@ -86,24 +96,29 @@ public ResponseDTO<PageResult<EmployeeVO>> queryEmployee(EmployeeQueryForm emplo | |
return ResponseDTO.ok(pageResult); | ||
} | ||
|
||
List<Long> employeeIdList = employeeList.stream().map(EmployeeVO::getEmployeeId).collect(Collectors.toList()); | ||
// 查询员工角色 | ||
List<RoleEmployeeVO> roleEmployeeEntityList = roleEmployeeDao.selectRoleByEmployeeIdList(employeeIdList); | ||
List<Long> employeeIdList = employeeList.stream().map(EmployeeVO::getEmployeeId).collect(Collectors.toList()); | ||
List<RoleEmployeeVO> roleEmployeeEntityList = employeeIdList.isEmpty() ? Collections.emptyList() : roleEmployeeDao.selectRoleByEmployeeIdList(employeeIdList); | ||
Map<Long, List<Long>> employeeRoleIdListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleId, Collectors.toList()))); | ||
Map<Long, List<String>> employeeRoleNameListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleName, Collectors.toList()))); | ||
|
||
// 查询员工职位 | ||
List<Long> positionIdList = employeeList.stream().map(EmployeeVO::getPositionId).filter(Objects::nonNull).collect(Collectors.toList()); | ||
List<PositionEntity> positionEntityList = positionIdList.isEmpty() ? Collections.emptyList() : positionDao.selectBatchIds(positionIdList); | ||
Map<Long, String> positionNameMap = positionEntityList.stream().collect(Collectors.toMap(PositionEntity::getPositionId, PositionEntity::getPositionName)); | ||
|
||
employeeList.forEach(e -> { | ||
e.setRoleIdList(employeeRoleIdListMap.getOrDefault(e.getEmployeeId(), Lists.newArrayList())); | ||
e.setRoleNameList(employeeRoleNameListMap.getOrDefault(e.getEmployeeId(), Lists.newArrayList())); | ||
e.setDepartmentName(departmentService.getDepartmentPath(e.getDepartmentId())); | ||
e.setPositionName(positionNameMap.get(e.getPositionId())); | ||
}); | ||
PageResult<EmployeeVO> pageResult = SmartPageUtil.convert2PageResult(pageParam, employeeList); | ||
return ResponseDTO.ok(pageResult); | ||
} | ||
|
||
/** | ||
* 新增员工 | ||
* | ||
*/ | ||
public synchronized ResponseDTO<String> addEmployee(EmployeeAddForm employeeAddForm) { | ||
// 校验名称是否重复 | ||
|
@@ -143,7 +158,6 @@ public synchronized ResponseDTO<String> addEmployee(EmployeeAddForm employeeAddF | |
|
||
/** | ||
* 更新员工 | ||
* | ||
*/ | ||
public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employeeUpdateForm) { | ||
|
||
|
@@ -183,12 +197,38 @@ public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employ | |
// 更新数据 | ||
employeeManager.updateEmployee(entity, employeeUpdateForm.getRoleIdList()); | ||
|
||
// 清除员工缓存 | ||
loginService.clearLoginEmployeeCache(employeeId); | ||
|
||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
||
/** | ||
* 更新禁用/启用状态 | ||
* 更新登录人头像 | ||
* | ||
* @param employeeUpdateAvatarForm | ||
* @return | ||
*/ | ||
public ResponseDTO<String> updateAvatar(EmployeeUpdateAvatarForm employeeUpdateAvatarForm) { | ||
Long employeeId = employeeUpdateAvatarForm.getEmployeeId(); | ||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId); | ||
if (employeeEntity == null) { | ||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST); | ||
} | ||
// 更新头像 | ||
EmployeeEntity updateEntity = new EmployeeEntity(); | ||
updateEntity.setEmployeeId(employeeId); | ||
updateEntity.setAvatar(employeeUpdateAvatarForm.getAvatar()); | ||
employeeDao.updateById(updateEntity); | ||
|
||
// 清除员工缓存 | ||
loginService.clearLoginEmployeeCache(employeeId); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
/** | ||
* 更新禁用/启用状态 | ||
*/ | ||
public ResponseDTO<String> updateDisableFlag(Long employeeId) { | ||
if (null == employeeId) { | ||
|
@@ -210,7 +250,6 @@ public ResponseDTO<String> updateDisableFlag(Long employeeId) { | |
|
||
/** | ||
* 批量删除员工 | ||
* | ||
*/ | ||
public ResponseDTO<String> batchUpdateDeleteFlag(List<Long> employeeIdList) { | ||
if (CollectionUtils.isEmpty(employeeIdList)) { | ||
|
@@ -239,7 +278,6 @@ public ResponseDTO<String> batchUpdateDeleteFlag(List<Long> employeeIdList) { | |
|
||
/** | ||
* 批量更新部门 | ||
* | ||
*/ | ||
public ResponseDTO<String> batchUpdateDepartment(EmployeeBatchUpdateDepartmentForm batchUpdateDepartmentForm) { | ||
List<Long> employeeIdList = batchUpdateDepartmentForm.getEmployeeIdList(); | ||
|
@@ -262,7 +300,6 @@ public ResponseDTO<String> batchUpdateDepartment(EmployeeBatchUpdateDepartmentFo | |
|
||
/** | ||
* 更新密码 | ||
* | ||
*/ | ||
public ResponseDTO<String> updatePassword(EmployeeUpdatePasswordForm updatePasswordForm) { | ||
Long employeeId = updatePasswordForm.getEmployeeId(); | ||
|
@@ -299,7 +336,6 @@ public ResponseDTO<String> updatePassword(EmployeeUpdatePasswordForm updatePassw | |
|
||
/** | ||
* 获取某个部门的员工信息 | ||
* | ||
*/ | ||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) { | ||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag); | ||
|
@@ -326,7 +362,6 @@ public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmen | |
|
||
/** | ||
* 重置密码 | ||
* | ||
*/ | ||
public ResponseDTO<String> resetPassword(Integer employeeId) { | ||
String password = protectPasswordService.randomPassword(); | ||
|
@@ -336,7 +371,6 @@ public ResponseDTO<String> resetPassword(Integer employeeId) { | |
|
||
/** | ||
* 获取 加密后 的密码 | ||
* | ||
*/ | ||
public static String getEncryptPwd(String password) { | ||
return DigestUtils.md5Hex(String.format(PASSWORD_SALT_FORMAT, password)); | ||
|
@@ -345,7 +379,6 @@ public static String getEncryptPwd(String password) { | |
|
||
/** | ||
* 查询全部员工 | ||
* | ||
*/ | ||
public ResponseDTO<List<EmployeeVO>> queryAllEmployee(Boolean disabledFlag) { | ||
List<EmployeeVO> employeeList = employeeDao.selectEmployeeByDisabledAndDeleted(disabledFlag, Boolean.FALSE); | ||
|
@@ -354,7 +387,6 @@ public ResponseDTO<List<EmployeeVO>> queryAllEmployee(Boolean disabledFlag) { | |
|
||
/** | ||
* 根据登录名获取员工 | ||
* | ||
*/ | ||
public EmployeeEntity getByLoginName(String loginName) { | ||
return employeeDao.getByLoginName(loginName, null); | ||
|
Oops, something went wrong.