mirror of https://gitee.com/stylefeng/roses
【HrPosition】职位业务优化
parent
c08308a7d4
commit
058bbe638a
|
@ -17,7 +17,7 @@ import javax.annotation.Resource;
|
||||||
/**
|
/**
|
||||||
* 系统职位控制器
|
* 系统职位控制器
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/18 21:56
|
* @date 2020/11/18 21:56
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -30,7 +30,7 @@ public class HrPositionController {
|
||||||
/**
|
/**
|
||||||
* 添加系统职位
|
* 添加系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "添加系统职位", path = "/hrPosition/add")
|
@PostResource(name = "添加系统职位", path = "/hrPosition/add")
|
||||||
|
@ -42,7 +42,7 @@ public class HrPositionController {
|
||||||
/**
|
/**
|
||||||
* 编辑系统职位
|
* 编辑系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "编辑系统职位", path = "/hrPosition/edit")
|
@PostResource(name = "编辑系统职位", path = "/hrPosition/edit")
|
||||||
|
@ -54,19 +54,19 @@ public class HrPositionController {
|
||||||
/**
|
/**
|
||||||
* 删除系统职位
|
* 删除系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "删除系统职位", path = "/hrPosition/delete")
|
@PostResource(name = "删除系统职位", path = "/hrPosition/delete")
|
||||||
public ResponseData delete(@RequestBody @Validated(HrPositionRequest.delete.class) HrPositionRequest hrPositionRequest) {
|
public ResponseData delete(@RequestBody @Validated(HrPositionRequest.delete.class) HrPositionRequest hrPositionRequest) {
|
||||||
hrPositionService.delete(hrPositionRequest);
|
hrPositionService.del(hrPositionRequest);
|
||||||
return new SuccessResponseData();
|
return new SuccessResponseData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新职位状态
|
* 更新职位状态
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "更新职位状态", path = "/hrPosition/updateStatus")
|
@PostResource(name = "更新职位状态", path = "/hrPosition/updateStatus")
|
||||||
|
@ -78,7 +78,7 @@ public class HrPositionController {
|
||||||
/**
|
/**
|
||||||
* 查看详情系统职位
|
* 查看详情系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "查看详情系统职位", path = "/hrPosition/detail")
|
@GetResource(name = "查看详情系统职位", path = "/hrPosition/detail")
|
||||||
|
@ -89,23 +89,23 @@ public class HrPositionController {
|
||||||
/**
|
/**
|
||||||
* 分页查询系统职位
|
* 分页查询系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "分页查询系统职位", path = "/hrPosition/page")
|
@GetResource(name = "分页查询系统职位", path = "/hrPosition/page")
|
||||||
public ResponseData page(HrPositionRequest hrPositionRequest) {
|
public ResponseData page(HrPositionRequest hrPositionRequest) {
|
||||||
return new SuccessResponseData(hrPositionService.page(hrPositionRequest));
|
return new SuccessResponseData(hrPositionService.findPage(hrPositionRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部系统职位
|
* 获取全部系统职位
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "获取全部系统职位", path = "/hrPosition/list")
|
@GetResource(name = "获取全部系统职位", path = "/hrPosition/list")
|
||||||
public ResponseData list(HrPositionRequest hrPositionRequest) {
|
public ResponseData list(HrPositionRequest hrPositionRequest) {
|
||||||
return new SuccessResponseData(hrPositionService.list(hrPositionRequest));
|
return new SuccessResponseData(hrPositionService.findList(hrPositionRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 职位信息服务
|
* 职位信息服务
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
public interface HrPositionService extends IService<HrPosition> {
|
public interface HrPositionService extends IService<HrPosition> {
|
||||||
|
@ -19,76 +19,66 @@ public interface HrPositionService extends IService<HrPosition> {
|
||||||
* 添加职位
|
* 添加职位
|
||||||
*
|
*
|
||||||
* @param hrPositionRequest 请求参数
|
* @param hrPositionRequest 请求参数
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
void add(HrPositionRequest hrPositionRequest);
|
void add(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除职位
|
||||||
|
*
|
||||||
|
* @param hrPositionRequest 请求参数
|
||||||
|
* @author chenjinlong
|
||||||
|
* @date 2020/11/04 11:07
|
||||||
|
*/
|
||||||
|
void del(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑职位
|
* 编辑职位
|
||||||
*
|
*
|
||||||
* @param hrPositionRequest 请求参数
|
* @param hrPositionRequest 请求参数
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
void edit(HrPositionRequest hrPositionRequest);
|
void edit(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除职位
|
|
||||||
*
|
|
||||||
* @param hrPositionRequest 请求参数
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/11/04 11:07
|
|
||||||
*/
|
|
||||||
void delete(HrPositionRequest hrPositionRequest);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新装填
|
* 更新装填
|
||||||
*
|
*
|
||||||
* @param hrPositionRequest 请求参数
|
* @param hrPositionRequest 请求参数
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/18 23:00
|
* @date 2020/11/18 23:00
|
||||||
*/
|
*/
|
||||||
void updateStatus(HrPositionRequest hrPositionRequest);
|
void updateStatus(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看详情职位
|
* 查看详情
|
||||||
*
|
*
|
||||||
* @param hrPositionRequest 请求参数
|
* @param hrPositionRequest 请求参数
|
||||||
* @return 职位详情
|
* @return 职位详情
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
HrPosition detail(HrPositionRequest hrPositionRequest);
|
HrPosition detail(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询职位
|
* 查询职位详情列表
|
||||||
*
|
|
||||||
* @param hrPositionRequest 请求参数
|
|
||||||
* @return 职位详情分页列表
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/11/04 11:07
|
|
||||||
*/
|
|
||||||
PageResult<HrPosition> page(HrPositionRequest hrPositionRequest);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有职位
|
|
||||||
*
|
*
|
||||||
* @param hrPositionRequest 请求参数
|
* @param hrPositionRequest 请求参数
|
||||||
* @return 职位详情列表
|
* @return 职位详情列表
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/04 11:07
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
List<HrPosition> list(HrPositionRequest hrPositionRequest);
|
List<HrPosition> findList(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过职位id列表,获取对应的名称列表
|
* 分页查询职位详情列表
|
||||||
*
|
*
|
||||||
* @param positionIds 职位id列表
|
* @param hrPositionRequest 请求参数
|
||||||
* @return 职位名称列表
|
* @return 职位详情分页列表
|
||||||
* @author fengshuonan
|
* @author chenjinlong
|
||||||
* @date 2020/11/19 23:22
|
* @date 2020/11/04 11:07
|
||||||
*/
|
*/
|
||||||
List<String> getPositionNamesByPositionIds(List<Long> positionIds);
|
PageResult<HrPosition> findPage(HrPositionRequest hrPositionRequest);
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,11 +19,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统职位表 服务实现类
|
* 系统职位表 服务实现类
|
||||||
|
@ -50,24 +48,16 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void edit(HrPositionRequest hrPositionRequest) {
|
public void edit(HrPositionRequest hrPositionRequest) {
|
||||||
|
HrPosition sysPosition = this.querySysPositionById(hrPositionRequest);
|
||||||
HrPosition sysPosition = this.querySysPosition(hrPositionRequest);
|
|
||||||
BeanUtil.copyProperties(hrPositionRequest, sysPosition);
|
BeanUtil.copyProperties(hrPositionRequest, sysPosition);
|
||||||
|
|
||||||
// 不能修改状态,用修改状态接口修改状态
|
|
||||||
sysPosition.setStatusFlag(null);
|
|
||||||
|
|
||||||
this.updateById(sysPosition);
|
this.updateById(sysPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
public void del(HrPositionRequest hrPositionRequest) {
|
||||||
public void delete(HrPositionRequest hrPositionRequest) {
|
HrPosition sysPosition = this.querySysPositionById(hrPositionRequest);
|
||||||
|
|
||||||
HrPosition sysPosition = this.querySysPosition(hrPositionRequest);
|
// 该职位下是否有员工,如果有将不能删除
|
||||||
|
|
||||||
// 该职位下是否有员工
|
|
||||||
// 职位有绑定员工,不能删除
|
|
||||||
Boolean userOrgFlag = userOrgServiceApi.getUserOrgFlag(null, sysPosition.getPositionId());
|
Boolean userOrgFlag = userOrgServiceApi.getUserOrgFlag(null, sysPosition.getPositionId());
|
||||||
if (userOrgFlag) {
|
if (userOrgFlag) {
|
||||||
throw new SystemModularException(PositionExceptionEnum.CANT_DELETE_POSITION);
|
throw new SystemModularException(PositionExceptionEnum.CANT_DELETE_POSITION);
|
||||||
|
@ -75,92 +65,43 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
||||||
|
|
||||||
// 逻辑删除
|
// 逻辑删除
|
||||||
sysPosition.setDelFlag(YesOrNotEnum.Y.getCode());
|
sysPosition.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||||
|
|
||||||
this.updateById(sysPosition);
|
this.updateById(sysPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(HrPositionRequest hrPositionRequest) {
|
public void updateStatus(HrPositionRequest hrPositionRequest) {
|
||||||
|
HrPosition sysPosition = this.querySysPositionById(hrPositionRequest);
|
||||||
// 先查询有没有这条记录,再更新
|
|
||||||
HrPosition sysPosition = this.querySysPosition(hrPositionRequest);
|
|
||||||
|
|
||||||
sysPosition.setStatusFlag(hrPositionRequest.getStatusFlag());
|
sysPosition.setStatusFlag(hrPositionRequest.getStatusFlag());
|
||||||
|
|
||||||
this.updateById(sysPosition);
|
this.updateById(sysPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HrPosition detail(HrPositionRequest hrPositionRequest) {
|
public HrPosition detail(HrPositionRequest hrPositionRequest) {
|
||||||
return this.querySysPosition(hrPositionRequest);
|
return this.querySysPositionById(hrPositionRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<HrPosition> page(HrPositionRequest hrPositionRequest) {
|
public List<HrPosition> findList(HrPositionRequest hrPositionRequest) {
|
||||||
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(hrPositionRequest);
|
LambdaQueryWrapper<HrPosition> wrapper = this.createWrapper(hrPositionRequest);
|
||||||
|
return this.list(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<HrPosition> findPage(HrPositionRequest hrPositionRequest) {
|
||||||
|
LambdaQueryWrapper<HrPosition> wrapper = this.createWrapper(hrPositionRequest);
|
||||||
|
|
||||||
Page<HrPosition> page = this.page(PageFactory.defaultPage(), wrapper);
|
Page<HrPosition> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||||
return PageResultFactory.createPageResult(page);
|
return PageResultFactory.createPageResult(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<HrPosition> list(HrPositionRequest hrPositionRequest) {
|
|
||||||
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(hrPositionRequest);
|
|
||||||
return this.list(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getPositionNamesByPositionIds(List<Long> positionIds) {
|
|
||||||
|
|
||||||
// 拼接查询条件
|
|
||||||
LambdaQueryWrapper<HrPosition> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.in(HrPosition::getPositionId, positionIds);
|
|
||||||
queryWrapper.select(HrPosition::getPositionName);
|
|
||||||
|
|
||||||
// 查询结果
|
|
||||||
List<HrPosition> sysPositions = this.list(queryWrapper);
|
|
||||||
|
|
||||||
// 把name组装起来
|
|
||||||
return sysPositions.stream().map(HrPosition::getPositionName).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼接查询条件
|
* 根据主键id获取对象信息
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @return 实体对象
|
||||||
* @date 2020/11/6 18:35
|
* @author chenjinlong
|
||||||
|
* @date 2021/2/2 10:16
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<HrPosition> createWrapper(HrPositionRequest hrPositionRequest) {
|
private HrPosition querySysPositionById(HrPositionRequest hrPositionRequest) {
|
||||||
LambdaQueryWrapper<HrPosition> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (ObjectUtil.isNotNull(hrPositionRequest)) {
|
|
||||||
|
|
||||||
// 拼接职位名称条件
|
|
||||||
if (ObjectUtil.isNotEmpty(hrPositionRequest.getPositionName())) {
|
|
||||||
queryWrapper.like(HrPosition::getPositionName, hrPositionRequest.getPositionName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接职位编码条件
|
|
||||||
if (ObjectUtil.isNotEmpty(hrPositionRequest.getPositionCode())) {
|
|
||||||
queryWrapper.eq(HrPosition::getPositionCode, hrPositionRequest.getPositionCode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询未删除状态的
|
|
||||||
queryWrapper.eq(HrPosition::getDelFlag, YesOrNotEnum.N.getCode());
|
|
||||||
|
|
||||||
// 根据排序升序排列,序号越小越在前
|
|
||||||
queryWrapper.orderByAsc(HrPosition::getPositionSort);
|
|
||||||
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取系统职位表
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/11/18 22:59
|
|
||||||
*/
|
|
||||||
private HrPosition querySysPosition(HrPositionRequest hrPositionRequest) {
|
|
||||||
HrPosition hrPosition = this.getById(hrPositionRequest.getPositionId());
|
HrPosition hrPosition = this.getById(hrPositionRequest.getPositionId());
|
||||||
if (ObjectUtil.isEmpty(hrPosition)) {
|
if (ObjectUtil.isEmpty(hrPosition)) {
|
||||||
String userTip = StrUtil.format(PositionExceptionEnum.CANT_FIND_POSITION.getUserTip(), hrPositionRequest.getPositionId());
|
String userTip = StrUtil.format(PositionExceptionEnum.CANT_FIND_POSITION.getUserTip(), hrPositionRequest.getPositionId());
|
||||||
|
@ -168,4 +109,34 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
||||||
}
|
}
|
||||||
return hrPosition;
|
return hrPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体构建 QueryWrapper
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @author chenjinlong
|
||||||
|
* @date 2021/2/2 10:17
|
||||||
|
*/
|
||||||
|
private LambdaQueryWrapper<HrPosition> createWrapper(HrPositionRequest hrPositionRequest) {
|
||||||
|
LambdaQueryWrapper<HrPosition> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
Long positionId = hrPositionRequest.getPositionId();
|
||||||
|
String positionName = hrPositionRequest.getPositionName();
|
||||||
|
String positionCode = hrPositionRequest.getPositionCode();
|
||||||
|
|
||||||
|
// SQL条件拼接
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotNull(positionId), HrPosition::getPositionId, positionId);
|
||||||
|
queryWrapper.like(StrUtil.isNotEmpty(positionName), HrPosition::getPositionName, positionName);
|
||||||
|
queryWrapper.eq(StrUtil.isNotEmpty(positionCode), HrPosition::getPositionCode, positionCode);
|
||||||
|
|
||||||
|
// 查询未删除状态的
|
||||||
|
queryWrapper.eq(HrPosition::getDelFlag, YesOrNotEnum.N.getCode());
|
||||||
|
// 根据排序升序排列,序号越小越在前
|
||||||
|
queryWrapper.orderByAsc(HrPosition::getPositionSort);
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue