CheckClinicalPathwayAop.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package thyyxxk.webserver.aop.aspect;
  2. import cn.hutool.core.convert.Convert;
  3. import lombok.RequiredArgsConstructor;
  4. import org.aspectj.lang.annotation.Aspect;
  5. import org.aspectj.lang.annotation.Before;
  6. import org.aspectj.lang.annotation.Pointcut;
  7. import org.springframework.stereotype.Component;
  8. import thyyxxk.webserver.config.exception.BizException;
  9. import thyyxxk.webserver.config.exception.ExceptionEnum;
  10. import thyyxxk.webserver.dao.his.dictionary.clinicalPathway.ClinicalPathwayDao;
  11. import thyyxxk.webserver.entity.dictionary.pathwayTemplates.dto.ClinicalPathwayTemplates;
  12. import thyyxxk.webserver.utils.TokenUtil;
  13. import javax.servlet.http.HttpServletRequest;
  14. @Aspect
  15. @Component
  16. @RequiredArgsConstructor
  17. public class CheckClinicalPathwayAop {
  18. private final ClinicalPathwayDao dao;
  19. @Pointcut("@annotation(thyyxxk.webserver.aop.interfaces.CheckClinicalPathway)")
  20. public void pointcut() {
  21. }
  22. @Before("pointcut()")
  23. public void doBefore() {
  24. HttpServletRequest request = TokenUtil.getInstance().getRequest();
  25. if (request == null) {
  26. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "请求错误,请重新登录");
  27. }
  28. String templateId = request.getHeader("templateId");
  29. if (templateId == null) {
  30. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板id不存在请刷新页面");
  31. }
  32. ClinicalPathwayTemplates clinicalPathwayTemplates = dao.selectById(templateId);
  33. if (clinicalPathwayTemplates == null) {
  34. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板已经被停用了。");
  35. }
  36. if (!TokenUtil.getInstance().getTokenUserId().equals(clinicalPathwayTemplates.getCreateCode())) {
  37. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "改模板不是您创建的无法修改。");
  38. }
  39. // if (clinicalPathwayTemplates.getPublish()) {
  40. // throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板已经发布无法修改");
  41. // }
  42. }
  43. }