コード例 #1
0
 @Override
 public Integer getDUpvoteCount(DUpvoteDto dUpvoteDto) {
   if (dUpvoteDto != null && dUpvoteDto.getDDiaryDto() != null) {
     StringBuffer stringBuffer = new StringBuffer(DbType.SELECT + " count(*) ");
     Map<String, Object> params = new HashMap<String, Object>();
     stringBuffer.append(" from " + DUpvote.class.getName() + " a where 1=1");
     stringBuffer.append(" and a.DDiary.diaryId=:diaryId");
     params.put("diaryId", dUpvoteDto.getDDiaryDto().getDiaryId());
     if (dUpvoteDto.getStatus() != null) {
       stringBuffer.append(" and a.status=:status");
       params.put("status", dUpvoteDto.getStatus());
     } else {
       stringBuffer.append(" and a.status=1");
     }
     return this.count(stringBuffer.toString(), params);
   }
   return 0;
 }
コード例 #2
0
 @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;
 }