Kaynağa Gözat

处理循环依赖

liaoyongfei 4 yıl önce
ebeveyn
işleme
52301b4cd1

+ 3 - 2
ymall/src/main/java/com/liangjian11/ymall/config/RedirectPathSource.java

@@ -108,10 +108,11 @@ public class RedirectPathSource {
 
   private String patientUser;
 
-
-  @Autowired
   private DoctorService doctorService;
 
+  public void setDoctorService(DoctorService doctorService) {
+    this.doctorService = doctorService;
+  }
 
   public String getRedirectPath(String redirectCode, UserAccount user, String id){
      return this.getRedirectPath(redirectCode,user,id,null);

+ 10 - 0
ymall/src/main/java/com/liangjian11/ymall/service/impl/DoctorServiceImpl.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.liangjian11.ymall.config.RedirectPathSource;
 import com.liangjian11.ymall.handle.WechatHandle;
 import com.liangjian11.ymall.mapper.*;
 import com.liangjian11.ymall.model.*;
@@ -32,6 +33,7 @@ import org.springframework.web.client.RestTemplate;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
+import javax.annotation.PostConstruct;
 import javax.management.Query;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
@@ -87,6 +89,14 @@ public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> impleme
   @Autowired
   private UserRoleService userRoleService;
 
+  @Autowired
+  private RedirectPathSource redirectPathSource;
+
+  @PostConstruct
+  public void init(){
+    redirectPathSource.setDoctorService(this);
+  }
+
   @Override
   public ResultInfo query(FiltersData data) {
     Integer size = data.getPageSize();