info.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <?php
  2. $audit = Dever::config('base')->audit;
  3. $status = Dever::config('base')->status;
  4. $brand = function()
  5. {
  6. $array = array();
  7. $info = Dever::db('goods/brand')->state();
  8. if($info)
  9. {
  10. $array += $info;
  11. }
  12. return $array;
  13. };
  14. $shop = function()
  15. {
  16. $array = array();
  17. $info = Dever::db('goods/shop')->state();
  18. if($info)
  19. {
  20. $array += $info;
  21. }
  22. return $array;
  23. };
  24. $config = array
  25. (
  26. # 表名
  27. 'name' => 'info',
  28. # 显示给用户看的名称
  29. 'lang' => '商品列表',
  30. 'order' => 200,
  31. 'auto' => 10000000,
  32. 'end' => array
  33. (
  34. 'insert' => 'goods/lib/manage.infoUpdate',
  35. 'update' => 'goods/lib/manage.infoUpdate',
  36. ),
  37. # 同步更新另外一个或多个表的数据,将数据同步到关联表中
  38. 'sync' => array
  39. (
  40. 'goods/info_category' => array
  41. (
  42. # 更新另外一个表的字段 => 本表的字段
  43. 'where' => array('info_id', 'id'),
  44. # 要更新的数据
  45. 'update' => array('category_id' => 'category'),
  46. # 同步更新的类型,delete为先删再插入,update为直接更新
  47. 'type' => 'delete',
  48. )
  49. ),
  50. # 数据结构 不同的字段放这里
  51. 'struct' => array
  52. (
  53. 'id' => array
  54. (
  55. 'type' => 'int-11',
  56. 'name' => 'ID',
  57. 'default' => '',
  58. 'desc' => '',
  59. 'match' => 'is_numeric',
  60. //'list' => true,
  61. ),
  62. 'name' => array
  63. (
  64. 'type' => 'varchar-800',
  65. 'name' => '标题',
  66. 'default' => '',
  67. 'desc' => '标题',
  68. 'match' => 'is_string',
  69. 'update' => 'textarea',
  70. 'search' => 'fulltext',
  71. //'list' => true,
  72. //'edit' => true,
  73. ),
  74. 'brand_id' => array
  75. (
  76. 'type' => 'int-11',
  77. 'name' => '品牌',
  78. 'default' => '',
  79. 'desc' => '品牌',
  80. 'match' => 'is_numeric',
  81. 'update' => 'select',
  82. 'option' => $brand,
  83. ),
  84. 'shop_id' => array
  85. (
  86. 'type' => 'int-11',
  87. 'name' => '店铺',
  88. 'default' => '',
  89. 'desc' => '店铺',
  90. 'match' => 'is_numeric',
  91. 'update' => 'select',
  92. 'option' => $shop,
  93. ),
  94. 'category' => array
  95. (
  96. 'type' => 'varchar-500',
  97. 'name' => '分类',
  98. 'default' => '',
  99. 'desc' => '分类',
  100. 'match' => 'is_string',
  101. 'search' => 'linkage',
  102. 'update' => 'linkage',
  103. 'option' => Dever::url('api.get', 'category'),
  104. //'list' => 'Dever::load("category/api.string", "{category}")',
  105. ),
  106. # 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
  107. 'top_category_id' => array
  108. (
  109. 'type' => 'int-11',
  110. 'name' => '顶级分类ID-顶级分类,用于分类查询',
  111. 'default' => '-1',
  112. 'desc' => '顶级分类ID',
  113. 'match' => 'is_numeric',
  114. ),
  115. 'second_category_id' => array
  116. (
  117. 'type' => 'int-11',
  118. 'name' => '二级分类ID-二级分类,用于分类查询',
  119. 'default' => '-1',
  120. 'desc' => '二级分类ID',
  121. 'match' => 'is_numeric',
  122. ),
  123. 'category_id' => array
  124. (
  125. 'type' => 'int-11',
  126. 'name' => '子分类ID-最后一个级别的分类,用于分类查询',
  127. 'default' => '-1',
  128. 'desc' => '子分类ID',
  129. 'match' => 'is_numeric',
  130. ),
  131. 'pic_cover' => array
  132. (
  133. 'type' => 'varchar-150',
  134. 'name' => '封面图-图片尺寸300*300px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
  135. 'default' => '',
  136. 'desc' => '封面图',
  137. 'match' => 'option',
  138. 'update' => 'image',
  139. 'key' => '1',
  140. 'place' => '300*300',
  141. 'list_name' => '资源详情',
  142. 'list' => 'Dever::load("goods/lib/manage.info", "{id}")',
  143. ),
  144. 'pic' => array
  145. (
  146. 'type' => 'text-255',
  147. 'name' => '多张图片-图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
  148. 'default' => '',
  149. 'desc' => '多张图片',
  150. 'match' => 'option',
  151. 'update' => 'images',
  152. 'key' => '1',
  153. 'place' => '750*422',
  154. ),
  155. 'audit' => array
  156. (
  157. 'type' => 'tinyint-1',
  158. 'name' => '审核',
  159. 'default' => '2',
  160. 'desc' => '审核',
  161. 'match' => 'is_numeric',
  162. //'update' => 'select',
  163. 'option' => $audit,
  164. 'search' => 'select',
  165. 'list' => true,
  166. 'edit' => true,
  167. ),
  168. 'status' => array
  169. (
  170. 'type' => 'tinyint-1',
  171. 'name' => '状态',
  172. 'default' => '1',
  173. 'desc' => '状态',
  174. 'match' => 'is_numeric',
  175. //'update' => 'select',
  176. 'option' => $status,
  177. 'search' => 'select',
  178. 'list' => true,
  179. 'edit' => true,
  180. ),
  181. 'reorder' => array
  182. (
  183. 'type' => 'int-11',
  184. 'name' => '排序-数值越大越靠前,相当于置顶',
  185. 'default' => '1',
  186. 'desc' => '请输入排序',
  187. 'match' => 'option',
  188. //'update' => 'text',
  189. 'search' => 'order',
  190. 'list' => true,
  191. 'order' => 'desc',
  192. 'edit' => true,
  193. ),
  194. 'udate' => array
  195. (
  196. 'type' => 'int-11',
  197. 'name' => '更新时间',
  198. 'match' => array('is_numeric', time()),
  199. 'desc' => '',
  200. ),
  201. 'content' => array
  202. (
  203. 'type' => 'text-800',
  204. 'name' => '内容介绍',
  205. 'default' => '',
  206. 'desc' => '内容介绍',
  207. 'match' => 'is_string',
  208. 'update' => 'editor',
  209. 'key' => '1',
  210. ),
  211. 'state' => array
  212. (
  213. 'type' => 'tinyint-1',
  214. 'name' => '数据状态',
  215. 'default' => '1',
  216. 'desc' => '请选择状态',
  217. 'match' => 'is_numeric',
  218. ),
  219. 'cdate' => array
  220. (
  221. 'type' => 'int-11',
  222. 'name' => '发布时间',
  223. 'match' => array('is_numeric', time()),
  224. 'desc' => '',
  225. # 只有insert时才生效
  226. 'insert' => true,
  227. 'search' => 'date',
  228. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  229. ),
  230. ),
  231. # 索引
  232. 'index' => array
  233. (
  234. 1 => array
  235. (
  236. 'search' => 'shop_id,brand_id,category,top_category_id,second_category_id,category_id',
  237. ),
  238. # 版本号 更改版本号会更新当前表的索引
  239. 'version' => 1,
  240. ),
  241. # 管理功能
  242. 'manage' => array
  243. (
  244. // 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
  245. 'res' => array
  246. (
  247. //'css' => 'demo',
  248. ),
  249. //'insert' => false,
  250. //'delete' => false,
  251. 'mul' => true,
  252. # 自定义快捷新增和编辑
  253. 'button' => array
  254. (
  255. //'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'),
  256. ),
  257. # 列表里的按钮
  258. 'list_button' => array
  259. (
  260. 'add' => array('属性设置', '"info_attr
  261. &project=goods
  262. &search_option_info_id={id}
  263. &search_option_category={category}
  264. &oper_parent=info&oper_project=goods
  265. &oper_save_jump=info
  266. &where_id={id}"'),
  267. 'list' => array('sku设置', '"info_sku
  268. &project=goods
  269. &search_option_info_id={id}
  270. &oper_parent=info&oper_project=goods
  271. &oper_save_jump=info&page_type=1"'),
  272. 'br1' => array('<br />'),
  273. 'delete' => '删除',
  274. ),
  275. ),
  276. # request 请求接口定义
  277. 'request' => array
  278. (
  279. # 后台搜索用到
  280. 'search' => array
  281. (
  282. # 匹配的正则或函数 选填项
  283. 'option' => array
  284. (
  285. 'ids' => array('yes-id', 'in'),
  286. 'name' => array('yes', 'like'),
  287. 'id' => 'yes',
  288. 'state' => 1,
  289. ),
  290. 'type' => 'all',
  291. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  292. 'limit' => '0,1000',
  293. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  294. ),
  295. # 列表
  296. 'getAll' => array
  297. (
  298. # 匹配的正则或函数 选填项
  299. 'option' => array
  300. (
  301. 'audit' => 2,
  302. 'category' => array('yes', 'like'),
  303. 'top_category_id' => 'yes',
  304. 'second_category_id' => 'yes',
  305. 'category_id' => 'yes',
  306. //'status' => 1,
  307. 'state' => 1,
  308. ),
  309. 'type' => 'all',
  310. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  311. 'limit' => '0,10',
  312. //'page' => array(10, 'list'),
  313. 'col' => '*',
  314. ),
  315. # 分页
  316. 'getPageAll' => array
  317. (
  318. # 匹配的正则或函数 选填项
  319. 'option' => array
  320. (
  321. 'shop_id' => 'yes',
  322. 'brand_id' => 'yes',
  323. 'name' => array('yes', 'like'),
  324. 'audit' => 2,
  325. 'category' => array('yes', 'like'),
  326. 'top_category_id' => 'yes',
  327. 'second_category_id' => 'yes',
  328. 'category_id' => 'yes',
  329. //'status' => 1,
  330. 'state' => 1,
  331. ),
  332. 'type' => 'all',
  333. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  334. 'page' => array(10, 'list'),
  335. 'col' => '*',
  336. ),
  337. # 更新浏览量
  338. 'addView' => array
  339. (
  340. 'type' => 'update',
  341. 'where' => array
  342. (
  343. 'id' => 'yes',
  344. ),
  345. 'set' => array
  346. (
  347. 'num_view' => array('1', '+='),
  348. ),
  349. ),
  350. ),
  351. );
  352. return $config;