サービス情報登録実装編#
1.1. 処理概要#
画面の入力内容をもとにサービス情報の登録を行います。
本処理を行うには、API認証よりAPIを呼び出すためのアクセストークンが必要となります。
1.1.1. 呼出API#
以下、サービス情報登録で呼び出すAPIとなります。
No | API | 処理内容 | 使用用途 |
---|---|---|---|
1 | POST /API/v2/api/servicepricemaster | サービス料金情報を編集する | サービス登録画面で登録ボタン押下時にサービス情報を作成 |
1.1.2. 処理フロー#
サービス情報登録を行うまでの処理は以下のフローとなります。
1.1.3. 実装例#
以下API呼び出しの実装例となります。
※本マニュアルに記載している実装例は、分かりやすさを優先し簡易的に記載しております。提供しているソースと異なりますので詳細については提供ソースをご確認ください。
ServiceMasterRegistController.java
/** * サービス登録処理 * @param model モデル * @param form サービス登録フォーム * @param result バリデーション結果 * @return サービス変更 */ @RequestMapping(value = "/ServiceMasterRegist/regist", method = RequestMethod.POST) public String regist( Model model, @Valid ServiceMasterRegistForm form, BindingResult result) { form.setMessage(""); form.setErrorInformation(""); model.addAttribute("serviceMasterRegistForm", form); serviceMasterRegistFormSession.setServiceMasterRegistForm(form); if (result.hasErrors()) { return ControllerConstants.SERVICE_MASTER_REGIST_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 = "0000000000"; web_IFServicePriceInformationUpdate_I.basic_product_id_tentative_flag = "1"; //サービスマスタ編集リスト web_ServiceMasterEditionList.service_code = "0000000000"; web_ServiceMasterEditionList.service_division = "0"; 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 = "0"; web_ServiceMasterEditionList.administration_number = "001"; 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", SampleUtil.emptyToNull(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 = "1"; //サービスマスタ多言語用情報リスト web_ServiceMasterForMultiLingualInformationList.language_locale = CommonConstants.言語ロケール_ja; 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.administration_number = "001"; web_PricePlanList.apply_start_date = form.getApplyStartDate() + "01"; web_PricePlanList.apply_start_date_division = "0"; web_PricePlanList.apply_start_date_add_number_of_days = "0"; web_PricePlanList.apply_end_date_division = "0"; web_PricePlanList.apply_end_date_add_number_of_days = "0"; web_PricePlanList.charging_start_date_division = "0"; web_PricePlanList.charging_start_date_add_number_of_days = "0"; web_PricePlanList.charging_end_date_division = "0"; web_PricePlanList.charging_end_date_add_number_of_days = "0"; web_PricePlanList.price_plan_division = "1"; web_PricePlanList.price_plan_change_apply_start_date_division = "0"; web_PricePlanList.price_plan_change_apply_start_date_add_number_of_days = "0"; //料金プラン多言語情報リスト web_PricePlanForMultiLingualInformationList.entry_id = CommonConstants.登録者ID; web_PricePlanForMultiLingualInformationList.language_locale = CommonConstants.言語ロケール_ja; 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_REGIST_JSP; } } catch (ApiException e) { model.addAttribute("errorCode", e.getErrorCode().getValue()); return ControllerConstants.SYSTEM_ERROR_JSP; } catch (Exception e) { return ControllerConstants.SYSTEM_ERROR_JSP; } form.setServiceCode(web_IFServicePriceInformationUpdate_O.service_master_edition_list.get(0).service_code); form.setAdministrationNumber(web_IFServicePriceInformationUpdate_O.service_master_edition_list.get(0).administration_number); // メッセージ表示 form.setMessage(getMsg(MessageConstants.MSGI00001, getMsg(MessageConstants.LBL000007), web_IFServicePriceInformationUpdate_O.basic_product_id)); return ControllerConstants.SERVICE_MASTER_REGIST_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]の実装例についてはこちらをご参照ください。