Authored by zhaoyue

Merge branch 'zhaoyue-dev4' into 'master'

Zhaoyue dev4



See merge request !46
@@ -2,7 +2,7 @@ git pull @@ -2,7 +2,7 @@ git pull
2 git add --all src/main/java/* 2 git add --all src/main/java/*
3 git add push.sh 3 git add push.sh
4 git add pom.xml 4 git add pom.xml
5 -git commit -m "ADD report location log" 5 +git commit -m "ADD member pulse and breathrate"
6 #git push origin master 6 #git push origin master
7 git push origin zhaoyue-dev4 7 git push origin zhaoyue-dev4
8 git status 8 git status
  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> setPulseBreath(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 +}
@@ -54,6 +54,12 @@ public class XklMemberEntity { @@ -54,6 +54,12 @@ public class XklMemberEntity {
54 @Basic 54 @Basic
55 @Column(name = "status") 55 @Column(name = "status")
56 private int status; 56 private int status;
  57 + @Basic
  58 + @Column(name = "cur_pulse")
  59 + private int curPulse;
  60 + @Basic
  61 + @Column(name = "cur_breathrate")
  62 + private int curBreathrate;
57 63
58 public long getId() { 64 public long getId() {
59 return id; 65 return id;
@@ -158,4 +164,20 @@ public class XklMemberEntity { @@ -158,4 +164,20 @@ public class XklMemberEntity {
158 public void setStatus(int status) { 164 public void setStatus(int status) {
159 this.status = status; 165 this.status = status;
160 } 166 }
  167 +
  168 + public int getCurPulse() {
  169 + return curPulse;
  170 + }
  171 +
  172 + public void setCurPulse(int curPulse) {
  173 + this.curPulse = curPulse;
  174 + }
  175 +
  176 + public int getCurBreathrate() {
  177 + return curBreathrate;
  178 + }
  179 +
  180 + public void setCurBreathrate(int curBreathrate) {
  181 + this.curBreathrate = curBreathrate;
  182 + }
161 } 183 }