file.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?php
  2. /**
  3. * 上传表
  4. * demo: data/upload/upload_name/10000/10/10.thumb_test.jpg
  5. * 基本操作:根据upload上传、保存到pic表,所有保存到pic表的图片,均可参与后续处理操作 
  6. */
  7. # 定义几个常用的选项
  8. $option = array
  9. (
  10. 1 => '启用',
  11. 2 => '关闭',
  12. );
  13. $cate = function()
  14. {
  15. return Dever::db('upload/cate')->state();
  16. };
  17. $upload = function()
  18. {
  19. return Dever::db('upload/upload')->state();
  20. };
  21. return array
  22. (
  23. # 表名
  24. 'name' => 'file',
  25. # 显示给用户看的名称
  26. 'lang' => '资源列表',
  27. 'order' => 9,
  28. 'end' => array
  29. (
  30. //'insert' => 'upload/lib/manage.add_tag',
  31. //'update' => 'upload/lib/manage.add_tag',
  32. ),
  33. /*
  34. # 同步更新另外一个或多个表的数据
  35. 'sync' => array
  36. (
  37. 'upload/file_tag' => array
  38. (
  39. # 更新另外一个表的字段 => 本表的字段
  40. 'where' => array('file_id', 'id'),
  41. # 要更新的数据
  42. 'update' => array('tag_id' => 'tag'),
  43. # 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
  44. 'type' => 'delete',
  45. )
  46. ),*/
  47. # 数据结构
  48. 'struct' => array
  49. (
  50. 'id' => array
  51. (
  52. 'type' => 'int-11',
  53. 'name' => 'ID',
  54. 'default' => '',
  55. 'desc' => '',
  56. 'match' => 'is_numeric',
  57. 'search' => 'order',
  58. //'list' => true,
  59. ),
  60. 'name' => array
  61. (
  62. 'type' => 'varchar-32',
  63. 'name' => '文件名',
  64. 'default' => '',
  65. 'desc' => '请输入文件名',
  66. 'match' => 'is_string',
  67. 'search' => 'fulltext',
  68. //'list' => true,
  69. ),
  70. 'source_name' => array
  71. (
  72. 'type' => 'varchar-200',
  73. 'name' => '原文件名',
  74. 'default' => '',
  75. 'desc' => '请输入原文件名',
  76. 'match' => 'is_string',
  77. 'search' => 'fulltext',
  78. 'list' => true,
  79. ),
  80. 'upload' => array
  81. (
  82. 'type' => 'int-11',
  83. 'name' => '所属资源配置',
  84. 'default' => '1',
  85. 'desc' => '所属资源配置',
  86. 'match' => 'is_numeric',
  87. 'option' => $upload,
  88. //'update' => 'select',
  89. 'search' => 'select',
  90. //'control' => 'type',
  91. //'list' => true,
  92. ),
  93. 'cate' => array
  94. (
  95. 'type' => 'int-11',
  96. 'name' => '所属分类',
  97. 'default' => '1',
  98. 'desc' => '分类',
  99. 'match' => 'is_numeric',
  100. 'option' => $cate,
  101. 'update' => 'select',
  102. 'search' => 'select',
  103. //'control' => 'type',
  104. 'list' => true,
  105. 'edit' => true,
  106. ),
  107. /*
  108. 'tag' => array
  109. (
  110. 'type' => 'text-255',
  111. 'name' => '标签',
  112. 'default' => '',
  113. 'desc' => '标签',
  114. 'match' => 'is_numeric',
  115. 'update' => 'text',
  116. 'search' => 'fulltext',
  117. 'autocomplete' => array('upload/lib/manage.search_tag?json=1', 'id', 'upload/lib/manage.search_tag_by_ids'),
  118. //'control' => 'type',
  119. //'list' => true,
  120. ),
  121. */
  122. 'key' => array
  123. (
  124. 'type' => 'varchar-32',
  125. 'name' => 'key',
  126. 'default' => '',
  127. 'desc' => 'key',
  128. 'match' => 'is_string',
  129. //'search' => 'fulltext',
  130. //'list' => true,
  131. ),
  132. 'search' => array
  133. (
  134. 'type' => 'varchar-100',
  135. 'name' => 'search',
  136. 'default' => '',
  137. 'desc' => 'search',
  138. 'match' => 'is_string',
  139. //'search' => 'fulltext',
  140. //'list' => true,
  141. ),
  142. 'value' => array
  143. (
  144. 'type' => 'varchar-800',
  145. 'name' => '附加值',
  146. 'default' => '',
  147. 'desc' => '附加值',
  148. 'match' => 'is_string',
  149. //'search' => 'fulltext',
  150. //'list' => true,
  151. ),
  152. 'ext' => array
  153. (
  154. 'type' => 'varchar-24',
  155. 'name' => '后缀名',
  156. 'default' => '',
  157. 'desc' => '请输入后缀名',
  158. 'match' => 'is_string',
  159. 'list_name' => '文件信息',
  160. 'list' => 'Dever::load("upload/lib/manage.file", {id})',
  161. ),
  162. 'file' => array
  163. (
  164. 'type' => 'varchar-150',
  165. 'name' => '访问路径',
  166. 'default' => '',
  167. 'desc' => '请输入访问路径',
  168. 'match' => 'is_string',
  169. //'list' => true,
  170. ),
  171. 'yunfile' => array
  172. (
  173. 'type' => 'varchar-150',
  174. 'name' => '云端访问路径',
  175. 'default' => '',
  176. 'desc' => '云端访问路径',
  177. 'match' => 'is_string',
  178. //'list' => true,
  179. ),
  180. 'pic' => array
  181. (
  182. 'type' => 'varchar-150',
  183. 'name' => '封面图-一般为视频截图',
  184. 'default' => '',
  185. 'desc' => '请输入封面图',
  186. 'match' => 'is_string',
  187. //'list' => true,
  188. ),
  189. 'pic_num' => array
  190. (
  191. 'type' => 'int-11',
  192. 'name' => '视频截图的秒数',
  193. 'default' => '',
  194. 'desc' => '视频截图的秒数',
  195. 'match' => 'is_numeric',
  196. //'list' => true,
  197. ),
  198. 'width' => array
  199. (
  200. 'type' => 'int-11',
  201. 'name' => '宽度',
  202. 'default' => '0',
  203. 'desc' => '请输入宽度',
  204. 'match' => 'option',
  205. //'list' => true,
  206. ),
  207. 'height' => array
  208. (
  209. 'type' => 'int-11',
  210. 'name' => '高度',
  211. 'default' => '0',
  212. 'desc' => '请输入高度',
  213. 'match' => 'option',
  214. //'list' => true,
  215. ),
  216. 'size' => array
  217. (
  218. 'type' => 'int-11',
  219. 'name' => '大小',
  220. 'default' => '0',
  221. 'desc' => '请输入大小',
  222. 'match' => 'option',
  223. //'list' => true,
  224. ),
  225. 'state' => array
  226. (
  227. 'type' => 'tinyint-1',
  228. 'name' => '状态',
  229. 'default' => '1',
  230. 'desc' => '请选择状态',
  231. 'match' => 'is_numeric',
  232. ),
  233. 'cdate' => array
  234. (
  235. 'type' => 'int-11',
  236. 'name' => '上传时间',
  237. 'match' => array('is_numeric', time()),
  238. 'desc' => '',
  239. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  240. 'order' => 'desc',
  241. ),
  242. ),
  243. # 索引
  244. 'index' => array
  245. (
  246. # 索引名 => 索引id
  247. 4 => array
  248. (
  249. 'search' => '`key`,cate,search',
  250. 'name' => 'name,upload',
  251. ),
  252. 'version' => 4,
  253. ),
  254. # 更新表结构
  255. 'alter' => array
  256. (
  257. 3 => array
  258. (
  259. array('update', 'upload', 'upload', 'int-11 1 所属资源配置'),
  260. array('update', 'size', 'size', 'varchar-100 文件大小'),
  261. //array('add', 'config', 'config', 'int-11 1 配置'),
  262. ),
  263. 'version' => 3,
  264. ),
  265. 'manage' => array
  266. (
  267. 'insert' => false,
  268. 'delete' => false,
  269. ),
  270. # request 请求接口定义
  271. 'request' => array
  272. (
  273. # info 根据文件名获取数据
  274. 'file' => array
  275. (
  276. 'where' => array
  277. (
  278. 'file' => 'is_string',
  279. ),
  280. 'type' => 'one',
  281. ),
  282. 'name' => array
  283. (
  284. 'where' => array
  285. (
  286. 'name' => 'yes',
  287. 'upload' => 'yes',
  288. ),
  289. 'type' => 'one',
  290. ),
  291. 'getData' => array
  292. (
  293. 'option' => array
  294. (
  295. 'state' => 'yes',
  296. 'upload' => 'yes',
  297. 'cate' => 'yes',
  298. 'search' => 'yes',
  299. 'source_name' => array('yes', 'like'),
  300. //'source_name' => array('yes', 'like', 'and('),
  301. //'name' => array('yes', 'like', 'or)'),
  302. ),
  303. 'order' => array('id' => 'desc'),
  304. 'type' => 'all',
  305. 'page' => array(12, 'list')
  306. ),
  307. )
  308. );