Fix sql injection vulnerability
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / controller / LanguageController.java
1 /**
2  * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.portalapp.portal.controller;
17
18 import com.alibaba.fastjson.JSONObject;
19 import org.onap.portalapp.portal.domain.Language;
20 import org.onap.portalapp.portal.service.LanguageService;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.web.bind.annotation.*;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26 import java.util.List;
27
28 @RestController
29 @RequestMapping("/auxapi")
30 public class LanguageController {
31
32     @Autowired
33     private LanguageService languageService;
34
35     @RequestMapping(value = "/language",method = RequestMethod.GET)
36     public JSONObject getLanguageList() {
37         return languageService.getLanguages();
38     }
39
40     @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.POST)
41     public void setUpUserLanguage(@RequestBody JSONObject jsonLanguageId,
42                                   @PathVariable("loginId") String loginId) throws Exception {
43         Integer languageId = jsonLanguageId.getInteger("languageId");
44         languageService.setUpUserLanguage(languageId,loginId);
45     }
46
47     @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.GET)
48     public JSONObject getUserLanguage(HttpServletRequest request, HttpServletResponse response,
49                                       @PathVariable("loginId") String loginId) {
50         return languageService.getUserLanguage(loginId);
51     }
52
53 }