Skip to content

サービス情報変更実装編#

1.1. 処理概要#

サービス情報の検索で取得した情報をもとに、画面上で入力ができる形でサービス情報を表示します。
変更ボタンが押された際に、画面の入力内容をもとにサービス情報の変更を行います。
本処理を行うには、API認証よりAPIを呼び出すためのアクセストークンが必要となります。

1.1.1. 呼出API#

以下、サービス情報変更で呼び出すAPIとなります。

No API 処理内容 使用用途
1 POST /API/v2/api/servicepricemaster サービス料金情報を編集する サービス変更画面で変更ボタン押下時にサービス情報を変更
2 GET /API/v2/api/servicepricemaster サービス料金情報を検索する サービス変更画面で前画面より引き継がれた情報をもとにサービス情報を検索

1.1.2. 処理フロー#

サービス情報変更を行うまでの処理は以下のフローとなります。

1.1.3. 実装例#

以下API呼出の実装例となります。
サービス情報変更画面表示時の「サービス料金情報を検索する」API呼び出しについては、「サービス情報検索実装編」及び提供ソースをご確認ください。
※本マニュアルに記載している実装例は、分かりやすさを優先し簡易的に記載しております。提供しているソースと異なりますので詳細については提供ソースをご確認ください。

ServiceMasterChangeController.java

/**
 * サービス変更処理
 * @param model モデル
 * @param form サービス変更フォーム
 * @param result バリデーション結果
 * @return サービス変更
 */
@RequestMapping(value = "/ServiceMasterChange/change", method = RequestMethod.POST)
public String change(
        Model model,
        @Valid ServiceMasterChangeForm form,
        BindingResult result) {

    form.setMessage("");
    form.setErrorInformation("");
    model.addAttribute("serviceMasterChangeForm", form);
    serviceMasterChangeFormSession.setServiceMasterChangeForm(form);

    if (result.hasErrors()) {
        return ControllerConstants.SERVICE_MASTER_CHANGE_JSP;
    }

    //サービスマスタ編集
    Web_IFServicePriceInformationUpdate_I web_IFServicePriceInformationUpdate_I = new Web_IFServicePriceInformationUpdate_I();
    Web_IFServicePriceInformationUpdate_O web_IFServicePriceInformationUpdate_O = new Web_IFServicePriceInformationUpdate_O();
    //サービスマスタ編集リスト
    Web_ServiceMasterEditionList web_ServiceMasterEditionList = new Web_ServiceMasterEditionList();
    //サービスマスタ多言語用情報リスト
    Web_ServiceMasterForMultiLingualInformationList web_ServiceMasterForMultiLingualInformationList = new Web_ServiceMasterForMultiLingualInformationList();
    //料金プランリスト
    Web_PricePlanList web_PricePlanList = new Web_PricePlanList();
    //料金プラン多言語用情報リスト
    Web_PricePlanForMultiLingualInformationList web_PricePlanForMultiLingualInformationList = new Web_PricePlanForMultiLingualInformationList();

    //サービスマスタ編集
    web_IFServicePriceInformationUpdate_I.entry_id = CommonConstants.登録者ID;
    web_IFServicePriceInformationUpdate_I.basic_product_id = SampleUtil.emptyToNull(form.getBasicProductId());
    web_IFServicePriceInformationUpdate_I.basic_product_id_tentative_flag = null;
    //サービスマスタ編集リスト
    web_ServiceMasterEditionList.service_code = SampleUtil.emptyToNull(form.getServiceCode());      |-- サービスコードを設定することにより変更処理が行われる。
    web_ServiceMasterEditionList.service_division = SampleUtil.emptyToNull(form.getServiceDivision());
    web_ServiceMasterEditionList.version_info = SampleUtil.emptyToNull(form.getServiceVersionInfo());
    web_ServiceMasterEditionList.apply_start_date = form.getApplyStartDate() + "01";
    web_ServiceMasterEditionList.service_version = SampleUtil.emptyToNull(form.getServiceVersion());
    web_ServiceMasterEditionList.service_image_url = SampleUtil.emptyToNull(form.getServiceImageUrl());
    web_ServiceMasterEditionList.link_url = SampleUtil.emptyToNull(form.getLinkUrl());
    web_ServiceMasterEditionList.service_provider_code = SampleUtil.emptyToNull(form.getServiceProviderCode());
    web_ServiceMasterEditionList.reception_start_date = SampleUtil.emptyToNull(form.getReceptionStartDate());
    web_ServiceMasterEditionList.reception_end_date = SampleUtil.emptyToNull(form.getReceptionEndDate());
    web_ServiceMasterEditionList.product_type = SampleUtil.emptyToNull(form.getProductType());
    web_ServiceMasterEditionList.administration_number = SampleUtil.emptyToNull(form.getAdministrationNumber());
    web_ServiceMasterEditionList.release_start_date = SampleUtil.emptyToNull(form.getReleaseStartDate());
    web_ServiceMasterEditionList.release_end_date = SampleUtil.emptyToNull(form.getReleaseEndDate());
    JsonObject free_json = new JsonObject();
    free_json.addProperty("referencePrice",  form.getReferencePrice());
    web_ServiceMasterEditionList.free_item = free_json;
    web_ServiceMasterEditionList.free_item1 = SampleUtil.emptyToNull(form.getSizeVolume());
    web_ServiceMasterEditionList.free_item2 = SampleUtil.emptyToNull(form.getMaxNumberOfConnections());
    web_ServiceMasterEditionList.free_item3 = SampleUtil.emptyToNull(form.getRelatedService());
    web_ServiceMasterEditionList.service_code_tentative_flag = null;
    //サービスマスタ多言語用情報リスト
    web_ServiceMasterForMultiLingualInformationList.language_locale = SampleUtil.emptyToNull(form.getServiceLanguageLocale());
    web_ServiceMasterForMultiLingualInformationList.service_name = SampleUtil.emptyToNull(form.getServiceName());
    web_ServiceMasterForMultiLingualInformationList.service_name_abbreviation = SampleUtil.emptyToNull(form.getServiceNameAbbreviation());
    web_ServiceMasterForMultiLingualInformationList.description = SampleUtil.emptyToNull(form.getDescription());
    //料金プランリスト
    web_PricePlanList.entry_id = CommonConstants.登録者ID;
    web_PricePlanList.fee_code = SampleUtil.emptyToNull(form.getFeeCode());
    web_PricePlanList.price_plan_code = SampleUtil.emptyToNull(form.getPricePlanCode());
    web_PricePlanList.administration_number = SampleUtil.emptyToNull(form.getAdministrationNumber());
    web_PricePlanList.apply_start_date = form.getApplyStartDate() + "01";
    web_PricePlanList.apply_start_date_division = SampleUtil.emptyToNull(form.getApplyStartDateDivision());
    web_PricePlanList.apply_start_date_add_number_of_days = SampleUtil.emptyToNull(form.getApplyStartDateAddNumberOfDays());
    web_PricePlanList.apply_end_date_division = SampleUtil.emptyToNull(form.getApplyEndDateDivision());
    web_PricePlanList.apply_end_date_add_number_of_days = SampleUtil.emptyToNull(form.getApplyEndDateAddNumberOfDays());
    web_PricePlanList.charging_start_date_division = SampleUtil.emptyToNull(form.getChargingStartDateDivision());
    web_PricePlanList.charging_start_date_add_number_of_days = SampleUtil.emptyToNull(form.getChargingStartDateAddNumberOfDays());
    web_PricePlanList.charging_end_date_division = SampleUtil.emptyToNull(form.getChargingEndDateDivision());
    web_PricePlanList.charging_end_date_add_number_of_days = SampleUtil.emptyToNull(form.getChargingEndDateAddNumberOfDays());
    web_PricePlanList.price_plan_division = SampleUtil.emptyToNull(form.getPricePlanDivision());
    web_PricePlanList.price_plan_change_apply_start_date_division = SampleUtil.emptyToNull(form.getPricePlanChangeApplyStartDateDivision());
    web_PricePlanList.price_plan_change_apply_start_date_add_number_of_days = SampleUtil.emptyToNull(form.getPricePlanChangeApplyStartDateAddNumberOfDays());
    //料金プラン多言語情報リスト
    web_PricePlanForMultiLingualInformationList.entry_id = CommonConstants.登録者ID;
    web_PricePlanForMultiLingualInformationList.language_locale = SampleUtil.emptyToNull(form.getPriceLanguageLocale());
    web_PricePlanForMultiLingualInformationList.price_plan_name = SampleUtil.emptyToNull(form.getServiceName());
    web_PricePlanForMultiLingualInformationList.price_plan_name_abbreviation = SampleUtil.emptyToNull(form.getServiceNameAbbreviation());

    //リストに値をセット
    web_ServiceMasterEditionList.service_master_formultilingual_information_list.add(web_ServiceMasterForMultiLingualInformationList);
    web_PricePlanList.price_plan_for_multilingual_information_list.add(web_PricePlanForMultiLingualInformationList);
    web_IFServicePriceInformationUpdate_I.service_master_edition_list.add(web_ServiceMasterEditionList);
    web_IFServicePriceInformationUpdate_I.service_master_edition_list.get(0).price_plan_list.add(web_PricePlanList);

    try {
        //サービス料金情報を編集する
        web_IFServicePriceInformationUpdate_O = serviceMasterService.servicePriceInformationUpdate(web_IFServicePriceInformationUpdate_I);
        if (ControllerConstants.API_RESULT_NG.equals(web_IFServicePriceInformationUpdate_O.result_information.result)) {
            form.setErrorInformation(web_IFServicePriceInformationUpdate_O.result_information.detailed_result);
            return ControllerConstants.SERVICE_MASTER_CHANGE_JSP;
        }

    } catch (ApiException e) {
        if(ApiErrorType.排他エラー.equals(e.getErrorCode()))
        {
            // メッセージ表示
            form.setErrorInformation(getMsg(MessageConstants.MSGE00001, 
                    getMsg(MessageConstants.SCN000006)));
            return ControllerConstants.SERVICE_MASTER_CHANGE_JSP;
        } else {
            model.addAttribute("errorCode", e.getErrorCode().getValue());
            return ControllerConstants.SYSTEM_ERROR_JSP;
        }

    } catch (Exception e) {
        return ControllerConstants.SYSTEM_ERROR_JSP;
    }

    // メッセージ表示
    form.setMessage(getMsg(MessageConstants.MSGI00002, 
            getMsg(MessageConstants.LBL000007), 
            web_IFServicePriceInformationUpdate_O.basic_product_id));

    return ControllerConstants.SERVICE_MASTER_CHANGE_JSP;

}

ServiceMasterService.java

/**
 * サービス料金情報_編集 API
 * 
 * @param web_IFServicePriceInformationUpdate_I IFサービス料金情報_編集_入力
 * @return IFサービス料金情報_編集_出力
 */
public Web_IFServicePriceInformationUpdate_O servicePriceInformationUpdate(Web_IFServicePriceInformationUpdate_I web_IFServicePriceInformationUpdate_I) {

    // 通信設定
    String strURI = ClientUtil.makeURI(UriInfo.ServicePriceMasterUpdate, null, null);
    HttpPost postMethod = ClientUtil.makeHttpPost(strURI, web_IFServicePriceInformationUpdate_I);

    return CommonHttpClient.httpPost(postMethod, Web_IFServicePriceInformationUpdate_O.class);

}

共通HTTPリクエストクラス[CommonHttpClient.java]の実装例についてはこちらをご参照ください。

Top