43 lines
1.3 KiB
Java
43 lines
1.3 KiB
Java
|
|
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;
|
||
|
|
}
|
||
|
|
}
|