books.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <?php
  2. $audit = Dever::config('base')->audit;
  3. $status = array
  4. (
  5. 1 => '上架',
  6. 2 => '下架',
  7. );
  8. # 常用的col
  9. $col = 'id,name,pic_cover,num_add_view+num_view as num_view,content,buy_link,`desc`';
  10. return array
  11. (
  12. # 表名
  13. 'name' => 'books',
  14. # 显示给用户看的名称
  15. 'lang' => '图书管理',
  16. 'order' => 98,
  17. # 数据结构
  18. 'struct' => array
  19. (
  20. 'id' => array
  21. (
  22. 'type' => 'int-11',
  23. 'name' => 'ID',
  24. 'default' => '',
  25. 'desc' => '',
  26. 'match' => 'is_numeric',
  27. 'list' => true,
  28. ),
  29. 'name' => array
  30. (
  31. 'type' => 'varchar-80',
  32. 'name' => '标题',
  33. 'default' => '',
  34. 'desc' => '标题',
  35. 'match' => 'is_string',
  36. 'update' => 'text',
  37. 'list' => true,
  38. 'search' => 'fulltext',
  39. //增加预览
  40. 'preview' => true,
  41. ),
  42. 'price' => array
  43. (
  44. 'type' => 'varchar-32',
  45. 'name' => '销售价格',
  46. 'default' => '',
  47. 'desc' => '销售价格',
  48. 'match' => 'is_string',
  49. 'update' => 'text',
  50. ),
  51. 'old_price' => array
  52. (
  53. 'type' => 'varchar-32',
  54. 'name' => '原价',
  55. 'default' => '',
  56. 'desc' => '原价',
  57. 'match' => 'is_string',
  58. 'update' => 'text',
  59. ),
  60. 'desc' => array
  61. (
  62. 'type' => 'varchar-500',
  63. 'name' => '摘要',
  64. 'default' => '',
  65. 'desc' => '摘要',
  66. 'match' => 'is_string',
  67. 'update' => 'textarea',
  68. ),
  69. 'buy_link' => array
  70. (
  71. 'type' => 'varchar-500',
  72. 'name' => '购买链接',
  73. 'default' => '',
  74. 'desc' => '购买链接',
  75. 'match' => 'is_string',
  76. 'update' => 'textarea',
  77. ),
  78. 'pic_cover' => array
  79. (
  80. 'type' => 'varchar-150',
  81. 'name' => '1:1封面图-图片尺寸380*380px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
  82. 'default' => '',
  83. 'desc' => '封面图',
  84. 'match' => 'is_string',
  85. 'update' => 'image',
  86. 'key' => '1',
  87. 'place' => '150',
  88. //直接上传到云端
  89. //'upload' => 'qiniu',
  90. //上传大数据
  91. //'large' => true,
  92. ),
  93. 'num_add_view' => array
  94. (
  95. 'type' => 'int-11',
  96. 'name' => '浏览量基数',
  97. 'default' => '0',
  98. 'desc' => '浏览量基数',
  99. 'match' => 'option',
  100. //'update' => 'text',
  101. ),
  102. 'num_view' => array
  103. (
  104. 'type' => 'int-11',
  105. 'name' => '浏览量',
  106. 'default' => '0',
  107. 'desc' => '请填写浏览量',
  108. 'match' => 'option',
  109. 'search' => 'order',
  110. 'list' => '{num_view}+{num_add_view}',
  111. ),
  112. 'pdate' => array
  113. (
  114. 'type' => 'int-11',
  115. 'name' => '发布时间',
  116. 'match' => array('is_numeric', time()),
  117. 'default' => '',
  118. 'desc' => '',
  119. 'update' => 'date',
  120. 'callback' => 'maketime',
  121. 'insert' => true,
  122. //'list' => 'date("Y-m-d H:i:s", {pdate})',
  123. 'auth' => '"{pdate}" > 0',
  124. ),
  125. 'reorder' => array
  126. (
  127. 'type' => 'int-11',
  128. 'name' => '排序(数值越大越靠前)',
  129. 'default' => '1',
  130. 'desc' => '请输入排序',
  131. 'match' => 'option',
  132. 'update' => 'text',
  133. 'search' => 'order',
  134. 'list' => true,
  135. 'order' => 'desc',
  136. 'edit' => true,
  137. ),
  138. 'udate' => array
  139. (
  140. 'type' => 'int-11',
  141. 'name' => '更新时间',
  142. 'match' => array('is_numeric', time()),
  143. 'desc' => '',
  144. ),
  145. 'status' => array
  146. (
  147. 'type' => 'int-11',
  148. 'name' => '状态',
  149. 'default' => '1',
  150. 'desc' => '状态',
  151. 'match' => 'is_numeric',
  152. 'update' => 'radio',
  153. 'option' => $status,
  154. ),
  155. 'state' => array
  156. (
  157. 'type' => 'tinyint-1',
  158. 'name' => '状态',
  159. 'default' => '1',
  160. 'desc' => '请选择状态',
  161. 'match' => 'is_numeric',
  162. ),
  163. 'cdate' => array
  164. (
  165. 'type' => 'int-11',
  166. 'name' => '录入时间',
  167. 'match' => array('is_numeric', time()),
  168. 'desc' => '',
  169. # 只有insert时才生效
  170. 'insert' => true,
  171. ),
  172. ),
  173. # 管理功能
  174. 'manage' => array
  175. (
  176. ),
  177. # request 请求接口定义
  178. 'request' => array
  179. (
  180. 'search' => array
  181. (
  182. # 匹配的正则或函数 选填项
  183. 'option' => array
  184. (
  185. 'ids' => array('yes-id', 'in'),
  186. 'name' => array('yes', 'like'),
  187. 'id' => 'yes',
  188. 'status' => 1,
  189. 'state' => 1,
  190. ),
  191. 'type' => 'all',
  192. 'order' => array('reorder' => 'desc', 'pdate' => 'desc'),
  193. 'limit' => '0,1000',
  194. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  195. ),
  196. 'getAll' => array
  197. (
  198. # 匹配的正则或函数 选填项
  199. 'option' => array
  200. (
  201. 'id' => 'yes',
  202. 'status' => 1,
  203. 'state' => 1,
  204. ),
  205. 'type' => 'all',
  206. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  207. 'page' => array(10, 'list'),
  208. 'col' => $col,
  209. ),
  210. 'getList' => array
  211. (
  212. # 匹配的正则或函数 选填项
  213. 'option' => array
  214. (
  215. 'status' => 1,
  216. 'state' => 1,
  217. ),
  218. 'type' => 'all',
  219. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  220. 'limit' => '0,10',
  221. 'col' => $col,
  222. ),
  223. 'getRelation' => array
  224. (
  225. # 匹配的正则或函数 选填项
  226. 'option' => array
  227. (
  228. 'noid' => array('yes-id', '!='),
  229. 'status' => 1,
  230. 'state' => 1,
  231. ),
  232. 'type' => 'all',
  233. 'order' => array('reorder' => 'desc','pdate' => 'desc'),
  234. 'limit' => '0,4',
  235. 'col' => $col,
  236. ),
  237. 'getOne' => array
  238. (
  239. # 匹配的正则或函数 选填项
  240. 'where' => array
  241. (
  242. 'id' => 'yes',
  243. ),
  244. 'type' => 'one',
  245. 'col' => $col,
  246. ),
  247. # 更新浏览量
  248. 'addView' => array
  249. (
  250. 'type' => 'update',
  251. 'where' => array
  252. (
  253. 'id' => 'yes',
  254. ),
  255. 'set' => array
  256. (
  257. 'num_view' => array('1', '+='),
  258. ),
  259. ),
  260. ),
  261. );