Tables.php 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. <?php
  2. namespace install\database;
  3. use Yii;
  4. use yii\base\BaseObject;
  5. use yii\base\InvalidConfigException;
  6. use yii\db\Connection;
  7. use yii\db\SchemaBuilderTrait;
  8. use yii\rbac\DbManager;
  9. use yii\rbac\ManagerInterface;
  10. class Tables extends BaseObject
  11. {
  12. use SchemaBuilderTrait;
  13. /**
  14. * @var Connection
  15. */
  16. public $db;
  17. /**
  18. * @var ManagerInterface
  19. */
  20. private $authManager;
  21. private $tableOptions = null;
  22. private $frontendURL = "";
  23. public function init()
  24. {
  25. parent::init();
  26. if ($this->isMySQL()) {
  27. // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
  28. $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  29. }
  30. $this->authManager = Yii::$app->getAuthManager();
  31. if (!$this->authManager instanceof DbManager) {
  32. throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.');
  33. }
  34. }
  35. public function getDb()
  36. {
  37. return $this->db;
  38. }
  39. public function importDatabase(){
  40. $tables = $this->getTables();
  41. foreach ($tables as $tableName => $table){
  42. /*try {
  43. $this->db->createCommand()->dropTable($tableName)->execute();
  44. }catch (\Exception $e){
  45. }*/
  46. $displayTableName = preg_replace("/{{%(\w+)}}/isu", $this->db->tablePrefix . "$1", $tableName);
  47. $this->db->createCommand()->createTable($tableName, $table['columns'], $table['tableOptions'])->execute();
  48. $this->showMessage(Yii::t('install', "Create table {table} finished", ['table' => $displayTableName]));
  49. if( isset($table['indexes']) ){
  50. foreach ($table['indexes'] as $index){
  51. $this->db->createCommand()->createIndex($index['name'], $tableName, $index['columns'])->execute();
  52. $this->showMessage(Yii::t('install', "Create table {table} index {index} finished", ['table' => $displayTableName, 'index' => $index['name']]));
  53. }
  54. }
  55. if( isset($table['fields']) ){//批量添加
  56. $this->db->createCommand()->batchInsert($tableName, $table['fields'], $table['rows'])->execute();
  57. $this->showMessage(Yii::t('install', "Insert table {table} data finished", ['table' => $displayTableName]));
  58. }else if( isset($table['rows']) ){
  59. foreach ($table['rows'] as $row){
  60. $this->db->createCommand()->insert($tableName, $row)->execute();
  61. }
  62. $this->showMessage(Yii::t('install', "Insert table {table} data finished", ['table' => $displayTableName]));
  63. }
  64. if(isset($table['rawSQLs'])){
  65. foreach ($table['rawSQLs'] as $rawSQL){
  66. $this->db->createCommand($rawSQL)->execute();
  67. }
  68. }
  69. if( $this->isPgSQL() ){
  70. $rawSQL = "ALTER SEQUENCE ###TABLE_NAME###_id_seq RESTART WITH ###VALUE###;";
  71. $value = null;
  72. if( isset($table['fields']) && isset($table['rows']) && count($table['rows']) > 0 ){//批量
  73. $value = $table['rows'][count($table['rows'])-1][0];
  74. }else if( isset($table['rows']) && count($table['rows']) > 0 ){//逐个
  75. $value = $table['rows'][count($table['rows'])-1]['id'];
  76. }
  77. if($value !== null && $value > 0){
  78. $rawSQL = str_replace(["###TABLE_NAME###", "###VALUE###"], [$displayTableName, 100], $rawSQL);
  79. $this->db->createCommand($rawSQL)->execute();
  80. }
  81. }
  82. }
  83. }
  84. public function showMessage($msg, $class = '')
  85. {
  86. echo str_repeat(" ", 1024 * 64 * 99);
  87. echo "<script type=\"text/javascript\">showmsg(\"{$msg}\", \"{$class}\")</script>";
  88. ob_flush();
  89. flush();
  90. }
  91. public function getTables()
  92. {
  93. return [
  94. "{{%article}}" => $this->tableArticle(),
  95. "{{%user}}" => $this->tableUser(),
  96. "{{%admin_user}}" => $this->tableAdminUser(),
  97. "{{%admin_log}}" => $this->tableAdminLog(),
  98. "{{%category}}" => $this->tableCategory(),
  99. "{{%article_content}}" => $this->tableArticleContent(),
  100. "{{%article_meta}}" => $this->tableArticleMeta(),
  101. "{{%comment}}" => $this->tableComment(),
  102. "{{%friendly_link}}" => $this->tableFriendlyLink(),
  103. "{{%menu}}" => $this->tableMenu(),
  104. "{{%options}}" => $this->tableOptions(),
  105. $this->authManager->ruleTable => $this->tableAuthRule(),
  106. $this->authManager->itemTable => $this->tableAuthItem(),
  107. $this->authManager->itemChildTable => $this->tableAuthItemChild(),
  108. $this->authManager->assignmentTable => $this->tableAuthAssignment(),
  109. ];
  110. }
  111. public function tableUser()
  112. {
  113. //table user
  114. $userId = $this->primaryKey();
  115. $userUsername = $this->string()->notNull()->unique();
  116. $userAuthKey = $this->string(32)->notNull();
  117. $userPasswordHash = $this->string()->notNull();
  118. $userPasswordResetToken = $this->string()->unique();
  119. $userEmail = $this->string()->notNull()->unique();
  120. $userAvatar = $this->string()->defaultValue('');
  121. $userAccessToken = $this->string(42)->defaultValue("")->notNull();
  122. $userStatus = $this->smallInteger()->notNull()->defaultValue(10);
  123. $userCreatedAt = $this->integer()->notNull();
  124. $userUpdatedAt = $this->integer()->notNull();
  125. if (!$this->isSqlite()) {
  126. $userId->unsigned()->comment("user id(auto increment)");
  127. $userUsername->comment("username");
  128. $userAuthKey->comment("auth key for generate logged in cookie");
  129. $userPasswordHash->comment("crypt password");
  130. $userPasswordResetToken->comment("reset password temp token");
  131. $userEmail->comment("user email");
  132. $userAvatar->comment("avatar url");
  133. $userAccessToken->comment("token");
  134. $userStatus->comment("user status, (normal:10)");
  135. $userCreatedAt->comment("created at");
  136. $userUpdatedAt->comment("updated at");
  137. }
  138. return [
  139. "columns" => [
  140. 'id' => $userId,
  141. 'username' => $userUsername,
  142. 'auth_key' => $userAuthKey,
  143. 'password_hash' => $userPasswordHash,
  144. 'password_reset_token' => $userPasswordResetToken,
  145. 'email' => $userEmail,
  146. 'avatar' => $userAvatar,
  147. "access_token" => $userAccessToken,
  148. 'status' => $userStatus,
  149. 'created_at' => $userCreatedAt,
  150. 'updated_at' => $userUpdatedAt,
  151. ],
  152. 'tableOptions' => $this->tableOptions,
  153. 'fields' => ['id', 'username', 'auth_key', 'password_hash', 'email', 'status', 'created_at', 'updated_at'],
  154. 'rows' => [],
  155. ];
  156. }
  157. public function tableAdminUser(){
  158. //table admin_user
  159. $adminUserId = $this->primaryKey();
  160. $adminUsername = $this->string()->notNull()->unique();
  161. $adminUserAuthKey = $this->string(32)->notNull();
  162. $adminUserPasswordHash = $this->string()->notNull();
  163. $adminUserPasswordResetToken = $this->string()->unique();
  164. $adminUserEmail = $this->string()->notNull()->unique();
  165. $adminUserAvatar = $this->string()->defaultValue('');
  166. $adminUserStatus = $this->smallInteger()->notNull()->defaultValue(10);
  167. $adminUserAccessToken = $this->string(42)->defaultValue("")->notNull();
  168. $adminUserCreatedAt = $this->integer()->notNull();
  169. $adminUserUpdatedAt = $this->integer()->notNull();
  170. if (!$this->isSqlite()) {
  171. $adminUserId->unsigned()->comment("admin user id(auto increment)");
  172. $adminUsername->comment("admin username");
  173. $adminUserAuthKey->comment("admin user auth key for generate logged in cookie");
  174. $adminUserPasswordHash->comment("admin user crypt password");
  175. $adminUserPasswordResetToken->comment("admin user reset password temp token");
  176. $adminUserEmail->comment("admin user email");
  177. $adminUserAvatar->comment("admin user avatar url");
  178. $adminUserAccessToken->comment("token");
  179. $adminUserStatus->comment("admin user status, (normal:10)");
  180. $adminUserCreatedAt->comment("created at");
  181. $adminUserUpdatedAt->comment("updated at");
  182. }
  183. return[
  184. 'columns' => [
  185. 'id' => $adminUserId,
  186. 'username' => $adminUsername,
  187. 'auth_key' => $adminUserAuthKey,
  188. 'password_hash' => $adminUserPasswordHash,
  189. 'password_reset_token' => $adminUserPasswordResetToken,
  190. 'email' => $adminUserEmail,
  191. 'avatar' => $adminUserAvatar,
  192. "access_token" => $adminUserAccessToken,
  193. 'status' => $adminUserStatus,
  194. 'created_at' => $adminUserCreatedAt,
  195. 'updated_at' => $adminUserUpdatedAt,
  196. ],
  197. 'tableOptions' => $this->tableOptions,
  198. 'fields' => ['id','username','auth_key','password_hash','email','avatar','status','created_at','updated_at'],
  199. 'rows' => [
  200. [
  201. "1",
  202. "admin",
  203. "zr9mY7lt23oAhj_ZYjydbLJKcbE3FJ19",
  204. "$2y$13$8aF72c/7Nqq/atyMivhVTej0bIXS1t8daPJXKtVjFzJUsG68eGgaG",
  205. "admin@feehi.com",
  206. "",
  207. "10",
  208. "1468288038",
  209. "1476711945",
  210. ],
  211. ]
  212. ];
  213. }
  214. public function tableAdminLog()
  215. {
  216. $adminLogId = $this->primaryKey();
  217. $adminLogUserId = $this->integer()->unsigned()->notNull();
  218. $adminLogRoute = $this->string()->defaultValue('')->notNull();
  219. $adminLogDescription = $this->text();
  220. $adminLogCreatedAt = $this->integer()->unsigned()->notNull();
  221. if (!$this->isSqlite()) {
  222. $adminLogId->unsigned()->comment("admin log id(auto increment)");
  223. $adminLogUserId->comment("admin user id");
  224. $adminLogRoute->comment("admin user operate route, like article/create");
  225. $adminLogDescription->comment("admin user operate description");
  226. $adminLogCreatedAt->comment("created at");
  227. }
  228. return [
  229. "columns" => [
  230. 'id' => $adminLogId,
  231. 'user_id' => $adminLogUserId,
  232. 'route' => $adminLogRoute,
  233. 'description' => $adminLogDescription,
  234. 'created_at' => $adminLogCreatedAt
  235. ],
  236. 'tableOptions' => $this->tableOptions,
  237. 'fields' => ["id", "user_id", "route", "description", "created_at"],
  238. 'rows' => [
  239. [
  240. '1',
  241. '1',
  242. '/feehi/index',
  243. 'this is a demo',
  244. '1468293965'
  245. ]
  246. ]
  247. ];
  248. }
  249. public function tableCategory(){
  250. $categoryId = $this->primaryKey();
  251. $categoryParentId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  252. $categoryName = $this->string()->notNull();
  253. $categoryAlias = $this->string()->notNull();
  254. $categorySort = $this->integer()->unsigned()->defaultValue(0)->notNull();
  255. $categoryTemplate = $this->string()->defaultValue("")->notNull();
  256. $categoryArticleTemplate = $this->string()->defaultValue("")->notNull();
  257. $categoryRemark = $this->string()->defaultValue('')->notNull();
  258. $categoryCreatedAt = $this->integer()->unsigned()->notNull();
  259. $categoryUpdatedAt = $this->integer()->unsigned()->defaultValue(0)->notNull();
  260. if (!$this->isSqlite()) {
  261. $categoryId->unsigned()->comment("category id(auto increment)");
  262. $categoryParentId->comment("category parent id(an exist category id)");
  263. $categoryName->comment("category name");
  264. $categoryAlias->comment("category alias");
  265. $categorySort->comment("category order");
  266. $categoryTemplate->comment("category page template path");
  267. $categoryArticleTemplate->comment("article detail page template path");
  268. $categoryRemark->comment("category remark info");
  269. $categoryCreatedAt->comment("created at");
  270. $categoryUpdatedAt->comment("updated at");
  271. }
  272. return[
  273. 'columns' => [
  274. 'id' => $categoryId,
  275. 'parent_id' => $categoryParentId,
  276. 'name' => $categoryName,
  277. 'alias' => $categoryAlias,
  278. 'sort' => $categorySort,
  279. 'remark' => $categoryRemark,
  280. "template" => $categoryTemplate,
  281. "article_template" => $categoryArticleTemplate,
  282. 'created_at' => $categoryCreatedAt,
  283. 'updated_at' => $categoryUpdatedAt,
  284. ],
  285. 'tableOptions' => $this->tableOptions,
  286. 'fields' => ['id','parent_id','name','alias','sort','created_at','updated_at','remark'],
  287. 'rows' => [
  288. [
  289. '1',
  290. '0',
  291. 'php',
  292. 'php',
  293. '0',
  294. '1468293958',
  295. '0',
  296. '',
  297. ],
  298. [
  299. '2',
  300. '0',
  301. 'java',
  302. 'java',
  303. '0',
  304. '1468293965',
  305. '0',
  306. '',
  307. ],
  308. [
  309. '3',
  310. '0',
  311. 'javascript',
  312. 'javascript',
  313. '0',
  314. '1468293974',
  315. '0',
  316. '',
  317. ],
  318. ],
  319. ];
  320. }
  321. public function tableArticle(){
  322. //table article
  323. $articleId = $this->primaryKey();
  324. $articleCategoryId = $this->integer()->defaultValue(0)->notNull();
  325. $articleType = $this->integer()->defaultValue(0)->notNull();
  326. $articleTitle = $this->string()->notNull();
  327. $articleSubTitle = $this->string()->defaultValue('')->notNull();
  328. $articleSummary = $this->string()->defaultValue('')->notNull();
  329. $articleThumb = $this->string()->defaultValue('')->notNull();
  330. $articleSeoTitle = $this->string()->defaultValue('')->notNull();
  331. $articleSeoKeywords = $this->string()->defaultValue('')->notNull();
  332. $articleSeoDescription = $this->string()->defaultValue('')->notNull();
  333. $articleStatus = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  334. $articleSort = $this->integer()->unsigned()->defaultValue(0)->notNull();
  335. $articleAuthorId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  336. $articleAuthorName = $this->string()->defaultValue('')->notNull();
  337. $articleScanCount = $this->integer()->unsigned()->defaultValue(0)->notNull();
  338. $articleCommentCount = $this->integer()->unsigned()->defaultValue(0)->notNull();
  339. $articleCanComment = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  340. $articleVisibility = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  341. $articlePassword = $this->string()->defaultValue('')->notNull();
  342. $articleFlagHeadLine = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  343. $articleFlagRecommend = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  344. $articleFlagSlideShow = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  345. $articleFlagSpecialRecommend = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  346. $articleFlagRoll = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  347. $articleFlagBold = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  348. $articleFlagPicture = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  349. $articleTemplate = $this->string()->defaultValue("")->notNull();
  350. $articleCreatedAt = $this->integer()->unsigned()->notNull();
  351. $articleUpdatedAt = $this->integer()->unsigned()->defaultValue(0)->notNull();
  352. if (!$this->isSqlite()) {
  353. $articleId->unsigned()->comment("article id(auto increment)");
  354. $articleCategoryId->unsigned()->comment("article category id");
  355. $articleType->unsigned()->comment("type(0 article, 1 page)");
  356. $articleTitle->comment("article title");
  357. $articleSubTitle->comment("article sub title");
  358. $articleSummary->comment("article summary");
  359. $articleThumb->comment("thumb");
  360. $articleSeoTitle->comment("seo title");
  361. $articleSeoKeywords->comment("seo keywords");
  362. $articleSeoDescription->comment("seo description");
  363. $articleStatus->comment("article status(0 draft,1 published)");
  364. $articleSort->comment("article order");
  365. $articleAuthorId->comment("article published by admin user id");
  366. $articleAuthorName->comment("article published by admin username");
  367. $articleScanCount->comment("article visited count");
  368. $articleCommentCount->comment("article comment count");
  369. $articleCanComment->comment("article can be comment. (0 no, 1 yes)");
  370. $articleVisibility->comment("article visibility(1.public,2.after commented,3.password,4.after logged in)");
  371. $articlePassword->comment("article password(plain text)");
  372. $articleFlagHeadLine->comment("is head line(0 no, 1 yes");
  373. $articleFlagRecommend->comment("is recommend(0 no, 1 yes");
  374. $articleFlagSlideShow->comment("is slide show(0 no, 1 yes");
  375. $articleFlagSpecialRecommend->comment("is special recommend(0 no, 1 yes");
  376. $articleFlagRoll->comment("is roll(0 no, 1 yes");
  377. $articleFlagBold->comment("is bold(0 no, 1 yes");
  378. $articleFlagPicture->comment("is picture(0 no, 1 yes");
  379. $articleTemplate->comment("article detail page template path");
  380. $articleCreatedAt->comment("created at");
  381. $articleUpdatedAt->comment("updated at");
  382. }
  383. $articles = require(Yii::getAlias("@console/migrations").'/article.php');
  384. $rows = [];
  385. foreach ($articles['article'] as $item) {
  386. $rows[] = [
  387. 'id' => $item[0],
  388. 'cid' => $item[1],
  389. 'type' => $item[2],
  390. 'title' => $item[3],
  391. 'sub_title' => $item[4],
  392. 'summary' => $item[5],
  393. 'thumb' => $item[6],
  394. 'seo_title' => $item[7],
  395. 'seo_keywords' => $item[8],
  396. 'seo_description' => $item[9],
  397. 'status' => $item[10],
  398. 'sort' => $item[11],
  399. 'author_id' => $item[12],
  400. 'author_name' => $item[13],
  401. 'scan_count' => $item[14],
  402. 'comment_count' => $item[15],
  403. 'can_comment' => $item[16],
  404. 'visibility' => $item[17],
  405. 'flag_headline' => $item[18],
  406. 'flag_recommend' => $item[19],
  407. 'flag_slide_show' => $item[20],
  408. 'flag_special_recommend' => $item[21],
  409. 'flag_roll' => $item[22],
  410. 'flag_bold' => $item[23],
  411. 'flag_picture' => $item[24],
  412. 'created_at' => $item[25],
  413. 'updated_at' => $item[26],
  414. ];
  415. }
  416. return[
  417. 'columns' => [
  418. 'id' => $articleId,
  419. 'cid' => $articleCategoryId,
  420. 'type' => $articleType,
  421. 'title' => $articleTitle,
  422. 'sub_title' => $articleSubTitle,
  423. 'summary' => $articleSummary,
  424. 'thumb' => $articleThumb,
  425. 'seo_title' => $articleSeoTitle,
  426. 'seo_keywords' => $articleSeoKeywords,
  427. 'seo_description' => $articleSeoDescription,
  428. 'status' => $articleStatus,
  429. 'sort' => $articleSort,
  430. 'author_id' => $articleAuthorId,
  431. 'author_name' => $articleAuthorName,
  432. 'scan_count' => $articleScanCount,
  433. 'comment_count' => $articleCommentCount,
  434. 'can_comment' => $articleCanComment,
  435. 'visibility' => $articleVisibility,
  436. 'password' => $articlePassword,
  437. 'flag_headline' => $articleFlagHeadLine,
  438. 'flag_recommend' => $articleFlagRecommend,
  439. 'flag_slide_show' => $articleFlagSlideShow,
  440. 'flag_special_recommend' => $articleFlagSpecialRecommend,
  441. 'flag_roll' => $articleFlagRoll,
  442. 'flag_bold' => $articleFlagBold,
  443. 'flag_picture' => $articleFlagPicture,
  444. "template" => $articleTemplate,
  445. 'created_at' => $articleCreatedAt,
  446. 'updated_at' => $articleUpdatedAt,
  447. ],
  448. 'tableOptions' => $this->tableOptions,
  449. 'rows' => $rows,
  450. ];
  451. }
  452. public function tableArticleContent(){
  453. $articleContentId = $this->primaryKey();
  454. $articleContentArticleId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  455. $articleContentContent = $this->text()->notNull();
  456. if (!$this->isSqlite()) {
  457. $articleContentId->unsigned()->comment("article content id(auto increment)");
  458. $articleContentArticleId->comment("article id");
  459. $articleContentContent->comment("article content");
  460. }
  461. $articles = require(Yii::getAlias("@console/migrations").'/article.php');
  462. foreach($articles['article_content'] as $item){
  463. $rows[] = ['aid'=>$item[1], 'content'=>$item[2]];
  464. }
  465. return[
  466. "columns" => [
  467. 'id' => $articleContentId,
  468. 'aid' => $articleContentArticleId,
  469. 'content' => $articleContentContent,
  470. ],
  471. 'tableOptions' => $this->tableOptions,
  472. 'rows' => $rows,
  473. ];
  474. }
  475. public function tableArticleMeta()
  476. {
  477. $articleMetaId = $this->primaryKey();
  478. $articleMetaAid = $this->integer()->unsigned()->notNull();
  479. $articleMetaKey = $this->string()->defaultValue('')->notNull();
  480. $articleMetaValue = $this->text()->notNull();
  481. $articleMetaCratedAt = $this->integer()->unsigned()->notNull();
  482. if (!$this->isSqlite()) {
  483. $articleMetaId->unsigned()->comment("article meta id(auto increment)");
  484. $articleMetaAid->comment("article id");
  485. $articleMetaKey->comment("key");
  486. $articleMetaValue->comment("value");
  487. $articleMetaCratedAt->comment("article meta created at");
  488. }
  489. return [
  490. 'columns' => [
  491. 'id' => $articleMetaId,
  492. 'aid' => $articleMetaAid,
  493. 'key' => $articleMetaKey,
  494. 'value' => $articleMetaValue,
  495. 'created_at' => $articleMetaCratedAt,
  496. ],
  497. 'tableOptions' => $this->tableOptions,
  498. 'fields' => ['aid', 'key', 'value', 'created_at'],
  499. 'indexes' => [
  500. ['name' => "article_meta_index_aid", "columns" => ["aid"]],
  501. ['name' => "article_meta_index_key", "columns" => ["key"]]
  502. ],
  503. 'rows' => [
  504. ['1', 'tag', 'AngularJS', 1507514051],
  505. ['3', 'tag', 'Facebook', 1507514051],
  506. ['3', 'tag', 'hack', 1507514051],
  507. ['3', 'tag', 'php', 1507514051],
  508. ['5', 'tag', 'gc', 1507514051],
  509. ['5', 'tag', '垃圾回收', 1507514051],
  510. ['5', 'tag', 'java', 1507514051],
  511. ['6', 'tag', 'php7', 1507514051],
  512. ['6', 'tag', 'php', 1507514051],
  513. ['6', 'tag', 'wordpress', 1507514051],
  514. ['8', 'tag', 'spring', 1507514051],
  515. ['8', 'tag', 'java', 1507514051],
  516. ['9', 'tag', 'css', 1507514051],
  517. ['9', 'tag', '重构', 1507514051],
  518. ['10', 'tag', 'php', 1507514051],
  519. ['10', 'tag', '分页', 1507514051],
  520. ['11', 'tag', 'php脚本', 1507514051],
  521. ['11', 'tag', '下载', 1507514051],
  522. ['11', 'tag', '代码下载', 1507514051],
  523. ['12', 'tag', 'java', 1507514051],
  524. ['12', 'tag', 'Javascript', 1507514051],
  525. ['12', 'tag', 'Lisp', 1507514051],
  526. ['12', 'tag', 'php', 1507514051],
  527. ['12', 'tag', 'Python', 1507514051],
  528. ['12', 'tag', 'Ruby', 1507514051],
  529. ['12', 'tag', '编程语言', 1507514051],
  530. ['12', 'tag', '趣文', 1507514051],
  531. ['13', 'tag', '缓存', 1507514051],
  532. ['13', 'tag', '浏览器缓存', 1507514051],
  533. ['13', 'tag', 'http协议', 1507514051],
  534. ['14', 'tag', 'javascript', 1507514051],
  535. ['14', 'tag', '流行', 1507514051],
  536. ['15', 'tag', 'java', 1507514051],
  537. ['16', 'tag', 'java', 1507514051],
  538. ['16', 'tag', '用户界面', 1507514051],
  539. ['17', 'tag', 'css', 1507514051],
  540. ['17', 'tag', '样式', 1507514051],
  541. ['18', 'tag', 'java', 1507514051],
  542. ['18', 'tag', '入门', 1507514051],
  543. ['18', 'tag', '编程书籍', 1507514051],
  544. ['19', 'tag', 'java', 1507514051],
  545. ['19', 'tag', 'java8', 1507514051],
  546. ['19', 'tag', '垃圾收集', 1507514051],
  547. ['20', 'tag', 'jvm', 1507514051],
  548. ['20', 'tag', 'java', 1507514051],
  549. ['21', 'tag', 'jvm', 1507514051],
  550. ['21', 'tag', 'java', 1507514051],
  551. ['22', 'tag', 'java', 1507514051],
  552. ['22', 'tag', 'java集合', 1507514051],
  553. ],
  554. ];
  555. }
  556. public function tableComment()
  557. {
  558. $commentId = $this->primaryKey();
  559. $commentArticleId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  560. $commentUserId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  561. $commentAdminUserId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  562. $commentReplyTo = $this->integer()->unsigned()->defaultValue(0)->notNull();
  563. $commentNickname = $this->string()->defaultValue('游客')->notNull();
  564. $commentEmail = $this->string()->defaultValue('')->notNull();
  565. $commentWebsiteUrl = $this->string()->defaultValue('')->notNull();
  566. $commentContent = $this->string()->notNull();
  567. $commentIp = $this->string()->defaultValue('')->notNull();
  568. $commentStatus = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  569. $commentCreatedAt = $this->integer()->unsigned()->notNull();
  570. $commentUpdatedAt = $this->integer()->unsigned()->defaultValue(0)->notNull();
  571. if (!$this->isSqlite()) {
  572. $commentId->unsigned()->comment("comment id(auto increment)");
  573. $commentArticleId->comment("article id");
  574. $commentUserId->comment("user id(0 for guest)");
  575. $commentAdminUserId->comment("admin user id(other user reply 0)");
  576. $commentReplyTo->comment("reply to comment id");
  577. $commentNickname->comment("user nickname");
  578. $commentEmail->comment("email");
  579. $commentWebsiteUrl->comment("user website");
  580. $commentContent->comment("comment content");
  581. $commentIp->comment("user ip");
  582. $commentStatus->comment("comment status(0 to be audit, 1 approved, 2 reject");
  583. $commentCreatedAt->comment("created at");
  584. $commentUpdatedAt->comment("updated at");
  585. }
  586. return [
  587. 'columns' => [
  588. 'id' => $commentId,
  589. 'aid' => $commentArticleId,
  590. 'uid' => $commentUserId,
  591. 'admin_id' => $commentAdminUserId,
  592. 'reply_to' => $commentReplyTo,
  593. 'nickname' => $commentNickname,
  594. 'email' => $commentEmail,
  595. 'website_url' => $commentWebsiteUrl,
  596. 'content' => $commentContent,
  597. 'ip' => $commentIp,
  598. 'status' => $commentStatus,
  599. 'created_at' => $commentCreatedAt,
  600. 'updated_at' => $commentUpdatedAt,
  601. ],
  602. 'tableOptions' => $this->tableOptions,
  603. 'indexes' => [
  604. ['name' => 'comment_index_aid', 'columns' => ['aid']]
  605. ],
  606. 'fields' => ['id', 'aid', 'uid', 'reply_to', 'nickname', 'email', 'website_url', 'content', 'ip', 'status', 'created_at', 'updated_at'],
  607. 'rows' => [
  608. [
  609. "1",
  610. "12",
  611. "0",
  612. "0",
  613. "aaa",
  614. "",
  615. "",
  616. "你好,世界!",
  617. "127.0.0.1",
  618. "1",
  619. "1476066961",
  620. "0",
  621. ],
  622. [
  623. "2",
  624. "22",
  625. "0",
  626. "0",
  627. "aaa",
  628. "",
  629. "",
  630. " :mrgreen: :roll: 哎哟,不错哟~",
  631. "127.0.0.1",
  632. "1",
  633. "1476066990",
  634. "0",
  635. ],
  636. [
  637. "3",
  638. "22",
  639. "0",
  640. "2",
  641. "bbb",
  642. "",
  643. "",
  644. "呵呵哒",
  645. "127.0.0.1",
  646. "1",
  647. "1476067011",
  648. "0",
  649. ],
  650. [
  651. "4",
  652. "12",
  653. "0",
  654. "0",
  655. "ccc",
  656. "",
  657. "",
  658. " :shock: ",
  659. "127.0.0.1",
  660. "1",
  661. "1476067042",
  662. "0",
  663. ],
  664. [
  665. "5",
  666. "12",
  667. "0",
  668. "0",
  669. "aaa",
  670. "",
  671. "",
  672. "嘻嘻嘻",
  673. "127.0.0.1",
  674. "1",
  675. "1476067060",
  676. "0",
  677. ],
  678. [
  679. "6",
  680. "21",
  681. "0",
  682. "0",
  683. "aaa",
  684. "",
  685. "",
  686. "流弊哄哄~~~",
  687. "127.0.0.1",
  688. "1",
  689. "1476067093",
  690. "0",
  691. ],
  692. ]
  693. ];
  694. }
  695. public function tableFriendlyLink(){
  696. $friendlyLinkId = $this->primaryKey();
  697. $friendlyLinkName = $this->string()->notNull();
  698. $friendlyLinkImage = $this->string()->defaultValue('')->notNull();
  699. $friendlyLinkURL = $this->string()->defaultValue('')->notNull();
  700. $friendlyLinkTarget = $this->string()->defaultValue('_blank')->notNull();
  701. $friendlyLinkSort = $this->integer()->unsigned()->defaultValue(0)->notNull();
  702. $friendlyLinkStatus = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  703. $friendlyLinkCreatedAt = $this->integer()->unsigned()->notNull();
  704. $friendlyLinkIdUpdatedAt = $this->integer()->unsigned()->defaultValue(0)->notNull();
  705. if (!$this->isSqlite()) {
  706. $friendlyLinkId->unsigned()->comment("friendly link id(auto increment)");
  707. $friendlyLinkName->comment("website name");
  708. $friendlyLinkImage->comment("website icon url");
  709. $friendlyLinkURL->comment("website url");
  710. $friendlyLinkTarget->comment("open method(_blank, _self)");
  711. $friendlyLinkSort->comment("order");
  712. $friendlyLinkStatus->comment("status(0 hide, 1 display");
  713. $friendlyLinkCreatedAt->comment("created at");
  714. $friendlyLinkIdUpdatedAt->comment("updated at");
  715. }
  716. return [
  717. 'columns' => [
  718. 'id' => $friendlyLinkId,
  719. 'name' => $friendlyLinkName,
  720. 'image' => $friendlyLinkImage,
  721. 'url' => $friendlyLinkURL,
  722. 'target' => $friendlyLinkTarget,
  723. 'sort' => $friendlyLinkSort,
  724. 'status' => $friendlyLinkStatus,
  725. 'created_at' => $friendlyLinkCreatedAt,
  726. 'updated_at' => $friendlyLinkIdUpdatedAt,
  727. ],
  728. 'tableOptions' => $this->tableOptions,
  729. 'fields' => ['id','name','image','url','target','sort','status','created_at','updated_at'],
  730. 'rows' => [
  731. [
  732. '1',
  733. '飞嗨博客',
  734. '',
  735. 'http://blog.feehi.com',
  736. '_blank',
  737. '0',
  738. '1',
  739. '1468303851',
  740. '0',
  741. ],
  742. [
  743. '2',
  744. '飞嗨网',
  745. '',
  746. 'http://www.feehi.com',
  747. '_blank',
  748. '0',
  749. '1',
  750. '1468303882',
  751. '0',
  752. ],
  753. [
  754. '3',
  755. '36kr',
  756. '',
  757. 'http://www.36kr.com',
  758. '_blank',
  759. '0',
  760. '1',
  761. '1468303902',
  762. '0',
  763. ],
  764. [
  765. '4',
  766. '破晓电影',
  767. '',
  768. 'http://www.poxiao.com',
  769. '_blank',
  770. '0',
  771. '1',
  772. '1468303938',
  773. '0',
  774. ],
  775. [
  776. '5',
  777. '翠竹林主题',
  778. '',
  779. 'http://www.cuizl.com/',
  780. '_blank',
  781. '0',
  782. '1',
  783. '1468303974',
  784. '0',
  785. ],
  786. ]
  787. ];
  788. }
  789. public function tableMenu()
  790. {
  791. $menuId = $this->primaryKey();
  792. $menuType = $this->integer()->unsigned()->defaultValue(0)->notNull();
  793. $menuParentId = $this->integer()->unsigned()->defaultValue(0)->notNull();
  794. $menuName = $this->string()->notNull();
  795. $menuURL = $this->string()->notNull();
  796. $menuIcon = $this->string()->defaultValue('')->notNull();
  797. $menuSort = $this->float()->unsigned()->defaultValue(0)->notNull();
  798. $menuTarget = $this->string()->defaultValue('_blank')->notNull();
  799. $menuIsAbsoluteURL = $this->smallInteger()->unsigned()->defaultValue(0)->notNull();
  800. $menuIsDisplay = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  801. $menuCreatedAt = $this->integer()->unsigned()->notNull();
  802. $menuUpdatedAt = $this->integer()->unsigned()->defaultValue(0)->notNull();
  803. if (!$this->isSqlite()) {
  804. $menuId->unsigned()->comment("menu id(auto increment)");
  805. $menuType->comment("menu type(0 backend, 1 frontend");
  806. $menuParentId->comment("parent menu id");
  807. $menuName->comment("menu name");
  808. $menuURL->comment("menu url");
  809. $menuIcon->comment("menu icon");
  810. $menuSort->comment("menu order");
  811. $menuTarget->comment("open method(_blank, _self");
  812. $menuIsAbsoluteURL->comment("is absolute url");
  813. $menuIsDisplay->comment("is display(0 no, 1 yes");
  814. $menuCreatedAt->comment("created at");
  815. $menuUpdatedAt->comment("updated at");
  816. }
  817. return [
  818. 'columns' => [
  819. 'id' => $menuId,
  820. 'type' => $menuType,
  821. 'parent_id' => $menuParentId,
  822. 'name' => $menuName,
  823. 'url' => $menuURL,
  824. 'icon' => $menuIcon,
  825. 'sort' => $menuSort,
  826. 'target' => $menuTarget,
  827. 'is_absolute_url' => $menuIsAbsoluteURL,
  828. 'is_display' => $menuIsDisplay,
  829. 'created_at' => $menuCreatedAt,
  830. 'updated_at' => $menuUpdatedAt,
  831. ],
  832. 'tableOptions' => $this->tableOptions,
  833. 'fields' => ['id', 'type', 'parent_id', 'name', 'url', 'icon', 'sort', 'target', 'is_absolute_url', 'is_display', 'created_at', 'updated_at'],
  834. 'rows' => [
  835. ['1', '0', '0', '设置', '', 'fa fa-cogs', '0', '_blank', '0', '1', '1505570067', '1505570067'],
  836. ['2', '0', '1', '网站设置', '/setting/website', '', '1', '_blank', '0', '1', '1505570108', '1505570108'],
  837. ['3', '0', '1', 'SMTP设置', 'setting/smtp', '', '2', '_blank', '0', '1', '1505570155', '1505570283'],
  838. ['4', '0', '1', '自定义设置', 'setting/custom', '', '4', '_blank', '0', '1', '1505570187', '1505570187'],
  839. ['5', '0', '0', '菜单', '', 'fa fa-th-list', '2', '_blank', '0', '1', '1505570320', '1512380045'],
  840. ['6', '0', '5', '前台菜单', 'frontend-menu/index', '', '0', '_blank', '0', '1', '1505570366', '1505570366'],
  841. ['7', '0', '5', '后台菜单', 'menu/index', '', '0', '_blank', '0', '1', '1505570382', '1505570382'],
  842. ['8', '0', '0', '内容', '', 'fa fa-edit', '3', '_blank', '0', '1', '1505570558', '1512380045'],
  843. ['9', '0', '8', '文章', 'article/index', '', '0', '_blank', '0', '1', '1505570610', '1505570610'],
  844. ['10', '0', '8', '分类', 'category/index', '', '0', '_blank', '0', '1', '1505570638', '1505570638'],
  845. ['11', '0', '8', '评论', 'comment/index', '', '0', '_blank', '0', '1', '1505570661', '1505570707'],
  846. ['12', '0', '8', '单页', 'page/index', '', '0', '_blank', '0', '1', '1505570687', '1505570687'],
  847. ['13', '0', '0', '用户', 'user/index', 'fa fa-users', '4', '_blank', '0', '1', '1505570745', '1512380045'],
  848. ['14', '0', '0', '权限管理', '', 'fa fa-th-large', '5', '_blank', '0', '1', '1505570819', '1512380045'],
  849. ['15', '0', '14', '权限', 'rbac/permissions', '', '0', '_blank', '0', '1', '1505570862', '1505570862'],
  850. ['16', '0', '14', '角色', 'rbac/roles', '', '0', '_blank', '0', '1', '1505570882', '1505570882'],
  851. ['17', '0', '14', '管理员', 'admin-user/index', '', '0', '_blank', '0', '1', '1505570902', '1505570902'],
  852. ['18', '0', '0', '友情链接', 'friendly-link/index', 'fa fa-link', '6', '_blank', '0', '1', '1505570934', '1512380045'],
  853. ['19', '0', '0', '缓存', '', 'fa fa-file', '7', '_blank', '0', '1', '1505570947', '1512380045'],
  854. ['20', '0', '19', '清除前台', 'clear/frontend', '', '0', '_blank', '0', '1', '1505570974', '1505570974'],
  855. ['21', '0', '19', '清除后台', 'clear/backend', '', '0', '_blank', '0', '1', '1505570994', '1505570994'],
  856. ['22', '0', '0', '日志', 'log/index', 'fa fa-history', '8', '_blank', '0', '1', '1505571212', '1512380045'],
  857. ['23', '1', '0', '首页', 'article/index', '', '0', '_self', '0', '1', '1505636890', '1505637024'],
  858. ['24', '1', '0', 'php', '{"0":"article/index","cat":"php"}', '', '0', '_self', '0', '1', '1505636915', '1505636937'],
  859. ['25', '1', '0', 'java', '{"0":"article/index","cat":"java"}', '', '0', '_self', '0', '1', '1505636975', '1505636975'],
  860. ['26', '1', '0', 'javascript', '{"0":"article/index","cat":"javascript"}', '', '0', '_self', '0', '1', '1505637000', '1505637000'],
  861. ['27', '0', '0', '运营管理', '', 'fa fa-ils', '1', '_self', '0', '1', '1505637000', '1505637000'],
  862. ['28', '0', '27', 'Banner管理', 'banner/index', '', '0', '_self', '0', '1', '1505637000', '1505637000'],
  863. ['29', '0', '27', '广告管理', 'ad/index', '', '0', '_self', '0', '1', '1505637000', '1505637000'],
  864. ],
  865. ];
  866. }
  867. public function tableOptions()
  868. {
  869. $optionsId = $this->primaryKey();
  870. $optionsType = $this->integer()->unsigned()->defaultValue(0)->notNull();
  871. $optionsName = $this->string()->notNull();
  872. $optionsValue = $this->text()->notNull();
  873. $optionsInputType = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  874. $optionsAutoload = $this->smallInteger()->unsigned()->defaultValue(1)->notNull();
  875. $optionTips = $this->string()->defaultValue('')->notNull();
  876. $optionsSort = $this->integer()->unsigned()->defaultValue(0)->notNull();
  877. if (!$this->isSqlite()) {
  878. $optionsId->unsigned()->comment("options id(auto increment)");
  879. $optionsType->comment("type (0 system, 1 custom, 2 banner, 3 advertisement");
  880. $optionsName->comment("identifier");
  881. $optionsValue->comment("value");
  882. $optionsInputType->comment("input box type");
  883. $optionsAutoload->comment("is autoload(0 no, 1 yes");
  884. $optionTips->comment("tips");
  885. $optionsSort->comment("order");
  886. }
  887. return [
  888. 'columns' => [
  889. 'id' => $optionsId,
  890. 'type' => $optionsType,
  891. 'name' => $optionsName,
  892. 'value' => $optionsValue,
  893. 'input_type' => $optionsInputType,
  894. 'autoload' => $optionsAutoload,
  895. 'tips' => $optionTips,
  896. 'sort' => $optionsSort,
  897. ],
  898. 'tableOptions' => $this->tableOptions,
  899. 'fields' => ['type', 'name', 'value', 'input_type', 'tips', 'autoload', 'sort'],
  900. 'rows' => [
  901. [
  902. '0',
  903. 'seo_keywords',
  904. '飞嗨,cms,yii2,php,feehi cms',
  905. '1',
  906. '',
  907. '0',
  908. '0',
  909. ],
  910. [
  911. '0',
  912. 'seo_description',
  913. 'Feehi CMS,最好的cms之一',
  914. '1',
  915. '',
  916. '0',
  917. '0',
  918. ],
  919. [
  920. '0',
  921. 'website_title',
  922. 'Feehi CMS',
  923. '1',
  924. '',
  925. '0',
  926. '0',
  927. ],
  928. [
  929. '0',
  930. 'website_description',
  931. 'Based on most popular php framework yii2',
  932. '1',
  933. '',
  934. '0',
  935. '0',
  936. ],
  937. [
  938. '0',
  939. 'website_email',
  940. 'admin@feehi.com',
  941. '1',
  942. '',
  943. '0',
  944. '0',
  945. ],
  946. [
  947. '0',
  948. 'website_language',
  949. 'zh-CN',
  950. '1',
  951. '',
  952. '0',
  953. '0',
  954. ],
  955. [
  956. '0',
  957. 'website_icp',
  958. '粤ICP备15018643号',
  959. '1',
  960. '',
  961. '0',
  962. '0',
  963. ],
  964. [
  965. '0',
  966. 'website_statics_script',
  967. '',
  968. '1',
  969. '',
  970. '0',
  971. '0',
  972. ],
  973. [
  974. '0',
  975. 'website_status',
  976. '1',
  977. '1',
  978. '',
  979. '0',
  980. '0',
  981. ],
  982. [
  983. '0',
  984. 'website_comment',
  985. '1',
  986. '1',
  987. '',
  988. '0',
  989. '0',
  990. ],
  991. [
  992. '0',
  993. 'website_comment_need_verify',
  994. '0',
  995. '1',
  996. '',
  997. '0',
  998. '0',
  999. ],
  1000. [
  1001. '0',
  1002. 'website_timezone',
  1003. 'Asia/Shanghai',
  1004. '1',
  1005. '',
  1006. '0',
  1007. '0',
  1008. ],
  1009. [
  1010. '0',
  1011. 'website_url',
  1012. $this->frontendURL,
  1013. '1',
  1014. '',
  1015. '0',
  1016. '0',
  1017. ],
  1018. [
  1019. '0',
  1020. 'smtp_host',
  1021. '',
  1022. '1',
  1023. '',
  1024. '0',
  1025. '0',
  1026. ],
  1027. [
  1028. '0',
  1029. 'smtp_username',
  1030. '',
  1031. '1',
  1032. '',
  1033. '0',
  1034. '0',
  1035. ],
  1036. [
  1037. '0',
  1038. 'smtp_password',
  1039. '',
  1040. '1',
  1041. '',
  1042. '0',
  1043. '0',
  1044. ],
  1045. [
  1046. '0',
  1047. 'smtp_port',
  1048. '',
  1049. '1',
  1050. '',
  1051. '0',
  1052. '0',
  1053. ],
  1054. [
  1055. '0',
  1056. 'smtp_encryption',
  1057. '',
  1058. '1',
  1059. '',
  1060. '0',
  1061. '0',
  1062. ],
  1063. [
  1064. '0',
  1065. 'smtp_nickname',
  1066. '',
  1067. '1',
  1068. '',
  1069. '0',
  1070. '0',
  1071. ],
  1072. [
  1073. '1',
  1074. 'weibo',
  1075. 'http://www.weibo.com/feeppp',
  1076. '1',
  1077. '新浪微博',
  1078. '1',
  1079. '0',
  1080. ],
  1081. [
  1082. '1',
  1083. 'facebook',
  1084. 'http://www.facebook.com/liufee',
  1085. '1',
  1086. 'facebook',
  1087. '1',
  1088. '0',
  1089. ],
  1090. [
  1091. '1',
  1092. 'wechat',
  1093. '飞得更高',
  1094. '1',
  1095. '微信',
  1096. '1',
  1097. '0',
  1098. ],
  1099. [
  1100. '1',
  1101. 'qq',
  1102. '1838889850',
  1103. '1',
  1104. 'QQ号码',
  1105. '1',
  1106. '0',
  1107. ],
  1108. [
  1109. '1',
  1110. 'email',
  1111. 'admin@feehi.com',
  1112. '1',
  1113. '邮箱',
  1114. '1',
  1115. '0',
  1116. ],
  1117. ['2', 'index', '[{"sign":"5a251a3013586","img":"\/uploads\/setting\/banner\/5a251a301280d_1.png","target":"_blank","link":"\/view\/11","sort":"3","status":"1","desc":""},{"sign":"5a251a4932a52","img":"\/uploads\/setting\/banner\/5a251a4930fc2_2.jpg","target":"_blank","link":"\/view\/15","sort":"2","status":"1","desc":""},{"sign":"5a251a5690fe9","img":"\/uploads\/setting\/banner\/5a251a568f966_3.jpg","target":"_blank","link":"\/view\/16","sort":"1","status":"1","desc":""}]', '1', '首页banner', '1', '0'],
  1118. ['3', 'sidebar_right_1', '{"ad":"\/uploads\/setting\/ad\/5a292c0fda836_cms.jpg","link":"http://www.feehi.com","target":"_blank","desc":"FeehiCMS","created_at":1512641320,"updated_at":1512647776}', '1', '网站右侧广告位1', '1', '0'],
  1119. ['3', 'sidebar_right_2', '{"ad":"\/uploads\/setting\/ad\/5a291f9236479_22.jpg","link":"","target":"_blank","desc":"\u6700\u597d\u7684\u8fd0\u52a8\u624b\u8868","created_at":1512644498,"updated_at":1512647586}', '1', '网站右侧广告位2', '1', '0'],
  1120. ],
  1121. ];
  1122. }
  1123. public function tableAuthRule()
  1124. {
  1125. return [
  1126. 'columns' => [
  1127. 'name' => $this->string(64)->notNull(),
  1128. 'data' => $this->binary(),
  1129. 'created_at' => $this->integer(),
  1130. 'updated_at' => $this->integer(),
  1131. 'PRIMARY KEY ([[name]])',
  1132. ],
  1133. 'tableOptions' => $this->tableOptions
  1134. ];
  1135. }
  1136. public function tableAuthItem()
  1137. {
  1138. $rows = [
  1139. ['/ad/create:GET', 2, '创建(查看)', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"622","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1140. ['/ad/create:POST', 2, '创建(确定)', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"623","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1141. ['/ad/delete:POST', 2, '删除', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"626","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1142. ['/ad/index:GET', 2, '列表', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"620","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1143. ['/ad/sort:POST', 2, '排序', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"627","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1144. ['/ad/update:GET', 2, '修改(查看)', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"624","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1145. ['/ad/update:POST', 2, '修改(确定)', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"625","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1146. ['/ad/view-layer:GET', 2, '查看', NULL, 's:75:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"621","category":"\u5e7f\u544a"}";', 1543937188, 1543937188],
  1147. ['/admin-user/create:GET', 2, '创建(查看)', NULL, 's:69:"{"group":"\u6743\u9650","sort":"524","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1148. ['/admin-user/create:POST', 2, '创建(确定)', NULL, 's:69:"{"group":"\u6743\u9650","sort":"525","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1149. ['/admin-user/delete:POST', 2, '删除', NULL, 's:69:"{"group":"\u6743\u9650","sort":"522","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1150. ['/admin-user/index:GET', 2, '列表', NULL, 's:69:"{"group":"\u6743\u9650","sort":"520","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1151. ['/admin-user/sort:POST', 2, '排序', NULL, 's:69:"{"group":"\u6743\u9650","sort":"523","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1152. ['/admin-user/update:GET', 2, '修改(查看)', NULL, 's:69:"{"group":"\u6743\u9650","sort":"526","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1153. ['/admin-user/update:POST', 2, '修改(确定)', NULL, 's:69:"{"group":"\u6743\u9650","sort":"527","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1154. ['/admin-user/view-layer:GET', 2, '查看', NULL, 's:69:"{"group":"\u6743\u9650","sort":"521","category":"\u7ba1\u7406\u5458"}";', 1543937188, 1543937188],
  1155. ['/article/create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"302","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1156. ['/article/create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"303","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1157. ['/article/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"306","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1158. ['/article/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"300","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1159. ['/article/sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"307","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1160. ['/article/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"304","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1161. ['/article/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"305","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1162. ['/article/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"301","category":"\u6587\u7ae0"}";', 1543937188, 1543937188],
  1163. ['/banner/banner-create:GET', 2, '创建(查看)', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"611","category":"banner"}";', 1543937188, 1543937188],
  1164. ['/banner/banner-create:POST', 2, '创建(确定)', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"612","category":"banner"}";', 1543937188, 1543937188],
  1165. ['/banner/banner-delete:POST', 2, '删除(确定)', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"617","category":"banner"}";', 1543937188, 1543937188],
  1166. ['/banner/banner-sort:POST', 2, '排序', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"616","category":"banner"}";', 1543937188, 1543937188],
  1167. ['/banner/banner-update:GET', 2, '修改(查看)', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"614","category":"banner"}";', 1543937188, 1543937188],
  1168. ['/banner/banner-update:POST', 2, '修改(确定)', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"615","category":"banner"}";', 1543937188, 1543937188],
  1169. ['/banner/banner-view-layer:GET', 2, '查看', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"613","category":"banner"}";', 1543937188, 1543937188],
  1170. ['/banner/banners:GET', 2, '列表', NULL, 's:69:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"610","category":"banner"}";', 1543937188, 1543937188],
  1171. ['/banner/create:GET', 2, '创建(查看)', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"601","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1172. ['/banner/create:POST', 2, '创建(确定)', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"602","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1173. ['/banner/delete:POST', 2, '删除', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"605","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1174. ['/banner/index:GET', 2, '列表', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"600","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1175. ['/banner/update:GET', 2, '修改(查看)', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"603","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1176. ['/banner/update:POST', 2, '修改(确定)', NULL, 's:81:"{"group":"\u8fd0\u8425\u7ba1\u7406","sort":"604","category":"banner\u7c7b\u578b"}";', 1543937188, 1543937188],
  1177. ['/category/create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"312","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1178. ['/category/create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"313","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1179. ['/category/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"316","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1180. ['/category/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"310","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1181. ['/category/sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"317","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1182. ['/category/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"314","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1183. ['/category/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"315","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1184. ['/category/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"311","category":"\u5206\u7c7b"}";', 1543937188, 1543937188],
  1185. ['/clear/backend:GET', 2, '清除后台缓存', NULL, 's:63:"{"group":"\u5176\u4ed6","sort":"720","category":"\u7f13\u5b58"}";', 1543937188, 1543937188],
  1186. ['/clear/frontend:GET', 2, '清除前台缓存', NULL, 's:63:"{"group":"\u5176\u4ed6","sort":"721","category":"\u7f13\u5b58"}";', 1543937188, 1543937188],
  1187. ['/comment/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"324","category":"\u8bc4\u8bba"}";', 1543937188, 1543937188],
  1188. ['/comment/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"320","category":"\u8bc4\u8bba"}";', 1543937188, 1543937188],
  1189. ['/comment/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"322","category":"\u8bc4\u8bba"}";', 1543937188, 1543937188],
  1190. ['/comment/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"323","category":"\u8bc4\u8bba"}";', 1543937188, 1543937188],
  1191. ['/comment/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"321","category":"\u8bc4\u8bba"}";', 1543937188, 1543937188],
  1192. ['/friendly-link/create:GET', 2, '创建(查看)', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"702","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1193. ['/friendly-link/create:POST', 2, '创建(确定)', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"703","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1194. ['/friendly-link/delete:POST', 2, '删除', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"706","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1195. ['/friendly-link/index:GET', 2, '列表', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"700","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1196. ['/friendly-link/sort:POST', 2, '排序', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"707","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1197. ['/friendly-link/update:GET', 2, '修改(查看)', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"704","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1198. ['/friendly-link/update:POST', 2, '修改(确定)', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"705","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1199. ['/friendly-link/view-layer:GET', 2, '查看', NULL, 's:75:"{"group":"\u5176\u4ed6","sort":"701","category":"\u53cb\u60c5\u94fe\u63a5"}";', 1543937188, 1543937188],
  1200. ['/frontend-menu/create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"202","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1201. ['/frontend-menu/create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"203","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1202. ['/frontend-menu/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"206","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1203. ['/frontend-menu/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"200","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1204. ['/frontend-menu/sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"207","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1205. ['/frontend-menu/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"204","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1206. ['/frontend-menu/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"205","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1207. ['/frontend-menu/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"201","category":"\u524d\u53f0"}";', 1543937188, 1543937188],
  1208. ['/log/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u5176\u4ed6","sort":"723","category":"\u65e5\u5fd7"}";', 1543937188, 1543937188],
  1209. ['/log/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u5176\u4ed6","sort":"711","category":"\u65e5\u5fd7"}";', 1543937188, 1543937188],
  1210. ['/log/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u5176\u4ed6","sort":"712","category":"\u65e5\u5fd7"}";', 1543937188, 1543937188],
  1211. ['/menu/create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"212","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1212. ['/menu/create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"213","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1213. ['/menu/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"216","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1214. ['/menu/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"210","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1215. ['/menu/sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"217","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1216. ['/menu/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"214","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1217. ['/menu/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"215","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1218. ['/menu/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u83dc\u5355","sort":"211","category":"\u540e\u53f0"}";', 1543937188, 1543937188],
  1219. ['/page/create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"332","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1220. ['/page/create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"333","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1221. ['/page/delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"336","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1222. ['/page/index:GET', 2, '列表', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"330","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1223. ['/page/sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"337","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1224. ['/page/update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"334","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1225. ['/page/update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"335","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1226. ['/page/view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u5185\u5bb9","sort":"331","category":"\u5355\u9875"}";', 1543937188, 1543937188],
  1227. ['/rbac/permission-create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"502","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1228. ['/rbac/permission-create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"503","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1229. ['/rbac/permission-delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u6743\u9650","sort":"507","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1230. ['/rbac/permission-sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u6743\u9650","sort":"501","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1231. ['/rbac/permission-update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"504","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1232. ['/rbac/permission-update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"505","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1233. ['/rbac/permission-view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u6743\u9650","sort":"506","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1234. ['/rbac/permissions:GET', 2, '列表', NULL, 's:63:"{"group":"\u6743\u9650","sort":"500","category":"\u89c4\u5219"}";', 1543937187, 1543937187],
  1235. ['/rbac/role-create:GET', 2, '创建(查看)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"511","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1236. ['/rbac/role-create:POST', 2, '创建(确定)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"512","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1237. ['/rbac/role-delete:POST', 2, '删除', NULL, 's:63:"{"group":"\u6743\u9650","sort":"517","category":"\u89d2\u8272"}";', 1543937188, 1543937188],
  1238. ['/rbac/role-update:GET', 2, '修改(查看)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"513","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1239. ['/rbac/role-update:POST', 2, '修改(确定)', NULL, 's:63:"{"group":"\u6743\u9650","sort":"514","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1240. ['/rbac/role-view-layer:GET', 2, '查看', NULL, 's:63:"{"group":"\u6743\u9650","sort":"515","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1241. ['/rbac/role-sort:POST', 2, '排序', NULL, 's:63:"{"group":"\u6743\u9650","sort":"516","category":"\u89d2\u8272"}";', 1543937188, 1543937188],
  1242. ['/rbac/roles:GET', 2, '列表', NULL, 's:63:"{"group":"\u6743\u9650","sort":"510","category":"\u89d2\u8272"}";', 1543937187, 1543937187],
  1243. ['/setting/custom-create:GET', 2, '自定义设置创建(查看)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"133","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1244. ['/setting/custom-create:POST', 2, '自定义设置创建(确定)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"134","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1245. ['/setting/custom-delete:POST', 2, '删除', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"132","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1246. ['/setting/custom-update:GET', 2, '自定义设置修改(查看)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"135","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1247. ['/setting/custom-update:POST', 2, '自定义设置修改(确定)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"136","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1248. ['/setting/custom:GET', 2, '修改(查看)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"130","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1249. ['/setting/custom:POST', 2, '修改(确定)', NULL, 's:81:"{"group":"\u8bbe\u7f6e","sort":"131","category":"\u81ea\u5b9a\u4e49\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1250. ['/setting/smtp:GET', 2, '修改(查看)', NULL, 's:67:"{"group":"\u8bbe\u7f6e","sort":"110","category":"smtp\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1251. ['/setting/smtp:POST', 2, '修改(确定)', NULL, 's:67:"{"group":"\u8bbe\u7f6e","sort":"111","category":"smtp\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1252. ['/setting/test-smtp:POST', 2, '测试stmp设置', NULL, 's:67:"{"group":"\u8bbe\u7f6e","sort":"112","category":"smtp\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1253. ['/setting/website:GET', 2, '网站设置(查看)', NULL, 's:75:"{"group":"\u8bbe\u7f6e","sort":"100","category":"\u7f51\u7ad9\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1254. ['/setting/website:POST', 2, '网站设置(确定)', NULL, 's:75:"{"group":"\u8bbe\u7f6e","sort":"101","category":"\u7f51\u7ad9\u8bbe\u7f6e"}";', 1543937188, 1543937188],
  1255. ['/user/create:GET', 2, '创建(查看)', NULL, 's:75:"{"group":"\u7528\u6237","sort":"402","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1256. ['/user/create:POST', 2, '创建(确定)', NULL, 's:75:"{"group":"\u7528\u6237","sort":"403","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1257. ['/user/delete:POST', 2, '删除', NULL, 's:75:"{"group":"\u7528\u6237","sort":"406","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1258. ['/user/index:GET', 2, '列表', NULL, 's:75:"{"group":"\u7528\u6237","sort":"400","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1259. ['/user/sort:POST', 2, '排序', NULL, 's:75:"{"group":"\u7528\u6237","sort":"407","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1260. ['/user/update:GET', 2, '修改(查看)', NULL, 's:75:"{"group":"\u7528\u6237","sort":"404","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1261. ['/user/update:POST', 2, '修改(确定)', NULL, 's:75:"{"group":"\u7528\u6237","sort":"405","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1262. ['/user/view-layer:GET', 2, '查看', NULL, 's:75:"{"group":"\u7528\u6237","sort":"401","category":"\u524d\u53f0\u7528\u6237"}";', 1543937187, 1543937187],
  1263. ];
  1264. $rawSQLs = [];
  1265. if ($this->isMSSQL()) {
  1266. $rawSQLs[] = "CREATE TRIGGER dbo.trigger_auth_item_child
  1267. ON dbo.{$this->authManager->itemTable}
  1268. INSTEAD OF DELETE, UPDATE
  1269. AS
  1270. DECLARE @old_name VARCHAR (64) = (SELECT name FROM deleted)
  1271. DECLARE @new_name VARCHAR (64) = (SELECT name FROM inserted)
  1272. BEGIN
  1273. IF COLUMNS_UPDATED() > 0
  1274. BEGIN
  1275. IF @old_name <> @new_name
  1276. BEGIN
  1277. ALTER TABLE {$this->authManager->itemChildTable} NOCHECK CONSTRAINT FK__auth_item__child;
  1278. UPDATE {$this->authManager->itemChildTable} SET child = @new_name WHERE child = @old_name;
  1279. END
  1280. UPDATE {$this->authManager->itemTable}
  1281. SET name = (SELECT name FROM inserted),
  1282. type = (SELECT type FROM inserted),
  1283. description = (SELECT description FROM inserted),
  1284. rule_name = (SELECT rule_name FROM inserted),
  1285. data = (SELECT data FROM inserted),
  1286. created_at = (SELECT created_at FROM inserted),
  1287. updated_at = (SELECT updated_at FROM inserted)
  1288. WHERE name IN (SELECT name FROM deleted)
  1289. IF @old_name <> @new_name
  1290. BEGIN
  1291. ALTER TABLE {$this->authManager->itemChildTable} CHECK CONSTRAINT FK__auth_item__child;
  1292. END
  1293. END
  1294. ELSE
  1295. BEGIN
  1296. DELETE FROM dbo.{$this->authManager->itemChildTable} WHERE parent IN (SELECT name FROM deleted) OR child IN (SELECT name FROM deleted);
  1297. DELETE FROM dbo.{$this->authManager->itemTable} WHERE name IN (SELECT name FROM deleted);
  1298. END
  1299. END;";
  1300. }
  1301. return [
  1302. 'columns' => [
  1303. 'name' => $this->string(64)->notNull(),
  1304. 'type' => $this->smallInteger()->notNull(),
  1305. 'description' => $this->text(),
  1306. 'rule_name' => $this->string(64),
  1307. 'data' => $this->text(),
  1308. 'created_at' => $this->integer(),
  1309. 'updated_at' => $this->integer(),
  1310. 'PRIMARY KEY ([[name]])',
  1311. 'FOREIGN KEY ([[rule_name]]) REFERENCES ' . $this->authManager->ruleTable . ' ([[name]])'.
  1312. $this->buildFkClause('ON DELETE SET NULL', 'ON UPDATE CASCADE')
  1313. ],
  1314. 'tableOptions' => $this->tableOptions,
  1315. 'indexes' => [
  1316. ['name'=>'idx-auth_item-type', 'columns'=>['type']]
  1317. ],
  1318. 'rawSQLs' => $rawSQLs,
  1319. 'fields' => ['name', 'type', 'description', 'rule_name', 'data', 'created_at', 'updated_at'],
  1320. 'rows' => $rows,
  1321. ];
  1322. }
  1323. public function tableAuthItemChild()
  1324. {
  1325. return [
  1326. 'columns' => [
  1327. 'parent' => $this->string(64)->notNull(),
  1328. 'child' => $this->string(64)->notNull(),
  1329. 'PRIMARY KEY ([[parent]], [[child]])',
  1330. 'FOREIGN KEY ([[parent]]) REFERENCES ' . $this->authManager->itemTable . ' ([[name]])'.
  1331. $this->buildFkClause('ON DELETE CASCADE', 'ON UPDATE CASCADE'),
  1332. 'FOREIGN KEY ([[child]]) REFERENCES ' . $this->authManager->itemTable . ' ([[name]])'.
  1333. $this->buildFkClause('ON DELETE CASCADE', 'ON UPDATE CASCADE'),
  1334. ],
  1335. 'tableOptions' => $this->tableOptions,
  1336. ];
  1337. }
  1338. public function tableAuthAssignment()
  1339. {
  1340. return [
  1341. 'columns' => [
  1342. 'item_name' => $this->string(64)->notNull(),
  1343. 'user_id' => $this->string(64)->notNull(),
  1344. 'created_at' => $this->integer(),
  1345. 'PRIMARY KEY ([[item_name]], [[user_id]])',
  1346. 'FOREIGN KEY ([[item_name]]) REFERENCES ' . $this->authManager->itemTable . ' ([[name]])' .
  1347. $this->buildFkClause('ON DELETE CASCADE', 'ON UPDATE CASCADE'),
  1348. ],
  1349. 'tableOptions' => $this->tableOptions,
  1350. ];
  1351. }
  1352. protected function buildFkClause($delete = '', $update = '')
  1353. {
  1354. if ($this->isMSSQL()) {
  1355. return '';
  1356. }
  1357. if ($this->isOracle()) {
  1358. return ' ' . $delete;
  1359. }
  1360. return implode(' ', ['', $delete, $update]);
  1361. }
  1362. protected function isMSSQL()
  1363. {
  1364. return $this->db->driverName === 'mssql' || $this->db->driverName === 'sqlsrv' || $this->db->driverName === 'dblib';
  1365. }
  1366. protected function isMySQL()
  1367. {
  1368. return $this->db->driverName === 'mysql';
  1369. }
  1370. protected function isOracle()
  1371. {
  1372. return $this->db->driverName === 'oci';
  1373. }
  1374. protected function isPgSQL()
  1375. {
  1376. return $this->db->driverName === 'pgsql';
  1377. }
  1378. protected function isSqlite()
  1379. {
  1380. return $this->db->driverName === 'sqlite';
  1381. }
  1382. }