Commit edf6dbd5e15723e99c721797b2459385da18edc4

Authored by jiangjiazhi
1 parent 4abe7fd72f

增加权限

Showing 15 changed files with 62 additions and 15 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java View file @ edf6dbd
... ... @@ -17,7 +17,7 @@
17 17 private String provinceId;
18 18 private String cityId;
19 19 private String areaId;
20   - private String streetId; //½ÖµÀ ³ÇÕò
  20 + private String streetId;
21 21 private String address;
22 22 private String description;
23 23 private Integer publishId;
platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java View file @ edf6dbd
... ... @@ -15,7 +15,7 @@
15 15 private String provinceId;
16 16 private String cityId;
17 17 private String areaId;
18   - private String streetId; //½ÖµÀ ³ÇÕò
  18 + private String streetId;
19 19 private String address;
20 20 private String description;
21 21 private Integer publishId;
platform-common/src/main/java/com/lyms/platform/common/base/ExceptionHandlerController.java View file @ edf6dbd
... ... @@ -7,12 +7,20 @@
7 7 import javax.servlet.http.HttpServletRequest;
8 8 import javax.servlet.http.HttpServletResponse;
9 9  
  10 +import com.lyms.platform.common.core.resolve.MessageResolver;
  11 +import com.lyms.platform.common.result.BaseResponse;
  12 +import org.apache.commons.collections.CollectionUtils;
  13 +import org.springframework.aop.AopInvocationException;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.dao.DataAccessResourceFailureException;
10 16 import org.springframework.http.HttpStatus;
  17 +import org.springframework.http.converter.HttpMessageNotReadableException;
11 18 import org.springframework.validation.BindException;
12 19 import org.springframework.validation.BindingResult;
13 20 import org.springframework.web.bind.MethodArgumentNotValidException;
14 21 import org.springframework.web.bind.MissingServletRequestParameterException;
15 22 import org.springframework.web.bind.annotation.ExceptionHandler;
  23 +import org.springframework.web.bind.annotation.ResponseBody;
16 24 import org.springframework.web.bind.annotation.ResponseStatus;
17 25  
18 26 import com.lyms.platform.common.constants.ErrorCodeConstants;
... ... @@ -27,6 +35,42 @@
27 35 */
28 36 public class ExceptionHandlerController {
29 37  
  38 + @Autowired
  39 + private MessageResolver messageResolver;
  40 +
  41 + @ExceptionHandler(HttpMessageNotReadableException.class)
  42 + @ResponseBody
  43 + @ResponseStatus(HttpStatus.BAD_REQUEST)
  44 + public BaseResponse handException(HttpMessageNotReadableException e) {
  45 + ExceptionUtils.catchException(e, e.getMessage());
  46 + BaseResponse error = new BaseResponse();
  47 + error.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
  48 + error.setErrormsg("参数错误");
  49 + return error;
  50 + }
  51 +
  52 + @ExceptionHandler(org.springframework.dao.DataAccessResourceFailureException.class)
  53 + @ResponseBody
  54 + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
  55 + public BaseResponse handException(DataAccessResourceFailureException e) {
  56 + ExceptionUtils.catchException(e, e.getMessage());
  57 + BaseResponse error = new BaseResponse();
  58 + error.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
  59 + error.setErrormsg("错误");
  60 + return error;
  61 + }
  62 + @ExceptionHandler(org.springframework.aop.AopInvocationException.class)
  63 + @ResponseBody
  64 + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
  65 + public BaseResponse handException(AopInvocationException e) {
  66 + ExceptionUtils.catchException(e, e.getMessage());
  67 + BaseResponse error = new BaseResponse();
  68 + error.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
  69 + error.setErrormsg("错误");
  70 + return error;
  71 + }
  72 +
  73 +
30 74 @ExceptionHandler(MethodArgumentNotValidException.class)
31 75 @ResponseStatus(HttpStatus.OK)
32 76 public void validationError(MethodArgumentNotValidException e, HttpServletResponse httpServletResponse) {
... ... @@ -132,7 +176,8 @@
132 176 List<org.springframework.validation.FieldError> fieldErrors = bindingResult.getFieldErrors();
133 177 for (org.springframework.validation.FieldError fieldError : fieldErrors) {
134 178 map.put("errorcode", ErrorCodeConstants.PARAMETER_ERROR);
135   - map.put("errormsg",fieldError.getDefaultMessage());
  179 + map.put("errormsg",messageResolver.getErrorMessage(fieldError
  180 + .getDefaultMessage()));
136 181 break;
137 182 }
138 183 return map;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AssayConfigController.java View file @ edf6dbd
... ... @@ -23,7 +23,7 @@
23 23  
24 24 //化验项配置
25 25 @Controller
26   -public class AssayConfigController extends RestController{
  26 +public class AssayConfigController extends BaseController{
27 27 @Autowired
28 28 private AssayConfigService assayConfigService;
29 29  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyManageController.java View file @ edf6dbd
... ... @@ -25,7 +25,7 @@
25 25 *
26 26 */
27 27 @Controller
28   -public class BabyManageController extends RestController {
  28 +public class BabyManageController extends BaseController {
29 29  
30 30 /**
31 31 *
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java View file @ edf6dbd
... ... @@ -27,7 +27,7 @@
27 27 * @author Administrator
28 28 */
29 29 @Controller
30   -public class BasicConfigController extends RestController {
  30 +public class BasicConfigController extends BaseController {
31 31  
32 32 @Autowired
33 33 private BasicConfigFacade basicConfigFacade;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java View file @ edf6dbd
... ... @@ -42,7 +42,7 @@
42 42 * Created by Zhang.Rui on 2016/3/18.
43 43 */
44 44 @Controller
45   -public class CommunityConfigController extends RestController {
  45 +public class CommunityConfigController extends BaseController {
46 46 @Autowired
47 47 private CommunityConfigService communityConfigService;
48 48 @Autowired
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java View file @ edf6dbd
... ... @@ -23,7 +23,7 @@
23 23 * Created by zhang.rui on 2015/9/28 0028.
24 24 */
25 25 @Controller
26   -public class DepartmentsController extends RestController {
  26 +public class DepartmentsController extends BaseController {
27 27 @Autowired
28 28 private DepartmentsService departmentsService;
29 29 @Autowired
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PermissionsController.java View file @ edf6dbd
... ... @@ -32,7 +32,7 @@
32 32 * Created by Administrator on 2015/9/28 0028.
33 33 */
34 34 @Controller
35   -public class PermissionsController extends RestController {
  35 +public class PermissionsController extends BaseController {
36 36  
37 37 @Autowired
38 38 private PermissionsService permissionsService;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java View file @ edf6dbd
... ... @@ -24,7 +24,7 @@
24 24 * @author Administrator
25 25 */
26 26 @Controller
27   -public class PuerperaManageController extends RestController {
  27 +public class PuerperaManageController extends BaseController {
28 28  
29 29  
30 30 @Autowired
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReferConfigController.java View file @ edf6dbd
... ... @@ -6,6 +6,7 @@
6 6  
7 7 import com.lyms.platform.biz.param.ReferConfigQuery;
8 8 import com.lyms.platform.common.annotation.TokenRequired;
  9 +import com.lyms.platform.common.base.BaseController;
9 10 import com.lyms.platform.common.enums.YnEnums;
10 11 import com.lyms.platform.operate.web.result.FrontEndResult;
11 12 import org.apache.commons.lang.StringUtils;
... ... @@ -29,7 +30,7 @@
29 30 * 参考值配置
30 31 */
31 32 @Controller
32   -public class ReferConfigController extends RestController{
  33 +public class ReferConfigController extends BaseController {
33 34 @Autowired
34 35 ReferConfigService referConfigService;
35 36 @Autowired
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java View file @ edf6dbd
... ... @@ -27,7 +27,7 @@
27 27 * Created by Administrator on 2015/9/17 0017.
28 28 */
29 29 @Controller
30   -public class RegionController extends RestController{
  30 +public class RegionController extends BaseController{
31 31  
32 32 @Autowired
33 33 private BasicConfigService basicConfigService;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RolesController.java View file @ edf6dbd
... ... @@ -25,7 +25,7 @@
25 25 * Created by Administrator on 2015/9/29 0029.
26 26 */
27 27 @Controller
28   -public class RolesController extends RestController {
  28 +public class RolesController extends BaseController {
29 29  
30 30 @Autowired
31 31 private RolesService rolesService;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/VisitController.java View file @ edf6dbd
... ... @@ -3,6 +3,7 @@
3 3 import javax.validation.Valid;
4 4  
5 5 import com.lyms.platform.common.annotation.TokenRequired;
  6 +import com.lyms.platform.common.base.BaseController;
6 7 import org.apache.commons.lang.StringUtils;
7 8 import org.springframework.beans.factory.annotation.Autowired;
8 9 import org.springframework.http.MediaType;
... ... @@ -23,7 +24,7 @@
23 24 * @author Administrator
24 25 */
25 26 @Controller
26   -public class VisitController extends RestController {
  27 +public class VisitController extends BaseController {
27 28  
28 29 @Autowired
29 30 private VisitFacade visitFacade;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/TokenValidateInteceptor.java View file @ edf6dbd
... ... @@ -65,7 +65,7 @@
65 65 public boolean validateToken(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
66 66 String token = httpServletRequest.getHeader("Authorization");
67 67 if (StringUtils.isEmpty(token)) {
68   - throw new ParameterException();
  68 + throw new TokenException();
69 69 }
70 70 LoginContext loginContext = LoginUtil.checkLoginState(token);
71 71 if(!loginContext.isLogin()) {