|
@@ -29,21 +29,25 @@ class FollowController extends Controller
|
|
|
public array $tableArr = [];
|
|
public array $tableArr = [];
|
|
|
public string $type = '';
|
|
public string $type = '';
|
|
|
|
|
|
|
|
- public function beforeAction($action): bool
|
|
|
|
|
|
|
+ public function actionSchoolAdd()
|
|
|
{
|
|
{
|
|
|
- if (!parent::beforeAction($action)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- $this->type = Helper::getPostString('type');
|
|
|
|
|
- if (!$this->type || !isset(self::TYPE_TABLE_MAP[$this->type])) {
|
|
|
|
|
- Helper::error('类型错误');
|
|
|
|
|
- }
|
|
|
|
|
- $this->tableArr = self::TYPE_TABLE_MAP[$this->type];
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ $this->_add('school');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCanteenAdd()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_add('canteen');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function actionAdd()
|
|
|
|
|
|
|
+ public function actionCompanyAdd()
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->_add('company');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _add($type)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->type = $type;
|
|
|
|
|
+ $this->tableArr = self::TYPE_TABLE_MAP[$this->type];
|
|
|
$firstId = Helper::getPostInt('first_id');
|
|
$firstId = Helper::getPostInt('first_id');
|
|
|
$secondId = Helper::getPostInt('second_id');
|
|
$secondId = Helper::getPostInt('second_id');
|
|
|
$chatImgs = Helper::getArrParam($_POST, 'chat_imgs', Helper::PARAM_KEY_TYPE['array_string']);
|
|
$chatImgs = Helper::getArrParam($_POST, 'chat_imgs', Helper::PARAM_KEY_TYPE['array_string']);
|
|
@@ -61,8 +65,25 @@ class FollowController extends Controller
|
|
|
Helper::ok();
|
|
Helper::ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function actionAll()
|
|
|
|
|
|
|
+ public function actionSchoolAll()
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->_all('school');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCanteenAll()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_all('canteen');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCompanyAll()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_all('company');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _all($type)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->type = $type;
|
|
|
|
|
+ $this->tableArr = self::TYPE_TABLE_MAP[$this->type];
|
|
|
$firstId = Helper::getPostInt('first_id');
|
|
$firstId = Helper::getPostInt('first_id');
|
|
|
if ($firstId <= 0) {
|
|
if ($firstId <= 0) {
|
|
|
Helper::error('参数错误');
|
|
Helper::error('参数错误');
|
|
@@ -77,8 +98,25 @@ class FollowController extends Controller
|
|
|
Helper::ok($data['records']);
|
|
Helper::ok($data['records']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function actionInfo()
|
|
|
|
|
|
|
+ public function actionSchoolInfo()
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->_info('school');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCanteenInfo()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_info('canteen');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCompanyInfo()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_info('company');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _info($type)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->type = $type;
|
|
|
|
|
+ $this->tableArr = self::TYPE_TABLE_MAP[$this->type];
|
|
|
$id = Helper::getPostInt('id');
|
|
$id = Helper::getPostInt('id');
|
|
|
if (empty($id)) {
|
|
if (empty($id)) {
|
|
|
Helper::error('参数错误');
|
|
Helper::error('参数错误');
|
|
@@ -88,12 +126,34 @@ class FollowController extends Controller
|
|
|
Helper::ok($data);
|
|
Helper::ok($data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function actionList()
|
|
|
|
|
|
|
+ public function actionSchoolList()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_list('school');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCanteenList()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_list('canteen');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function actionCompanyList()
|
|
|
{
|
|
{
|
|
|
|
|
+ $this->_list('company');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _list($type)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->type = $type;
|
|
|
|
|
+ $this->tableArr = self::TYPE_TABLE_MAP[$this->type];
|
|
|
|
|
+ $schoolArr = Helper::getArrParam($_POST, 'school', Helper::PARAM_KEY_TYPE['array_int']);
|
|
|
$filter = [
|
|
$filter = [
|
|
|
- $this->tableArr['first_id'] => Helper::getPostInt('second_id'),
|
|
|
|
|
- $this->tableArr['second_id'] => Helper::getPostInt('second_id'),
|
|
|
|
|
|
|
+ $this->tableArr['first_id'] => Helper::getPostInt('first_id')? : null,
|
|
|
|
|
+ $this->tableArr['second_id'] => Helper::getPostInt('first_id')? : null,
|
|
|
];
|
|
];
|
|
|
|
|
+ if ($phone = Helper::getPostString('phone')) {
|
|
|
|
|
+ $rs = Helper::arrayColumn(DB::getListWithCriteria($this->tableArr['table2'], DbCriteria::simpleCompare(['phone' => $phone])->setSelect('id')), 'id');
|
|
|
|
|
+ $filter[$this->tableArr['second_id']] = $rs?: [-1];
|
|
|
|
|
+ }
|
|
|
$criteria = DbCriteria::simpleCompareWithPage($filter)->setOrder('id desc');
|
|
$criteria = DbCriteria::simpleCompareWithPage($filter)->setOrder('id desc');
|
|
|
$data = DB::getListWithCriteria($this->tableArr['table'], $criteria);
|
|
$data = DB::getListWithCriteria($this->tableArr['table'], $criteria);
|
|
|
$data['records'] = $this->formatFollowList($data['records']);
|
|
$data['records'] = $this->formatFollowList($data['records']);
|