/**
  * 添加一个新的DUpvote到数据库
  *
  * @author 陈义
  * @date 2016-04-09 16:11:18
  */
 @Override
 public Integer addDUpvote(DUpvoteDto dUpvoteDto) {
   // TODO Auto-generated method stub
   if (dUpvoteDto != null) {
     DUpvote dUpvote = new DUpvote();
     dUpvote = beanToDto.D1ToT1(dUpvote, dUpvoteDto);
     return this.save(dUpvote);
   }
   return 0;
 }
 /**
  * 添加一个新的BSite到数据库
  *
  * @author 陈义
  * @date 2016-04-09 16:11:18
  */
 @Override
 public Integer addBSite(BSiteDto bSiteDto) {
   // TODO Auto-generated method stub
   if (bSiteDto != null) {
     BSite bSite = new BSite();
     bSite = beanToDto.D1ToT1(bSite, bSiteDto);
     return this.save(bSite);
   }
   return 0;
 }
 /**
  * 通过id获取DUpvoteDto
  *
  * @author 陈义
  * @date 2016-04-09 16:11:18
  */
 @Override
 public DUpvoteDto getDUpvoteByID(DUpvoteDto dUpvoteDto) {
   // TODO Auto-generated method stub
   if (dUpvoteDto != null && dUpvoteDto.getDupvoteId() != null) {
     StringBuffer stringBuffer = new StringBuffer();
     Map<String, Object> params = new HashMap<String, Object>();
     stringBuffer.append("from  " + DUpvote.class.getName() + "  a where a.dupvoteId=:id");
     params.put("id", dUpvoteDto.getDupvoteId());
     List<DUpvote> list = this.find(stringBuffer.toString(), params);
     if (list != null && list.size() > 0) {
       DUpvote t1 = list.get(0);
       DUpvoteDto dto = new DUpvoteDto();
       dto = beanToDto.T1ToD1(t1, dto);
       return dto;
     }
   }
   return null;
 }
 @Override
 public DUpvoteDto getDUpvote(DUpvoteDto dUpvoteDto) {
   // TODO Auto-generated method stub
   if (dUpvoteDto != null) {
     StringBuffer stringBuffer = new StringBuffer();
     Map<String, Object> params = new HashMap<String, Object>();
     stringBuffer.append("from  " + DUpvote.class.getName() + "  a where a.status=1 ");
     stringBuffer.append(" and a.UUser.userId=:userId and a.DDiary.diaryId=:diaryId");
     params.put("userId", dUpvoteDto.getUUserDto().getUserId());
     params.put("diaryId", dUpvoteDto.getDDiaryDto().getDiaryId());
     List<DUpvote> list = this.find(stringBuffer.toString(), params);
     if (list != null && list.size() > 0) {
       DUpvote t1 = list.get(0);
       DUpvoteDto dto = new DUpvoteDto();
       dto = beanToDto.T1ToD1(t1, dto);
       return dto;
     }
   }
   return null;
 }