| 
					
				 | 
			
			
				@@ -2,8 +2,6 @@ package com.tzld.longarticle.recommend.server.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.longarticle.recommend.server.model.WxUserGetResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.longarticle.recommend.server.remote.WxUserManagementRemoteService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.tzld.longarticle.recommend.server.repository.crawler.ArticleUserGroupRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.tzld.longarticle.recommend.server.repository.entity.crawler.ArticleUserGroupNew; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.longarticle.recommend.server.repository.mapper.crawler.ArticleUserGroupMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.longarticle.recommend.server.repository.model.ArticleUserGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -27,8 +25,6 @@ import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class UserManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private WxUserManagementRemoteService wxUserManagementRemoteService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private ArticleUserGroupRepository articleUserGroupRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ArticleUserGroupMapper articleUserGroupMapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -168,36 +164,37 @@ public class UserManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void handleSubscribe(String gzhId, String openId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ArticleUserGroupNew group = articleUserGroupRepository.findFirstByGzhIdAndOpenId(gzhId, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ArticleUserGroup group = articleUserGroupMapper.selectByGzhIdAndOpenId(gzhId, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (group == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // insert 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 查库,知道所有分组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<Integer> ugIds = articleUserGroupRepository.findAllUserGroupId(gzhId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> ugIds = articleUserGroupMapper.selectUserGroupIdByGzhId(gzhId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 随机选一个组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             int ugId = ugIds.get(RandomUtils.nextInt(ugIds.size())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            group = new ArticleUserGroupNew(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            group = new ArticleUserGroup(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group.setGzhId(gzhId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group.setOpenId(openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group.setUserGroupId(ugId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            articleUserGroupRepository.save(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            group.setIsDelete(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            articleUserGroupMapper.insert(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // update 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group.setIsDelete(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            articleUserGroupRepository.save(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            articleUserGroupMapper.updateByPrimaryKey(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void handleUnsubscribe(String gzhId, String openId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ArticleUserGroupNew group = articleUserGroupRepository.findFirstByGzhIdAndOpenId(gzhId, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ArticleUserGroup group = articleUserGroupMapper.selectByGzhIdAndOpenId(gzhId, openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (group != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             group.setIsDelete(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            articleUserGroupRepository.save(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            articleUserGroupMapper.updateByPrimaryKey(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<String> listByUserGroupId(String gzhId, int userGroupId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return articleUserGroupRepository.findAllOpenId(gzhId, userGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return articleUserGroupMapper.selectOpenIdByGzhIdAndUserGroupId(gzhId, userGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |