修改员工SQL

This commit is contained in:
zhoumingfa 2024-11-13 00:34:42 +08:00
parent 69ff0a9631
commit 7b712bae71
4 changed files with 29 additions and 35 deletions

View File

@ -104,7 +104,7 @@ public class EmployeeController {
@Operation(summary = "查询员工-根据部门id @author 卓大") @Operation(summary = "查询员工-根据部门id @author 卓大")
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}") @GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) { public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE); return employeeService.getAllEmployeeByDepartmentId(departmentId);
} }
@Operation(summary = "查询所有员工 @author 卓大") @Operation(summary = "查询所有员工 @author 卓大")

View File

@ -36,7 +36,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
/** /**
* 更新单个 * 更新禁用状态
*/ */
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag); void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
@ -44,21 +44,18 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
/** /**
* 通过登录名查询 * 通过登录名查询
*/ */
EmployeeEntity getByLoginName(@Param("loginName") String loginName, EmployeeEntity getByLoginName(@Param("loginName") String loginName, @Param("deletedFlag") Boolean deletedFlag);
@Param("disabledFlag") Boolean disabledFlag);
/** /**
* 通过姓名查询 * 通过姓名查询
*/ */
EmployeeEntity getByActualName(@Param("actualName") String actualName, EmployeeEntity getByActualName(@Param("actualName") String actualName, @Param("deletedFlag") Boolean deletedFlag);
@Param("disabledFlag") Boolean disabledFlag
);
/** /**
* 通过手机号查询 * 通过手机号查询
*/ */
EmployeeEntity getByPhone(@Param("phone") String phone, @Param("disabledFlag") Boolean disabledFlag); EmployeeEntity getByPhone(@Param("phone") String phone, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 获取所有员工 * 获取所有员工
@ -86,29 +83,29 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
/** /**
* 获取某个部门的员工 * 获取某个部门的员工
*/ */
List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag); List<EmployeeEntity> selectByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 查询某些部门下用户名是xxx的员工 * 查询某些部门下用户名是xxx的员工
*/ */
List<EmployeeEntity> selectByActualName(@Param("departmentIdList") List<Long> departmentIdList, @Param("actualName") String actualName, @Param("disabledFlag") Boolean disabledFlag); List<EmployeeEntity> selectByActualName(@Param("departmentIdList") List<Long> departmentIdList, @Param("actualName") String actualName, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 获取某批部门的员工Id * 获取某批部门的员工Id
*/ */
List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("disabledFlag") Boolean disabledFlag); List<Long> getEmployeeIdByDepartmentIdList(@Param("departmentIds") List<Long> departmentIds, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 获取所有 * 获取所有
*/ */
List<Long> getEmployeeId(@Param("leaveFlag") Boolean leaveFlag, @Param("disabledFlag") Boolean disabledFlag); List<Long> getEmployeeId(@Param("leaveFlag") Boolean leaveFlag, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 获取某个部门的员工Id * 获取某个部门的员工Id
*/ */
List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("disabledFlag") Boolean disabledFlag); List<Long> getEmployeeIdByDepartmentId(@Param("departmentId") Long departmentId, @Param("deletedFlag") Boolean deletedFlag);
/** /**
* 员工重置密码 * 员工重置密码

View File

@ -337,11 +337,8 @@ public class EmployeeService {
/** /**
* 获取某个部门的员工信息 * 获取某个部门的员工信息
*/ */
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) { public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId) {
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag); List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, Boolean.FALSE);
if (disabledFlag != null) {
employeeEntityList = employeeEntityList.stream().filter(e -> e.getDisabledFlag().equals(disabledFlag)).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(employeeEntityList)) { if (CollectionUtils.isEmpty(employeeEntityList)) {
return ResponseDTO.ok(Collections.emptyList()); return ResponseDTO.ok(Collections.emptyList());
@ -389,7 +386,7 @@ public class EmployeeService {
* 根据登录名获取员工 * 根据登录名获取员工
*/ */
public EmployeeEntity getByLoginName(String loginName) { public EmployeeEntity getByLoginName(String loginName) {
return employeeDao.getByLoginName(loginName, null); return employeeDao.getByLoginName(loginName, false);
} }
} }

View File

@ -46,8 +46,8 @@
FROM t_employee FROM t_employee
<where> <where>
login_name = #{loginName} login_name = #{loginName}
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
</select> </select>
@ -57,8 +57,8 @@
FROM t_employee FROM t_employee
<where> <where>
actual_name = #{actualName} actual_name = #{actualName}
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
</select> </select>
@ -69,8 +69,8 @@
FROM t_employee FROM t_employee
<where> <where>
phone = #{phone} phone = #{phone}
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
</select> </select>
@ -95,8 +95,8 @@
FROM t_employee FROM t_employee
<where> <where>
department_id = #{departmentId} department_id = #{departmentId}
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
ORDER BY create_time DESC ORDER BY create_time DESC
@ -111,8 +111,8 @@
<foreach collection="departmentIdList" item="item" open="(" close=")" separator=","> <foreach collection="departmentIdList" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
</select> </select>
@ -125,8 +125,8 @@
<foreach collection="departmentIds" item="item" open="(" close=")" separator=","> <foreach collection="departmentIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
ORDER BY create_time DESC ORDER BY create_time DESC
@ -137,8 +137,8 @@
SELECT employee_id SELECT employee_id
FROM t_employee FROM t_employee
<where> <where>
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
</select> </select>
@ -148,8 +148,8 @@
FROM t_employee FROM t_employee
<where> <where>
department_id = #{departmentId} department_id = #{departmentId}
<if test="disabledFlag != null"> <if test="deletedFlag != null">
AND disabled_flag = #{disabledFlag} AND deleted_flag = #{deletedFlag}
</if> </if>
</where> </where>
ORDER BY create_time DESC ORDER BY create_time DESC