2 * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
4 * Modification Copyright © 2020 IBM.
5 * ===================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.onap.portalapp.portal.controller;
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22 import org.onap.portalapp.portal.service.LanguageService;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.web.bind.annotation.PathVariable;
25 import org.springframework.web.bind.annotation.RequestBody;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.GetMapping;
28 import org.springframework.web.bind.annotation.PostMapping;
29 import org.springframework.web.bind.annotation.RequestMethod;
30 import org.springframework.web.bind.annotation.RestController;
31 import com.alibaba.fastjson.JSONObject;
34 @RequestMapping("/auxapi")
35 public class LanguageController {
38 private LanguageService languageService;
40 @GetMapping(value = "/language", produces = "application/json;charset=UTF-8")
41 public JSONObject getLanguageList() {
42 return languageService.getLanguages();
45 @PostMapping(value = "/languageSetting/user/{loginId}")
46 public void setUpUserLanguage(@RequestBody JSONObject jsonLanguageId,
47 @PathVariable("loginId") String loginId) throws Exception {
48 Integer languageId = jsonLanguageId.getInteger("languageId");
49 languageService.setUpUserLanguage(languageId,loginId);
52 @GetMapping(value = "/languageSetting/user/{loginId}")
53 public JSONObject getUserLanguage(HttpServletRequest request, HttpServletResponse response,
54 @PathVariable("loginId") String loginId) {
55 return languageService.getUserLanguage(loginId);