Merge branch 'zhaoyue-dev4' into 'master'
Add hasReport inter See merge request !55
Showing
3 changed files
with
79 additions
and
16 deletions
| @@ -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 "Mod online url" | 5 | +git commit -m "Add hasReport inter" |
| 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 |
| @@ -8,38 +8,41 @@ public enum ResultStatus { | @@ -8,38 +8,41 @@ public enum ResultStatus { | ||
| 8 | SIGN_ERROR(-100, "签名错误、未授权或者客户端时间有误"), | 8 | SIGN_ERROR(-100, "签名错误、未授权或者客户端时间有误"), |
| 9 | SIGN_NO_ACTIVE(-101, "数据共享签名未激活"), | 9 | SIGN_NO_ACTIVE(-101, "数据共享签名未激活"), |
| 10 | 10 | ||
| 11 | - USER_REGISTER(1000,"用户注册成功"), | ||
| 12 | - USER_LOGOUT(1001,"退出登录成功"), | ||
| 13 | - USER_MODPASS_LOGOUT(1002,"修改密码成功,请重新登录"), | 11 | + USER_REGISTER(1000, "用户注册成功"), |
| 12 | + USER_LOGOUT(1001, "退出登录成功"), | ||
| 13 | + USER_MODPASS_LOGOUT(1002, "修改密码成功,请重新登录"), | ||
| 14 | USERNAME_OR_PASSWORD_ERROR(-1001, "用户名或密码错误/Account or Password is wrong"), | 14 | USERNAME_OR_PASSWORD_ERROR(-1001, "用户名或密码错误/Account or Password is wrong"), |
| 15 | USER_NOT_FOUND(-1002, "用户不存在/User is not exist"), | 15 | USER_NOT_FOUND(-1002, "用户不存在/User is not exist"), |
| 16 | USER_NOT_LOGIN(-1004, "用户未登录"), | 16 | USER_NOT_LOGIN(-1004, "用户未登录"), |
| 17 | USER_IS_EXIT(-1005, "用户已注册"), | 17 | USER_IS_EXIT(-1005, "用户已注册"), |
| 18 | 18 | ||
| 19 | //2开头的都是openId相关 | 19 | //2开头的都是openId相关 |
| 20 | - OPENID_BIND_SUCCESS(2001,"OPENID绑定成功"), | ||
| 21 | - OPENID_UNBIND_SUCESS(2002,"OPENID解除绑定成功"), | ||
| 22 | - OPENID_ERROR(-2001,"OPENID错误"), | 20 | + OPENID_BIND_SUCCESS(2001, "OPENID绑定成功"), |
| 21 | + OPENID_UNBIND_SUCESS(2002, "OPENID解除绑定成功"), | ||
| 22 | + OPENID_ERROR(-2001, "OPENID错误"), | ||
| 23 | 23 | ||
| 24 | // 111开头的都是与amp报告上传软件相关的 | 24 | // 111开头的都是与amp报告上传软件相关的 |
| 25 | AMP_KEY_ERROR(-11100, "AMP密钥不匹配"), | 25 | AMP_KEY_ERROR(-11100, "AMP密钥不匹配"), |
| 26 | - REPORT_FORMAT_ERROR(-11140,"报告格式错误/Report json format error"), | ||
| 27 | - REPORT_EXISTED_ERROR(-11141,"报告重复上传/Report is already exist"), | ||
| 28 | - REPORT_INVALID_ERROR(-11142,"报告在数据库中不存在/Report is not exist in the DB"), | 26 | + REPORT_FORMAT_ERROR(-11140, "报告格式错误/Report json format error"), |
| 27 | + REPORT_EXISTED_ERROR(-11141, "报告重复上传/Report is already exist"), | ||
| 28 | + REPORT_INVALID_ERROR(-11142, "报告在数据库中不存在/Report is not exist in the DB"), | ||
| 29 | 29 | ||
| 30 | - INVALID_USER_ERROR(-11150,"报告所属用户未注册/Report user's account is not exist"), | ||
| 31 | - INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!/Operator can not delete the report which is not create by him"), | 30 | + INVALID_USER_ERROR(-11150, "报告所属用户未注册/Report user's account is not exist"), |
| 31 | + INVALID_ADMIN_RPDEL_ERROR(-11151, "报告非此操作员创建,无权删除!/Operator can not delete the report which is not create by him"), | ||
| 32 | 32 | ||
| 33 | - DB_ERROR(-11160,"服务器错误,无法写入数据库/Server error, can not write into database"), | 33 | + DB_ERROR(-11160, "服务器错误,无法写入数据库/Server error, can not write into database"), |
| 34 | 34 | ||
| 35 | - COMPANY_ERROR(-11170,"用户所属公司信息有误/Company information error"), | 35 | + COMPANY_ERROR(-11170, "用户所属公司信息有误/Company information error"), |
| 36 | 36 | ||
| 37 | // 112开头的与QR Code有关 | 37 | // 112开头的与QR Code有关 |
| 38 | - INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code"), | 38 | + INVALID_QR_CODE(-11201, "无效QR码/Invalid QR code"), |
| 39 | 39 | ||
| 40 | // 113开头的与操作统计有关 | 40 | // 113开头的与操作统计有关 |
| 41 | - INVALID_OPERATION_CODE(-11301,"无效操作/Invalid operation"); | 41 | + INVALID_OPERATION_CODE(-11301, "无效操作/Invalid operation"), |
| 42 | 42 | ||
| 43 | + // 114开头与相关报告相关 | ||
| 44 | + REPORT_EXIST(11401, "Has"),// 该用户在系统中有报告 | ||
| 45 | + REPORT_NOT_EXIST(11400, "No");// 无报告 | ||
| 43 | 46 | ||
| 44 | 47 | ||
| 45 | /** | 48 | /** |
| 1 | +package com.xkl.controller; | ||
| 2 | + | ||
| 3 | +import com.wordnik.swagger.annotations.ApiOperation; | ||
| 4 | +import com.xkl.authorization.annotation.LogAnnotation; | ||
| 5 | +import com.xkl.authorization.annotation.Sign; | ||
| 6 | +import com.xkl.config.Constants; | ||
| 7 | +import com.xkl.config.ResultStatus; | ||
| 8 | +import com.xkl.domain.User; | ||
| 9 | +import com.xkl.domain.XklAmpReportEntity; | ||
| 10 | +import com.xkl.model.ResultModel; | ||
| 11 | +import com.xkl.repository.UserRepository; | ||
| 12 | +import com.xkl.repository.XklAmpReportRespository; | ||
| 13 | +import com.xkl.security.AntiXSS; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.http.HttpStatus; | ||
| 16 | +import org.springframework.http.ResponseEntity; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 18 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 19 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 20 | +import org.springframework.web.bind.annotation.RestController; | ||
| 21 | + | ||
| 22 | +import javax.servlet.http.HttpServletRequest; | ||
| 23 | +import java.util.List; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 判断用户是否有报告。 | ||
| 27 | + */ | ||
| 28 | +@RestController | ||
| 29 | +@RequestMapping("/hasReport") | ||
| 30 | +public class HasReportController { | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + @Autowired | ||
| 34 | + private UserRepository userRepository; | ||
| 35 | + @Autowired | ||
| 36 | + private XklAmpReportRespository xklAmpReportRespository; | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + @LogAnnotation | ||
| 40 | + @AntiXSS | ||
| 41 | + @Sign | ||
| 42 | + @RequestMapping(method = RequestMethod.GET) | ||
| 43 | + @ApiOperation(value = "判断用户在该系统中是否有报告") | ||
| 44 | + public ResponseEntity<ResultModel> hasReport(HttpServletRequest request, | ||
| 45 | + @RequestParam String username, @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | ||
| 46 | + | ||
| 47 | + if (!(boolean) request.getAttribute("signAspect")) | ||
| 48 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | ||
| 49 | + User user = userRepository.findByLoginAccountAndStatus(username, Constants.STATUS_OK2); | ||
| 50 | + if (user == null) { //用户不存在 | ||
| 51 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK); | ||
| 52 | + } | ||
| 53 | + List<XklAmpReportEntity> reportList = xklAmpReportRespository.findByMemberIdAndStatus(user.getMemberId(), Constants.STATUS_OK); | ||
| 54 | + if (reportList == null || reportList.size() <= 0) { | ||
| 55 | + return new ResponseEntity<>(ResultModel.ok(ResultStatus.REPORT_NOT_EXIST), HttpStatus.OK); | ||
| 56 | + } else { | ||
| 57 | + return new ResponseEntity<>(ResultModel.ok(ResultStatus.REPORT_EXIST), HttpStatus.OK); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +} |
-
Please register or login to post a comment