lihong 2 rokov pred
rodič
commit
219fa6a775

+ 2 - 4
src/main/java/cn/hnthyy/thmz/Utils/TokenUtil.java

@@ -60,11 +60,9 @@ public class TokenUtil {
      * @return
      * @throws MzException
      */
-    public static User getUser(HttpServletRequest httpServletRequest) throws MzException {
+    public static User getUser(HttpServletRequest httpServletRequest){
         String token = TokenUtil.getToken(httpServletRequest);
-        if (StringUtils.isBlank(token)) {
-            throw new MzException("业务处理失败,用户Token不存在");
-        }
+        AssertUtil.isNotBlank(token,"业务处理失败,用户Token不存在");
         DecodedJWT decodedJWT = TokenUtil.parseJWT(token);
         return (User) JsonUtil.jsontoObject(decodedJWT.getSubject(), User.class);
     }

+ 6 - 18
src/main/java/cn/hnthyy/thmz/controller/bb/ReportStaticController.java

@@ -1,7 +1,10 @@
 package cn.hnthyy.thmz.controller.bb;
 
+import cn.hnthyy.thmz.Utils.AssertUtil;
+import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.service.his.bb.ReportStaticService;
 import cn.hnthyy.thmz.vo.ReportVo;
@@ -34,26 +37,11 @@ public class ReportStaticController {
 
     @UserLoginToken
     @RequestMapping(value = "/selectDoctorIndexData", method = {RequestMethod.GET, RequestMethod.POST})
-    public Map<String, Object> selectDoctorIndexData(@RequestBody ReportVo vo, HttpServletRequest httpServletRequest) {
-        Map<String, Object> resultMap = new HashMap<>();
-        try {
-            if (StringUtils.isEmpty(vo.getReportId()) && vo.getReportIds() == null) {
-                resultMap.put("code", -1);
-                resultMap.put("message", "报表id为空,查询报表数据失败");
-                return resultMap;
-            }
+    public R selectDoctorIndexData(@RequestBody ReportVo vo, HttpServletRequest httpServletRequest){
+            AssertUtil.isNotBlank(vo.getReportId(),"报表id为空,查询报表数据失败");
             User user = TokenUtil.getUser(httpServletRequest);
             vo.setDoctorId(user.getUserIdCode());
             Map<String, Object> map = reportStaticService.selectDoctorIndexData(vo);
-            resultMap.put("code", 0);
-            resultMap.put("message", "查询报表数据成功");
-            resultMap.put("data", map);
-            return resultMap;
-        } catch (Exception e) {
-            log.error("查询报表数据,错误信息{}", e);
-            resultMap.put("code", -1);
-            resultMap.put("message", "查询报表数据失败");
-            return resultMap;
+           return R.ok("查询报表数据成功").put("data",map);
         }
-    }
 }

+ 7 - 1
src/main/java/cn/hnthyy/thmz/interceptor/GlobalExceptionHandler.java

@@ -48,7 +48,13 @@ public class GlobalExceptionHandler {
 
     @ExceptionHandler(BizException.class)
     @ResponseBody
-    public R handleRRException(BizException e){
+    public R handleBizException(BizException e){
        return R.error(e.getCode(),e.getMessage());
     }
+
+    @ExceptionHandler(Exception.class)
+    @ResponseBody
+    public R handleException(Exception e){
+        return R.error("系统错误:"+e.getMessage());
+    }
 }