火力规则:返回平台以及组件
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.solution.rule.strategy;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.solution.common.constant.ExceptionConstants;
|
||||
import com.solution.rule.domain.RuleParam;
|
||||
import com.solution.rule.domain.dto.WeaponModelDTO;
|
||||
import com.solution.rule.domain.vo.WeaponModelVO;
|
||||
import com.solution.rule.enums.SceneType;
|
||||
import com.solution.rule.handler.RuleChainHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DefenseStrategy implements SceneStrategy{
|
||||
|
||||
|
||||
@Autowired
|
||||
private RuleChainHandler ruleChainHandler;
|
||||
/**
|
||||
* 防御场景处理
|
||||
* @param weaponModelDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public WeaponModelVO execute(WeaponModelDTO weaponModelDTO) {
|
||||
if(ObjectUtil.isEmpty(weaponModelDTO)){
|
||||
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
|
||||
}
|
||||
RuleParam ruleParam = new RuleParam();
|
||||
ruleParam.setWeaponModelDTO(weaponModelDTO);
|
||||
ruleParam = ruleChainHandler.findRuleParam(ruleParam);
|
||||
if(ObjectUtil.isEmpty(ruleParam.getWeaponModelVO())){
|
||||
throw new RuntimeException(ExceptionConstants.RESULT_EXCEPTION);
|
||||
}
|
||||
return ruleParam.getWeaponModelVO();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneType getSceneType() {
|
||||
return SceneType.DEFENSE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user