<?php require '../dao/AchieveDao.php'; $userId = $_REQUEST['userId']; //搜索词,按成就名进行模糊查询,不能为空 $achieveSearch = $_REQUEST['achieveSearch']; $achieveDao = new AchieveDao(); echo $achieveDao->getAchieveBySearch($userId, $achieveSearch);
<?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);
<?php require '../dao/AchieveDao.php'; /** * @Note 用户所关注的成就的动态。包括吐槽(即评论)和完成成就,按时间降序排列,分页获取 */ date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $time = empty($_REQUEST['time']) ? Date("Y-m-d H:i:s") : $_REQUEST['time']; $acheiveDao = new AchieveDao(); echo $acheiveDao->getAchieveNewsList($userId, $time);
<?php require '../dao/AchieveDao.php'; require 'ImageUpload.php'; $imageUpload = new ImageUpload(); $userId = $_REQUEST['userId']; $achieveType = $_REQUEST['achieveType']; if (!empty($_REQUEST['achieveImage'])) { $achieveImage = $_REQUEST['achieveImage']; } else { $achieveImage = $imageUpload->setAchieveImage(); } $achieveTitle = $_REQUEST['achieveTitle']; $achieveContent = $_REQUEST['achieveContent']; $isGet = (int) $_REQUEST['isGet']; //boolean $achieveDao = new AchieveDao(); if ($achieveDao->setAchieve($userId, $achieveType, $achieveImage, $achieveTitle, $achieveContent, $isGet) > 0) { echo json_encode(array('mesg' => 'success', 'result' => true)); } else { echo json_encode(array('mesg' => 'fail', 'result' => false)); }
<?php require '../dao/AchieveDao.php'; header("content-type: text/html; charset = utf-8"); /** * 列表采用基于查询的分页,一次15条 */ date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $achieveTime = empty($_REQUEST['achieveTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['achieveTime']; $achieveDao = new AchieveDao(); /** * 按照类型查询成就列表(包括推荐内容:发布时间在30天内,用户尚未完成且完成数小于等于3的成就,按时间降序排列) */ if (isset($_REQUEST['achieveType'])) { $achieveType = $_REQUEST['achieveType']; //判断是否获取推荐的成就 if ($achieveType == "推荐") { echo $achieveDao->getRecommendAchieve($userId, $achieveTime); exit; } //默认排序条件为“最新”,否则为“最热” $condition = empty($_REQUEST['condition']) ? "最新" : $_REQUEST['condition']; if ($condition != "最新") { $pageIndex = $_REQUEST['pageIndex']; $isGetOrder = (bool) $_REQUEST['isGetOrder']; //是否按完成数作为排序依据,否则按吐槽数 echo $achieveDao->getHotAchieve($userId, $achieveType, $pageIndex, $isGetOrder); //按热度排序pageIndex, isGetOrder为必传参数, //初始pageIndex值为1,每次分页查询均会返回当前pageIndex,下次查询时加1再传入 } else {
<?php require '../dao/AchieveDao.php'; date_default_timezone_set('PRC'); /** * @Note 获取个人关注的成就列表,包括已经完成和未完成的成就,完成的成就默认关注,分页返回,一次15条 * $getTime 上一次查询最后一条显示的时间,如果是第一次加载则为当前时间 */ $getTime = empty($_REQUEST['getTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['getTime']; $userId = $_REQUEST['userId']; $achieveDao = new AchieveDao(); echo $achieveDao->getAchieveByUser($_REQUEST['userId'], $getTime, true);