|  | @ -1,6 +1,8 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.hospital.service.consult;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientBusinessDao;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @ -14,18 +16,100 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private BasePatientBusinessDao patientBusinessDao;
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private KnowledgeArticleDao knowledgeArticleDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 *
 | 
	
		
			
				|  |  | 	 * @param id
 | 
	
		
			
				|  |  | 	 * @param collection
 | 
	
		
			
				|  |  | 	 * @param flag 1收藏2阅读3点赞4分享
 | 
	
		
			
				|  |  | 	 * @param status
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public BasePatientBusinessDO setCollectionById(String id,Integer collection){
 | 
	
		
			
				|  |  | 	public BasePatientBusinessDO setCollectionById(String id,Integer flag,Integer status){
 | 
	
		
			
				|  |  | 		BasePatientBusinessDO patientBusinessDO = patientBusinessDao.findByIdAndDel(id);
 | 
	
		
			
				|  |  | 		if (patientBusinessDO!=null){
 | 
	
		
			
				|  |  | 			patientBusinessDO.setCollection(collection);
 | 
	
		
			
				|  |  | 			patientBusinessDao.save(patientBusinessDO);
 | 
	
		
			
				|  |  | 			if (flag!=null&&flag==1){
 | 
	
		
			
				|  |  | 				patientBusinessDO.setCollection(status);
 | 
	
		
			
				|  |  | 				patientBusinessDao.save(patientBusinessDO);
 | 
	
		
			
				|  |  | 				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
 | 
	
		
			
				|  |  | 				if (knowledgeArticleDO!=null){
 | 
	
		
			
				|  |  | 					if (knowledgeArticleDO.getCollection()!=null){
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setCollection(knowledgeArticleDO.getCollection()+1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}else {
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setCollection(knowledgeArticleDO.getCollection()-1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}else {
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setCollection(1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}
 | 
	
		
			
				|  |  | 				}
 | 
	
		
			
				|  |  | 			}else if (flag!=null&&flag==2){
 | 
	
		
			
				|  |  | 				patientBusinessDO.setIsRead(status);
 | 
	
		
			
				|  |  | 				patientBusinessDao.save(patientBusinessDO);
 | 
	
		
			
				|  |  | 				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
 | 
	
		
			
				|  |  | 				if (knowledgeArticleDO!=null){
 | 
	
		
			
				|  |  | 					if (knowledgeArticleDO.getReadCount()!=null){
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setReadCount(knowledgeArticleDO.getReadCount()+1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}else {
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setReadCount(knowledgeArticleDO.getReadCount()-1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}else {
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setReadCount(1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}
 | 
	
		
			
				|  |  | 				}
 | 
	
		
			
				|  |  | 			}else if (flag!=null&&flag==3){
 | 
	
		
			
				|  |  | 				patientBusinessDO.setFabulous(status);
 | 
	
		
			
				|  |  | 				patientBusinessDao.save(patientBusinessDO);
 | 
	
		
			
				|  |  | 				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
 | 
	
		
			
				|  |  | 				if (knowledgeArticleDO!=null){
 | 
	
		
			
				|  |  | 					if (knowledgeArticleDO.getFabulous()!=null){
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setFabulous(knowledgeArticleDO.getFabulous()+1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}else {
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setFabulous(knowledgeArticleDO.getFabulous()-1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}else {
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setFabulous(1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}
 | 
	
		
			
				|  |  | 				}
 | 
	
		
			
				|  |  | 			}else if (flag!=null&&flag==4){
 | 
	
		
			
				|  |  | 				patientBusinessDO.setShare(status);
 | 
	
		
			
				|  |  | 				patientBusinessDao.save(patientBusinessDO);
 | 
	
		
			
				|  |  | 				KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
 | 
	
		
			
				|  |  | 				if (knowledgeArticleDO!=null){
 | 
	
		
			
				|  |  | 					if (knowledgeArticleDO.getShare()!=null){
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setShare(knowledgeArticleDO.getShare()+1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}else {
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setShare(knowledgeArticleDO.getShare()-1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}else {
 | 
	
		
			
				|  |  | 						if (status==1){
 | 
	
		
			
				|  |  | 							knowledgeArticleDO.setShare(1);
 | 
	
		
			
				|  |  | 							knowledgeArticleDao.save(knowledgeArticleDO);
 | 
	
		
			
				|  |  | 						}
 | 
	
		
			
				|  |  | 					}
 | 
	
		
			
				|  |  | 				}
 | 
	
		
			
				|  |  | 			}
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		return patientBusinessDO;
 | 
	
		
			
				|  |  | 	}
 |