Commit 6c163a2d by 林冲

解锁开单权限

1 parent b3343194
......@@ -15,4 +15,12 @@ public interface LearningCenterTrainingPlanPersonRemote {
})
@ApiResponse("人员ID集合")
RpcResponse<List<Integer>> queryPersonIdsByPlanAndStatus(Integer planId, Byte openOrderStatus);
@ApiMethod("解锁开单权限")
@ApiParams({
@ApiParam(name = "planId", notes = "培训计划ID", dataType = ApiParam.DataTypeEnum.INTEGER, required = true),
@ApiParam(name = "personId", notes = "北森人员标识", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
})
@ApiResponse("解锁结果")
RpcResponse<String> unlockOpenOrder(Integer planId, Integer personId);
}
......@@ -26,4 +26,14 @@ public class LearningCenterTrainingPlanPersonRemoteImpl implements LearningCente
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<String> unlockOpenOrder(Integer planId, Integer personId) {
try {
return RpcResponse.success(learningCenterTrainingPlanPersonService.unlockOpenOrder(planId, personId));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
}
......@@ -40,4 +40,45 @@ public class LearningCenterTrainingPlanPersonService {
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
/**
* 解锁开单权限
*/
public String unlockOpenOrder(Integer planId, Integer personId) {
RpcAssert.assertNotNull(planId, DefaultErrorEnum.PARAMETER_NULL, "planId not be null");
RpcAssert.assertNotNull(personId, DefaultErrorEnum.PARAMETER_NULL, "personId not be null");
try {
// 查询人员记录
Example example = new Example(LearningCenterTrainingPlanPerson.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("planId", planId);
criteria.andEqualTo("personId", personId);
criteria.andEqualTo("deletedFlag", "N");
LearningCenterTrainingPlanPerson person = learningCenterTrainingPlanPersonMapper.selectOneByExample(example);
if (person == null) {
throw new RpcServiceException(DefaultErrorEnum.DATA_NULL, "人员记录不存在");
}
// 检查当前状态
if (person.getOpenOrderStatus() != null && person.getOpenOrderStatus() == 1) {
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "开单权限已解锁,无需重复操作");
}
// 更新为已解锁状态
person.setOpenOrderStatus((byte) 1);
int count = learningCenterTrainingPlanPersonMapper.updateByPrimaryKeySelective(person);
if (count > 0) {
return "解锁成功";
} else {
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, "解锁失败");
}
} catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!