|  | @ -6,12 +6,10 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorMessageDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.doctor.dao.BaseDoctorBackgroundDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.PageRequest;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.Pageable;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.Sort;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
	
		
			
				|  | @ -27,6 +25,8 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |     private BaseDoctorDao baseDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorMessageDao doctorMessageDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HibenateUtils hibenateUtils;
 | 
	
		
			
				|  |  |     //查询背景
 | 
	
		
			
				|  |  |     public List<BaseDoctorBackgroundDO> getBackground(Integer page,Integer pageSize){
 | 
	
		
			
				|  |  |         return baseDoctorBackgroundDao.getBackroundAll(page,pageSize);
 | 
	
	
		
			
				|  | @ -84,10 +84,19 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<BaseDoctorMessageDO> selectByDoctor(String doctor,Integer page,Integer size){
 | 
	
		
			
				|  |  |         Sort sort = new Sort(Sort.Direction.DESC, "isSort");
 | 
	
		
			
				|  |  |         Pageable pageRequest = new PageRequest(page-1,size,sort);
 | 
	
		
			
				|  |  |         return doctorMessageDao.findByDoctorAndDel(doctor,pageRequest);
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> selectByDoctor(String doctor, Integer contentType, String content, Integer page, Integer size){
 | 
	
		
			
				|  |  |         String sql = "select id as \"id\", doctor as \"doctor\",doctor_name as \"doctorName\",content_type as \"contentType\"," +
 | 
	
		
			
				|  |  |                 "content as \"content\" , content_desc as \"contentDesc\",is_sort as \"isSort\",del as \"del\" " +
 | 
	
		
			
				|  |  |                 " from base_doctor_message whre del=1 and doctor='"+doctor+"' ";
 | 
	
		
			
				|  |  |         if (contentType!=null){
 | 
	
		
			
				|  |  |             sql +=" and content_type= "+contentType;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(content)){
 | 
	
		
			
				|  |  |             sql +=" and content_type like '%"+contentType+"%'v";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,size);
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -96,9 +105,10 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |      * @param doctorMessageDO
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public BaseDoctorMessageDO saveDoctorMessage(BaseDoctorMessageDO doctorMessageDO){
 | 
	
		
			
				|  |  |         if (!StringUtils.isNotBlank(doctorMessageDO.getId())){
 | 
	
		
			
				|  |  |             String sql = "select max(dm.is_sort) as total from base_doctor_message dm ";
 | 
	
		
			
				|  |  |             String sql = "select max(dm.is_sort) as total from base_doctor_message dm where dm.del=1 ";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |             Integer isSort=0;
 | 
	
		
			
				|  |  |             if (maps!=null&&maps.size()!=0){
 | 
	
	
		
			
				|  | @ -108,6 +118,7 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             doctorMessageDO.setIsSort(isSort);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         doctorMessageDO.setDel(1);
 | 
	
		
			
				|  |  |         doctorMessageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         doctorMessageDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         return  doctorMessageDao.save(doctorMessageDO);
 | 
	
	
		
			
				|  | @ -119,9 +130,10 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |      * @param id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public BaseDoctorMessageDO setMessageHead(String id){
 | 
	
		
			
				|  |  |         BaseDoctorMessageDO doctorMessageDO = doctorMessageDao.findOne(id);
 | 
	
		
			
				|  |  |         String sql = "select max(dm.is_sort) as total from base_doctor_message dm ";
 | 
	
		
			
				|  |  |         String sql = "select max(dm.is_sort) as total from base_doctor_message dm where dm.del=1  ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         Integer isSort=0;
 | 
	
		
			
				|  |  |         if (maps!=null&&maps.size()!=0){
 | 
	
	
		
			
				|  | @ -136,4 +148,14 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public BaseDoctorMessageDO delDoctorMessage(String id){
 | 
	
		
			
				|  |  |         BaseDoctorMessageDO doctorMessageDO = doctorMessageDao.findOne(id);
 | 
	
		
			
				|  |  |         doctorMessageDO.setDel(0);
 | 
	
		
			
				|  |  |         doctorMessageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         doctorMessageDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         return doctorMessageDao.save(doctorMessageDO);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |