View Javadoc
1   package fr.ifremer.quadrige3.synchro.server.rest.system.generalCondition;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Synchro Server
6    * %%
7    * Copyright (C) 2017 - 2024 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import fr.ifremer.quadrige3.core.service.system.generalCondition.GeneralConditionService;
25  import fr.ifremer.quadrige3.core.vo.system.generalCondition.GeneralConditionVO;
26  import fr.ifremer.quadrige3.synchro.server.security.SecurityContextHelper;
27  import fr.ifremer.quadrige3.synchro.server.service.ServiceLocator;
28  import org.springframework.web.bind.annotation.*;
29  
30  @RestController
31  @RequestMapping("/generalCondition")
32  public class GeneralConditionController {
33  
34      @RequestMapping(value="/lastNonAccepted", method = RequestMethod.GET)
35      public @ResponseBody GeneralConditionVO getLastNonAccepted() {
36          int userId = SecurityContextHelper.getPrincipalUserId();
37          GeneralConditionService service = ServiceLocator.instance().getGeneralConditionService();
38  
39          return service.getLastNonAccepted(userId);
40      }
41  
42      @RequestMapping(value="/accept", method = RequestMethod.POST)
43      public @ResponseBody void accept(@RequestBody int id) {
44          int userId = SecurityContextHelper.getPrincipalUserId();
45          GeneralConditionService service = ServiceLocator.instance().getGeneralConditionService();
46  
47          service.acceptForUser(id, userId);
48      }
49  
50  }