<?php

require '../dao/GetDao.php';
require '../dao/MessageDao.php';
$achieveId = $_REQUEST['achieveId'];
$userId = $_REQUEST['userId'];
$requestType = strtolower($_REQUEST['requestType']);
/**
 *	@Note: 获得成就的完成列表
 */
if ($requestType == 'get') {
    $getDao = new GetDao();
    echo json_encode(array('resultArray' => $getDao->getCompleteList($achieveId, $userId)));
} else {
    if ($requestType == 'message') {
        $messageDao = new MessageDao();
        echo $messageDao->achieveMessageList($achieveId);
    }
}
exit;
<?php

require '../dao/AchieveDao.php';
date_default_timezone_set('PRC');
/**
 *	$getTime 上一次查询最后一条显示的时间,如果是第一次加载则为当前时间
 */
$getTime = empty($_REQUEST['getTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['getTime'];
$userId = $_REQUEST['userId'];
$achieveDao = new AchieveDao();
$getDao = new GetDao();
$achieve = json_decode($achieveDao->getAchieveByUser($_REQUEST['userId'], $getTime));
$achieve->userGetCount = $getDao->getCount($userId);
echo json_encode($achieve);
예제 #3
0
<?php

require '../dao/GetDao.php';
$userId = $_REQUEST['userId'];
$getDao = new GetDao();
$self = (int) $getDao->getCount($userId);
if ($self == 0) {
    echo json_encode(array('mesg' => '没有完成任何成就,匹配不成功', 'result' => false));
    exit;
}
$match_list = json_decode($getDao->match($userId))->resultArray;
if (count($match_list) == 0) {
    echo json_encode(array('mesg' => '未找到任何与您有相同成就的人,匹配不成功', 'result' => false));
    exit;
}
$index = 0;
$max = 0;
for ($i = 0; $i < count($match_list); $i++) {
    $common = $match_list[$i]->common;
    $total = $match_list[$i]->total;
    $value = round($common / sqrt($total * $self), 4);
    if ($value > $max) {
        $max = $value;
        $index = $i;
    }
}
$match = $getDao->getMatchUser($match_list[$index]->getUser, $userId);
$match->matchScore = $max;
echo json_encode($match);
<?php

require '../dao/GetDao.php';
$achieveId = $_REQUEST['achieveId'];
$userId = $_REQUEST['userId'];
$getDao = new GetDao();
if ($getDao->cancelCompleteAchieve($achieveId, $userId) > 0) {
    echo json_encode(array('mesg' => 'success', 'result' => true));
} else {
    echo json_encode(array('mesg' => 'fail', 'result' => false));
}
<?php

require '../dao/TopicDao.php';
require '../dao/GetDao.php';
require '../dao/MessageDao.php';
$topicName = $_REQUEST['topicName'];
$userId = $_REQUEST['userId'];
//是否精确查询,否则采取模糊匹配
$isExact = (bool) $_REQUEST['isExact'];
$topicDao = new TopicDao();
$getDao = new GetDao();
$messageDao = new MessageDao();
$topicDao = new TopicDao();
$topic = (object) array();
$topic->postTopic = json_decode($topicDao->searchPostTopic($userId, $topicName, $isExact))->resultArray;
$topic->achieveTopic = json_decode($topicDao->searchAchieveTopic($userId, $topicName, $isExact))->resultArray;
foreach ($topic->achieveTopic as $index => $achieve) {
    $achieveId = $achieve->achieveId;
    $achieve->getCount = (int) $getDao->achieveGetCount($achieveId);
    $achieve->mesgCount = (int) $messageDao->achieveMessageCount($achieveId);
}
echo json_encode($topic);
<?php

require '../dao/GetDao.php';
$achieveId = $_REQUEST['achieveId'];
$userId = $_REQUEST['userId'];
$getDao = new GetDao();
$getDao->setConcern($achieveId, $userId);
echo json_encode(array('mesg' => 'success', 'result' => true));
예제 #7
0
<?php

require '../dao/GetDao.php';
$userId = $_REQUEST['userId'];
$targetUser = $_REQUEST['targetUser'];
$getDao = new GetDao();
echo json_encode($getDao->getMatchUser($targetUser, $userId));
예제 #8
0
 /**
  *	获得成就列表中每条成就的详尽信息,包括吐槽数、完成数
  *	@Param $userId
  *	@Param $sq
  *	@Param $orderField( default '') 排序字段
  *	@Param $achieveType( default '')
  *	@Return
  */
 private function achieve($userId, $sql, $orderField = '', $achieveType = '')
 {
     if ($userId != null) {
         $sql = "select p.* , g.isGet from ({$sql}) p left outer join tb_get g on g.getUser = '******' and g.getAchieve = p.achieveId ";
         if (!empty($orderField)) {
             $sql .= "order by p.{$orderField} desc";
         }
     }
     $achieveList = json_decode($this->query($sql))->resultArray;
     $messageDao = new MessageDao();
     $getDao = new GetDao();
     $result = (object) array();
     if (!empty($achieveType)) {
         $result->userGetCount = $this->userGetCount($userId, $achieveType);
         $result->totalAchieveCount = $this->totalAchieveCount($achieveType);
     }
     foreach ($achieveList as $index => $achieve) {
         $achieveId = $achieve->achieveId;
         $achieve->getCount = $getDao->achieveGetCount($achieveId);
         $achieve->mesgCount = $messageDao->achieveMessageCount($achieveId);
     }
     $result->achieveList = $achieveList;
     return json_encode($result);
 }