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