| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | <?phpnamespace app\admin\controller\device;use app\admin\validate\device\DeviceValidate;use app\controller\Curd;use app\model\Device;use app\model\SysSerial;use support\Request;use support\Response;class DeviceController extends Curd{    public function __construct()    {        $this->model = new Device();        $this->validate = true;        $this->validateClass = new DeviceValidate();    }    public function select(Request $request): Response    {        [$where, $format, $limit, $field, $order] = $this->selectInput($request);        $order = $request->get('order', 'desc');        $field = $field ?? 'device_addtimes';        $query = $this->doSelect($where, $field, $order);        return $this->doFormat($query, $format, $limit);    }    protected function insertInput(Request $request): array    {        $data = $this->inputFilter($request->post());        $data['device_id'] = $this->generateDeviceId();        return $data;    }    /**     * @Desc 生成设备ID     * @Author Gorden     * @Date 2024/3/26 13:32     *     * @return string     * @throws \support\exception\BusinessException     */    private function generateDeviceId()    {        $id = SysSerial::getSerial();        return "DE".str_pad($id,16,'0',STR_PAD_LEFT).random_string(8);    }}
 |