新增-es查询缺少字段判断,部门不存在时也可以登录

This commit is contained in:
liuzhaotian
2025-03-17 11:21:34 +08:00
parent 77ff867e86
commit 51532b2c67
6 changed files with 54 additions and 7 deletions
@@ -28,6 +28,7 @@ public class ErrorCodeConstants {
// public static final ErrorCode ORDER_PLAN_ERROR = new ErrorCode(1_001_109_001, "选中删除对象有已开料板件,请联系管理员修改开料状态后再删除!");
public static final ErrorCode PLATE_IS_PLAN = new ErrorCode(1_001_109_002, "删除对象中有已排单板件,请将该对象从排单中移除后再选择删除!");
public static final ErrorCode ORDER_ERROR = new ErrorCode(1_001_109_003, "当前生产单柜体,房间已全部删除!");
public static final ErrorCode ORDER_DATA_ERROR = new ErrorCode(1_001_109_004, "生产单/排单的数据已无法使用,请删除重新");
// ========== 生产单 TODO 补充编号 ==========
public static final ErrorCode MODULE_NOT_EXISTS = new ErrorCode(1_001_110_000, "模块不存在");
@@ -12,6 +12,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.elasticsearch.indices.RefreshRequest;
import co.elastic.clients.json.JsonpMappingException;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.es.core.dal.ESDocument;
import com.cf.imes.framework.es.core.service.ESDocumentService;
@@ -25,6 +26,7 @@ import java.util.List;
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.DATA_DATA_ERROR;
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.ES_DATA_ERROR;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_DATA_ERROR;
/**
* @author ES 工具类
@@ -67,7 +69,10 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (IOException | ElasticsearchException e) {
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
}catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
@@ -89,6 +94,9 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
} catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
@@ -116,7 +124,10 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (IOException | ElasticsearchException e) {
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
}catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
@@ -138,7 +149,10 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (IOException | ElasticsearchException e) {
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
}catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
@@ -165,7 +179,10 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (IOException | ElasticsearchException e) {
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
}catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
@@ -192,7 +209,10 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (IOException | ElasticsearchException e) {
}catch (JsonpMappingException e){
log.error(e.getMessage());
throw new ServiceException(ORDER_DATA_ERROR);
}catch (IOException | ElasticsearchException e) {
log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
@@ -99,7 +99,7 @@ public class RemainPlateController {
@GetMapping("/page")
@Operation(summary = "获得生产单余料板表分页")
@PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:query','placeorder:optimize','placeorder:remain-insert')")
@PreAuthorize("@ss.hasAnyPermissions('manage:remain-plate:query','placeorder:optimize','placeorder:remain-insert','production:manager-list:calculate')")
public CommonResult<PageResult<RemainPlateRespVO>> getRemainPlatePage(@Valid RemainPlatePageReqVO pageReqVO) {
PageResult<RemainPlateDO> pageResult = remainPlateService.getRemainPlatePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, RemainPlateRespVO.class));
@@ -111,7 +111,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 校验机构有效性
organService.validOrgan(user.getOrganId());
// 校验部门有效性
deptService.validDept(user.getDeptId());
deptService.validUserLoginDept(user.getDeptId());
// 校验密码
if (!userService.isPasswordMatch(password, user.getPassword())) {
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
@@ -106,6 +106,13 @@ public interface DeptService {
*/
void validDept(Long deptId);
/**
* 用户登陆时部门校验
*
* @param deptId
*/
void validUserLoginDept(Long deptId);
/**
* 移除没有归属(上级)的部门
*
@@ -309,6 +309,25 @@ public class DeptServiceImpl implements DeptService {
validParentDept(deptDO);
}
// 用户登陆时部门校验,部门不存在时也可以进行登录
@Override
public void validUserLoginDept(Long deptId){
DeptDO deptDO = deptMapper.selectById(deptId);
if (deptDO == null) {
return;
}
if (!CommonStatusEnum.ENABLE.getStatus().equals(deptDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.DEPT_DISABLE, deptDO.getName());
}
// 递归校验上级部门
validParentDept(deptDO);
}
/**
* 递归校验上级部门
*