Skip to content

Commit

Permalink
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】…
Browse files Browse the repository at this point in the history
…部门员工管理
  • Loading branch information
zhuoda committed Jul 15, 2024
1 parent 8fdcf13 commit e0c2b5a
Show file tree
Hide file tree
Showing 505 changed files with 59,748 additions and 1,111 deletions.
35 changes: 35 additions & 0 deletions smart-admin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-collections4.version>4.4</commons-collections4.version>
<commons-codec.version>1.13</commons-codec.version>
<commons-text.version>1.9</commons-text.version>
<xerces.version>2.12.0</xerces.version>
<easy-excel.version>3.3.2</easy-excel.version>
<poi.version>5.2.4</poi.version>
Expand All @@ -52,6 +53,7 @@
<bcprov.version>1.59</bcprov.version>
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
<smartdb.version>1.2.0</smartdb.version>
<redisson.version>3.25.0</redisson.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -193,6 +195,12 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-spring-boot</artifactId>
Expand Down Expand Up @@ -306,6 +314,33 @@
<artifactId>smartdb</artifactId>
<version>${smartdb.version}</version>
</dependency>

<!-- redisson 排除和依赖data-27 为了springboot2.x 和 java8 -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>${redisson.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</exclusion>
<exclusion>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-32</artifactId>
</exclusion>
<exclusion>
<artifactId>objenesis</artifactId>
<groupId>org.objenesis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-27</artifactId>
<version>${redisson.version}</version>
</dependency>

</dependencies>

</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static class Business {
public static final String OA_INVOICE = "OA办公-发票信息";

public static final String OA_NOTICE = "OA办公-通知公告";

}


Expand All @@ -48,6 +49,8 @@ public static class System {

public static final String SYSTEM_ROLE_MENU = "系统-角色-菜单";

public static final String SYSTEM_POSITION = "系统-职务管理";

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
* 部门
*
Expand Down Expand Up @@ -33,4 +35,10 @@ public class DepartmentVO {
@Schema(description = "排序")
private Integer sort;

@Schema(description = "更新时间")
private LocalDateTime updateTime;

@Schema(description = "创建时间")
private LocalDateTime createTime;

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ public ResponseDTO<String> updateEmployee(@Valid @RequestBody EmployeeUpdateForm
return employeeService.updateEmployee(employeeUpdateForm);
}

@Operation(summary = "更新登录人信息 @author 善逸")
@PostMapping("/employee/update/login")
public ResponseDTO<String> updateByLogin(@Valid @RequestBody EmployeeUpdateForm employeeUpdateForm) {
employeeUpdateForm.setEmployeeId(SmartRequestUtil.getRequestUserId());
return employeeService.updateEmployee(employeeUpdateForm);
}

@Operation(summary = "更新登录人头像 @author 善逸")
@PostMapping("/employee/update/avatar")
public ResponseDTO<String> updateAvatar(@Valid @RequestBody EmployeeUpdateAvatarForm employeeUpdateAvatarForm) {
employeeUpdateAvatarForm.setEmployeeId(SmartRequestUtil.getRequestUserId());
return employeeService.updateAvatar(employeeUpdateAvatarForm);
}

@Operation(summary = "更新员工禁用/启用状态 @author 卓大")
@GetMapping("/employee/update/disabled/{employeeId}")
@SaCheckPermission("system:employee:disabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class EmployeeEntity {
*/
private String actualName;

/**
* 头像
*/
private String avatar;

/**
* 性别
*/
Expand All @@ -53,6 +58,11 @@ public class EmployeeEntity {
*/
private Long departmentId;

/**
* 职务级别ID
*/
private Long positionId;

/**
* 是否为超级管理员: 0 不是,1是
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ public class EmployeeAddForm {

@Schema(description = "角色列表")
private List<Long> roleIdList;

@Schema(description = "备注")
@Length(max = 30, message = "备注最多200字符")
private String remark;

@Schema(description = "职务级别ID")
private Long positionId;

}
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ public class EmployeeVO {

@Schema(description = "角色名称列表")
private List<String> roleNameList;

@Schema(description = "职务ID")
private Long positionId;

@Schema(description = "职务名称")
private String positionName;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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) {
// 校验名称是否重复
Expand Down Expand Up @@ -143,7 +158,6 @@ public synchronized ResponseDTO<String> addEmployee(EmployeeAddForm employeeAddF

/**
* 更新员工
*
*/
public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employeeUpdateForm) {

Expand Down Expand Up @@ -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) {
Expand All @@ -210,7 +250,6 @@ public ResponseDTO<String> updateDisableFlag(Long employeeId) {

/**
* 批量删除员工
*
*/
public ResponseDTO<String> batchUpdateDeleteFlag(List<Long> employeeIdList) {
if (CollectionUtils.isEmpty(employeeIdList)) {
Expand Down Expand Up @@ -239,7 +278,6 @@ public ResponseDTO<String> batchUpdateDeleteFlag(List<Long> employeeIdList) {

/**
* 批量更新部门
*
*/
public ResponseDTO<String> batchUpdateDepartment(EmployeeBatchUpdateDepartmentForm batchUpdateDepartmentForm) {
List<Long> employeeIdList = batchUpdateDepartmentForm.getEmployeeIdList();
Expand All @@ -262,7 +300,6 @@ public ResponseDTO<String> batchUpdateDepartment(EmployeeBatchUpdateDepartmentFo

/**
* 更新密码
*
*/
public ResponseDTO<String> updatePassword(EmployeeUpdatePasswordForm updatePasswordForm) {
Long employeeId = updatePasswordForm.getEmployeeId();
Expand Down Expand Up @@ -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);
Expand All @@ -326,7 +362,6 @@ public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmen

/**
* 重置密码
*
*/
public ResponseDTO<String> resetPassword(Integer employeeId) {
String password = protectPasswordService.randomPassword();
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -354,7 +387,6 @@ public ResponseDTO<List<EmployeeVO>> queryAllEmployee(Boolean disabledFlag) {

/**
* 根据登录名获取员工
*
*/
public EmployeeEntity getByLoginName(String loginName) {
return employeeDao.getByLoginName(loginName, null);
Expand Down
Loading

0 comments on commit e0c2b5a

Please sign in to comment.