|
|
package com.xkl.controller;
|
|
|
|
|
|
import com.wordnik.swagger.annotations.ApiOperation;
|
|
|
import com.xkl.authorization.annotation.Authorization;
|
|
|
import com.xkl.authorization.annotation.CurrentAdmin;
|
|
|
import com.xkl.authorization.annotation.LogAnnotation;
|
|
|
import com.xkl.authorization.annotation.Sign;
|
|
|
import com.xkl.config.Constants;
|
|
|
import com.xkl.config.ResultStatus;
|
|
|
import com.xkl.domain.User;
|
|
|
import com.xkl.domain.XklAdminEntity;
|
|
|
import com.xkl.domain.XklMemberEntity;
|
|
|
import com.xkl.model.ResultModel;
|
|
|
import com.xkl.repository.UserRepository;
|
|
|
import com.xkl.repository.XklMemberRespository;
|
|
|
import com.xkl.security.AntiXSS;
|
|
|
import com.xkl.service.IAdminOpsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
/**
|
|
|
* Created by zhaoyue on 2017/04/15
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/setPulseBreath")
|
|
|
public class PulseBreathSetController {
|
|
|
@Autowired
|
|
|
private IAdminOpsService adminOpsService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserRepository userRepository;
|
|
|
|
|
|
@Autowired
|
|
|
private XklMemberRespository memberRespository;
|
|
|
|
|
|
@LogAnnotation
|
|
|
@AntiXSS
|
|
|
@Authorization
|
|
|
@Sign
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "admin设置用户当前的呼吸频率和脉搏")
|
|
|
public ResponseEntity<ResultModel> setPulseBreath(HttpServletRequest request, @CurrentAdmin XklAdminEntity admin, @RequestParam String username,
|
|
|
@RequestParam int pulse, @RequestParam int breathrate, @RequestParam String sign, @RequestParam long t) {
|
|
|
|
|
|
if (!(boolean) request.getAttribute("signAspect"))
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
|
|
|
User user = userRepository.findByLoginAccountAndStatus(username, Constants.STATUS_OK2);
|
|
|
if (user == null) { //用户不存在
|
|
|
return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK);
|
|
|
}
|
|
|
XklMemberEntity memberEntity = memberRespository.findOne(user.getMemberId());
|
|
|
memberEntity.setCurPulse(pulse);
|
|
|
memberEntity.setCurBreathrate(breathrate);
|
|
|
memberRespository.save(memberEntity);
|
|
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|