首页 > 代码库 > hybris interceptor 应用于对象保存前的数据验证
hybris interceptor 应用于对象保存前的数据验证
package com.aaa.backoffice.Interceptors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import com.aaa.core.model.CAHOrderApprovedConfigModel; import com.aaa.core.services.util.dao.CahCommonDao; import de.hybris.platform.servicelayer.interceptor.InterceptorContext; import de.hybris.platform.servicelayer.interceptor.InterceptorException; import de.hybris.platform.servicelayer.interceptor.PrepareInterceptor; import de.hybris.platform.servicelayer.model.ModelService; public class OrderApprovedConfigSavingInterceptor implements PrepareInterceptor<OrderApprovedConfigModel> { private final static Logger LOG = LoggerFactory.getLogger(OrderApprovedConfigSavingInterceptor.class); @Autowired private ModelService modelService; @Autowired private CahCommonDao cahCommonDao; @Override public void onPrepare(OrderApprovedConfigModel config, InterceptorContext arg1) throws InterceptorException { // 内容check checkSavedValues(config); // 保存Code String code = config.getSalesOrg().getUid()+"-"+config.getOrderReason().getCode()+"-"+config.getOrderType(); config.setCode(code); } private void checkSavedValues(OrderApprovedConfigModel config) throws InterceptorException { if (null == config.getSalesOrg()) { throw new InterceptorException("请选择xxx!"); } if (null == config.getOrderReason()) { throw new InterceptorException("请选择xxx!"); } if (null == config.getOrderType()) { throw new InterceptorException("请选择xxx!"); } if (null == config.getRoles()) { throw new InterceptorException("请选择角色!"); } } }
hybris interceptor 应用于对象保存前的数据验证
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。