<?php

namespace app\api\controller\HonoraryAchievement;

use app\BaseController;
use app\common\model\HonoraryAchievement\Achievement as ModelAchievement;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;


class Achievement extends BaseController
{
    /**
     * 获取录取院校成绩列表
     */
    public function getAchievementList(Request $request): array
    {
        $params = $request->param();
        $con = [];
        // $this->validate($params, [
        //     'school_category_id|录取院校类型id' => 'require',
        // ]);

        // $con = Tool::getOptionalQuery(['b.school_category_id', '=']);

        $query = ModelAchievement::where($con)
            ->field([
                'a.achievement_id',
                'a.school_category_guid',
                'b.school_category_id',
                'b.school_category_name',
                'a.achievement_title',
                'a.achievement_content',
                'a.achievement_sub_content',
                'a.achievement_sort'
            ])
            ->alias('a')
            ->leftJoin('school_category b', 'a.school_category_guid = b.school_category_guid')
            ->hidden(['school_category_guid'])
            ->order('achievement_sort', 'asc')
            ->select();


        return msg(0, "获取录取院校成绩列表成功!", [
            'data' => $query,
            'count' => count($query)
        ]);
    }
}
