diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..3e31ceb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +composer.lock +*.log +thinkphp diff --git a/.htaccess b/.htaccess new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..80ef291 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +sudo: false + +language: php + +branches: + only: + - stable + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: + - composer install --no-dev --no-interaction --ignore-platform-reqs + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . + - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" + - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . + +script: + - php think unit + +deploy: + provider: releases + api_key: + secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= + file: + - ThinkPHP_Core.zip + - ThinkPHP_Full.zip + skip_cleanup: true + on: + tags: true diff --git a/404.html b/404.html new file mode 100755 index 0000000..6096254 --- /dev/null +++ b/404.html @@ -0,0 +1,16 @@ + + + + +404 Not Found + +

404 Not Found

+
+
Power by 堡塔 (免费,高效和安全的托管控制面板)
+ + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..f1bd6eb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,1236 @@ +## 2019-1-11 V5.0.24 + +本次更新包含了一个安全更新,建议更新 + +- 改进关联的save方法 +- 改进模型数据验证 +- Collection增加values方法 +- 改进unique验证方法 +- 改进Request类的method方法 + +## 2018-12-9 V5.0.23 + +本次版本更新主要涉及一个安全更新,推荐尽快更新到最新版本。 + +* Query支持调用模型的查询范围 +* 聚合查询字段支持`DISTINCT` +* 改进闭包验证的参数 +* 多对多关联支持指定中间表数据名称 +* after/before验证支持指定字段验证 +* 改进多对多关联 +* 改进验证类 +* 增加`afterWith`和`beforeWith`验证规则 用于比较日期字段 +* 完善规则提示 +* 改进断线重连 +* 修正软删除的`destroy`方法 +* 修复模型的`save`方法当`data`变量为空 数据不验证 +* 模型增加`replace`方法 +* MorphOne 增加 make 方法创建关联对象实例 +* 改进`count`方法返回值类型 +* 改进聚合查询方法的正则判断 +* 改进`sqlsrv`驱动 +* 完善关联的`save`方法 +* 修正控制器名获取 + + +## 2018-10-22 V5.0.22 + +该版本主要增加了JSON日志格式的支持,并且包含了一个安全更新。 + +* 调试模式下关闭路由解析缓存 +* 改进Log类支持`json`日志格式 +* 改进聚合查询的安全性 +* 改进`count`查询的返回值类型 + +## 2018-9-7 V5.0.21 + +该版本主要做了一些已知问题的修正,改进了对Swoole的支持,以及增加路由解析缓存功能。 + +* 增加路由解析缓存功能 +* 改进url生成的端口问题 +* 改进缓存驱动 +* 改进value方法的缓存处理 +* 修正Builder类的insertAll方法 +* 改进对Swoole的支持(使用参考:[xavier-swoole](https://github.com/xavieryang007/xavier-swoole)) + +## 2018-5-11 V5.0.20 + +该版本为修正版本,修正了一些已知的问题。 + +* `join`方法的条件支持传入`Expression`对象 +* 改进驱动的`parseKey`方法 +* 改进Request类的`host`方法 +* 使用`exp`表达式更新数据的异常提示 +* 修正查询 +* 改进多对多关联的中间表模型更新 + +## 2018-4-25 V5.0.19 + +该版本属于改进版本,主要改进了composer自动加载及内置模板引擎的一处可能的安全隐患。 + +* 改进composer自动加载 +* 改进模板引擎一处安全隐患 +* 改进`comment`方法解析 +* 改进分布式写入数据后及时读取的问题 +* 改进url操作方法的自动转换 +* 改进分页类魔术方法的返回值 +* SQL日志增加主从标记 + +## 2018-4-14 V5.0.18 + +该版本主要修正上一个发布的一些BUG,并且改进了`exp`表达式查询/写入的严谨性。 + +* 修正`field`方法`*`兼容问题; +* 修正`inc/dec`方法; +* 修正`setInc/setDec`方法; +* 改进`insertAll`方法; +* 改进`parseTime`方法; +* 改进`exp`表达式查询/写入的严谨性; + +## 2018-4-12 V5.0.17 + +该版本主要是一些修正和改进,并且包含了一个安全更新。 + +* 改进Response类`create`方法 +* 改进`inc/dec`查询 +* 默认模板渲染规则支持直接使用操作方法名 +* 改进视图驱动 +* 改进Request类ip方法 支持代理设置 +* 修正request类的`create`方法 +* 闭包查询使用`cache(true)`抛出异常 +* 改进composer自动加载文件 +* 增加`Expression`类及相关方法 + +## 2018-3-26 V5.0.16 + +该版本主要做了一些修正和改进,由于包含了一个安全更新,是一个推荐更新的版本。 + +* 改进Url生成 +* 改进composer自动加载性能 +* 改进一对一查询 +* 改进查询缓存 +* 改进field方法 +* 优化Template类 +* 修正分页参数 +* 改进默认模板的自动识别 +* 改进Query类查询 +* Collection类改进 +* 改进模型类`readTransform`方法对序列化类型的处理 +* 改进trace显示 +* 文件日志支持自动清理 +* 改进断线重连的判断 +* 改进验证方法 +* 修正Query类view方法的数组表名定义 +* 改进参数绑定 +* 改进文件缓存的并发删除 +* 改进`inc/dec/exp`更新的安全性 +* 增加控制台配置 + +## 2018-1-31 V5.0.15 + +该版本主要进行了一些修正和完善 + +* 改进View类 +* 改进chunk方法 +* 改进模板引擎的表达式语法 +* 改进自关联查询多级调用问题 +* 关联定义增加`selfRelation`方法用于设置是否自关联 +* 改进file类型的缓存`inc`和`dec`方法不改变缓存有效期 +* 改进软删除 支持设置`deleteTime`属性关闭 +* 改进`union`查询 +* 改进查询缓存 +* 优化File缓存自动生成空目录的问题 +* 改进日志写入并发问题 +* 修正`MorphTo`关联 +* 改进`join`自关联查询 +* 改进`case`标签解析 +* 改进Url类对`url_convert`配置的支持 + + +## 2018-1-1 V5.0.14 + +V5.0.14版本主对复合主键进行了更多支持,改进了PHP7的兼容性,并且对数据库的一些问题做了改进。 + +主要更新如下: + +* 改进Validate类的unique验证 +* Validate类增加checkRule方法用于静态验证多个规则 +* 改进多对多关联的save方法 +* 改进多对多的pivot对象 +* 修正setDec方法的延迟写入 +* max和min方法增加第二个参数用于设置是否强制转换数字 +* 改进View类 +* 改进join关联自身的问题 +* 改进union查询 +* 改进Url类 +* 改进同名路由不同请求的注册 +* 改进Builder类parseData对空数组的判断 +* 改进模板替换 +* 调整BelongsTo的hasWhere方法 +* 改进模板的编译缓存命名规则 增加布局模板的标识 +* 改进insertall方法 +* 改进chunk方法支持复合主键 +* 改进Error类的一个兼容问题 +* 改进model类的save方法的复合主键包含自增的情况 +* save方法改进复合主键的支持 +* 改进mysql的insertAll方法 +* 改进redis长连接多编号库的情况 + +## 2017-12-12 V5.0.13 + +`V5.0.13`主要是对模型和日志方面做了一些改进 + +### [数据库和模型] + +* 改进Model类`save`方法对`oracle`的支持 +* 改进中间表模型的实例化 +* 改进`Pivot`类 +* 模型`saveall`方法支持配合`isUpdate`方法 +* 模型类增加`force`方法设置是否强制更新所有数据 +* 关联自动删除增加一对多关联删除支持 +* 改进`hasWhere`查询的数据重复问题 +* 改进一对多`with`关联查询的`field`支持 +* 模型`saveall`方法支持返回数据集 读取`resultSetType`属性 +* 改进废弃字段判断 +* 模型的`hasWhere`方法增加`fields`参数 +* 改进断线重连异常捕获机制 +* 修正Query类的`inc`和`dec`方法的Mysql关键词问题 +* 修正数据集对象的BUG + +### [其它] + +* 增加`app_dispatch`钩子位置 +* cookie类`httponly`参数默认改为false +* File日志驱动增加`single`参数配置是否记录单个文件日志 +* 单个日志文件支持大小设置 +* 改进日志记录的ip地址 +* Redis缓存驱动改用`serialize`序列化替代json序列化 +* 改进异常捕获 +* 改进上传文件验证 +* 修正redis驱动 +* 改进File缓存的`clear`方法 +* 代码格式化规范 +* 改进一处PHP7.2的兼容问题 +* 调试模式下不读取字段缓存文件 +* `default_filter`支持在模块中配置生效 + +## 2017-11-06 V5.0.12 + +5.0.12是一个修正版本,包含了上个版本发布以来的一些修正和完善,主要包括: + +* 上传类和验证类的多语言支持; +* 模型增加排除和废弃字段支持; +* 改进insertAll方法的分批处理; +* 改进对枚举类型的参数绑定支持; +* 修正社区反馈的问题; + + +### [数据库和模型] + +* 改进Connection类的getRealSql方法 +* 改进append方法支持一对一关联的bind设置 +* 改进whereTime查询 +* 改进model类的`destroy`方法 +* 修正softdelete +* 修正`chunk`方法对时间字段的支持 +* Collection类增加`push`方法 +* 改进alias方法 +* 修正模型类的`append`处理 +* 改进`appendRelationAttr`方法 +* 改进HasManyThrough关联 +* 改进MorphTo关联 +* 模型增加废除字段`disuse`定义 +* 增加排除字段方法`except` +* 修正`has`方法 +* 改进参数绑定类型对枚举类型的支持 +* 改进`insertAll`方法的分批处理 + + +### [其它] + +* 改进Loader类`controller`和`validate`方法支持多层 +* 验证提示信息支持多语言 +* File类错误信息支持多语言 +* 模板渲染异常处理 +* 修正rest控制器 +* 改进trace驱动 +* 改进Cache类的`remember`方法 +* 改进`url_common_param`的情况下urlencode的问题 +* 改进Url类 +* 改进`exception_handle`配置参数对闭包的支持 +* 执行路由缓存命令前检测RUNTIME_PATH是否存在 +* 调整部分`CacheDriver::dec`在为空的时候递减的行为 +* 优化移动端的显示 +* 改进对JSON-Handle插件的支持 +* 改进redis的`get`方法 +* 改进Request类的`host`方法 + + +## 2017-09-08 V5.0.11 + +5.0.11是一个安全及修正版本,包含了上个版本发布以来的一些修正和完善,更新了几处可能的安全问题,主要包括: + +* 完善缓存驱动; +* 改进数据库查询; +* 改进URL生成类; +* 缓存有效期支持指定过期时间; + +### [数据库和模型] + +* 改进数据库驱动类 +* 改进`group`方法的字段关键字冲突 +* 修正聚合查询返回null的问题 +* 改进Db类的强制重连 +* 改进关联的属性绑定 +* 修正事务的断线重连 +* 修正对象的条件查询 +* Db类增加`clear`方法 +* 改进数组查询条件中的`null`查询 +* 改进Query类的`chunk`方法支持排序设置 +* 改进HasOne和HasMany关联的`has`方法 +* 改进软删除的关联删除 +* 改进一个字段多次查询条件 + +### [其它] + +* 缓存有效期支持指定过期时间(`DateTime`); +* 改进Url生成对端口号的支持 +* 改进`RouteNotFound`异常提示 +* 改进路由分组的全局完整路由匹配 +* 修正部分验证规则的错误提示问题 +* 支持数据集和模型的XML响应输出 +* 改进模板的三元运算标签 +* 改进控制器不存在的错误提示 +* input助手函数支持`route`变量获取 +* 支持在配置文件中读取额外配置参数 +* 完善分页类 +* 修复Trait命名空间重复问题 +* 修正Request类的env方法 +* 优先使用Cookie中的多语言设置 +* 获取缓存标签的时候过滤无效的缓存标识 +* 修正路由批量注册的一个BUG +* `exception_handle`配置参数支持使用闭包定义`render`处理 +* 请求缓存支持缓存标签设置 +* 缓存类`remember`方法增加并发锁定机制 +* 改进上传类对`swf`的支持 +* 改进Session类的`prefix`方法 + +## 2017-07-04 V5.0.10 + +5.0.10是一个修正版本,并包含了一个安全更新,推荐更新,主要包含: + +* 数据库和模型的多处改进 +* 添加新的行为监听 +* 路由支持Response设置 +* 改进调试模式下数据库敏感信息暴露 + +### [数据库和模型] + +* 修正join其他表时生成的delete语句错误 +* 修正远程一对多 +* insertall支持replace +* 修正多对多默认的中间表获取 +* 改进更新后的模型`update_time`数据更新 +* model类增加`removeRelation`方法 +* 模型类增加`setInc`和`setDec`方法 +* 模型类增加`autoWriteTimestamp`方法动态设置时间字段写入 +* 改进驱动类方法的断线重连判断 +* 改进多对多的数据更新 +* 改进BelongsToMany关联查询 +* 修正Query类的value和column方法 +* 改进in查询的去重问题 +* 修正模型类的scope方法传值问题 +* 调整模型的save方法`before_update`检查位置 +* 修改器和获取器方法支持第三个关联数据参数 + +### [其它] + +* 默认关闭调试模式 +* 修复配置extra目录临时文件的错误加载 +* 添加log存储完成行为监听 `log_write_done` +* 改进Build类生成公共文件的目录判断 +* 增加`response_send`行为监听 +* 路由增加response参数用于绑定response处理行为 +* 改进redirect的参数传入 +* 改进环境变量的布尔值读取 +* 改进Url类的域名传入 +* 修正命令行文件生成 +* 改进命令行下面的URL生成 +* 添加`app_host`参数设置默认的URL根地址 +* 改进`Request`类`isSsl`方法判断支持CDN +* 增加`record_trace`配置参数用于日志记录trace信息 + +## 2017-05-20 V5.0.9 + +5.0.9是一个修正版本,推荐更新,主要更新包含: + +### [数据库和模型] + +* 修正关联自动写入 +* 修正模型数据变化判断对为空数据的支持 +* 修正Query类的useSoftDelete方法返回值 +* 修正一对一嵌套关联数组定义的问题 +* 修正使用了手动参数绑定的时候的缓存BUG +* 改进数据库类的一处不能嵌套查询的缺陷 +* 改进数据库断线重连判断 +* 改进模型的appendRelationAttr方法 +* 改进模型类destroy方法传入空数组的时候不进行任何删除操作 +* 改进一对多关联数据的输出 +* 改进模型的save方法对allowField方法的支持 +* 改进分页类的toarray方法 增加总页数 +* 比较运算增加闭包子查询支持 +* db助手函数默认不再强制重新连接 +* 改进belongsToMany的查询字段指定 +* 分页类增加each方法 + +### [其它] + +* 修正路由分组的路由规则大小写识别问题 +* 修正命令行的日志切割生成 +* 修复URL生成时路由规则中的参数没有进行 urlencode +* 改进Request类的filter过滤机制 支持正则 +* 改进Response类支持手动设置contentType +* 修正异常模板中助手函数未定义错误 + +## 2017-04-28 V5.0.8 + +### 主要调整 + +* 改进关联模型 +* 改进日志记录 +* 增加多态一对一关联 +* 修正社区反馈的一些BUG + +### [ 请求和路由 ] + +* 修正Request类`cookie`方法对前缀的支持 +* 改进全局请求缓存的缓存标识 +* 改进Request类`param`方法 +* 修正别名路由 + +### [ 模型和数据库 ] + +* 改进模型数据的更新检查 +* 改进Query类的`column`方法 +* 改进软删除条件在使用闭包查询情况下多次生成的问题 +* belongsToMany增加数据同步方法 +* 查询范围支持静态调用 +* 增加多态一对一(MorphOne)关联 +* 改进BelongsTo关联 +* 改进多态关联支持关联数据添加和注销 +* 改进多对多关联,支持中间表模型自定义 并且定义的时候不需要使用完整表名 +* 改进浮点数类型转换避免出现逗号 +* 调整关联模型的save方法返回值 +* 模型类的get方法第一个参数必须 如果传入null则返回null +* model的save方法改进如果数据没有更新不执行 +* Query增加`useSoftDelete`方法可以单独设置软删除条件 +* 重载BelongsToMany的`selectOrFail`和`findOrFail`方法 +* 重载BelongsToMany的`select` 、`find`和 `paginate`方法 +* 增加模型和`Pivot`对象的`parent`属性 +* 多对多关联支持设置中间表模型 +* 改进Query类的`view`方法中字段的关键字问题 +* 主从数据库的时候开启事务始终操作主库 + +### [ 其它 ] + +* 改进Cookie类的`get`方法支持获取全部 +* `schema`指令增加`config`参数,支持传入数据库连接配置 +* 改进cache类的`store`方法为当次有效 +* 修正cache助手函数对`option`传参的支持 +* 修复`optimize:autoload`命令在`EXTEND_PATH`目录不存在的情况下,类库映射生成错误问题 +* 支持自定义的根命名空间也可以生成类库映射缓存 +* 验证字段比较支持对比其他字段 +* 修复`Session::prefix('xxx');`设置当前作用域BUG +* 改进`optimize::schema`指令 +* 修复`clear`指令无法删除多级目录下文件的问题 +* 改进默认语言读取和自动侦测 +* 改进日志记录格式 并且命令行下面日志改为实时写入 +* 修正模板标签默认值某些情况无效bug +* 改进Url生成对完整域名的支持 +* 改进`Clear`指令不删除`.gitignore` 文件 +* 修复Memcache缓存驱动的`inc`方法 + +### 调整 + +* 如果自定义了应用的命名空间的话,原来的`app_namespace`配置参数改为`APP_NAMESPACE`常量在入口文件中定义 +* 多对多关联的中间表名称不需要添加表前缀 +* 模型的scope方法之后只能使用数据库查询方法而不能使用模型的方法 + +## 2017-02-24 V5.0.7 + +### 主要调整 + +本次更新主要为BUG修正和改进,主要改进如下: + +* 改进全局请求缓存对子域名的支持; +* 改进数据缓存自动更新机制; +* 关联统计支持指定统计属性名; +* 模型嵌套关联支持数组方式; +* HasOne关联支持`has`和`hasWhere`方法; +* 路由的`ext`和`deny_ext`参数允许设置为空(表示不允许任何后缀或者必须使用后缀访问); + +### 修正如下 + +* 修正 IN / NOT IN 型查询条件为空导致的 sql 语法错误 +* 修正分页类的`toArray`方法对简洁模式的支持 +* 修正Model类`delete`方法对多主键的处理 +* 修正软删除对`Mongodb`的支持 +* 修正`Connection`类一处可能的错误 +* 改进Query类的find方法的缓存机制 +* 修正BelongsTo关联 +* 修正JOIN方式一对一关联预载入闭包查询 +* 修正Query类的`insert`方法一处可能存在的警告错误 +* 修正Model类一处Collection的`use`冲突 +* 修正Model类`hasWhere`方法 +* 修正URl生成对`ext`参数的支持 +* 文件缓存`clear`方法会删除空目录 +* 修正Route类的`parseUrlPath`方法一处问题 + +### 调整如下 + +* 默认关闭session的安全参数`secure`,此选项仅能在HTTPS下设置开启 + +## 2017-02-07 V5.0.6 + +### 主要调整: + +本次更新主要为BUG修正及优化(可无缝升级): + +* 数据库支持断线重连机制; +* 改进查询事件的回调参数; +* 改进数据自动缓存机制; +* 增加时间字段自动格式转换设置; +* `MongoDb`和`Oracle`扩展更新至最新核心框架; + +### [数据库和模型] + +* 修正hasMany关联的`has`方法 +* 去除一些数据库惯例配置 避免使用数据库扩展的时候影响 +* 改进多对多的`attach`方法的返回值 +* 增加Mysql的断线重连机制和开关 +* 改进Query类的`find`方法数据缓存机制 +* 改进Query类查询事件的回调参数 +* 改进Query类的自动缓存更新 +* Model类增加`readonly`方法 +* 改进Model类的`has`和`hasWhere`方法 +* 改进模型类的`get`和`all`方法 第二个参数为true或者数字表示缓存参数 +* 修复闭包查询条件为空导致的 sql 语法错误 +* 改进Query类的`setBuilder`方法 避免因自定义连接器类后找不到生成器类 +* 删除Connection类废弃属性`resultSetType` +* 优化Connection类`close`方法 +* 修正Connection类的`bindParam`方法对存储过程的支持 +* 数据库配置参数`datetime_format` 设置为`false`表示关闭时间字段自动转换输出 +* 改进软删除的数据库兼容性问题 支持`Mongodb` + +### [其它] + +* 改进Url类生成 `root`为`/`的情况 +* redirect助手函数和controller类的redirect方法增加with参数 +* 全局请求缓存添加排除规则 添加request_cache_except配置参数 +* Cache类store方法参数允许为空 表示获取当前缓存驱动句柄 +* 改进Validate类的ip验证规则 + +## 2017-01-23 V5.0.5 +### 主要调整: + +本次更新主要改进了数据访问层和模型关联: + +* 增加快捷查询及设置方法; +* 增加关联统计功能; +* 增加关联查询延迟预载入功能; +* 增加关联一对一自动写入和删除; +* 改进存储过程查询; +* 改进关联数据输出; +* 优化查询性能; +* 模型时间字段自动格式化输出; + +### [请求和路由] + +* 改进路由定义的后缀检测 +* Route类的`rest`方法支持覆盖定义 +* 改进Request类的`put`和`post`方法对`json`格式参数的接收 +* Request类增加`contentType`方法 +* 改进Route类`setRule`方法 +* 改进Request类的`create`方法 +* 改进路由到控制器类的方法对默认渲染模板的影响 +* 修正Url类`build`方法定义路由别名后的BUG + +### [数据库和模型] + +* 增加关联统计功能 +* 增加一对一关联自动写入功能 +* 修正聚合模型的`delete`方法 +* 改进Model类的`useGlobalScope`方法 +* Model类的日期类型支持设置为类名 +* Query类增加`data`/`inc`/`dec`/`exp`方法用于快捷设置数据 `insert`和`update`方法参数可以为空 读取`data`设置数据 +* 优化Connection的查询性能 +* 修正Builder类的`parseOrder`方法 +* 修正BelongsToMany类的`attach`方法 +* BelongsToMany类的`attach`方法改进 支持批量写入 +* 改进BelongsToMany类的`saveall`方法 增加第三个参数 用于指定额外参数是否一致 +* Query类的`order`方法支持多次调用合并 +* 改进`count`方法对`group`查询的支持 +* 增加时间戳自动写入的判断 +* 改进Model类`writeTransform`方法 +* 改进Model的时间戳字段写入和读取 +* 写入数据为对象的时候检测是否有`__toString`方法 +* 改进Mysql驱动的`getFields`方法 +* 改进自动时间字段的输出 +* `like`查询条件支持数组 +* 自动时间字段的获取自动使用时间格式化 +* 改进单个字段多次Or查询情况的查询 +* 修正`null`查询的条件合并 +* 改进Query类`paginate`方法第一个参数可以使用数组参数 +* 改进数据集对象的返回,由Query类的select方法进行数据集转换,原生查询不再支持返回数据集对象 +* 增加`whereNull`、`whereIn`等一系列快捷查询方法 +* `fetchPdo`方法调整 +* 改进对存储过程调用的支持 改进`getRealSql`的调用机制 改进数据表字段使用中划线的参数绑定支持 +* 数据库配置参数增加`result_type` 用于设置数据返回类型 方法参数名称调整 +* 改进Query类的`whereTime`方法支持更多的时间日期表达式(默认查询条件为大于指定时间表达式) +* 取消`min`/`max`/`sum`/`avg`方法的参数默认值 +* Query类增加`getPdo`方法用于返回`PDOStatement`对象 +* 改进`today`的日期表达式查询 +* 改进关联属性的获取 +* 改进关联定义中包含查询条件后重复执行的问题 +* 改进参数绑定支持中文字段自动绑定 +* 改进Builder类的`insertall`方法 增加对null和对象数据的处理 +* 改进参数绑定类型 支持`bit`类型自动绑定 +* Connection类`model`方法更改为`getQuery` +* 优化Connection类`__call`方法 +* 修正聚合模型 +* 一对一关联预载入默认改为IN查询方式 +* 增加`collection`助手函数用于数据集转换 +* 增加`load_relation`助手函数用于数组的延迟预载入 +* 改进Model类的`has`方法第二个参数支持使用数组和闭包,无需再使用`hasWhere` +* `relation`方法支持嵌套关联查询 +* 增加`think\model\Collection`作为模型的数据集查询集合对象 +* 取消关联定义的`alias`参数(仅`morphTo`保留) +* Model类的`delete`方法,支持没有主键的情况 +* Model类的`allowField`方法支持逗号分割的字符串 +* 改进写入数据的自动参数绑定的参数名混淆问题 +* 关联预载入查询的属性名默认使用小写+下划线命名 +* Query类的`with`和`relation`方法支持多次调用 +* Collection类增加`hidden`、`visible`和`append`方法 +* 修正软删除的强制删除方法 + +### [其它] + +* `unique`验证规则支持指定完整模型类 并且默认会优先检测模型类是否存在 不存在则检测数据表 +* 改进`Loader`类的`model`、`controller` 和 `validate`方法 支持直接传入类名实例化 +* `Session`类增加安全选项`httponly`和`secure` +* 可以允许自定义`Output`的driver,以适应命令行模式下调用其它命令行指令 +* 改进`loader`类`action`的参数污染问题 +* Validate类的`confirm`验证改为恒等判断 +* 改进`Validate`类的错误信息处理 +* 修正`Validate`类的布尔值规则验证 +* 改进`cookie`助手函数对前缀的支持 +* 文件缓存默认开启子目录缓存避免文件过多导致性能问题 + +### [调整] +* Connection类`model`方法更改为`getQuery` +* 原生查询不再支持返回数据集对象 +* 分页查询返回类型变成`think\Paginator`(用法不变) +* 模型的时间日期字段会自动进行格式化输出,不需要进行额外处理。 +* Session类添加了`secure`和`httponly`参数,并且默认是true + +## 2016-12-20 V5.0.4 +### 主要调整: + +* 关联模型重构并增加多态一对多关联; +* 数据库支持一个字段多次调用不同查询条件; +* 增加数据库CURD事件支持; +* 路由到类和控制器的方法支持传入额外参数; +* 支持全局模板变量赋值; +* 模型支持独立设置查询数据集对象; +* 日志针对命令行及调试做出改进; +* 改进Hook类的行为方法调用 + +### [请求和路由] +* 请求缓存支持模块单独开启 +* Request类`post`方法支持获取`json`方式的请求数据 +* 路由到类的方法和控制器方法 支持传入额外参数,用于方法的参数 +* 改进控制器自动搜索的目录规范 +* 改进请求缓存 +* 改进自动参数绑定 +* 修正路由的请求缓存设置 +* 改进Route类name方法 + +### [数据库和模型] +* 增加数据库查询(CURD)事件 +* 改进多表更新的字段不存在问题 +* 改进Model类的`useGlobalScope`方法 +* 修正子查询作为表名查询的问题 +* Model类增加`resultSetType`属性 用于指定模型查询的数据集对象(默认为空返回数组) +* Model类增加`toCollection`方法(自动调用) +* 关联模型架构调整 +* 改进预载入`with`方法的参数支持小写和下划线定义 +* 修正关联多对多一处错误 +* 改进关联多对多的查询 +* 关联模型支持多态一对多关联 +* 预载入关联查询支持关联对象属性绑定到当前模型 +* 支持追加关联对象的属性到当前模型数据 +* 一对一关联预载入支持JOIN和IN两种方式(默认为JOIN) +* 改进多对多查询 +* 改进模型更新的数据变化比较规则 +* 查询支持一个字段多次查询条件 +* 改进sql日志的sql语句 +* 修正`join`自身表的别名覆盖问题 +* 模型类的`connection`属性和数据库默认配置合并 +* 改进`in`和`between`查询条件的自动参数绑定 +* 改进Query类对数据集对象以及关联字段排序的支持 +* 增加模型的快捷事件方法 +* 改进Query类的`getTableInfo`方法缓存读取 +* model类的`saveAll`方法支持调用`allowField`方法进行字段过滤 +* 修正关联查询的时候 `whereTime`方法的bug +* 改进Query类的聚合查询 +* table方法支持字符串方式的子查询 +* 修正`count` `avg`方法使用`fetchsql`无法正确返回sql的问题 + +### [其它] +* 改进命令行下的日志记录 +* 部署模式下简化日志记录 +* 增加debug日志类型 仅限调试模式记录 +* 改进Template类`parseTemplateFile`方法 +* 改进Validate类的`getRuleMsg`方法 +* 控制器的`error`方法在AJAX请求默认返回url为空 +* Validate类架构方法增加`field`参数 用于设置验证字段的描述 +* 改进App类`invokeMethod`方法对架构函数依赖注入的支持 +* 增加RedirectResponse的`restore`方法返回值 +* View类增加`share`静态方法 用于静态赋值模板变量 +* 验证类增加`hasScene`方法判断是否存在某个场景的验证配置 +* 修正redis和session驱动的`destroy`方法返回值 +* 空操作方法的参数传入去掉操作方法后缀 +* 在控制器中调用request和view增加类型提示 +* 改进`input`助手函数支持多维数据获取 +* Cache类增加`pull`和`remember`方法 +* 改进验证类的`confirm`验证规则 支持自动规则识别 +* 改进验证类的错误信息定义 +* 增加Validate类自定义验证错误信息的替换规则 +* Cookie类增加`forever`方法用于永久保存 +* 模板渲染支持从视图根目录读取模板 +* 改进Hook类的exec方法 + +### [调整] +* Db类查询不再支持设置自定义数据集对象 +* 废除Query类的`fetchClass`方法 +* 控制器的`error`方法在AJAX请求默认返回的url为空 +* 关联方法定义不支持使用小写下划线,必须使用驼峰法 +* 行为类的方法必须使用驼峰法命名 + +## 2016-11-11 V5.0.3 +### 主要调整: +* 请求缓存增强; +* 路由增强; +* 数据库和模型完善; +* 支持反射的异常捕获; +* File类改进; +* 修正社区反馈的一些BUG; + +### [ 请求和路由 ] + +* 资源路由自动注册的路由规则的时候会记录当前使用的资源标识; +* 增强请求缓存功能和规则定义,支持全局自动缓存 +* 修正控制器自动搜索的大小写问题 +* 修正路由绑定到命名空间后 类的自动定位 +* 改进Route类的parseRule方法 路由地址中的变量替换不自动去除路由变量 +* 改进控制器自动搜索 +* Route类增加setOption和getOption方法 用于记录当前路由执行过程中的参数信息 +* 优化路由分组方法 +* 改进分组路由的url生成 + +### [ 数据库和模型 ] + +* 一对一关联查询方法支持定义`field`方法 +* 聚合模型支持设置`field`属性 +* 改进Query类的`alias`方法 +* 改进Query类`join`和`view`方法的table参数 +* 改进Query类`where`方法 +* 改进Query类的`paginate`方法,支持`order`方法 +* 改进Query类的`min`和`max`方法支持日期类型 +* 修正软删除`withTrashed`方法 +* 优化Connection类的`getRealSql`方法生成的sql + +### [ 其它 ] +* 增加request_cache和request_cache_expire配置参数用于配置全局请求缓存; +* 修正input助手函数的数组过滤 +* cache助手函数支持清空操作 +* 改进Config类load方法 一级配置名称强制转为小写 +* 修正Url多次生成的问题 +* File类修正某些环境下面无法识别上传文件的问题 +* 改进App类的空操作方法调用 +* 域名部署URL生成不依赖 url_domain_deploy 配置参数 +* 修正Url类域名部署的问题 +* 视图文件目录支持集中式存放 不放入模块目录 +* cache助手函数支持 remember方法 +* Request类的input方法或者input助手函数的`filter`参数支持传入null 表示不过滤 + +## 2016-10-24 V5.0.2 +### 主要调整: + +* 数据库和模型完善; +* 路由功能完善; +* 增加`yaml`配置格式支持; +* 依赖注入完善; +* Session类完善; +* Cookie类完善; +* Validate类完善; +* 支持反射类的异常捕获; +* 修正社区反馈BUG; + +### [ 请求和路由 ] +* 依赖注入的类如果定义了`invoke`方法则自动调用 +* Request类的`header`方法增加自定义header支持 +* Request类禁止直接实例化调用 +* 改进Request类ip方法 +* 路由变量规则支持闭包定义 +* 路由参数增加`ajax`和`pjax`判断 +* 别名路由增加允许和排除操作 +* 改进路由域名绑定后的url生成 +* 路由生成改进对路由到类的支持 +* 路由生成支持`url_param_type`配置参数 +* 路由生成支持别名路由 +* Route重定向规则支持更多` schema` +* 别名路由支持定义单独方法的请求类型 +* 改进路由分组的url生成 +* 路由规则的组合变量支持可选分隔符定义 +* 改进路由合并参数的获取 +* 路由规则支持单独设置url分隔符,路由参数为 `param_depr` +* 自动搜索控制器支持自定义访问控制器层的情况 +* 改进路由标识不区分大小写 +* 改进路由地址是否定义过路由规则的检测 + +### [ 数据库和模型 ] +* 改进Query类的join方法 +* 改进Query类分页方法的参数绑定 +* 修正软删除方法 +* 修正Query类parseOrder方法一处错误 +* 修正sqlsrv驱动parseOrder方法 +* 修正Query类setInc和setDec方法 +* 改进Model类的save方法支持非自增主键的处理 +* 整型字段的参数绑定如果为空写入默认值0 +* 改进Model类has和hasWhere方法 +* 改进Query类的value方法缓存判断 +* 改进Query类join方法对子查询支持 +* 改进Query类的table方法和alias方法用法 +* 关联预载入支持`hasOne`自关联 +* 改进Builder类的parseKey方法 +* 改进Builder类的join/alias/table方法的解析 +* 改进全局查询范围 +* 改进Query类的聚合查询方法的返回值 +* 改进关联属性的读取 +* 改进聚合模型主键和关联键相同的情况 +* 改进模型在开启`class_suffix`参数情况下的name属性的识别 + +### [ 其它 ] +* Cache类增加`remember`方法 用于当获取的缓存不存在的时候自动写入 +* Session类增加`flash`方法用于设置下一次请求有效的值 +* Session类增加`flush`方法用于清空当前请求有效的值 +* Session类增加`push`方法用于更新数组数据 +* 增加yaml配置格式支持 +* 改进App类的反射异常无法捕获问题 +* 修正session助手函数的清空操作 +* 改进验证类的`image`方法 +* 改进验证类的`activeUrl`方法 +* 改进自定义验证规则的使用 +* 改进控制器自动搜索后的控制器名获取 +* 修正import方法加载extend目录类库 +* 修正json_encode时 "Failed calling XXX::jsonSerialize()" 的异常 +* 改进Loader类model和validate方法的单例问题 +* 改进方法执行的日志记录 +* 改进模板引擎的Think变量解析 +* 改进Lang类`load`方法 +* 验证错误信息支持多语言读取 +* 改进ROOT_PATH常量 +* 改进语言包加载 +* 改进模板session和cookie变量获取,自动判断前缀 +* 缓存驱动统一增加handler方法用于获取操作对象的句柄(某些缓存类型可能为null) +* File类增加`__call`方法用于兼容5.0版本的`md5`和 `sha1`方法 +* 改进文件缓存驱动的`clear`方法 +* Lang类增加`setLangCookieExpire`方法设置多语言cookie过期时间 +* 增加`route_complete_match`配置参数 + +### [ 调整 ] +下列模型属性和方法由原来的静态(static)定义改为动态定义: +* 聚合模型的`relationModel`属性 +* Model类的`useGlobalScope `属性 +* 全局查询范围方法`base`改为动态方法 +* 软删除属性 `deleteTime`属性 + + +## 2016-9-28 V5.0.1 +### 主要调整: +* [依赖注入](215849)完善; +* [扩展配置](118027)文件位置调整; +* 新增数据表[字段缓存命令](211524); +* 支持设置当前的查询对象; +* 支持[请求和路由缓存](215850); + +### [ 请求和路由 ] +* 改进Controller类的`success`和`error`方法的跳转地址识别 支持更多Scheme +* 操作方法和架构方法支持任何对象自动注入 +* Requesst类增加`getInput`方法 用于获取` php://input`值 +* 路由到方法的时候 支持架构方法注入请求对象 +* 改进Route类路由到类的判断 +* Request增加`cache`方法,支持请求缓存 +* 绑定到模块后 路由依然优先检查 +* 路由增加请求缓存参数 +* 修正路由组合变量的可选变量的BUG + +### [ 数据库 ] +* 修正`pgsql`数据库驱动的数据表字段信息读取 +* 改进Query类的`view`方法 第二个参数默认值更改为true 获取全部的字段 +* 数据库配置信息增加`query`参数用于配置查询对象名称 +* 型类增加`query`属性用于配置模型需要的查询对象名称 +* 改进数据表字段缓存读取 +* 改进数据表字段缓存生成 模型为抽象类或者 没有继承Model类 不生成字段缓存 +* 改进模型的字段缓存 虚拟模型不生成字段缓存 +* 改进数据表字段缓存生成 支持读取模块的模型生成 +* 改进聚合模型的`save`方法 主键写入 +* 模型类的field属性定义简化 取消`Query`类的`allowField`和`setFieldType`方法及相关属性 +* 改进数据表字段缓存生成 支持生成多个数据库的 +* 更新数据库驱动类 改进`getTables`方法 +* 增加` optimize:schema` 命令 用于生成数据表字段信息缓存 +* 修正一个查询条件多个条件的时候的参数绑定BUG +* 分页查询方法`paginate`第二个参数传入数字表示总记录数 +* 修正mysql的`JSON`字段查询 +* 改进Query类的getOptions方法 当name参数不存在的时候返回null + +### [ 模型和关联 ] +* 模型类的field属性不需要添加字段类型定义 +* 改进Model类 添加`getDb`静态方法获取db查询对象 +* 改进聚合模型`save`方法返回值 +* 改进Relation类`save`方法 +* 修正关联模型 多对多`save`方法一处问题 +* 改进Model类的save方法 修正不按主键查询的更新问题 +* 时间字段获取器获取的时候为NULL则不做转换 + +### [ 其它 ] + +* 改进配置缓存生成 支持扩展配置 +* 取消`extra_config_list`配置参数 扩展配置文件直接放到 `extra`目录下面即可自动加载(数据库配置文件位置不变) +* cache助手函数支持判断缓存是否有效 +* 修正 模板引擎驱动类的`config`方法 +* 修复在配置Model属性field=true情况下,通过`__call`调用db()引发的BUG +* 改进模板引擎驱动的config方法 支持获取配置参数值 +* 改进redirct的url地址解析 +* 删除`File`类的`md5`和`sha1`方法 改为`hash`方法 支持更多的散列值类型生成 +* 增加`response_end`行为标签 +* 改进默认语言的加载 + +## 2016-9-15 V5.0 + +### [ 请求和路由 ] + +* Request对象支持动态绑定属性 +* 定义了路由规则的URL原地址禁止访问 +* 改进路由规则存储结构 +* 路由分组功能增强,支持嵌套和虚拟分组 +* 路由URL高效反解 +* 改进Request对象param方法获取优先级 +* 路由增加name方法设置和获取路由标识 +* 增加MISS和AUTO路由规则 +* Route类增加auto方法 支持注册一个自动解析URL的路由 +* 路由规则支持模型绑定 +* 路由变量统一使用param方法获取 +* 路由规则标识功能和自动标识 +* 增加生成路由缓存指令 optimize:route +* Request对象增加route方法单独获取路由变量 +* Request对象的param get post put request delete server cookie env方法的第一个参数传入false 则表示获取原始数据 不进行过滤 +* 改进自动路由标识生成 支持不同的路由规则 指向同一个路由标识,改进Url自动生成对路由标识的支持 +* 改进Request类 filter属性的初始化 +* 改进Request类的isAjax和isPjax方法 +* Request类增加token方法 +* 路由配置文件支持多个 使用 route_config_file 配置参数配置 +* 域名绑定支持https检测 +* 改进域名绑定 支持同时绑定模块和其他 支持绑定到数组定义的路由规则,取消域名绑定到分组 +* 路由规则增加PATCH请求类型支持 +* 增加route_complete_match配置参数设置全局路由规则定义是否采用完整匹配 可以由路由规则的参数complete_match 进行覆盖 +* 改进路由的 后缀参数识别 优先于系统的伪静态后缀参数 +* Url类增加root方法用于指定当前root地址(不含域名) +* 改进Url生成对可选参数的支持 + +### [ 数据库 ] + +* 查询条件自动参数绑定 +* 改进分页方法支持参数绑定 +* Query类的cache方法增加缓存标签参数 +* Query类的update和delete方法支持调用cache方法 会自动清除指定key的缓存 配合查询方法的cache方法一起使用 +* 改进Query类的延迟写入方法 +* Query类的column和value方法支持fetchsql +* 改进日期查询方法 +* 改进存储过程方法exec的支持 +* 改进Connection类的getLastInsID方法获取 +* 记录数据库的连接日志(连接时间和DSN) +* 改进Query类的select方法的返回结果集判断 +* Connection类增加getNumRows方法 +* 数据库事务方法取消返回值 +* 改进Query类的chunk方法对主键的获取 +* 改进当数据库驱动类型使用完整命名空间的时候 Query类的builder方法的问题 + +### [ 模型 ] + +* 增加软删除功能 +* 关联模型和预载入改进 +* 关联预载入查询闭包支持更多的连贯操作 +* 完善savell方法支持更新和验证 +* 关联定义统一返回Relation类 +* Model类的has和hasWhere方法对join类型的支持 +* Model类的data方法 批量赋值数据的时候 清空原始数据 +* Model类的get方法第三个参数传入true的时候会自动更新缓存 +* Model类增加只读字段支持 +* Model类增加useGlobalScope方法设置是否启用全局查询范围 +* Model类的base方法改为静态定义 全局多次调用有效 +* Model类支持设定主键、字段信息和字段类型,不依赖自动获取,提高性能 +* Model类的data方法 支持修改器 +* 改进Relation类对非数字类型主键的支持 +* 改进Relation类的一对多删除 +* 修正Relation类的一对多关联预载入查询 + +### [ 日志和缓存 ] + +* 支持日志类型分离存储 +* 日志允许设置记录级别 +* 增加缓存标签功能 +* 缓存类增加pull方法用于获取并删除 +* cache助手函数增加tag参数 +* 简化日志信息,隐藏数据库密码 +* 增加cache/session redis驱动的库选择逻辑; +* memcached驱动的配置参数支持option参数 +* 调试模式下面 日志记录增加页面的header和param参数记录 +* memcached缓存驱动增加连接账号密码参数 +* 缓存支持设置complex类型 支持配置多种缓存并用store切换 +* 缓存类增加tag方法 用于缓存标签设置 clear方法支持清除某个缓存标签的数据 +* File类型日志驱动支持设置单独文件记录不同的日志级别 +* 改进文件缓存和日志的存储文件名命名规范 +* 缓存类增加inc和dec方法 针对数值型数据提供自增和自减操作 +* Cache类增加has方法 get方法支持默认值 + +### [ 其它 ] + +* 视图类支持设置模板引擎参数 +* 增加表单令牌生成和验证 +* 增加中文验证规则 +* 增加image和文件相关验证规则 +* 重定向Response对象支持with方法隐含传参 +* 改进Session类自动初始化 +* session类增加pull方法用于获取并删除 +* 增加Env类用于获取环境变量 +* Request类get/post/put等更改赋值后param方法依然有效 +* 改进Jump跳转地址支持Url::build 解析 +* 优化Hook类 +* 应用调试模式和页面trace支持环境变量设置 +* config助手函数支持 config('?name') 用法 +* 支持使用BIND_MODULE常量的方式绑定模块 +* 入口文件自动绑定模块功能 +* 改进验证异常类的错误信息和模板输出,支持批量验证的错误信息抛出 +* 完善console 增加output一些常用的方法 +* 增加token助手函数 用于在页面快速显示令牌 +* 增加halt方法用于变量调试并中断输出 +* 改进Validate类的number验证规则 和 integer区分开 +* optimize:autoload增加对extend扩展目录的扫描 +* 改进Validate类的boolean验证规则 支持表单数据 +* 改进cookie助手函数支持 判断是否存在某个cookie值 +* 改进abort助手函数 支持抛出HttpResponseException异常 +* 改进File类增加对上传错误的处理 +* 改进File类move方法的返回对象增加上传表单信息,增加获取文件散列值的方法 +* 改进File类的move方法的返回对象改为返回File对象实例 +* 增加clear和optimize:config 指令 +* 改进File类和Validate类的图像文件类型验证 +* 控制器的操作方法支持注入Request之外的对象实例 +* Request类 param(true) 支持获取带文件的数据 +* input助手函数第一个参数增加默认值 +* Validate类增加image验证规则 并改进max min length支持多种数据类型 +* json输出时数据编码失败后抛出异常 + +### [ 调整 ] +* 废除路由映射(静态路由)定义 +* 取消url_deny_suffix配置 改由路由的deny_ext参数设置 +* 模型save方法返回值改为影响的记录数,取消getId参数 +* Request对象controller方法返回驼峰控制器名 +* 控制器前置操作方法不存在则抛出异常 +* Loader类db方法增加name标识参数 +* db助手函数增加第三个参数用于指定连接标识 +* Sqlsrv驱动默认不对数据表字段进行小写转换 +* 移除sae驱动 改为扩展包 +* Oracle驱动移出核心包 +* Firebird驱动移出核心包 +* 取消别名定义文件alias.php +* 配置参数读取的时候取消环境变量判断 需要读取环境变量的时候使用Env类 +* 环境变量定义文件更改为 .env 由原来的PHP数组改为ini格式定义(支持数组方式) +* 状态配置和扩展配置的加载顺序调整 便于状态配置文件中可以更改扩展配置的参数 +* 取消域名绑定到路由分组功能 +* 控制器类的success和error方法url参数支持传入空字符串,则不做任何处理 +* 控制器的error success result redirect方法均不需要使用return +* 创建目录的权限修改为0644 + + +## 2016-7-1 RC4版本 +### [ 底层架构 ] +* 增加Request类 并支持自动注入 +* 统一Composer的自动加载机制 +* 增加Response类的子类扩展 +* 增加File类用于上传和文件操作 +* 取消模式扩展 SAE支持降权 +* 优化框架入口文件 +* 改进异常机制 +* App类输入/输出调整 +* 单元测试的完美支持 +* 增加新的控制台指令 +* 取消系统路径之外的大部分常量定义 +* 类库映射文件由命令行动态生成 包含应用类库 + +### [ 数据库 ] + +* 增加分表规则方法 +* 增加日期和时间表达式查询方法 +* 增加分页查询方法 +* 增加视图查询方法 +* 默认保持数据表字段大小写 +* 数据缓存自动更新机制 +* 完善事务嵌套支持 +* 改进存储过程数据读取 +* 支持设置数据库查询数据集返回类型 + +### [ 模型 ] +* 增加Merge扩展模型 +* 模型支持动态查询 +* 增加更多的类型自动转换支持 +* 增加全局查询范围 +* toJson/toArray支持隐藏和增加属性输出 +* 增加远程一对多关联 + +### [ 其它 ] +* 日志存储结构调整 +* Trace调试功能从日志类独立并增强 +* 原Input类功能并入Request类 +* 类库映射文件采用命令行生成 包含应用类库 +* 验证类的check方法data数据取消引用传参 +* 路由增加MISS路由规则 +* 路由增加路由别名功能 + +## 2016-4-23 RC3版本 +### [ 底层架构 ] +* 框架核心仓库和应用仓库分离 便于composer独立更新 +* 数据库类重构,拆分为Connection(连接器)/Query(查询器)/Builder(SQL生成器) +* 模型类重构,更加对象化 + +### [ 数据库 ] + +* 新的查询语法 +* 闭包查询和闭包事务 +* Query对象查询 +* 数据分批处理 +* 数据库SQL执行监听 + +### [ 模型 ] +* 对象化操作 +* 支持静态调用(查询) +* 支持读取器/修改器 +* 时间戳字段 +* 对象/数组访问 +* JSON序列化 +* 事件触发 +* 命名范围 +* 类型自动转换 +* 数据验证和完成 +* 关联查询/写入 +* 关联预载入 + +### [ 其它更新 ] +* 路由类增加快速路由支持 +* 验证Validate类重构 +* Build类增加快速创建模块的方法 +* Url生成类改进 +* Validate类改进 +* View类及模板引擎驱动设计改进 +* 取消模板引擎的模板主题设计 +* 修正社区反馈的一些问题 +* 助手函数重新命名 +* `router.php`文件位置移动 + +## 2016-3-11 RC2版本 + +* 重新设计的自动验证和自动完成机制(原有自动验证和完成支持采用traits\model\Auto兼容); +* 验证类Validate独立设计; +* 自动生成功能交给Console完成; +* 对数据表字段大小写的处理; +* 改进Controller类(取消traits\contorller\View); +* 改进Input类; +* 改进Url类; +* 改进Cookie类; +* 优化Loader类; +* 优化Route类; +* 优化Template类; +* Session类自动初始化; +* 增加traits\model\Bulk模型扩展用于大批量数据写入和更新; +* 缓存类和日志类增加Test驱动; +* 对异常机制和错误处理的改进; +* 增加URL控制器和操作是否自动转换开关; +* 支持类名后缀设置; +* 取消操作绑定到类的功能; +* 取消use_db_switch参数设计; + +## 2016-1-30 RC1版本 +### [ 底层架构 ] + +* 真正的惰性加载 +* 核心类库组件化 +* 框架引导文件 +* 完善的类库自动加载(支持Composer) +* 采用Traits扩展 +* API友好(输出、异常和调试) +* 文件命名规范调整 + +### [ 调试和异常 ] + +* 专为API开发而设计的输出、调试和异常处理 +* 日志类支持本地文件/SAE/页面Trace/SocketLog输出,可以实现远程浏览器插件调试 +* 内置trace方法直接远程调试 +* 异常预警通知驱动设计 +* 数据库SQL性能分析支持 + +### [ 路由 ] + +* 动态注册路由 +* 自定义路由检测方法 +* 路由分组功能 +* 规则路由中的变量支持采用正则规则定义(包括全局和局部) +* 闭包路由 +* 支持路由到多层控制器 + +### [ 控制器 ] + +* 控制器类无需继承controller类 +* 灵活的多层控制器支持 +* 可以Traits引入高级控制器功能 +* rest/yar/rpc/hprose/jsonrpc控制器扩展 +* 前置操作方法支持排除和指定操作 + + +### [ 模型 ] + +* 简化的核心模型 +* Traits引入高级模型/视图模型/关联模型 +* 主从分布时候主数据库读操作支持 +* 改进的join方法和order方法 + +### [ 视图 ] + +* 视图解析驱动设计(模板引擎) +* 所有方法不再直接输出而是返回交由系统统一输出处理 +* 动态切换模板主题设计 +* 动态切换模板引擎设计 + +### [ 数据库 ] + +* 完全基于PDO实现 +* 简化的数据库驱动设计 +* SQL性能监控(需要开启数据库调试模式) +* PDO参数绑定改进 + +### [ 其他方面 ] + +* 目录和MVC文件自动生成支持 +* I函数默认添加变量修饰符为/s +* 一个行为类里面支持为多个标签位定义不同的方法 +* 更多的社交扩展类库 \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 0000000..79f08a6 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/application/.htaccess b/application/.htaccess new file mode 100755 index 0000000..3418e55 --- /dev/null +++ b/application/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/application/admin/common.php b/application/admin/common.php new file mode 100644 index 0000000..6fd199e --- /dev/null +++ b/application/admin/common.php @@ -0,0 +1 @@ +redirect('login/index'); + return $this->error('您还未登录',url('Login/logoutJump')); + //Response::create(['status' => '0','msg'=> '还未登录,验证失败'], 'json')->send(); + exit; + }else{ + //登录信息超时 + $log_time=session('admin_user_login_time')-time(); + if($log_time < 0){ + Session::clear(); + //Response::create(['status' => '0','msg'=> '登录超时,需重新登陆'], 'json')->send(); + return $this->error('登录超时',url('Login/logoutJump')); + exit; + } + } + } + //简单的token生成函数 + /* protected function create_token() + { + $str = md5(uniqid(md5(microtime(true)), true)); //生成一个不会重复的字符串 + $str = sha1($str); //加密 + return $str; + } + //验证Token + public function checkToken($token) + { + $user = Db::name('user')->where('token', $token)->find(); + if (empty($user)) { + return ['status'=>0,'msg'=>'token错误,验证失败']; + }else{ + if (time() - $user['time_out'] > 0) { + return ['status'=>0,'msg'=>'token长时间未使用而过期,需重新登陆']; + } + return ['status'=>1,'msg'=>'成功!','data'=>$user]; + } + } + //通过分组id获取分组名称 + public function getGroupName($id){ + $res = Db::name('group')->field('group_name')->where('group_id',$id)->find(); + if($res){ + return $res['group_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'分组匹配不到']); + return ''; + } + } + //通过城市id获取城市名称 + public function getCityName($id){ + $res = Db::name('city')->field('city_name')->where('city_id',$id)->find(); + if($res){ + return $res['city_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'城市匹配不到']); + return ''; + } + } + //通过工厂id获取工厂名称 + public function getFirmName($id){ + $res = Db::name('firm')->field('firm_name')->where('firm_id',$id)->find(); + if($res){ + return $res['firm_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'工厂匹配不到']); + return ''; + } + } + //通过品牌id获取品牌名称 + public function getBrandName($id){ + $res = Db::name('brand')->field('brand_name')->where('brand_id',$id)->find(); + if($res){ + return $res['brand_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'品牌匹配不到']); + return ''; + } + } + //通过代理商id获取代理商名称 + public function getVenderName($id){ + $res = Db::name('vender')->field('vender_name')->where('vender_id',$id)->find(); + if($res){ + return $res['vender_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'代理商匹配不到']); + return ''; + } + } + //通过角色id获取角色名称 + public function getRoleName($id){ + $res = Db::name('role')->field('role_name')->where('role_id',$id)->find(); + if($res){ + return $res['role_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'角色匹配不到']); + return ''; + } + }*/ +} diff --git a/application/admin/config.php b/application/admin/config.php new file mode 100644 index 0000000..d36ae2b --- /dev/null +++ b/application/admin/config.php @@ -0,0 +1,5 @@ +"-1","error"=>"图片不能为空")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + return json(array("status"=>"-1","error"=>"请上传jpg,png,或jpeg类型的文件!"));//mov,webm + exit; + } + if ($size > (2 * 1024 * 1024)) { + return json(array("status"=>"-1","error"=>"文件大小已超过2MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + return json(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + return json(array("status"=>"-1","error"=>"上传有误,请检查服务器配置!")); + die(); + } + }else{ + return json(array("status"=>"-1","error"=>"系统错误!")); + die(); + } + } + /** + *上传视频 + */ + public function uploadVideo(Request $request){ + $typeArr = array("mp4","wkv");//官方推荐 mp4 + $path = "uploadnv/" . date('Y/m/d/');//上传路径 + if(!file_exists($path)){ + //创建文件 + mkdir($path,0777,true); + } + // if ($_FILES) { + $name = $_FILES['file']['name']; + $size = $_FILES['file']['size']; + $name_tmp = $_FILES['file']['tmp_name']; + if (empty($name)) { + // return json_encode(['status'=>0,'msg'=>'查询失败']); + echo json_encode(array("error"=>"您还未选择文件")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + echo json_encode(array("error"=>"请上传mp4,wkv类型的文件!"));//mov,webm + exit; + } + if ($size > (15 * 1024 * 1024)) { + echo json_encode(array("error"=>"文件大小已超过30MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + echo json_encode(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + echo json_encode(array("error"=>"上传有误,请检查服务器配置!")); + die(); + } + //} + } +} diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php new file mode 100644 index 0000000..0589a9a --- /dev/null +++ b/application/admin/controller/Index.php @@ -0,0 +1,197 @@ +send(); + exit; + } + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php new file mode 100644 index 0000000..9fb77e4 --- /dev/null +++ b/application/admin/controller/Login.php @@ -0,0 +1,92 @@ +view->fetch('login'); + }else{ + //登录信息超时 + $log_time=session('admin_user_login_time')-time(); + if($log_time < 0){ + return $this->view->fetch('login'); + } + } + return $this->view->fetch('nav'); + } + /** + * 验证用户身份. + * + * @return \think\Response + */ + public function login(Request $request) + { + //判断是否是post方法发送的数据:如果是则开始登陆 + if(Request::instance()->isPost()){ + $user_name=Request::instance()->param("username"); + $password=Request::instance()->param('password'); + if(empty($user_name) || empty($password)){ + $result=['status'=>0,'msg'=>'用户名或密码为空']; + return json($result); + } + //数据查询 + $infor=Db::name("user") + ->field('id,user_name,user_head') + ->where('phone',$user_name) + ->where('password',md5($password)) + ->where("status",1) + ->where('type',1) + ->find(); + if(empty($infor)){ + $result=['status'=>0,'msg'=>'用户不存在或密码不正确']; + }else{ + //Session::set('admin_user_type',$infor['role_id']); + Session::set('admin_user_id',$infor['id']); + //Session::set('admin_mechanism_id',$infor['mechanism_id']); + $time_out=time()+3600; + Session::set('admin_user_login_time',$time_out); + $result=['status'=>1,'msg'=>'登录成功','token'=>1]; + } + return json($result); + } + //如果不是post,则返回登陆界面 + else{ + $result=['status'=>0,'msg'=>'未获取到参数']; + return json($result); + } + } + /** + * 退出登录 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logout(Request $request) + { + Session::clear(); + return json(['status'=>1,'msg'=>'退出成功']); + } + /** + * 超时登录推出跳转页面 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logoutJump(Request $request) + { + return $this->view->fetch('logoutJump'); + } +} diff --git a/application/admin/controller/Menu.php b/application/admin/controller/Menu.php new file mode 100644 index 0000000..0a3a5c8 --- /dev/null +++ b/application/admin/controller/Menu.php @@ -0,0 +1,325 @@ +send(); + exit; + }*/ + } + public function index() + { + // $this->alreadyLogin(); + return $this->view->fetch('index'); + } + public function nav() + { + // $this->alreadyLogin(); + return $this->view->fetch('nav'); + } + public function getUserInfor(){ + $data=Db::name("user") + ->field('user_name,user_head') + ->where('id',session('admin_user_id')) + ->find(); + $result=['status'=>1,'msg'=>'查询成功','infro'=>$data]; + return json($result); + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != '' && $value['pid'] != 0){ + //二级 + $value['grade']="二级菜单"; + $second[]=$value; + unset($result[$key]); + }else{ + $result[$key]['grade']="一级菜单"; + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json(['status'=>$status,'msg'=>$msg]); + } + /** + * 修改菜单详情 + * @param $data 菜单id(一级菜单、二级菜单) + * @param $data 菜单详情 + * @author hjc + * @date 2024-05-14 + */ + public function updMenu(Request $request){ + $data=$request->param(); + $result=Db::name('menu')->field('id,pid,menu_name,url,menu_icon')->where('menu_id',$data['menu_id'])->find(); + $result['type']=1; + if(!empty($result['pid'])){ + $result['type']=2; + $result['father']=$result['pid']; + } + unset($result['pid']); + if($result){ + $status=1; + $msg="获取数据成功!!"; + }else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + public function doupdMenu(Request $request){ + $data=$request->param(); + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $data1['pid']=''; + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + }else{ + $data1['pid']=$data['father']; + //获取一级菜单最大序号 + if(!empty($data['url'])){ + $data1['url']=$data['url']; + } + } + $data1['menu_name']=$data['menu_name']; + $res=Db::name('menu')->where('id',$data['id'])->update($data1); + if($res){ + $status=1; + $msg='修改菜单成功!!'; + }else{ + $status=0; + $msg='修改菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 设置菜单状态 + * @param $data 一级菜单id、二级菜单id + * @author hjc + * @date 2024-05-14 + */ + public function setMenuStatus(Request $request){ + $data=$request->param(); + $this->checkToken($data['Token']); + $res=Db::name('menu')->where('id',$data['id'])->update(['status'=>$data['status']]); + if($res){ + $status=1; + $msg='设置成功!!'; + }else{ + $status=0; + $msg='设置失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 删除菜单 + * @param $data 一级菜单id、二级菜单id + *@author hjc + * @date 2024-05-14 + */ + public function delMenu(Request $request){ + $data=$request->param(); + $res=Db::name('menu')->where('id',$data['id'])->find(); + //一级菜单 + if($res['pid']==''){ + $map1['id|pid']=$data['id']; + $map2['id']=['in',[$data['id'],$res['pid']]]; + }else{ + $map1['id']=$data['id']; + $map2['id']=$data['id']; + } + // 启动事务 + Db::startTrans(); + try{ + //删除二级菜单 + Db::name('menu')->where($map1)->delete(); + // Db::table('t_nv_role_menu')->where($map2)->delete(); + // 提交事务 + Db::commit(); + $status=1; + $msg='删除菜单成功!!'; + } catch (\Exception $e) { + Log::record($e->getMessage(),'error'); + // 回滚事务 + Db::rollback(); + $status=0; + $msg='删除菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/admin/controller/Wechatinfro.php b/application/admin/controller/Wechatinfro.php new file mode 100644 index 0000000..12d3e6f --- /dev/null +++ b/application/admin/controller/Wechatinfro.php @@ -0,0 +1,105 @@ +send(); + exit; + }*/ + } + public function wechatUserList() + { + return $this->view->fetch('userList'); + } + /** + * 查看小程序注册用户信息 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatUserList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['nickname']=['like','%'.$post['title'].'%']; + } + //升序获取菜单列表 + $res = Db::name('wechat_user') + ->field('uid,nickname,headimg,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + /** + * 查看小程序记录 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatRecordList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['name']=['like','%'.$post['title'].'%']; + } + // 查询列表 + $res = Db::name('wechat_calculate_record') + ->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result = array(); + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } +} diff --git a/application/admin/controller/Wechatset.php b/application/admin/controller/Wechatset.php new file mode 100644 index 0000000..59bc33c --- /dev/null +++ b/application/admin/controller/Wechatset.php @@ -0,0 +1,182 @@ +send(); + exit; + }*/ + } + /** + * 小程序资讯信息页面 + */ + public function wechatRealTimeInfo() + { + return $this->view->fetch('realTimeInfo'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoAdd() + { + return $this->view->fetch('realTimeInfoAdd'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoUpdate(Request $request) + { + $id=$request->get('id'); + $this->assign('id',$id); + return $this->view->fetch('realTimeInfoUpdate'); + } + /** + * 查询小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatRealTimeInfoList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['title_plain']=['like','%'.$post['title'].'%']; + } + //升序获取菜单列表 + $res = Db::name('wechat_real_time_info') + ->field('id,title_plain,thumbnail,excerpt_plain,url,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + /** + * 删除小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function delWechatRealTimeInfo(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id']) ){ + $result['erro'] = -1; + $result['msg'] = "请选择要删除的记录"; + return json($result); + } + $id=Db::name('wechat_real_time_info')->where('id',$post['id'])->value('id'); + if(empty($id)){ + $result['erro'] = -1; + $result['msg'] = "该记录异常,无法删除"; + return json($result); + } + $res=Db::name('wechat_real_time_info')->where('id',$id)->delete(); + if($res > 0){ + $result['erro'] = 0; + $result['msg'] = '删除成功'; + }else{ + $result['erro'] = -1; + $result['msg'] = '删除失败'; + } + return json($result); + } + /*** + *保存小程序资讯信息 + **/ + public function saveWechatRealTimeInfo(Request $request){ + $post=$request->param(); + + if(!isset($post['title_plain']) || empty($post['title_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入标题"; + return json($result); + } + if(!isset($post['thumbnail']) || empty($post['thumbnail']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入图片"; + return json($result); + } + if(!isset($post['excerpt_plain']) || empty($post['excerpt_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入简介"; + return json($result); + } + if(!isset($post['url']) || empty($post['url'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯跳转链接"; + return json($result); + } + //提交数据 + $data=[]; + $data['title_plain']=$post['title_plain'];//标题 + $data['thumbnail']=$post['thumbnail'];//图片 + $data['excerpt_plain']=$post['excerpt_plain'];//介绍 + $data['url']=$post['url'];//跳转连接 + if(isset($post['id']) && !empty($post['id'])){ + //修改数据 + $res=Db::name('wechat_real_time_info')->where('id',$post['id'])->update($data); + }else{ + //保存记录数据 + $data['id']=md5(time().rand(100000,999999)); + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_real_time_info')->insert($data); + } + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "添加失败"; + return json($result); + }else{ + $result['erro'] = 0; + $result['msg'] = "添加成功"; + return json($result); + } + } + /** + *查询资讯信息详情 + */ + public function getRealTimeInfoDetail(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯id"; + return json($result); + } + //修改数据 + $result['infro']=Db::name('wechat_real_time_info')->where('id',$post['id'])->find(); + $result['erro'] = 0; + $result['msg'] = "查询成功"; + return json($result); + } +} diff --git a/application/admin/model/Permission.php b/application/admin/model/Permission.php new file mode 100644 index 0000000..b194568 --- /dev/null +++ b/application/admin/model/Permission.php @@ -0,0 +1,11 @@ +女神卡后台管理系统
\ No newline at end of file diff --git a/application/admin/view/login/login.html b/application/admin/view/login/login.html new file mode 100644 index 0000000..9b6019d --- /dev/null +++ b/application/admin/view/login/login.html @@ -0,0 +1,143 @@ + + + + + + + + + 用户登录 + + + + + +
+
+
+ +
+
+
+
+ +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/application/admin/view/login/logoutJump.html b/application/admin/view/login/logoutJump.html new file mode 100644 index 0000000..5a36aa5 --- /dev/null +++ b/application/admin/view/login/logoutJump.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/admin/view/login/nav.html b/application/admin/view/login/nav.html new file mode 100644 index 0000000..0699b5b --- /dev/null +++ b/application/admin/view/login/nav.html @@ -0,0 +1,58 @@ + + + + + + + + 瑞莱医疗后台 + + + + + + + + + + + +
+
+ +
+
+ +
+ + +
+ + + + + 退出 +
+
+
+ +
+ + + + + + diff --git a/application/admin/view/login/新建文件夹/index - 副本.html b/application/admin/view/login/新建文件夹/index - 副本.html new file mode 100644 index 0000000..2fcb006 --- /dev/null +++ b/application/admin/view/login/新建文件夹/index - 副本.html @@ -0,0 +1,743 @@ + + + + + + + + + + + +Hi,H-ui v4.0 + + + + +
+ +
+
+
+
+ +
+
+ + +
+

Hi,H-ui v4.0!

+

开始全新的前端之旅!

+
+
表单
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ 其他信息 +
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+
+ + + +
+
+ + + +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
按钮
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
buttoninputadisabled状态空心
默认
主要
次要
成功
警告
危险
链接
虚线
+

按钮大小

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
按钮class=""
size-XL
size-L
size-M 缺省值
size-S
size-MINI
+

按钮组

+
+ 左边按钮 + 中间按钮 + 中间按钮 + 右边按钮 +
+
+
+ +
+
+ + + + +
+ + + + + + +
+
+ + + +
+
+ + + +
+
+
列表
+
+
    +
  • 无序列表
  • +
  • 无序列表
  • +
  • 无序列表
  • +
+
    +
  1. 有序列表
  2. +
  3. 有序列表
  4. +
  5. 有序列表
  6. +
+
    +
  1. 1有序列表
  2. +
  3. 2有序列表
  4. +
  5. 3有序列表
  6. +
+
+
+
图片
+
+

+ ... + ... + ... +

+
+
+
+
《仙剑奇侠传》赵灵儿 + (20张) +
+
+
+
+
+ + + + + +
+
+ +
遮罩条
+
+
表格
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
表头表头表头
类别表格内容表格内容
类别表格内容表格内容
类别表格内容表格内容
+
+
+
+
选项卡
+
+
+
+ 选项卡一 + 选项卡二 + 自适应宽度 +
+
内容一
+
内容二
+
内容三
+
+
+
+
+
便签与标号
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
class=""标签标号描述
hui-label hui-label-default radius默认1默认
hui-label hui-label-primary radius主要2主要
hui-label hui-label-secondary radius次要3次要
hui-label hui-label-success radius成功4成功
hui-label hui-label-warning radius警告5警告
hui-label hui-label-danger radius危险6危险
+
+
+
+
警告
+
+
+ +
成功状态提示
+
+
+
危险状态提示
+
+
+ +
错误状态提示
+
+
+ +
信息状态提示
+
+
+
+
+
进度条
+
+
+
+ +
弹出窗口

+ + +

分享到
+
+
标签
星星评价
描述相符:
tooltip效果
popover效果
+ +
H-ui官方插件
+ +
名称版本号描述
jQuery.Huihover.js2.0hover
jQuery.Huifocusblur.js2.0得到失去焦点
jQuery.hui-fold.js2.0折叠
jQuery.Huipreview.js2.0图片预览
jQuery.Huispinner.js2.0微调器
jQuery.Huitab.js2.0选项卡
jQuery.Huitag.js2.0标签
jQuery.Huitextarealength.js2.0字数限制
jQuery.HuitogglePassword.js2.0隐藏显示密码
jQuery.Huitotop.js2.0返回顶部
H-ui.js v3.0 整合的第三方插件(引入了H-ui.js v3.0版本,无需再单独重复引用以下插件) + 感谢以下插件!优秀的插件就像金子一样,处处发光
+
名称版本号描述
jQuery.cookie.js1.4.1jQuery cookie插件。
jQuery.form.js3.51.0jquey表单插件。
jQuery.lazyload.js1.9.3图片的延迟加载插件。
jQuery.responsive-nav.js1.0.39响应式导航插件。
jQuery.placeholder.js1.0IE浏览器支持placeholder。
jQuery.emailsuggest.js1.0邮箱域名自动提示填充插件。
jQuery.format.js1.0格式化字符串。
jQuery.iCheck.js1.0单选框,复选框美化插件。
jQuery.onePageNav.js1.0单页面滚动导航。
jQuery.stickUp.js1.0网页滚动,元素固定置顶插件。
jQuery.ColorPicker.js1.0颜色控件。
Bootstrap.modal.js3.3.0Bootstrap模态窗口,弹窗插件。
Bootstrap.dropdown.js3.3.0Bootstrap下拉框插件。
Bootstrap.transition.js3.3.0Bootstrap过渡效果(Transition)插件。
Bootstrap.tooltip.js3.3.0Bootstrap工具提示插件。
Bootstrap.popover.js3.3.0Bootstrap弹出框插件。
Bootstrap.alert.js3.3.0Bootstrap警告框插件。
Bootstrap.slider.js1.0.1Bootstrap滑动条插件。
Bootstrap.datetimepicker.js1.0Bootstrap日期插件。
Bootstrap.Switch.js1.3Bootstrap 开关控件。
lib中的第三方插件 非必选插件,请有选择性的使用,用不上的可自行删除,减少框架体积
名称版本号描述
jQuery.js1.9.1jQuery库,可自行下载新版本,替换现有版本。
jquery.SuperSlide2.1.3幻灯片组件
jquery.validation1.14.0表单验证插件
datatables1.10.0表格插件
nprogress0.2.0进度条插件
layer3.1.1layer弹出层插件
laypage1.3laypage 翻页插件
html5shiv.js3.7.0html5插件,让低版本IE支持html5元素
DD_belatedPNG_0.0.8a-min.js0.0.8a解决IE6png透明
swfobject.js2.2Flash插件
waterfall.min0.1.6瀑布流插件
+ + + + + + + + \ No newline at end of file diff --git a/application/admin/view/login/新建文件夹/index11.html b/application/admin/view/login/新建文件夹/index11.html new file mode 100644 index 0000000..1536470 --- /dev/null +++ b/application/admin/view/login/新建文件夹/index11.html @@ -0,0 +1,112 @@ + + + + + + + + + + + +瑞莱医疗 + + + + + + + +
+
+

瑞莱医疗后台登录

+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/application/admin/view/login/新建文件夹/login.html b/application/admin/view/login/新建文件夹/login.html new file mode 100644 index 0000000..16a38ed --- /dev/null +++ b/application/admin/view/login/新建文件夹/login.html @@ -0,0 +1,117 @@ + + + + + + + + + 用户登录 + + + + + +
+
+
+ +
+
+
+
+ +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/application/admin/view/login/新建文件夹/nav.html b/application/admin/view/login/新建文件夹/nav.html new file mode 100644 index 0000000..119a9af --- /dev/null +++ b/application/admin/view/login/新建文件夹/nav.html @@ -0,0 +1,111 @@ + + + + + 蜂狐工厂后台 + + + + + + + + + + + + +
+
+ +
+
+ +
+ + +
+ + + + + 退出 +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + diff --git a/application/admin/view/wechatinfro/userList.html b/application/admin/view/wechatinfro/userList.html new file mode 100644 index 0000000..2f55a0d --- /dev/null +++ b/application/admin/view/wechatinfro/userList.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + 用户管理 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ + +
+ +
+ +
+
+
+ + +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/admin/view/wechatinfro/wechatRecordList.html b/application/admin/view/wechatinfro/wechatRecordList.html new file mode 100644 index 0000000..3c6d47e --- /dev/null +++ b/application/admin/view/wechatinfro/wechatRecordList.html @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + 计算结果 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/admin/view/wechatset/realTimeInfo.html b/application/admin/view/wechatset/realTimeInfo.html new file mode 100644 index 0000000..5b45f26 --- /dev/null +++ b/application/admin/view/wechatset/realTimeInfo.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + 用户管理 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ +
+ + 新增 +
+
+ +
+ +
+
+
+ + +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/admin/view/wechatset/realTimeInfoAdd.html b/application/admin/view/wechatset/realTimeInfoAdd.html new file mode 100644 index 0000000..6794a64 --- /dev/null +++ b/application/admin/view/wechatset/realTimeInfoAdd.html @@ -0,0 +1,319 @@ + + + + + + + + +新建编辑 + + + + + + + + +
+ +
+
+ +
+ 保存 +
+
+ +
+
+
+ +
+

+ * + 请输入标题: +

+
+ + + 0/ + 30 + +
+

+ * + 请输入介绍: +

+
+ +
+

+ * + 请输入资讯跳转链接: +

+
+ +
+

+ *请上传资讯图片: + +

+
+
+ + + +
+ +
+ +
+ + +
+
+ + +
+ + + + + + + + + + + diff --git a/application/admin/view/wechatset/realTimeInfoUpdate.html b/application/admin/view/wechatset/realTimeInfoUpdate.html new file mode 100644 index 0000000..0489e5c --- /dev/null +++ b/application/admin/view/wechatset/realTimeInfoUpdate.html @@ -0,0 +1,320 @@ + + + + + + + + +新建编辑 + + + + + + + + +
+ +
+
+
+ 保存 +
+
+ +
+
+
+ + +
+

+ * + 请输入标题: +

+
+ + + 0/ + 30 + +
+

+ * + 请输入介绍: +

+
+ +
+

+ * + 请输入资讯跳转链接: +

+
+ +
+

+ *请上传资讯图片: + +

+
+
+ + + +
+ +
+ +
+ + +
+
+ + +
+ + + + + + + + + + + diff --git a/application/adminghd/common.php b/application/adminghd/common.php new file mode 100644 index 0000000..6fd199e --- /dev/null +++ b/application/adminghd/common.php @@ -0,0 +1 @@ +redirect('login/index'); + var_dump(url('Login/logoutJump'));exit; + return $this->error('您还未登录',url('Login/logoutJump')); + //Response::create(['status' => '0','msg'=> '还未登录,验证失败'], 'json')->send(); + exit; + }else{ + //登录信息超时 + $log_time=session('adminghd_user_login_time')-time(); + if($log_time < 0){ + Session::clear(); + //Response::create(['status' => '0','msg'=> '登录超时,需重新登陆'], 'json')->send(); + return $this->error('登录超时',url('Login/logoutJump')); + exit; + } + } + } + //简单的token生成函数 + /* protected function create_token() + { + $str = md5(uniqid(md5(microtime(true)), true)); //生成一个不会重复的字符串 + $str = sha1($str); //加密 + return $str; + } + //验证Token + public function checkToken($token) + { + $user = Db::name('user')->where('token', $token)->find(); + if (empty($user)) { + return ['status'=>0,'msg'=>'token错误,验证失败']; + }else{ + if (time() - $user['time_out'] > 0) { + return ['status'=>0,'msg'=>'token长时间未使用而过期,需重新登陆']; + } + return ['status'=>1,'msg'=>'成功!','data'=>$user]; + } + } + //通过分组id获取分组名称 + public function getGroupName($id){ + $res = Db::name('group')->field('group_name')->where('group_id',$id)->find(); + if($res){ + return $res['group_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'分组匹配不到']); + return ''; + } + } + //通过城市id获取城市名称 + public function getCityName($id){ + $res = Db::name('city')->field('city_name')->where('city_id',$id)->find(); + if($res){ + return $res['city_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'城市匹配不到']); + return ''; + } + } + //通过工厂id获取工厂名称 + public function getFirmName($id){ + $res = Db::name('firm')->field('firm_name')->where('firm_id',$id)->find(); + if($res){ + return $res['firm_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'工厂匹配不到']); + return ''; + } + } + //通过品牌id获取品牌名称 + public function getBrandName($id){ + $res = Db::name('brand')->field('brand_name')->where('brand_id',$id)->find(); + if($res){ + return $res['brand_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'品牌匹配不到']); + return ''; + } + } + //通过代理商id获取代理商名称 + public function getVenderName($id){ + $res = Db::name('vender')->field('vender_name')->where('vender_id',$id)->find(); + if($res){ + return $res['vender_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'代理商匹配不到']); + return ''; + } + } + //通过角色id获取角色名称 + public function getRoleName($id){ + $res = Db::name('role')->field('role_name')->where('role_id',$id)->find(); + if($res){ + return $res['role_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'角色匹配不到']); + return ''; + } + }*/ +} diff --git a/application/adminghd/config.php b/application/adminghd/config.php new file mode 100644 index 0000000..d36ae2b --- /dev/null +++ b/application/adminghd/config.php @@ -0,0 +1,5 @@ +"-1","error"=>"图片不能为空")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + return json(array("status"=>"-1","error"=>"请上传jpg,png,或jpeg类型的文件!"));//mov,webm + exit; + } + if ($size > (2 * 1024 * 1024)) { + return json(array("status"=>"-1","error"=>"文件大小已超过2MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + return json(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + return json(array("status"=>"-1","error"=>"上传有误,请检查服务器配置!")); + die(); + } + }else{ + return json(array("status"=>"-1","error"=>"系统错误!")); + die(); + } + } + /** + *上传视频 + */ + public function uploadVideo(Request $request){ + $typeArr = array("mp4","wkv");//官方推荐 mp4 + $path = "uploadnv/" . date('Y/m/d/');//上传路径 + if(!file_exists($path)){ + //创建文件 + mkdir($path,0777,true); + } + // if ($_FILES) { + $name = $_FILES['file']['name']; + $size = $_FILES['file']['size']; + $name_tmp = $_FILES['file']['tmp_name']; + if (empty($name)) { + // return json_encode(['status'=>0,'msg'=>'查询失败']); + echo json_encode(array("error"=>"您还未选择文件")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + echo json_encode(array("error"=>"请上传mp4,wkv类型的文件!"));//mov,webm + exit; + } + if ($size > (15 * 1024 * 1024)) { + echo json_encode(array("error"=>"文件大小已超过30MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + echo json_encode(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + echo json_encode(array("error"=>"上传有误,请检查服务器配置!")); + die(); + } + //} + } +} diff --git a/application/adminghd/controller/Index.php b/application/adminghd/controller/Index.php new file mode 100644 index 0000000..f879cd2 --- /dev/null +++ b/application/adminghd/controller/Index.php @@ -0,0 +1,196 @@ +send(); + exit; + } + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/adminghd/controller/Login.php b/application/adminghd/controller/Login.php new file mode 100644 index 0000000..ff18876 --- /dev/null +++ b/application/adminghd/controller/Login.php @@ -0,0 +1,92 @@ +view->fetch('login'); + }else{ + //登录信息超时 + $log_time=session('adminghd_user_login_time')-time(); + if($log_time < 0){ + return $this->view->fetch('login'); + } + } + return $this->view->fetch('nav'); + } + /** + * 验证用户身份. + * + * @return \think\Response + */ + public function login(Request $request) + { + //判断是否是post方法发送的数据:如果是则开始登陆 + if(Request::instance()->isPost()){ + $user_name=Request::instance()->param("username"); + $password=Request::instance()->param('password'); + if(empty($user_name) || empty($password)){ + $result=['status'=>0,'msg'=>'用户名或密码为空']; + return json($result); + } + //数据查询 + $infor=Db::name("user") + ->field('id,user_name,user_head') + ->where('phone',$user_name) + ->where('password',md5($password)) + ->where("status",1) + ->where('type',1) + ->find(); + if(empty($infor)){ + $result=['status'=>0,'msg'=>'用户不存在或密码不正确']; + }else{ + //Session::set('admin_user_type',$infor['role_id']); + Session::set('adminghd_user_id',$infor['id']); + //Session::set('admin_mechanism_id',$infor['mechanism_id']); + $time_out=time()+3600; + Session::set('adminghd_user_login_time',$time_out); + $result=['status'=>1,'msg'=>'登录成功','token'=>1]; + } + return json($result); + } + //如果不是post,则返回登陆界面 + else{ + $result=['status'=>0,'msg'=>'未获取到参数']; + return json($result); + } + } + /** + * 退出登录 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logout(Request $request) + { + Session::clear(); + return json(['status'=>1,'msg'=>'退出成功']); + } + /** + * 超时登录推出跳转页面 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logoutJump(Request $request) + { + return $this->view->fetch('logoutJump'); + } +} diff --git a/application/adminghd/controller/Menu.php b/application/adminghd/controller/Menu.php new file mode 100644 index 0000000..93961f8 --- /dev/null +++ b/application/adminghd/controller/Menu.php @@ -0,0 +1,325 @@ +send(); + exit; + }*/ + } + public function index() + { + // $this->alreadyLogin(); + return $this->view->fetch('index'); + } + public function nav() + { + // $this->alreadyLogin(); + return $this->view->fetch('nav'); + } + public function getUserInfor(){ + $data=Db::name("user") + ->field('user_name,user_head') + ->where('id',session('admin_user_id')) + ->find(); + $result=['status'=>1,'msg'=>'查询成功','infro'=>$data]; + return json($result); + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != '' && $value['pid'] != 0){ + //二级 + $value['grade']="二级菜单"; + $second[]=$value; + unset($result[$key]); + }else{ + $result[$key]['grade']="一级菜单"; + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json(['status'=>$status,'msg'=>$msg]); + } + /** + * 修改菜单详情 + * @param $data 菜单id(一级菜单、二级菜单) + * @param $data 菜单详情 + * @author hjc + * @date 2024-05-14 + */ + public function updMenu(Request $request){ + $data=$request->param(); + $result=Db::name('menu')->field('id,pid,menu_name,url,menu_icon')->where('menu_id',$data['menu_id'])->find(); + $result['type']=1; + if(!empty($result['pid'])){ + $result['type']=2; + $result['father']=$result['pid']; + } + unset($result['pid']); + if($result){ + $status=1; + $msg="获取数据成功!!"; + }else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + public function doupdMenu(Request $request){ + $data=$request->param(); + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $data1['pid']=''; + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + }else{ + $data1['pid']=$data['father']; + //获取一级菜单最大序号 + if(!empty($data['url'])){ + $data1['url']=$data['url']; + } + } + $data1['menu_name']=$data['menu_name']; + $res=Db::name('menu')->where('id',$data['id'])->update($data1); + if($res){ + $status=1; + $msg='修改菜单成功!!'; + }else{ + $status=0; + $msg='修改菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 设置菜单状态 + * @param $data 一级菜单id、二级菜单id + * @author hjc + * @date 2024-05-14 + */ + public function setMenuStatus(Request $request){ + $data=$request->param(); + $this->checkToken($data['Token']); + $res=Db::name('menu')->where('id',$data['id'])->update(['status'=>$data['status']]); + if($res){ + $status=1; + $msg='设置成功!!'; + }else{ + $status=0; + $msg='设置失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 删除菜单 + * @param $data 一级菜单id、二级菜单id + *@author hjc + * @date 2024-05-14 + */ + public function delMenu(Request $request){ + $data=$request->param(); + $res=Db::name('menu')->where('id',$data['id'])->find(); + //一级菜单 + if($res['pid']==''){ + $map1['id|pid']=$data['id']; + $map2['id']=['in',[$data['id'],$res['pid']]]; + }else{ + $map1['id']=$data['id']; + $map2['id']=$data['id']; + } + // 启动事务 + Db::startTrans(); + try{ + //删除二级菜单 + Db::name('menu')->where($map1)->delete(); + // Db::table('t_nv_role_menu')->where($map2)->delete(); + // 提交事务 + Db::commit(); + $status=1; + $msg='删除菜单成功!!'; + } catch (\Exception $e) { + Log::record($e->getMessage(),'error'); + // 回滚事务 + Db::rollback(); + $status=0; + $msg='删除菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/adminghd/controller/Wechatinfro.php b/application/adminghd/controller/Wechatinfro.php new file mode 100644 index 0000000..9277bbe --- /dev/null +++ b/application/adminghd/controller/Wechatinfro.php @@ -0,0 +1,105 @@ +send(); + exit; + }*/ + } + public function wechatUserList() + { + return $this->view->fetch('userList'); + } + /** + * 查看小程序注册用户信息 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatUserList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['nickname']=['like','%'.$post['title'].'%']; + } + //升序获取菜单列表 + $res = Db::name('ghd_wechat_user') + ->field('uid,nickname,headimg,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + /** + * 查看小程序记录 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatRecordList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['name']=['like','%'.$post['title'].'%']; + } + // 查询列表 + $res = Db::name('wechat_calculate_record') + ->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result = array(); + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } +} diff --git a/application/adminghd/controller/Wechatset.php b/application/adminghd/controller/Wechatset.php new file mode 100644 index 0000000..059b4c2 --- /dev/null +++ b/application/adminghd/controller/Wechatset.php @@ -0,0 +1,182 @@ +send(); + exit; + }*/ + } + /** + * 小程序资讯信息页面 + */ + public function wechatRealTimeInfo() + { + return $this->view->fetch('realTimeInfo'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoAdd() + { + return $this->view->fetch('realTimeInfoAdd'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoUpdate(Request $request) + { + $id=$request->get('id'); + $this->assign('id',$id); + return $this->view->fetch('realTimeInfoUpdate'); + } + /** + * 查询小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatRealTimeInfoList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['title_plain']=['like','%'.$post['title'].'%']; + } + //升序获取菜单列表 + $res = Db::name('wechat_real_time_info') + ->field('id,title_plain,thumbnail,excerpt_plain,url,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + /** + * 删除小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function delWechatRealTimeInfo(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id']) ){ + $result['erro'] = -1; + $result['msg'] = "请选择要删除的记录"; + return json($result); + } + $id=Db::name('wechat_real_time_info')->where('id',$post['id'])->value('id'); + if(empty($id)){ + $result['erro'] = -1; + $result['msg'] = "该记录异常,无法删除"; + return json($result); + } + $res=Db::name('wechat_real_time_info')->where('id',$id)->delete(); + if($res > 0){ + $result['erro'] = 0; + $result['msg'] = '删除成功'; + }else{ + $result['erro'] = -1; + $result['msg'] = '删除失败'; + } + return json($result); + } + /*** + *保存小程序资讯信息 + **/ + public function saveWechatRealTimeInfo(Request $request){ + $post=$request->param(); + + if(!isset($post['title_plain']) || empty($post['title_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入标题"; + return json($result); + } + if(!isset($post['thumbnail']) || empty($post['thumbnail']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入图片"; + return json($result); + } + if(!isset($post['excerpt_plain']) || empty($post['excerpt_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入简介"; + return json($result); + } + if(!isset($post['url']) || empty($post['url'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯跳转链接"; + return json($result); + } + //提交数据 + $data=[]; + $data['title_plain']=$post['title_plain'];//标题 + $data['thumbnail']=$post['thumbnail'];//图片 + $data['excerpt_plain']=$post['excerpt_plain'];//介绍 + $data['url']=$post['url'];//跳转连接 + if(isset($post['id']) && !empty($post['id'])){ + //修改数据 + $res=Db::name('wechat_real_time_info')->where('id',$post['id'])->update($data); + }else{ + //保存记录数据 + $data['id']=md5(time().rand(100000,999999)); + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_real_time_info')->insert($data); + } + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "添加失败"; + return json($result); + }else{ + $result['erro'] = 0; + $result['msg'] = "添加成功"; + return json($result); + } + } + /** + *查询资讯信息详情 + */ + public function getRealTimeInfoDetail(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯id"; + return json($result); + } + //修改数据 + $result['infro']=Db::name('wechat_real_time_info')->where('id',$post['id'])->find(); + $result['erro'] = 0; + $result['msg'] = "查询成功"; + return json($result); + } +} diff --git a/application/adminghd/model/Permission.php b/application/adminghd/model/Permission.php new file mode 100644 index 0000000..1961153 --- /dev/null +++ b/application/adminghd/model/Permission.php @@ -0,0 +1,11 @@ + + + + + + + + + 用户登录 + + + + + +
+
+
+ +
+
+
+
+ +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/application/adminghd/view/login/logoutJump.html b/application/adminghd/view/login/logoutJump.html new file mode 100644 index 0000000..2a665b7 --- /dev/null +++ b/application/adminghd/view/login/logoutJump.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/adminghd/view/login/nav.html b/application/adminghd/view/login/nav.html new file mode 100644 index 0000000..e912606 --- /dev/null +++ b/application/adminghd/view/login/nav.html @@ -0,0 +1,58 @@ + + + + + + + + 瑞莱医疗后台 + + + + + + + + + + + +
+
+ +
+
+ +
+ + +
+ + + + + 退出 +
+
+
+ +
+ + + + + + diff --git a/application/adminghd/view/wechatinfro/userList.html b/application/adminghd/view/wechatinfro/userList.html new file mode 100644 index 0000000..c09604c --- /dev/null +++ b/application/adminghd/view/wechatinfro/userList.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + 用户管理 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ + +
+ +
+ +
+
+
+ + +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/adminghd/view/wechatinfro/wechatRecordList.html b/application/adminghd/view/wechatinfro/wechatRecordList.html new file mode 100644 index 0000000..152db2b --- /dev/null +++ b/application/adminghd/view/wechatinfro/wechatRecordList.html @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + 计算结果 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/adminghd/view/wechatset/realTimeInfo.html b/application/adminghd/view/wechatset/realTimeInfo.html new file mode 100644 index 0000000..b9e87a4 --- /dev/null +++ b/application/adminghd/view/wechatset/realTimeInfo.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + 用户管理 + + + +
+ +
+
+
+
+
+
+ +
+ + +
+
+ +
+ + 新增 +
+
+ +
+ +
+
+
+ + +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/application/adminghd/view/wechatset/realTimeInfoAdd.html b/application/adminghd/view/wechatset/realTimeInfoAdd.html new file mode 100644 index 0000000..13a3395 --- /dev/null +++ b/application/adminghd/view/wechatset/realTimeInfoAdd.html @@ -0,0 +1,319 @@ + + + + + + + + +新建编辑 + + + + + + + + +
+ +
+
+ +
+ 保存 +
+
+ +
+
+
+ +
+

+ * + 请输入标题: +

+
+ + + 0/ + 30 + +
+

+ * + 请输入介绍: +

+
+ +
+

+ * + 请输入资讯跳转链接: +

+
+ +
+

+ *请上传资讯图片: + +

+
+
+ + + +
+ +
+ +
+ + +
+
+ + +
+ + + + + + + + + + + diff --git a/application/adminghd/view/wechatset/realTimeInfoUpdate.html b/application/adminghd/view/wechatset/realTimeInfoUpdate.html new file mode 100644 index 0000000..1c20392 --- /dev/null +++ b/application/adminghd/view/wechatset/realTimeInfoUpdate.html @@ -0,0 +1,320 @@ + + + + + + + + +新建编辑 + + + + + + + + +
+ +
+
+
+ 保存 +
+
+ +
+
+
+ + +
+

+ * + 请输入标题: +

+
+ + + 0/ + 30 + +
+

+ * + 请输入介绍: +

+
+ +
+

+ * + 请输入资讯跳转链接: +

+
+ +
+

+ *请上传资讯图片: + +

+
+
+ + + +
+ +
+ +
+ + +
+
+ + +
+ + + + + + + + + + + diff --git a/application/app/controller/Base.php b/application/app/controller/Base.php new file mode 100644 index 0000000..62d33dd --- /dev/null +++ b/application/app/controller/Base.php @@ -0,0 +1,340 @@ +watermark->appid != $appid ) + { + return $IllegalBuffer; + } + $data = $result; + return $OK; + } + /** + *GET方式请求 + */ + function httpGet($url){ + $ch = curl_init(); + //设置选项,包括URL + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证证书 + //执行并获取HTML文档内容 + $output = curl_exec($ch); + //释放curl句柄 + curl_close($ch); + //$result = json_decode($output); + //$result->subscribe + return $output; + } + /** + * post访问url + */ + function https_post($url,$data){ + $ch = curl_init(); + curl_setopt($ch,CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证证书 + curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch,CURLOPT_POST,1); + curl_setopt($ch,CURLOPT_POSTFIELDS,$data); + $output = curl_exec($ch); + curl_close($ch); + return $output; + } + /* + *加解密 + *函数authcode($string, $operation, $key, $expiry)中的$string:字符串,明文或密文;$operation:DECODE表示解密,其它表示加密;$key:密匙;$expiry:密文有效期。 + */ + public function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { + // 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙 + $ckey_length = 4; + + // 密匙 + $key = md5($key ? $key : '' ); //md5($key ? $key : $GLOBALS['discuz_auth_key']); + + // 密匙a会参与加解密 + $keya = md5(substr($key, 0, 16)); + // 密匙b会用来做数据完整性验证 + $keyb = md5(substr($key, 16, 16)); + // 密匙c用于变化生成的密文 + $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; + // 参与运算的密匙 + $cryptkey = $keya.md5($keya.$keyc); + $key_length = strlen($cryptkey); + // 明文,前10位用来保存时间戳,解密时验证数据有效性,10到26位用来保存$keyb(密匙b), + //解密时会通过这个密匙验证数据完整性 + // 如果是解码的话,会从第$ckey_length位开始,因为密文前$ckey_length位保存 动态密匙,以保证解密正确 + $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; + $string_length = strlen($string); + $result = ''; + $box = range(0, 255); + $rndkey = array(); + // 产生密匙簿 + for($i = 0; $i <= 255; $i++) { + $rndkey[$i] = ord($cryptkey[$i % $key_length]); + } + // 用固定的算法,打乱密匙簿,增加随机性,好像很复杂,实际上对并不会增加密文的强度 + for($j = $i = 0; $i < 256; $i++) { + $j = ($j + $box[$i] + $rndkey[$i]) % 256; + $tmp = $box[$i]; + $box[$i] = $box[$j]; + $box[$j] = $tmp; + } + // 核心加解密部分 + for($a = $j = $i = 0; $i < $string_length; $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $tmp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $tmp; + // 从密匙簿得出密匙进行异或,再转成字符 + $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); + } + if($operation == 'DECODE') { + // 验证数据有效性,请看未加密明文的格式 + if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { + return substr($result, 26); + } else { + return ''; + } + } else { + // 把动态密匙保存在密文里,这也是为什么同样的明文,生产不同密文后能解密的原因 + // 因为加密后的密文可能是一些特殊字符,复制过程可能会丢失,所以用base64编码 + return $keyc.str_replace('=', '', base64_encode($result)); + } + } +/** +*微信提现,企业付款到零用钱 +*$openid 公众号下的用户openid +*$mch_billno 订单号 +*$total_amount 提现的金额 +*$mark 备注 +*@return 错误 false ,成功 +*/ +function wxBusinessPay($openid,$mch_billno,$total_amount,$mark,$MCHID,$APPID,$Key){ + $nonce_str=$this->createNoncestr( $length = 32 ); + $sendarry=array(); + // 随机字符串 + $sendarry["nonce_str"]=$nonce_str; + // 商户订单号 + $sendarry["partner_trade_no"]=$mch_billno; + // 商户号 + $sendarry["mchid"]=$MCHID; + // 公众账号appid + $sendarry["mch_appid"]=$APPID; + // 用户openid + $sendarry["openid"]=$openid; + // 付款金额 + $sendarry["amount"]=$total_amount*100; + // 红包祝福语 + $sendarry["check_name"]='NO_CHECK';//不超过20字 + // Ip地址 + $sendarry["spbill_create_ip"]='62.234.183.107'; + // 备注 + $sendarry["desc"]=$mark; + // 签名 + $sign=$this->getSign($sendarry,$Key); + $sendarry["sign"]=$sign; + //转换XML + $sendxml=$this->arrayToXml($sendarry); + // 调用的接口 + $url='https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; + // 使用证书,以post方式提交xml到对应的接口url + $data=$this->postXmlSSLCurl($sendxml,$url,$seconed=30); + if($data == false){ + return false; + }else{ + $obj = $this->xmlToArray($data); + //发送成功 + if($obj['return_code'] == 'SUCCESS' && $obj['result_code'] == 'SUCCESS'){ + return true; + //金额不足 + }else{ + return false; + } + } + } + /** + * 作用:产生随机字符串,不长于32位 + */ + public function createNoncestr( $length = 32 ) + { + $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; + $str =""; + for ( $i = 0; $i < $length; $i++ ) { + $str.= substr($chars, mt_rand(0, strlen($chars)-1), 1); + } + return $str; + } + /** + * 作用:格式化参数,签名过程需要使用 + */ + function formatBizQueryParaMap($paraMap, $urlencode) + { + $buff = ""; + ksort($paraMap); + foreach ($paraMap as $k => $v) + { + if($urlencode) + { + $v = urlencode($v); + } + //$buff .= strtolower($k) . "=" . $v . "&"; + $buff .= $k . "=" . $v . "&"; + } + $reqPar; + if (strlen($buff) > 0) + { + $reqPar = substr($buff, 0, strlen($buff)-1); + } + return $reqPar; + } + /** + * 作用:生成签名 + */ + public function getSign($Obj,$KEY) + { + foreach ($Obj as $k => $v) + { + $Parameters[$k] = $v; + } + //签名步骤一:按字典序排序参数 + ksort($Parameters); + $String = $this->formatBizQueryParaMap($Parameters, false); + //echo '【string1】'.$String.'
'; + //签名步骤二:在string后加入KEY + $String = $String."&key=".$KEY; + //echo "【string2】".$String."
"; + //签名步骤三:MD5加密 + $String = md5($String); + //echo "【string3】 ".$String."
"; + //签名步骤四:所有字符转为大写 + $result_ = strtoupper($String); + //echo "【result】 ".$result_."
"; + return $result_; + } + /** + * 作用:array转xml + */ + function arrayToXml($arr) + { + $xml = ""; + foreach ($arr as $key=>$val) + { + if (is_numeric($val)) + { + $xml.="<".$key.">".$val.""; + + } + else + $xml.="<".$key.">"; + } + $xml.=""; + return $xml; + } + + /** + * 作用:将xml转为array + */ + public function xmlToArray($xml) + { + //将XML转为array + $array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); + return $array_data; + } + /** + * 作用:使用证书,以post方式提交xml到对应的接口url + */ + function postXmlSSLCurl($xml,$url,$second=30) + { + $ch = curl_init(); + //超时时间 + curl_setopt($ch,CURLOPT_TIMEOUT,$second); + //这里设置代理,如果有的话 + //curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8'); + //curl_setopt($ch,CURLOPT_PROXYPORT, 8080); + curl_setopt($ch,CURLOPT_URL, $url); + curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); + curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); + //设置header + curl_setopt($ch,CURLOPT_HEADER,FALSE); + //要求结果为字符串且输出到屏幕上 + curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); + //设置证书 + //使用证书:cert 与 key 分别属于两个.pem文件 + //默认格式为PEM,可以注释 + curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); + curl_setopt($ch,CURLOPT_SSLCERT, ROOT_PATH."/application/app/cacert/apiclient_cert.pem"); + //默认格式为PEM,可以注释 + curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); + curl_setopt($ch,CURLOPT_SSLKEY, ROOT_PATH."/application/app/cacert/apiclient_key.pem"); + //post提交方式 + curl_setopt($ch,CURLOPT_POST, true); + curl_setopt($ch,CURLOPT_POSTFIELDS,$xml); + $data = curl_exec($ch); + //返回结果 + if($data){ + curl_close($ch); + return $data; + } + else { + $error = curl_errno($ch); + /* echo "curl出错,错误码:$error"."
"; + echo "错误原因查询
";*/ + curl_close($ch); + return false; + } + } + /******************************* 小程序公用 ******************************************/ +} + + + + + +?> diff --git a/application/app/controller/Ghdwechat.php b/application/app/controller/Ghdwechat.php new file mode 100644 index 0000000..f4db8b1 --- /dev/null +++ b/application/app/controller/Ghdwechat.php @@ -0,0 +1,388 @@ +Appid='wxa75a76964ae7ce73'; + $this->Appsecret='e14af51b729cabdbb232147ce9ad8b30'; + // $this->Mch_id='1611903889'; + // $this->Key='b046hjZnS6ioMacttGA66ffae887e55f'; + $this->TokenKey='ghd340u20k4se309sa'; + } + /********************************* 首页 *********************************/ + /** + *查询资讯列表 + */ + public function selectRealtimeInfoList(Request $request){ + $post=$request->param(); + /* if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + }*/ + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 20;//每页条数 + // 查询列表 + $res = Db::name('wechat_real_time_info') + ->field('title_plain,thumbnail,excerpt_plain,url') + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $result = array(); + $result['lists'] =$res->items(); + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 + // $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + /********************************* 首页 *********************************/ + /********************************* 计算 *********************************/ + /*** + *计算 + **/ + public function calculate(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + } + if(!isset($post['name']) || empty($post['name']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入姓名"; + return json_encode($result); + } + if(!isset($post['age']) || empty($post['age']) || !is_numeric($post['age'])){ + $result['erro'] = -1; + $result['msg'] = "未传入年龄"; + return json_encode($result); + } + if(!isset($post['height']) || empty($post['height']) || !is_numeric($post['height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入身高"; + return json_encode($result); + } + if(!isset($post['bone_age']) || empty($post['bone_age']) || !is_numeric($post['bone_age'])){ + $result['erro'] = -1; + $result['msg'] = "未传入骨龄"; + return json_encode($result); + } + if(!isset($post['father_height']) || empty($post['father_height']) || !is_numeric($post['father_height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入父亲身高"; + return json_encode($result); + } + if(!isset($post['mother_height']) || empty($post['mother_height']) || !is_numeric($post['mother_height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入母亲身高"; + return json_encode($result); + } + if(!isset($post['LH']) || empty($post['LH']) || !is_numeric($post['LH'])){ + $result['erro'] = -1; + $result['msg'] = "未传入LH或数据格式不对"; + return json_encode($result); + } + if(!isset($post['IGF']) || empty($post['IGF']) || !is_numeric($post['IGF'])){ + $result['erro'] = -1; + $result['msg'] = "未传入IGF或数据格式不对"; + return json_encode($result); + } + //子宫厚度 + if(!isset($post['uterus_thickness']) || empty($post['uterus_thickness']) || !is_numeric($post['uterus_thickness'])){ + $result['erro'] = -1; + $result['msg'] = "未传入uterus_thickness或数据格式不对"; + return json_encode($result); + } + + //计算 + //计算公式 P= (exp(-5.908+0.008*IGF-1+2.146*LH+0.286*子宫(厚)))/(1 + exp(-5.908+0.008*IGF-1+2.146*LH+0.286*子宫(厚))) + $exp = exp(-5.908 + 0.008*$post['IGF'] + 2.146*$post['LH'] + 0.286*$post['uterus_thickness']); + $probability = $exp / (1 + $exp); + + //保存记录数据 + $data=[]; + $data['id']=md5(time().rand(100000,999999)); + $data['uid']=$post['uid']; + $data['name']=$post['name']; + $data['age']=$post['age']; + $data['height']=$post['height']; + $data['bone_age']=$post['bone_age']; + $data['father_height']=$post['father_height']; + $data['mother_height']=$post['mother_height']; + $data['IGF']=$post['IGF']; + $data['LH']=$post['LH']; + $data['uterus_thickness']=$post['uterus_thickness']; + $data['calculate_resutlt']=round($probability,3); + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_calculate_record')->insert($data); + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "计算失败"; + return json_encode($result); + }else{ + $result['erro'] = 0; + $result['msg'] = "计算成功"; + $result['calculate_resutlt'] = $data['calculate_resutlt']; + return json_encode($result); + } + } + /** + *查询历史记录列表 + */ + public function selectRecordList(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + } + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + // 查询列表 + $res = Db::name('wechat_calculate_record') + ->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time') + ->where('uid',$post['uid']) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $result = array(); + $result['lists'] =$res->items(); + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 + // $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + /** + *删除历史记录 + */ + public function deleteRecord(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json($result); + } + if(!isset($post['id']) || empty($post['id']) ){ + $result['erro'] = -1; + $result['msg'] = "请选择要删除的记录"; + return json($result); + } + $id=Db::name('wechat_calculate_record')->where('id',$post['id'])->where('uid',$post['uid'])->value('id'); + if(empty($id)){ + $result['erro'] = -1; + $result['msg'] = "该记录异常,无法删除"; + return json($result); + } + $res=Db::name('wechat_calculate_record')->where('id',$id)->delete(); + if($res > 0){ + $result['erro'] = 0; + $result['msg'] = '删除成功'; + }else{ + $result['erro'] = -1; + $result['msg'] = '删除失败'; + } + return json($result); + } + /********************************* 计算 *********************************/ + /********************************* 登录 *********************************/ + /** + *小程序授权登录,获取微信用户信息 + * code: wx.login()获取到的code + * encryptedData:wx.getUserInfo获取到的encryptedData + * iv:wx.getUserInfo获取到的iv + */ + public function wechatLogin(Request $request){ + $post=$request->param(); + if(!isset($post['code']) || empty($post['code'])){ + $result['erro'] = -1; + $result['msg'] = "未传入code"; + return json_encode($result); + } + if(!isset($post['encryptedData']) || empty($post['encryptedData'])){ + $result['erro'] = -1; + $result['msg'] = "未传入encryptedData"; + return json_encode($result); + } + if(!isset($post['iv']) || empty($post['iv'])){ + $result['erro'] = -1; + $result['msg'] = "未传入iv"; + return json_encode($result); + } + + $encryptedData =$post['encryptedData']; + $iv = $post['iv']; + $code=$post['code']; + $URL = "https://api.weixin.qq.com/sns/jscode2session?appid=".$this->Appid."&secret=".$this->Appsecret."&js_code=$code&grant_type=authorization_code"; + $apiData=json_decode($this->httpGet($URL),true); + // $apiData=['session_key'=>'dsQb6qITD2CZyBilb22dag==','openid'=>'oXcSb66vSO0_aGbL0NXJ_cxXnt5g']; + // var_dump($apiData); + if(!isset($apiData['errcode'])){ + $sessionKey =$apiData['session_key'];//$post['sessionKey'];// + $errCode =$this->decryptData($sessionKey,$this->Appid,$encryptedData, $iv, $data ); + // LogUtils::error('小程序解析:'.$data, __METHOD__); + if ($errCode == 0) { + //保存用户信息 + $record=json_decode($data,true); + $res=$this->saveUseInfor($record); + return json_encode($res); + } else { + //LogUtils::error('解析数据错误:'.$errCode, __METHOD__); + $result['erro'] = -1; + $result['msg'] = "解析接口返回数据失败,请重试!"; + return json_encode($result); + } + }else{ + // LogUtils::error('错误码:'.$apiData['errcode'].',错误信息:'.$apiData['errmsg'], __METHOD__); + $result['erro'] = -1; + $result['msg'] = $apiData['errmsg'];//'获取信息失败' + return json_encode($result); + } + } + + /** + *保存用户的信息 + */ + private function saveUseInfor($record){ + $data=array(); + //用户昵称 + $data['nickname']=$record['nickName']; + //用户头像 + $data['headimg']=$record['avatarUrl']; + //var_dump(strlen($data['headimg'])); + //是否已经保存信息 + $rec=Db::name('ghd_wechat_user')->field('uid')->where('openid',$record['openId'])->find(); + + if(empty($rec)){ + //用户openid + $data['openid']=$record['openId']; + //时间 + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_user')->insertGetId($data); + $uid=$res; + }else{ + $res=Db::name('wechat_user')->where('uid',$rec['uid'])->update($data); + $uid=$rec['uid']; + } + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "保存信息失败"; + return $result; + }else{ + $result['erro'] = 0; + $result['msg'] = "登录成功"; + $result['uid'] = $uid; + return $result; + } + } + + /** + *获取访问令牌 + */ + public function getToken(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid'])){ + $result['erro'] = -1; + $result['msg'] = "未传登录用户id"; + return json_encode($result); + } + if(!isset($post['phone']) || empty($post['phone'])){ + $result['erro'] = -1; + $result['msg'] = "未传登录用户账号"; + return json_encode($result); + } + $arr=array(); + $arr['phone']=$post['phone']; + $arr['status']=1; + $res=Db::name('accounthosting')->where($arr)->value('id'); + if($res != $post['uid']){ + $result['erro'] = -1; + $result['msg'] = "账号异常"; + return json_encode($result); + } + $result['erro'] = 0; + $result['msg'] = "登录成功"; + $result['token']=$this->authcode($post['uid'].'_'.time(),'ENCODE',$this->TokenKey,60*60*3); + return json_encode($result); + } + /** + *检测令牌是否有效 + */ + private function checkToken($token,$uid){ + $res=$this->authcode($token,'DECODE',$this->TokenKey,60*60*3); + //失效过期 + if(empty($res)){ + return false; + }else{ + $data=explode('_',$res); + //不正确 + if($data[0] == $uid){ + return true; + }else{ + return false; + } + } + } + /********************************* 登录 *********************************/ + /********************************* 我的 *********************************/ + /** + *基本信息 + */ + public function getUserBaseInfo(Request $request){ + $post=$request->param(); + if(!isset($post['version_number']) || empty($post['version_number'])){ + $result['erro'] = -1; + $result['msg'] = "未传入版本号"; + return json_encode($result); + } + switch($post['version_number']){ + case '1.0.0': + return $this->getUserBaseInfo_1_0_0($post); + break; + default: + return $this->getUserBaseInfo_1_0_0($post); + break; + } + } + private function getUserBaseInfo_1_0_0($post){ + if(!isset($post['uid']) || empty($post['uid'])){ + $result['erro'] = -1; + $result['msg'] = "未传入登录人id"; + return json_encode($result); + } + if(!isset($post['token']) || empty($post['token'])){ + $result['erro'] = -1; + $result['msg'] = "未传入token"; + return json_encode($result); + } + if($this->checkToken($post['token'],$post['uid']) === false){ + $result['erro'] = -1; + $result['msg'] = "token异常"; + return json_encode($result); + } + $result['infor']=Db::name('accounthosting')->field('name,headimg,balance')->where('id',$post['uid'])->find(); + $result['erro'] = 0; + $result['msg'] = "获取数据成功"; + return json_encode($result); + } + +} +?> \ No newline at end of file diff --git a/application/app/controller/Ruilaiwechat.php b/application/app/controller/Ruilaiwechat.php new file mode 100644 index 0000000..6284169 --- /dev/null +++ b/application/app/controller/Ruilaiwechat.php @@ -0,0 +1,388 @@ +Appid='wx0847525a15342a46'; + $this->Appsecret='71cf8c524580ba6b262e6dc52d44da4c'; + // $this->Mch_id='1611903889'; + // $this->Key='b046hjZnS6ioMacttGA66ffae887e55f'; + $this->TokenKey='ruilai340u20k4'; + } + /********************************* 首页 *********************************/ + /** + *查询资讯列表 + */ + public function selectRealtimeInfoList(Request $request){ + $post=$request->param(); + /* if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + }*/ + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 20;//每页条数 + // 查询列表 + $res = Db::name('wechat_real_time_info') + ->field('title_plain,thumbnail,excerpt_plain,url') + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $result = array(); + $result['lists'] =$res->items(); + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 + // $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + /********************************* 首页 *********************************/ + /********************************* 计算 *********************************/ + /*** + *计算 + **/ + public function calculate(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + } + if(!isset($post['name']) || empty($post['name']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入姓名"; + return json_encode($result); + } + if(!isset($post['age']) || empty($post['age']) || !is_numeric($post['age'])){ + $result['erro'] = -1; + $result['msg'] = "未传入年龄"; + return json_encode($result); + } + if(!isset($post['height']) || empty($post['height']) || !is_numeric($post['height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入身高"; + return json_encode($result); + } + if(!isset($post['bone_age']) || empty($post['bone_age']) || !is_numeric($post['bone_age'])){ + $result['erro'] = -1; + $result['msg'] = "未传入骨龄"; + return json_encode($result); + } + if(!isset($post['father_height']) || empty($post['father_height']) || !is_numeric($post['father_height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入父亲身高"; + return json_encode($result); + } + if(!isset($post['mother_height']) || empty($post['mother_height']) || !is_numeric($post['mother_height'])){ + $result['erro'] = -1; + $result['msg'] = "未传入母亲身高"; + return json_encode($result); + } + if(!isset($post['LH']) || empty($post['LH']) || !is_numeric($post['LH'])){ + $result['erro'] = -1; + $result['msg'] = "未传入LH或数据格式不对"; + return json_encode($result); + } + if(!isset($post['IGF']) || empty($post['IGF']) || !is_numeric($post['IGF'])){ + $result['erro'] = -1; + $result['msg'] = "未传入IGF或数据格式不对"; + return json_encode($result); + } + //子宫厚度 + if(!isset($post['uterus_thickness']) || empty($post['uterus_thickness']) || !is_numeric($post['uterus_thickness'])){ + $result['erro'] = -1; + $result['msg'] = "未传入uterus_thickness或数据格式不对"; + return json_encode($result); + } + + //计算 + //计算公式 P= (exp(-5.908+0.008*IGF-1+2.146*LH+0.286*子宫(厚)))/(1 + exp(-5.908+0.008*IGF-1+2.146*LH+0.286*子宫(厚))) + $exp = exp(-5.908 + 0.008*$post['IGF'] + 2.146*$post['LH'] + 0.286*$post['uterus_thickness']); + $probability = $exp / (1 + $exp); + + //保存记录数据 + $data=[]; + $data['id']=md5(time().rand(100000,999999)); + $data['uid']=$post['uid']; + $data['name']=$post['name']; + $data['age']=$post['age']; + $data['height']=$post['height']; + $data['bone_age']=$post['bone_age']; + $data['father_height']=$post['father_height']; + $data['mother_height']=$post['mother_height']; + $data['IGF']=$post['IGF']; + $data['LH']=$post['LH']; + $data['uterus_thickness']=$post['uterus_thickness']; + $data['calculate_resutlt']=round($probability,3); + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_calculate_record')->insert($data); + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "计算失败"; + return json_encode($result); + }else{ + $result['erro'] = 0; + $result['msg'] = "计算成功"; + $result['calculate_resutlt'] = $data['calculate_resutlt']; + return json_encode($result); + } + } + /** + *查询历史记录列表 + */ + public function selectRecordList(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json_encode($result); + } + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + // 查询列表 + $res = Db::name('wechat_calculate_record') + ->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time') + ->where('uid',$post['uid']) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + + $result = array(); + $result['lists'] =$res->items(); + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 + // $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + /** + *删除历史记录 + */ + public function deleteRecord(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入用户id"; + return json($result); + } + if(!isset($post['id']) || empty($post['id']) ){ + $result['erro'] = -1; + $result['msg'] = "请选择要删除的记录"; + return json($result); + } + $id=Db::name('wechat_calculate_record')->where('id',$post['id'])->where('uid',$post['uid'])->value('id'); + if(empty($id)){ + $result['erro'] = -1; + $result['msg'] = "该记录异常,无法删除"; + return json($result); + } + $res=Db::name('wechat_calculate_record')->where('id',$id)->delete(); + if($res > 0){ + $result['erro'] = 0; + $result['msg'] = '删除成功'; + }else{ + $result['erro'] = -1; + $result['msg'] = '删除失败'; + } + return json($result); + } + /********************************* 计算 *********************************/ + /********************************* 登录 *********************************/ + /** + *小程序授权登录,获取微信用户信息 + * code: wx.login()获取到的code + * encryptedData:wx.getUserInfo获取到的encryptedData + * iv:wx.getUserInfo获取到的iv + */ + public function wechatLogin(Request $request){ + $post=$request->param(); + if(!isset($post['code']) || empty($post['code'])){ + $result['erro'] = -1; + $result['msg'] = "未传入code"; + return json_encode($result); + } + if(!isset($post['encryptedData']) || empty($post['encryptedData'])){ + $result['erro'] = -1; + $result['msg'] = "未传入encryptedData"; + return json_encode($result); + } + if(!isset($post['iv']) || empty($post['iv'])){ + $result['erro'] = -1; + $result['msg'] = "未传入iv"; + return json_encode($result); + } + + $encryptedData =$post['encryptedData']; + $iv = $post['iv']; + $code=$post['code']; + $URL = "https://api.weixin.qq.com/sns/jscode2session?appid=".$this->Appid."&secret=".$this->Appsecret."&js_code=$code&grant_type=authorization_code"; + $apiData=json_decode($this->httpGet($URL),true); + // $apiData=['session_key'=>'dsQb6qITD2CZyBilb22dag==','openid'=>'oXcSb66vSO0_aGbL0NXJ_cxXnt5g']; + // var_dump($apiData); + if(!isset($apiData['errcode'])){ + $sessionKey =$apiData['session_key'];//$post['sessionKey'];// + $errCode =$this->decryptData($sessionKey,$this->Appid,$encryptedData, $iv, $data ); + // LogUtils::error('小程序解析:'.$data, __METHOD__); + if ($errCode == 0) { + //保存用户信息 + $record=json_decode($data,true); + $res=$this->saveUseInfor($record); + return json_encode($res); + } else { + //LogUtils::error('解析数据错误:'.$errCode, __METHOD__); + $result['erro'] = -1; + $result['msg'] = "解析接口返回数据失败,请重试!"; + return json_encode($result); + } + }else{ + // LogUtils::error('错误码:'.$apiData['errcode'].',错误信息:'.$apiData['errmsg'], __METHOD__); + $result['erro'] = -1; + $result['msg'] = $apiData['errmsg'];//'获取信息失败' + return json_encode($result); + } + } + + /** + *保存用户的信息 + */ + private function saveUseInfor($record){ + $data=array(); + //用户昵称 + $data['nickname']=$record['nickName']; + //用户头像 + $data['headimg']=$record['avatarUrl']; + //var_dump(strlen($data['headimg'])); + //是否已经保存信息 + $rec=Db::name('wechat_user')->field('uid')->where('openid',$record['openId'])->find(); + + if(empty($rec)){ + //用户openid + $data['openid']=$record['openId']; + //时间 + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_user')->insertGetId($data); + $uid=$res; + }else{ + $res=Db::name('wechat_user')->where('uid',$rec['uid'])->update($data); + $uid=$rec['uid']; + } + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "保存信息失败"; + return $result; + }else{ + $result['erro'] = 0; + $result['msg'] = "登录成功"; + $result['uid'] = $uid; + return $result; + } + } + + /** + *获取访问令牌 + */ + public function getToken(Request $request){ + $post=$request->param(); + if(!isset($post['uid']) || empty($post['uid'])){ + $result['erro'] = -1; + $result['msg'] = "未传登录用户id"; + return json_encode($result); + } + if(!isset($post['phone']) || empty($post['phone'])){ + $result['erro'] = -1; + $result['msg'] = "未传登录用户账号"; + return json_encode($result); + } + $arr=array(); + $arr['phone']=$post['phone']; + $arr['status']=1; + $res=Db::name('accounthosting')->where($arr)->value('id'); + if($res != $post['uid']){ + $result['erro'] = -1; + $result['msg'] = "账号异常"; + return json_encode($result); + } + $result['erro'] = 0; + $result['msg'] = "登录成功"; + $result['token']=$this->authcode($post['uid'].'_'.time(),'ENCODE',$this->TokenKey,60*60*3); + return json_encode($result); + } + /** + *检测令牌是否有效 + */ + private function checkToken($token,$uid){ + $res=$this->authcode($token,'DECODE',$this->TokenKey,60*60*3); + //失效过期 + if(empty($res)){ + return false; + }else{ + $data=explode('_',$res); + //不正确 + if($data[0] == $uid){ + return true; + }else{ + return false; + } + } + } + /********************************* 登录 *********************************/ + /********************************* 我的 *********************************/ + /** + *基本信息 + */ + public function getUserBaseInfo(Request $request){ + $post=$request->param(); + if(!isset($post['version_number']) || empty($post['version_number'])){ + $result['erro'] = -1; + $result['msg'] = "未传入版本号"; + return json_encode($result); + } + switch($post['version_number']){ + case '1.0.0': + return $this->getUserBaseInfo_1_0_0($post); + break; + default: + return $this->getUserBaseInfo_1_0_0($post); + break; + } + } + private function getUserBaseInfo_1_0_0($post){ + if(!isset($post['uid']) || empty($post['uid'])){ + $result['erro'] = -1; + $result['msg'] = "未传入登录人id"; + return json_encode($result); + } + if(!isset($post['token']) || empty($post['token'])){ + $result['erro'] = -1; + $result['msg'] = "未传入token"; + return json_encode($result); + } + if($this->checkToken($post['token'],$post['uid']) === false){ + $result['erro'] = -1; + $result['msg'] = "token异常"; + return json_encode($result); + } + $result['infor']=Db::name('accounthosting')->field('name,headimg,balance')->where('id',$post['uid'])->find(); + $result['erro'] = 0; + $result['msg'] = "获取数据成功"; + return json_encode($result); + } + +} +?> \ No newline at end of file diff --git a/application/command.php b/application/command.php new file mode 100755 index 0000000..91b13c1 --- /dev/null +++ b/application/command.php @@ -0,0 +1,12 @@ + +// +---------------------------------------------------------------------- + +return []; diff --git a/application/common.php b/application/common.php new file mode 100755 index 0000000..6168db1 --- /dev/null +++ b/application/common.php @@ -0,0 +1,12 @@ + +// +---------------------------------------------------------------------- + +// 应用公共文件 diff --git a/application/config.php b/application/config.php new file mode 100755 index 0000000..27bb225 --- /dev/null +++ b/application/config.php @@ -0,0 +1,241 @@ + +// +---------------------------------------------------------------------- + +return [ + // +---------------------------------------------------------------------- + // | 应用设置 + // +---------------------------------------------------------------------- + + // 应用命名空间 + 'app_namespace' => 'app', + // 应用调试模式 + 'app_debug' => true, + // 应用Trace + 'app_trace' => false, + // 应用模式状态 + 'app_status' => '', + // 是否支持多模块 + 'app_multi_module' => true, + // 入口自动绑定模块 + 'auto_bind_module' => false, + // 注册的根命名空间 + 'root_namespace' => [], + // 扩展函数文件 + 'extra_file_list' => [THINK_PATH . 'helper' . EXT], + // 默认输出类型 + 'default_return_type' => 'html', + // 默认AJAX 数据返回格式,可选json xml ... + 'default_ajax_return' => 'json', + // 默认JSONP格式返回的处理方法 + 'default_jsonp_handler' => 'jsonpReturn', + // 默认JSONP处理方法 + 'var_jsonp_handler' => 'callback', + // 默认时区 + 'default_timezone' => 'PRC', + // 是否开启多语言 + 'lang_switch_on' => false, + // 默认全局过滤方法 用逗号分隔多个 + 'default_filter' => '', + // 默认语言 + 'default_lang' => 'zh-cn', + // 应用类库后缀 + 'class_suffix' => false, + // 控制器类后缀 + 'controller_suffix' => false, + + // +---------------------------------------------------------------------- + // | 模块设置 + // +---------------------------------------------------------------------- + + // 默认模块名 + 'default_module' => 'index', + // 禁止访问模块 + 'deny_module_list' => ['common'], + // 默认控制器名 + 'default_controller' => 'Index', + // 默认操作名 + 'default_action' => 'index', + // 默认验证器 + 'default_validate' => '', + // 默认的空控制器名 + 'empty_controller' => 'Error', + // 操作方法后缀 + 'action_suffix' => '', + // 自动搜索控制器 + 'controller_auto_search' => false, + + // +---------------------------------------------------------------------- + // | URL设置 + // +---------------------------------------------------------------------- + + // PATHINFO变量名 用于兼容模式 + 'var_pathinfo' => 's', + // 兼容PATH_INFO获取 + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], + // pathinfo分隔符 + 'pathinfo_depr' => '/', + // URL伪静态后缀 + 'url_html_suffix' => 'html', + // URL普通方式参数 用于自动生成 + 'url_common_param' => false, + // URL参数方式 0 按名称成对解析 1 按顺序解析 + 'url_param_type' => 0, + // 是否开启路由 + 'url_route_on' => true, + // 路由使用完整匹配 + 'route_complete_match' => false, + // 路由配置文件(支持配置多个) + 'route_config_file' => ['route'], + // 是否强制使用路由 + 'url_route_must' => false, + // 域名部署 + 'url_domain_deploy' => false, + // 域名根,如thinkphp.cn + 'url_domain_root' => '', + // 是否自动转换URL中的控制器和操作名 + 'url_convert' => true, + // 默认的访问控制器层 + 'url_controller_layer' => 'controller', + // 表单请求类型伪装变量 + 'var_method' => '_method', + // 表单ajax伪装变量 + 'var_ajax' => '_ajax', + // 表单pjax伪装变量 + 'var_pjax' => '_pjax', + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 + 'request_cache' => false, + // 请求缓存有效期 + 'request_cache_expire' => null, + // 全局请求缓存排除规则 + 'request_cache_except' => [], + + // +---------------------------------------------------------------------- + // | 模板设置 + // +---------------------------------------------------------------------- + + 'template' => [ + // 模板引擎类型 支持 php think 支持扩展 + 'type' => 'Think', + // 模板路径 + 'view_path' => '', + // 模板后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DS, + // 模板引擎普通标签开始标记 + 'tpl_begin' => '{', + // 模板引擎普通标签结束标记 + 'tpl_end' => '}', + // 标签库标签开始标记 + 'taglib_begin' => '{', + // 标签库标签结束标记 + 'taglib_end' => '}', + ], + + // 视图输出字符串内容替换 + 'view_replace_str' => [], + // 默认跳转页面对应的模板文件 + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + + // +---------------------------------------------------------------------- + // | 异常及错误设置 + // +---------------------------------------------------------------------- + + // 异常页面的模板文件 + 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', + + // 错误显示信息,非调试模式有效 + 'error_message' => '页面错误!请稍后再试~', + // 显示错误信息 + 'show_error_msg' => false, + // 异常处理handle类 留空使用 \think\exception\Handle + 'exception_handle' => '', + + // +---------------------------------------------------------------------- + // | 日志设置 + // +---------------------------------------------------------------------- + + 'log' => [ + // 日志记录方式,内置 file socket 支持扩展 + 'type' => 'File', + // 日志保存目录 + 'path' => LOG_PATH, + // 日志记录级别 + 'level' => [], + ], + + // +---------------------------------------------------------------------- + // | Trace设置 开启 app_trace 后 有效 + // +---------------------------------------------------------------------- + 'trace' => [ + // 内置Html Console 支持扩展 + 'type' => 'Html', + ], + + // +---------------------------------------------------------------------- + // | 缓存设置 + // +---------------------------------------------------------------------- + + 'cache' => [ + // 驱动方式 + 'type' => 'File', + // 缓存保存目录 + 'path' => CACHE_PATH, + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, + ], + + // +---------------------------------------------------------------------- + // | 会话设置 + // +---------------------------------------------------------------------- + + 'session' => [ + 'id' => '', + // SESSION_ID的提交变量,解决flash上传跨域 + 'var_session_id' => '', + // SESSION 前缀 + 'prefix' => 'think', + // 驱动方式 支持redis memcache memcached + 'type' => '', + // 是否自动开启 SESSION + 'auto_start' => true, + ], + + // +---------------------------------------------------------------------- + // | Cookie设置 + // +---------------------------------------------------------------------- + 'cookie' => [ + // cookie 名称前缀 + 'prefix' => '', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => '', + // 是否使用 setcookie + 'setcookie' => true, + ], + + //分页配置 + 'paginate' => [ + 'type' => 'bootstrap', + 'var_page' => 'page', + 'list_rows' => 15, + ], +]; diff --git a/application/database.php b/application/database.php new file mode 100755 index 0000000..8f91151 --- /dev/null +++ b/application/database.php @@ -0,0 +1,53 @@ + +// +---------------------------------------------------------------------- + +return [ + // 数据库类型 + 'type' => 'mysql', + // 服务器地址 + 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => 'ruilai', + // 用户名 + 'username' => 'rootrui', + // 密码 + 'password' => 'X2)jB+k%YH.p', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => 't_sys_', + // 数据库调试模式 + 'debug' => true, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据集返回类型 + 'resultset_type' => 'array', + // 自动写入时间戳字段 + 'auto_timestamp' => false, + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + // 是否需要进行SQL性能分析 + 'sql_explain' => false, +]; diff --git a/application/extra/queue.php b/application/extra/queue.php new file mode 100755 index 0000000..9223ef6 --- /dev/null +++ b/application/extra/queue.php @@ -0,0 +1,14 @@ + +// +---------------------------------------------------------------------- + +return [ + 'connector' => 'Sync' +]; diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php new file mode 100755 index 0000000..49233e1 --- /dev/null +++ b/application/index/controller/Index.php @@ -0,0 +1,12 @@ +*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5
十年磨一剑 - 为API开发设计的高性能框架

[ V5.0 版本由 七牛云 独家赞助发布 ]
'; + + } +} diff --git a/application/index/controller/Privacy.php b/application/index/controller/Privacy.php new file mode 100644 index 0000000..a4e8b2b --- /dev/null +++ b/application/index/controller/Privacy.php @@ -0,0 +1,11 @@ + + + + + + 西安瑞来兹软件科技有限公司 - 专注数字化转型解决方案 + + + + + + + + + + + +
+ +
+ + +
+ +
+ + +
+
+
+
+

关于我们

+

我们是一家专注于数字化转型解决方案的科技公司,致力于为企业提供创新的技术服务和产品。

+
+
+
10+
+
年行业经验
+
+
+
200+
+
成功案例
+
+
+
50+
+
专业团队
+
+
+
+
+
+
+ + +
+
+

产品服务

+
+
+
💻
+
+

网站开发

+

定制化网站开发服务

+
+
+
+
📊
+
+

数据分析

+

专业的数据分析解决方案

+
+
+
+
📱
+
+

移动应用开发

+

跨平台移动应用开发服务

+
+
+
+
+
+ + +
+
+

成功案例

+
+
+ 案例1 +
+

案例1

+

案例描述...

+
+
+
+ 案例2 +
+

案例2

+

案例描述...

+
+
+
+ 案例2 +
+

案例2

+

案例描述...

+
+
+
+
+
+ + + + + +
+
+

联系我们

+
+
+

联系方式

+
    +
  • 地址:陕西省西安市高新区科技二路65号启迪科技园D座9楼10901号
  • +
  • 电话:18691577328
  • +
  • 邮箱:info@example.com
  • +
+ +
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ + + + + + + + diff --git a/application/index/view/privacy/privacy.html b/application/index/view/privacy/privacy.html new file mode 100644 index 0000000..e817e14 --- /dev/null +++ b/application/index/view/privacy/privacy.html @@ -0,0 +1,89 @@ + + + + + + + 隐私协议 + + + + + + + + \ No newline at end of file diff --git a/application/route.php b/application/route.php new file mode 100755 index 0000000..b646c8d --- /dev/null +++ b/application/route.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- + +return [ + '__pattern__' => [ + 'name' => '\w+', + ], + '[hello]' => [ + ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], + ':name' => ['index/hello', ['method' => 'post']], + ], + +]; diff --git a/application/tags.php b/application/tags.php new file mode 100755 index 0000000..8c92cfa --- /dev/null +++ b/application/tags.php @@ -0,0 +1,28 @@ + +// +---------------------------------------------------------------------- + +// 应用行为扩展定义文件 +return [ + // 应用初始化 + 'app_init' => [], + // 应用开始 + 'app_begin' => [], + // 模块初始化 + 'module_init' => [], + // 操作开始执行 + 'action_begin' => [], + // 视图内容过滤 + 'view_filter' => [], + // 日志写入 + 'log_write' => [], + // 应用结束 + 'app_end' => [], +]; diff --git a/build.php b/build.php new file mode 100755 index 0000000..d63be3a --- /dev/null +++ b/build.php @@ -0,0 +1,25 @@ + +// +---------------------------------------------------------------------- + +return [ + // 生成应用公共文件 + '__file__' => ['common.php', 'config.php', 'database.php'], + + // 定义demo模块的自动生成 (按照实际定义的文件名生成) + 'demo' => [ + '__file__' => ['common.php'], + '__dir__' => ['behavior', 'controller', 'model', 'view'], + 'controller' => ['Index', 'Test', 'UserType'], + 'model' => ['User', 'UserType'], + 'view' => ['index/index'], + ], + // 其他更多的模块定义 +]; diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..fbc118f --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "http://thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "topthink/framework": "5.0.*" + }, + "autoload": { + "psr-4": { + "app\\": "application" + } + }, + "extra": { + "think-path": "thinkphp" + }, + "config": { + "preferred-install": "dist" + } +} diff --git a/extend/.gitignore b/extend/.gitignore new file mode 100755 index 0000000..a3a0c8b --- /dev/null +++ b/extend/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess new file mode 100755 index 0000000..3f3c334 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,9 @@ + + Options +FollowSymlinks -Multiviews + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + #RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] + RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] + \ No newline at end of file diff --git a/public/.user.ini b/public/.user.ini new file mode 100644 index 0000000..972d7d2 --- /dev/null +++ b/public/.user.ini @@ -0,0 +1 @@ +open_basedir=/www/wwwroot/code/:/tmp/ \ No newline at end of file diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100755 index 0000000..e71815a Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.php b/public/index.php new file mode 100755 index 0000000..cd1db18 --- /dev/null +++ b/public/index.php @@ -0,0 +1,17 @@ + +// +---------------------------------------------------------------------- + +// [ 应用入口文件 ] + +// 定义应用目录 +define('APP_PATH', __DIR__ . '/../application/'); +// 加载框架引导文件 +require __DIR__ . '/../thinkphp/start.php'; diff --git a/public/nginx.htaccess b/public/nginx.htaccess new file mode 100644 index 0000000..17115fe --- /dev/null +++ b/public/nginx.htaccess @@ -0,0 +1,7 @@ +try_files $uri $uri/ /index.php?$args; #去掉index.php + location / { + if (!-e $request_filename){ + rewrite ^/(.*)$ /index.php?s=/$1 last; + } + + } \ No newline at end of file diff --git a/public/robots.txt b/public/robots.txt new file mode 100755 index 0000000..a82d96e --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/public/router.php b/public/router.php new file mode 100755 index 0000000..257bcc8 --- /dev/null +++ b/public/router.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { + return false; +} else { + if (!isset($_SERVER['PATH_INFO'])) { + $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI']; + } + require __DIR__ . "/index.php"; +} diff --git a/public/static/.gitignore b/public/static/.gitignore new file mode 100755 index 0000000..a3a0c8b --- /dev/null +++ b/public/static/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/public/uploads/2024/06/04/171751114021497.jpg b/public/uploads/2024/06/04/171751114021497.jpg new file mode 100644 index 0000000..da13bcc Binary files /dev/null and b/public/uploads/2024/06/04/171751114021497.jpg differ diff --git a/public/uploads/2024/06/04/171751137371153.jpg b/public/uploads/2024/06/04/171751137371153.jpg new file mode 100644 index 0000000..da13bcc Binary files /dev/null and b/public/uploads/2024/06/04/171751137371153.jpg differ diff --git a/public/uploads/2024/06/04/171751144117605.jpg b/public/uploads/2024/06/04/171751144117605.jpg new file mode 100644 index 0000000..da13bcc Binary files /dev/null and b/public/uploads/2024/06/04/171751144117605.jpg differ diff --git a/public/uploads/2024/06/10/171803135769789.png b/public/uploads/2024/06/10/171803135769789.png new file mode 100644 index 0000000..b2f53ed Binary files /dev/null and b/public/uploads/2024/06/10/171803135769789.png differ diff --git a/public/uploads/2025/03/15/174201503080418.jpeg b/public/uploads/2025/03/15/174201503080418.jpeg new file mode 100644 index 0000000..00b27b3 Binary files /dev/null and b/public/uploads/2025/03/15/174201503080418.jpeg differ diff --git a/runtime/.gitignore b/runtime/.gitignore new file mode 100755 index 0000000..a3a0c8b --- /dev/null +++ b/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/think b/think new file mode 100755 index 0000000..1a31deb --- /dev/null +++ b/think @@ -0,0 +1,17 @@ +#!/usr/bin/env php + +// +---------------------------------------------------------------------- + +// 定义项目路径 +define('APP_PATH', __DIR__ . '/application/'); + +// 加载框架引导文件 +require __DIR__.'/thinkphp/console.php'; diff --git a/vendor/.gitignore b/vendor/.gitignore new file mode 100755 index 0000000..a3a0c8b --- /dev/null +++ b/vendor/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file