控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Formguide.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 表单模型
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\model\formguide;
  15. use think\Db;
  16. use think\Model;
  17. class Formguide extends Model
  18. {
  19. protected $name = 'ModelField';
  20. protected $autoWriteTimestamp = false;
  21. //
  22. public function getFieldInfo($modelid, $id = null)
  23. {
  24. //完整表名获取
  25. $tablename = $this->getModelTableName($modelid);
  26. $list = self::where('modelid', $modelid)->where('status', 1)->order('listorder asc,id asc')->column("name,title,remark,type,isadd,iscore,ifsystem,ifrequire,setting");
  27. if (!empty($list)) {
  28. if ($id) {
  29. $dataInfo = Db::name($tablename)->where('id', $id)->find();
  30. }
  31. foreach ($list as $key => &$value) {
  32. if ($value['iscore']) {
  33. unset($list[$key]);
  34. }
  35. if (isset($dataInfo[$value['name']])) {
  36. $value['value'] = $dataInfo[$value['name']];
  37. }
  38. $value['setting'] = unserialize($value['setting']);
  39. $value['options'] = $value['setting']['options'];
  40. if ('' != $value['options']) {
  41. $value['options'] = parse_attr($value['options']);
  42. }
  43. if ($value['type'] == 'image' || $value['type'] == 'file') {
  44. $value['value'] = !empty($value['value']) ? '<a href="' . $value['value'] . '" target="_blank">[查看]</a>' : '';
  45. }
  46. if ($value['type'] == 'datetime') {
  47. $value['value'] = empty($value['value']) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $value['value']);
  48. }
  49. }
  50. }
  51. return $list;
  52. }
  53. //删除信息
  54. public function deleteInfo($modelid, $id)
  55. {
  56. //完整表名获取
  57. $tablename = $this->getModelTableName($modelid);
  58. $data = Db::name($tablename)->where('id', $id)->find();
  59. if (empty($data)) {
  60. throw new \Exception("该信息不存在!");
  61. }
  62. return Db::name($tablename)->where('id', $id)->delete();
  63. }
  64. /**
  65. * 根据模型ID,返回表名
  66. * @param type $modelid
  67. * @return string
  68. */
  69. protected function getModelTableName($modelid)
  70. {
  71. //读取模型配置 以后优化缓存形式
  72. $model_cache = cache("Model");
  73. //表名获取
  74. return $model_cache[$modelid]['tablename'];
  75. }
  76. }