1 Star 2 Fork 0

贺强 / yunduan_education

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

yunduan_education

介绍

整合了elasticsearch,消息队列,操作数据库,第三方支付,发送短信,接口封装,h+ UI,后台管理等等

使用说明

  1. 会php语言开发,熟悉tp6

  2. 需要php 7.1 及以上的版本

  3. 调试参数

    参数名 参数值 说明
    debug es_w print_r 打印 es 参数数组
    debug es_var_w var_dump 打印 es 参数集合
    debug es_r print_r 打印 es 结果数组
    debug es_var_r var_dump 打印 es 结果集合
    debug model_w print_r 打印 model 参数数组
    debug model_var_w var_dump 打印 model 参数集合
    debug model_r print_r 打印 model 结果数组
    debug model_var_r var_dump 打印 model 结果集合
    debug es_list print_r 打印 es 返回到 model 的结果数组(很少用)
    debug es_var_list var_dump 打印 es 返回到 model 的结果集合(很少用)
  4. CommonModel 类使用 该类封装了操作数据库的常用方法,所有方法都为静态方法,并集成了 elasticsearch 的添加、修改、删除、查询,子类只需继承该类,不需要写额外的代码。数据库表命名规则:只能由小写字母和下划线(_)组成,单词之间用下划线分隔

    ㈠ 子类命名规则 以表名下划线分隔的单词合并作类名,每个单词首字母大写,类名后缀为 Model

    ㈡子类属性

    属性名 默认值 说明
    $elastic 1 子类数据是否启用es
    $datatable '' 子类对应的表名,一般不需要设置此属性值,除非有特殊表名和类名不对应,比如每天的登录表,设置表名可带表前缀也可不带
    $has_no_id false 子类对应的表是否不需要 id 字段

    ㈢ model类方法

    方法名

    参数

    add

    添加一条数据

    参数名

    类型

    是否必传

    说明

    $data

    array

    要添加的数据 ['name'=>'think',, ……]

    $field

    array

    字段合法性检测

    $fetchSql

    bool

    是否打印SQL语句

    addArr

    添加多条数据

    参数名

    类型

    是否必传

    说明

    $data

    array

    要添加的数据 [['name'=>'think', ……], ['name'=>'think', ……], ……]

    $limit

    integer

    每次插入的数量限制

    $fetchSql

    bool

    是否打印SQL语句

    delById

    根据主键ID删除数据

    参数名

    类型

    是否必传

    说明

    $id

    int|string|array

    要删除的主键ID:1或[1,2, ……]

    $fetchSql

    bool

    是否打印SQL语句

    delByWhere

    根据条件删除数据

    参数名

    类型

    是否必传

    说明

    $where

    array|string

    删除条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $fetchSql

    bool

    是否打印SQL语句

    modify

    根据条件修改数据

    参数名

    类型

    是否必传

    说明

    $data

    array

    要修改的数据['login_time'  => ['exp','now()'], 'name' => 'thinkphp', ……]

    $where

    array|string

    修改条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $fetchSql

    bool

    是否打印SQL语句

    increment

    根据条件自增某字段的值

    参数名

    类型

    是否必传

    说明

    $field

    string

    要自增的字段名

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $value

    Integer

    自增量,默认1

    $fetchSql

    bool

    是否打印SQL语句

    decrement

    根据条件自减某字段的值

    参数名

    类型

    是否必传

    说明

    $field

    string

    要自减的字段名

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $value

    Integer

    自减量,默认1

    $fetchSql

    bool

    是否打印SQL语句

    getField

    根据条件获取某一(些)列的值

    参数名

    类型

    是否必传

    说明

    $field

    array|string

    字段名,可以为多个字段的数组

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $limit

    Integer

    查询多少条,默认不限

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

    getFieldValue

    根据条件获取某一(些)列的第一条值

    参数名

    类型

    是否必传

    说明

    $field

    array|string

    字段名,可以为多个字段的数组

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $order

    array|string

    按某(些)字段排序,[‘id’=>’desc’]或者’id desc’

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

    getCount

    根据条件获取总数量

    参数名

    类型

    是否必传

    说明

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $field

    array|string

    要统计数量的字段,默认*

    $group

    string

    对结果进行分组

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

    getModel

    根据条件查询一条数据

    参数名

    类型

    是否必传

    说明

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $field

    array|string|bool

    要查询的字段,默认true,查所有

    $order

    array|string

    按某(些)字段排序,[‘id’=>’desc’]或者’id desc’

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

    getList

    根据条件查询数据集

    参数名

    类型

    是否必传

    说明

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $field

    array|string|bool

    要查询的字段,默认true,查所有

    $limit

    array|string

    分页查询,’1,10’或者[1,10]页码和每页条数

    $order

    array|string

    按某(些)字段排序,[‘id’=>’desc’]或者’id desc’

    $group

    string

    对结果进行分组

    $having

    string

    配合group使用的聚合筛选条件,从es中取数据时此参数无效

    $distinct

    string

    查询去重字段

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

    getLimitList

    参数名

    类型

    是否必传

    说明

    $where

    array|string

    条件:[‘id’=>1,’name’=’xxx’]或者[[‘id’,’<’,5],[‘name’,’like’,’%xxx%’]]或者SQL字符串

    $field

    array|string|bool

    要查询的字段,默认true,查所有

    $limit

    array|string

    分页查询,’1,10’或者[1,10]页码和每页条数

    $order

    array|string

    按某(些)字段排序,[‘id’=>’desc’]或者’id desc’

    $group

    string

    对结果进行分组

    $having

    string

    配合group使用的聚合筛选条件,从es中取数据时此参数无效

    $distinct

    string

    查询去重字段

    $is_es

    bool

    是否先从es中取数据,默认是

    $fetchSql

    bool

    是否打印SQL语句,若为true则$is_es参数无效

  5. common 公共函数使用

    方法名

    参数

    get_random_str

    生成随机字符串

    参数名

    类型

    是否必传

    说明

    $num

    Integer

    生成字符串长度,默认8

    $is_special_char

    Bool

    是否包含特殊字符,默认否

    get_random_num

    生成随机数字串

    参数名

    类型

    是否必传

    说明

    $num

    Integer

    生成数字串长度,默认6

    get_rid

    生成唯一加密串

    参数名

    类型

    是否必传

    说明

    $fixed

    String

    参与加密串生成的固定值

    $salt

    String

    参与加密串生成的盐

    format_timestamp

    格式化时间戳为 Y-m-d H:i:s 格式时间

    参数名

    类型

    是否必传

    说明

    &...$var_names

    int

    可以传任意多个时间戳参数

    format_datetime

    格式化日期或时间

    参数名

    类型

    是否必传

    说明

    &$datetime

    string

    要格式化的日期或时间

    $flag

    integer

    格式化后类型,1-日期+时间 2-时间戳 3-多久前

    format_num

    格式化数字

    参数名

    类型

    是否必传

    说明

    $num

    integer

    要格式化的数字

    $unit

    string

    单位,默认万,可选千、万、十万、百万、千万、亿

    format_money

    格式化金额

    参数名

    类型

    是否必传

    说明

    $money

    integer

    要格式化的金额

    $unit

    string

    单位,默认K(千),可选K(千)、W(万)、M(百万)

    format_number_myriad

    格式化大数据

    参数名

    类型

    是否必传

    说明

    $number

    integer

    要格式化的数据

    $unit

    string

    格式化后的单位,默认万

    $divisor

    integer

    除数,默认10000,和单位对应

    hump

    特殊字符分隔的字符串转驼峰

    参数名

    类型

    是否必传

    说明

    $str

    string

    要改变的字符串

    $first

    bool

    第一个单词首字母是否大写,默认是

    $separator

    string

    特殊符号,默认下划线(_)

    key2hump

    数组键值转驼峰

    参数名

    类型

    是否必传

    说明

    $arr

    array

    要转换键值的数组

    $first

    bool

    第一个单词首字母是否大写,默认是

    $separator

    string

    特殊符号,默认下划线(_)

    unhump

    驼峰转特殊字符分隔

    参数名

    类型

    是否必传

    说明

    $str

    string

    要修改的字符串

    $separator

    string

    特殊符号,默认下划线(_)

    get_millisecond

    获取当前毫秒

    get_microsecond

    获取当前微秒

    get_client_ip

    获取客户端IP

    get_password

    php加密密码

    参数名

    类型

    是否必传

    说明

    $str

    string

    明文密码

    get_md5_password

    md5加密密码

    参数名

    类型

    是否必传

    说明

    $str

    string

    明文密码

    eSubstr

    按字节数截取字符串

    参数名

    类型

    是否必传

    说明

    $str

    string

    要截取的字符串

    $length

    int

    截取的长度,默认不截取

    $suffix

    string

    截取后添加的后缀,默认不添加

    array2xml

    数组转xml

    参数名

    类型

    是否必传

    说明

    $arr

    array

    被转换的数组

    $root

    bool

    是否添加根标签,默认是

    xml2array

    xml转数组

    参数名

    类型

    是否必传

    说明

    $xml

    string

    被转换的xml

    eJson

    返回json字符串

    参数名

    类型

    是否必传

    说明

    $message

    string

    返回的消息

    $code

    integer

    状态码,默认200

    $data

    array

    返回的数据

    $callback

    string

    jsonp回调函数

    ajax

    返回json数组

    参数名

    类型

    是否必传

    说明

    $message

    string

    返回的消息

    $code

    integer

    状态码,默认200

    $data

    array

    返回的数据

    $callback

    string

    jsonp回调函数

    get_json_params

    获取json形式的参数

    get_id_card_info

    根据18位身份证号获取区域编码、生日、性别

    参数名

    类型

    是否必传

    说明

    $idCard

    string

    身份证号

    get_distance

    计算两点坐标之间的距离

    参数名

    类型

    是否必传

    说明

    $longitude1

    string

    起点经度

    $latitude1

    string

    起点纬度

    $longitude2

    string

    终点经度

    $latitude2

    string

    终点纬度

    $unit

    int

    结果单位,1-米 2-公里,默认1

    $decimal

    int

    结果精度,小数位数,默认0

    get_really_address

    百度地图获取具体位置

    参数名

    类型

    是否必传

    说明

    $lat

    float

    纬度

    $lng

    float

    经度

    change_to_baidu

    转换为百度经纬度

    参数名

    类型

    是否必传

    说明

    $lat

    float

    纬度

    $lng

    float

    经度

    参数名

    类型

    是否必传

    说明

    get_address_info

    百度地图获取地理位置信息

    $latLng

    string

    纬度和经度,以逗号(,)分隔

    $place

    string

    要获取的信息,all/location/formatted_address/city/province/district/direction/distance/street/street_number,默认all

    $type

    string

    返回数据格式,默认json

    get_video_cover

    获取视频文件的缩略图

    参数名

    类型

    是否必传

    说明

    $file

    string

    视频文件路径

    $s

    int

    指定从什么时间开始截取,单位秒,默认11

    $is_win

    bool

    是否在windows系统运行,默认否

    get_file_binary_info

    把文件转为二进制流

    参数名

    类型

    是否必传

    说明

    $path

    string

    文件路径

    utf8_to_gb2312

    UTF8转换为GB2312编码

    参数名

    类型

    是否必传

    说明

    $s

    string

    要转换编码的文字

    get_pinyin

    参数名

    类型

    是否必传

    说明

    $s

    string

    要获取拼音的汉字

    $isFirst

    bool

    是否只获取每个字的首字母,默认否

    get_initial

    获取汉字首字母

    参数名

    类型

    是否必传

    说明

    $s

    string

    要获取首字母的汉字

    get_pinyin_array

    得到拼音和ASCII码数组

    curl

    同步curl请求

    参数名

    类型

    是否必传

    说明

    $url

    string

    请求的URL

    $params

    mixed

    传递的参数

    $method

    string

    请求方式,默认GET

    $header

    array

    头参数

    $cert

    mixed

    证书信息

    $expire

    int

    超时时间,单位秒,默认30

    curl_async

    异步curl请求

    参数名

    类型

    是否必传

    说明

    $url

    string

    请求的URL

    $data

    mixed

    请求参数

    $type

    string

    传参方式,默认form

    excel_export

    导出excel表格

    参数名

    类型

    是否必传

    说明

    $list

    array

    表格数据

    $params

    array

    表格信息,filename:文件名,title:表格名,默认Sheet1,columns: 列标题,key(int)-value(array){title:列名,field:字段名, width:列宽(可选)}

    excel_multi_sheet_export

    导出多表格 excel

    参数名

    类型

    是否必传

    说明

    $params

    array

    导出表需要的所有参数,包括:

    ttl:文件中每个表格名称,包括title

    data:文件中每个表格的数据,多维数组

    cols:文件中每个表格的表头信息,多维数组

    column

    获取某一列

    参数名

    类型

    是否必传

    说明

    $key

    int

    列索引

    row_column

    获取某一行某一列

    参数名

    类型

    是否必传

    说明

    $key

    int

    列索引

    $row

    int

    行索引

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

整合了 TP6 和 elastic 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/roy_he/yunduan_education.git
git@gitee.com:roy_he/yunduan_education.git
roy_he
yunduan_education
yunduan_education
master

搜索帮助