|
|
1
|
+package com.xkl.controller;
|
|
|
2
|
+
|
|
|
3
|
+import com.wordnik.swagger.annotations.ApiOperation;
|
|
|
4
|
+import com.xkl.authorization.annotation.Authorization;
|
|
|
5
|
+import com.xkl.authorization.annotation.CurrentAdmin;
|
|
|
6
|
+import com.xkl.authorization.annotation.LogAnnotation;
|
|
|
7
|
+import com.xkl.authorization.annotation.Sign;
|
|
|
8
|
+import com.xkl.config.Constants;
|
|
|
9
|
+import com.xkl.config.ResultStatus;
|
|
|
10
|
+import com.xkl.domain.User;
|
|
|
11
|
+import com.xkl.domain.XklAdminEntity;
|
|
|
12
|
+import com.xkl.domain.XklMemberEntity;
|
|
|
13
|
+import com.xkl.model.ResultModel;
|
|
|
14
|
+import com.xkl.repository.UserRepository;
|
|
|
15
|
+import com.xkl.repository.XklMemberRespository;
|
|
|
16
|
+import com.xkl.security.AntiXSS;
|
|
|
17
|
+import com.xkl.service.IAdminOpsService;
|
|
|
18
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
19
|
+import org.springframework.http.HttpStatus;
|
|
|
20
|
+import org.springframework.http.ResponseEntity;
|
|
|
21
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
22
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
23
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
24
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
25
|
+
|
|
|
26
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
27
|
+
|
|
|
28
|
+/**
|
|
|
29
|
+ * Created by zhaoyue on 2017/04/15
|
|
|
30
|
+ */
|
|
|
31
|
+@RestController
|
|
|
32
|
+@RequestMapping("/setPulseBreath")
|
|
|
33
|
+public class PulseBreathSetController {
|
|
|
34
|
+ @Autowired
|
|
|
35
|
+ private IAdminOpsService adminOpsService;
|
|
|
36
|
+
|
|
|
37
|
+ @Autowired
|
|
|
38
|
+ private UserRepository userRepository;
|
|
|
39
|
+
|
|
|
40
|
+ @Autowired
|
|
|
41
|
+ private XklMemberRespository memberRespository;
|
|
|
42
|
+
|
|
|
43
|
+ @LogAnnotation
|
|
|
44
|
+ @AntiXSS
|
|
|
45
|
+ @Authorization
|
|
|
46
|
+ @Sign
|
|
|
47
|
+ @RequestMapping(method = RequestMethod.POST)
|
|
|
48
|
+ @ApiOperation(value = "admin设置用户当前的呼吸频率和脉搏")
|
|
|
49
|
+ public ResponseEntity<ResultModel> register(HttpServletRequest request, @CurrentAdmin XklAdminEntity admin, @RequestParam String username,
|
|
|
50
|
+ @RequestParam int pulse, @RequestParam int breathrate, @RequestParam String sign, @RequestParam long t) {
|
|
|
51
|
+
|
|
|
52
|
+ if (!(boolean) request.getAttribute("signAspect"))
|
|
|
53
|
+ return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
54
|
+ User user = userRepository.findByLoginAccountAndStatus(username, Constants.STATUS_OK2);
|
|
|
55
|
+ if (user == null) { //用户不存在
|
|
|
56
|
+ return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK);
|
|
|
57
|
+ }
|
|
|
58
|
+ XklMemberEntity memberEntity = memberRespository.findOne(user.getMemberId());
|
|
|
59
|
+ memberEntity.setCurPulse(pulse);
|
|
|
60
|
+ memberEntity.setCurBreathrate(breathrate);
|
|
|
61
|
+ memberRespository.save(memberEntity);
|
|
|
62
|
+ return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
|
|
63
|
+ }
|
|
|
64
|
+} |