Authored by zhaoyue

Merge branch 'zhaoyue-dev4' into 'master'

Add hasReport inter



See merge request !55
... ... @@ -2,7 +2,7 @@ git pull
git add --all src/main/java/*
git add push.sh
git add pom.xml
git commit -m "Mod online url"
git commit -m "Add hasReport inter"
#git push origin master
git push origin zhaoyue-dev4
git status
... ...
... ... @@ -8,38 +8,41 @@ public enum ResultStatus {
SIGN_ERROR(-100, "签名错误、未授权或者客户端时间有误"),
SIGN_NO_ACTIVE(-101, "数据共享签名未激活"),
USER_REGISTER(1000,"用户注册成功"),
USER_LOGOUT(1001,"退出登录成功"),
USER_MODPASS_LOGOUT(1002,"修改密码成功,请重新登录"),
USER_REGISTER(1000, "用户注册成功"),
USER_LOGOUT(1001, "退出登录成功"),
USER_MODPASS_LOGOUT(1002, "修改密码成功,请重新登录"),
USERNAME_OR_PASSWORD_ERROR(-1001, "用户名或密码错误/Account or Password is wrong"),
USER_NOT_FOUND(-1002, "用户不存在/User is not exist"),
USER_NOT_LOGIN(-1004, "用户未登录"),
USER_IS_EXIT(-1005, "用户已注册"),
//2开头的都是openId相关
OPENID_BIND_SUCCESS(2001,"OPENID绑定成功"),
OPENID_UNBIND_SUCESS(2002,"OPENID解除绑定成功"),
OPENID_ERROR(-2001,"OPENID错误"),
OPENID_BIND_SUCCESS(2001, "OPENID绑定成功"),
OPENID_UNBIND_SUCESS(2002, "OPENID解除绑定成功"),
OPENID_ERROR(-2001, "OPENID错误"),
// 111开头的都是与amp报告上传软件相关的
AMP_KEY_ERROR(-11100, "AMP密钥不匹配"),
REPORT_FORMAT_ERROR(-11140,"报告格式错误/Report json format error"),
REPORT_EXISTED_ERROR(-11141,"报告重复上传/Report is already exist"),
REPORT_INVALID_ERROR(-11142,"报告在数据库中不存在/Report is not exist in the DB"),
REPORT_FORMAT_ERROR(-11140, "报告格式错误/Report json format error"),
REPORT_EXISTED_ERROR(-11141, "报告重复上传/Report is already exist"),
REPORT_INVALID_ERROR(-11142, "报告在数据库中不存在/Report is not exist in the DB"),
INVALID_USER_ERROR(-11150,"报告所属用户未注册/Report user's account is not exist"),
INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!/Operator can not delete the report which is not create by him"),
INVALID_USER_ERROR(-11150, "报告所属用户未注册/Report user's account is not exist"),
INVALID_ADMIN_RPDEL_ERROR(-11151, "报告非此操作员创建,无权删除!/Operator can not delete the report which is not create by him"),
DB_ERROR(-11160,"服务器错误,无法写入数据库/Server error, can not write into database"),
DB_ERROR(-11160, "服务器错误,无法写入数据库/Server error, can not write into database"),
COMPANY_ERROR(-11170,"用户所属公司信息有误/Company information error"),
COMPANY_ERROR(-11170, "用户所属公司信息有误/Company information error"),
// 112开头的与QR Code有关
INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code"),
INVALID_QR_CODE(-11201, "无效QR码/Invalid QR code"),
// 113开头的与操作统计有关
INVALID_OPERATION_CODE(-11301,"无效操作/Invalid operation");
INVALID_OPERATION_CODE(-11301, "无效操作/Invalid operation"),
// 114开头与相关报告相关
REPORT_EXIST(11401, "Has"),// 该用户在系统中有报告
REPORT_NOT_EXIST(11400, "No");// 无报告
/**
... ...
package com.xkl.controller;
import com.wordnik.swagger.annotations.ApiOperation;
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.XklAmpReportEntity;
import com.xkl.model.ResultModel;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklAmpReportRespository;
import com.xkl.security.AntiXSS;
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;
import java.util.List;
/**
* 判断用户是否有报告。
*/
@RestController
@RequestMapping("/hasReport")
public class HasReportController {
@Autowired
private UserRepository userRepository;
@Autowired
private XklAmpReportRespository xklAmpReportRespository;
@LogAnnotation
@AntiXSS
@Sign
@RequestMapping(method = RequestMethod.GET)
@ApiOperation(value = "判断用户在该系统中是否有报告")
public ResponseEntity<ResultModel> hasReport(HttpServletRequest request,
@RequestParam String username, @RequestParam String sign, @RequestParam long t, @RequestParam int type) {
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);
}
List<XklAmpReportEntity> reportList = xklAmpReportRespository.findByMemberIdAndStatus(user.getMemberId(), Constants.STATUS_OK);
if (reportList == null || reportList.size() <= 0) {
return new ResponseEntity<>(ResultModel.ok(ResultStatus.REPORT_NOT_EXIST), HttpStatus.OK);
} else {
return new ResponseEntity<>(ResultModel.ok(ResultStatus.REPORT_EXIST), HttpStatus.OK);
}
}
}
\ No newline at end of file
... ...