71 lines
2.6 KiB
PHP
71 lines
2.6 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require_once APPPATH . 'controllers/api/BaseController.php';
|
|
|
|
class Enroll extends BaseController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('market/Market_sytopic_model', 'mSytopic');
|
|
$this->load->model('market/Market_sytopic_enroll_model', 'sytopic_enroll_model');
|
|
$this->load->model('market/market_sylive_user_model', 'user_model');
|
|
$this->load->library('MyEncryption');
|
|
}
|
|
|
|
public function page_get()
|
|
{
|
|
$page = $this->input_param('page');
|
|
$limit = $this->input_param('limit');
|
|
$sort = $this->input_param('sort');
|
|
$order = $this->input_param('order');
|
|
!$page && $page = 1;
|
|
!$limit && $limit = 10;
|
|
$sort_order = 'id desc';
|
|
if ($sort && $order) {
|
|
$sort_order = $sort . ' ' . $order;
|
|
}
|
|
$list = [];
|
|
$where['status>='] = 0;
|
|
$count = $this->sytopic_enroll_model->count($where);
|
|
if ($count) {
|
|
$res = $this->sytopic_enroll_model->select($where, $sort_order, $page, $limit);
|
|
$topicIds = array_column($res, 'topicId');
|
|
$topicIdsStr = implode(',', $topicIds);
|
|
$topicMap = [];
|
|
$topicIdsStr && $topicMap = $this->mSytopic->map('id', 'title', ["id in ({$topicIdsStr})" => null], '', '', '', 'id,title');
|
|
$channelUserIds = array_column($res, 'channelId');
|
|
$channelUserIdsStr = implode(',', array_unique($channelUserIds));
|
|
$channelUserMap = [];
|
|
$channelUserIdsStr && $channelUserMap = $this->user_model->map('userId', 'uname', ["userId in ({$channelUserIdsStr})" => null], '', '', '', 'userId,uname');
|
|
foreach ($res as $val) {
|
|
$val['channelName'] = $channelUserMap[$val['channelId']] ?: '';
|
|
$val['topicTitle'] = $topicMap[$val['topicId']] ?: '';
|
|
$val['status'] = intval($val['status']);
|
|
$list[] = $val;
|
|
}
|
|
}
|
|
$date = ['list' => $list, 'count' => $count];
|
|
$this->return_response_list($date);
|
|
}
|
|
|
|
public function status_get()
|
|
{
|
|
$statusArray = $this->sytopic_enroll_model->statusCn();
|
|
$this->return_response_list($statusArray);
|
|
}
|
|
|
|
/**
|
|
* 修改状态
|
|
*/
|
|
public function status_put()
|
|
{
|
|
$id = $this->input_param('id');
|
|
$status = $this->input_param('status');
|
|
if (!$id) {
|
|
$this->return_json('参数错误');
|
|
}
|
|
$this->sytopic_enroll_model->update(['status' => $status], ['id' => $id]);
|
|
$this->return_response();
|
|
}
|
|
} |