|
|
@@ -40,38 +40,6 @@ public class ParameterServiceImpl extends BaseService<Parameter> implements Para
|
|
|
return parameterDao.save(parameter);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 检查输入方式
|
|
|
- *
|
|
|
- * @param parameter 参数
|
|
|
- * @throws IllegalArgumentException 输入方式为 DropDownBox 时,未提供可选值或者默认值的序号不合法
|
|
|
- */
|
|
|
- private void checkInputMode(@NotEmpty("parameter") Parameter parameter) {
|
|
|
- Parameter.InputMode inputMode = parameter.getInputMode();
|
|
|
- // 输入方式为 {@link InputMode#Radio} 或 {@link InputMode#DropDownBox} 时,需提供可选值
|
|
|
- if (inputMode != null) {
|
|
|
- List<Object> optionalValues = parameter.getOptionalValues();
|
|
|
- Integer defaultOptionalValueIndex = parameter.getDefaultOptionalValueIndex();
|
|
|
- switch (inputMode) {
|
|
|
- case DropDownBox:
|
|
|
- if (CollectionUtils.isEmpty(optionalValues)) {
|
|
|
- throw new IllegalArgumentException("输入方式为 DropDownBox 时,需提供可选值");
|
|
|
- }
|
|
|
- if (defaultOptionalValueIndex != null
|
|
|
- && (defaultOptionalValueIndex < 1 || defaultOptionalValueIndex > optionalValues.size())) {
|
|
|
- throw new IllegalArgumentException("默认值的序号不合法:" + defaultOptionalValueIndex);
|
|
|
- }
|
|
|
- break;
|
|
|
- case Manual:
|
|
|
- if (!CollectionUtils.isEmpty(optionalValues) || defaultOptionalValueIndex != null) {
|
|
|
- throw new IllegalArgumentException(
|
|
|
- "输入方式为 Manual 时,不可指定 optionalValues 和 defaultOptionalValueIndex");
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Parameter savePart(@NotEmpty("json") String json) {
|
|
|
return save(json);
|
|
|
@@ -112,6 +80,38 @@ public class ParameterServiceImpl extends BaseService<Parameter> implements Para
|
|
|
return super.delete(codes);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查输入方式
|
|
|
+ *
|
|
|
+ * @param parameter 参数
|
|
|
+ * @throws IllegalArgumentException 输入方式为 DropDownBox 时,未提供可选值或者默认值的序号不合法
|
|
|
+ */
|
|
|
+ private void checkInputMode(@NotEmpty("parameter") Parameter parameter) {
|
|
|
+ Parameter.InputMode inputMode = parameter.getInputMode();
|
|
|
+ // 输入方式为 {@link InputMode#Radio} 或 {@link InputMode#DropDownBox} 时,需提供可选值
|
|
|
+ if (inputMode != null) {
|
|
|
+ List<Object> optionalValues = parameter.getOptionalValues();
|
|
|
+ Integer defaultOptionalValueIndex = parameter.getDefaultOptionalValueIndex();
|
|
|
+ switch (inputMode) {
|
|
|
+ case DropDownBox:
|
|
|
+ if (CollectionUtils.isEmpty(optionalValues)) {
|
|
|
+ throw new IllegalArgumentException("输入方式为 DropDownBox 时,需提供可选值");
|
|
|
+ }
|
|
|
+ if (defaultOptionalValueIndex != null
|
|
|
+ && (defaultOptionalValueIndex < 1 || defaultOptionalValueIndex > optionalValues.size())) {
|
|
|
+ throw new IllegalArgumentException("默认值的序号不合法:" + defaultOptionalValueIndex);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Manual:
|
|
|
+ if (!CollectionUtils.isEmpty(optionalValues) || defaultOptionalValueIndex != null) {
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ "输入方式为 Manual 时,不可指定 optionalValues 和 defaultOptionalValueIndex");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Parameter> getByPanelCode(@NotEmpty("panelCode") String panelCode) {
|
|
|
panelDao.checkExist(panelCode);
|