mirror of https://github.com/certd/certd
				
				
				
			chore: 兼容数据库
							parent
							
								
									2d580a26af
								
							
						
					
					
						commit
						c937f5afc7
					
				|  | @ -35,7 +35,9 @@ export type SysPublicSetting = { | |||
|   managerOtherUserPipeline?: boolean; | ||||
|   icpNo?: string; | ||||
| }; | ||||
| 
 | ||||
| export type SuiteSetting = { | ||||
|   enabled?: boolean; | ||||
| }; | ||||
| export type SysPrivateSetting = { | ||||
|   httpProxy?: string; | ||||
|   httpsProxy?: string; | ||||
|  | @ -67,6 +69,7 @@ export type AllSettings = { | |||
|   siteInfo: SiteInfo; | ||||
|   siteEnv: SiteEnv; | ||||
|   headerMenus: HeaderMenus; | ||||
|   suiteSetting: SuiteSetting; | ||||
| }; | ||||
| 
 | ||||
| export async function loadAllSettings(): Promise<AllSettings> { | ||||
|  |  | |||
|  | @ -138,7 +138,7 @@ export const certdResources = [ | |||
|         meta: { | ||||
|           show: () => { | ||||
|             const settingStore = useSettingStore(); | ||||
|             return settingStore.isComm; | ||||
|             return settingStore.isComm && settingStore.isSuiteEnabled; | ||||
|           }, | ||||
|           icon: "ion:cart-outline", | ||||
|           auth: true | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import * as _ from "lodash-es"; | |||
| import { LocalStorage } from "/src/utils/util.storage"; | ||||
| 
 | ||||
| import * as basicApi from "/@/api/modules/api.basic"; | ||||
| import { HeaderMenus, PlusInfo, SiteEnv, SiteInfo, SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; | ||||
| import { HeaderMenus, PlusInfo, SiteEnv, SiteInfo, SuiteSetting, SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; | ||||
| import { useUserStore } from "/@/store/modules/user"; | ||||
| import { mitter } from "/@/utils/util.mitt"; | ||||
| import { env } from "/@/utils/util.env"; | ||||
|  | @ -37,6 +37,7 @@ export interface SettingState { | |||
|   siteEnv?: SiteEnv; | ||||
|   headerMenus?: HeaderMenus; | ||||
|   inited?: boolean; | ||||
|   suiteSetting?: SuiteSetting; | ||||
| } | ||||
| 
 | ||||
| const defaultThemeConfig = { | ||||
|  | @ -88,6 +89,7 @@ export const useSettingStore = defineStore({ | |||
|     headerMenus: { | ||||
|       menus: [] | ||||
|     }, | ||||
|     suiteSetting: { enabled: false }, | ||||
|     inited: false | ||||
|   }), | ||||
|   getters: { | ||||
|  | @ -124,6 +126,10 @@ export const useSettingStore = defineStore({ | |||
|     getHeaderMenus() { | ||||
|       // @ts-ignore
 | ||||
|       return this.headerMenus?.menus || { menus: [] }; | ||||
|     }, | ||||
|     isSuiteEnabled() { | ||||
|       // @ts-ignore
 | ||||
|       return this.suiteSetting?.enabled === true; | ||||
|     } | ||||
|   }, | ||||
|   actions: { | ||||
|  | @ -142,6 +148,7 @@ export const useSettingStore = defineStore({ | |||
|       _.merge(this.siteEnv, allSettings.siteEnv || {}); | ||||
|       _.merge(this.plusInfo, allSettings.plusInfo || {}); | ||||
|       _.merge(this.headerMenus, allSettings.headerMenus || {}); | ||||
|       _.merge(this.suiteSetting, allSettings.suiteSetting || {}); | ||||
|       //@ts-ignore
 | ||||
|       this.initSiteInfo(allSettings.siteInfo || {}); | ||||
|     }, | ||||
|  |  | |||
|  | @ -22,6 +22,8 @@ | |||
|           <product-info :product="item" @order="doOrder" /> | ||||
|         </a-col> | ||||
|       </a-row> | ||||
| 
 | ||||
|       <a-empty v-if="suites.length == 0 && addons.length == 0" class="w-100 mt-10" description="暂无套餐可购买" /> | ||||
|     </div> | ||||
| 
 | ||||
|     <order-modal ref="orderModalRef" /> | ||||
|  |  | |||
|  | @ -36,6 +36,9 @@ | |||
|             </span> | ||||
|             <span>(<expires-time-text :value="item.expiresTime" />)</span> | ||||
|           </a-tag> | ||||
|           <div class="flex-o ml-5"> | ||||
|             暂无套餐 <a-button v-if="detail.suites?.length === 0" class="ml-5" type="primary" size="small" @click="goBuy">去购买</a-button> | ||||
|           </div> | ||||
|         </div> | ||||
|       </a-popover> | ||||
|     </div> | ||||
|  | @ -48,6 +51,7 @@ import { ref } from "vue"; | |||
| import ExpiresTimeText from "/@/components/expires-time-text.vue"; | ||||
| import api, { SuiteDetail } from "/@/views/certd/suite/mine/api"; | ||||
| import { FsIcon } from "@fast-crud/fast-crud"; | ||||
| import { useRouter } from "vue-router"; | ||||
| 
 | ||||
| defineOptions({ | ||||
|   name: "SuiteCard" | ||||
|  | @ -60,4 +64,11 @@ async function loadSuiteDetail() { | |||
| } | ||||
| 
 | ||||
| loadSuiteDetail(); | ||||
| 
 | ||||
| const router = useRouter(); | ||||
| function goBuy() { | ||||
|   router.push({ | ||||
|     path: "/certd/suite/buy" | ||||
|   }); | ||||
| } | ||||
| </script> | ||||
|  |  | |||
|  | @ -45,6 +45,7 @@ import { notification } from "ant-design-vue"; | |||
| import { request } from "/@/api/service"; | ||||
| import SuiteDurationSelector from "/@/views/sys/suite/setting/suite-duration-selector.vue"; | ||||
| import ProductManager from "/@/views/sys/suite/product/index.vue"; | ||||
| import { useSettingStore } from "/@/store/modules/settings"; | ||||
| 
 | ||||
| defineOptions({ | ||||
|   name: "SettingsSuite" | ||||
|  | @ -83,11 +84,13 @@ async function loadSettings() { | |||
|   merge(formState, data); | ||||
| } | ||||
| 
 | ||||
| const settingsStore = useSettingStore(); | ||||
| loadSettings(); | ||||
| const onClick = async () => { | ||||
|   const form = await formRef.value.validateFields(); | ||||
|   await api.SuiteSettingSave(form); | ||||
|   await loadSettings(); | ||||
|   await settingsStore.loadSysSettings(); | ||||
|   notification.success({ | ||||
|     message: "保存成功" | ||||
|   }); | ||||
|  |  | |||
|  | @ -0,0 +1,137 @@ | |||
| CREATE TABLE `cd_product` | ||||
| ( | ||||
|   `id`              bigint PRIMARY KEY AUTO_INCREMENT NOT NULL, | ||||
|   `icon`            varchar(100), | ||||
|   `title`           varchar(100), | ||||
|   `type`            varchar(100), | ||||
|   `content`         varchar(4096), | ||||
|   `duration_prices` varchar(4096), | ||||
|   `duration`        bigint, | ||||
|   `price`           bigint, | ||||
|   `intro`           varchar(4096), | ||||
|   `order`           bigint, | ||||
|   `support_buy`     boolean, | ||||
|   `disabled`        boolean  NOT NULL DEFAULT false, | ||||
|   `create_time`     timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
|   `update_time`     timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||||
| ); | ||||
| 
 | ||||
| CREATE TABLE `cd_trade` | ||||
| ( | ||||
|   `id`          bigint PRIMARY KEY AUTO_INCREMENT NOT NULL, | ||||
|   `trade_no`    varchar(100), | ||||
|   `user_id`     bigint, | ||||
|   `product_id`  bigint, | ||||
|   `title`       varchar(1024), | ||||
|   `desc`        varchar(2048), | ||||
|   `num`         bigint, | ||||
|   `duration`    bigint, | ||||
|   `price`       bigint, | ||||
|   `amount`      bigint, | ||||
|   `remark`      varchar(2048), | ||||
|   `status`      varchar(100), | ||||
|   `pay_type`    varchar(50), | ||||
|   `pay_time`    bigint, | ||||
|   `pay_no`      varchar(100), | ||||
|   `end_time`    bigint, | ||||
|   `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
|   `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `index_trade_user_id` ON `cd_trade` (`user_id`); | ||||
| CREATE UNIQUE INDEX `index_trade_trade_no` ON `cd_trade` (`trade_no`); | ||||
| CREATE INDEX `index_trade_pay_no` ON `cd_trade` (`pay_type`, `pay_no`); | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE `cd_user_suite` | ||||
| ( | ||||
|   `id`                bigint PRIMARY KEY AUTO_INCREMENT NOT NULL, | ||||
|   `user_id`           bigint, | ||||
|   `product_id`        bigint, | ||||
|   `trade_id`          bigint, | ||||
|   `icon`              varchar(100), | ||||
|   `title`             varchar(100), | ||||
|   `content`           text, | ||||
|   `duration`          bigint, | ||||
|   `product_type`      varchar(50), | ||||
|   `deploy_count_used` bigint, | ||||
|   `is_present`        boolean, | ||||
|   `is_bootstrap`      boolean, | ||||
|   `is_empty`          boolean, | ||||
|   `disabled`          boolean  NOT NULL DEFAULT false, | ||||
|   `active_time`       bigint, | ||||
|   `expires_time`      bigint, | ||||
|   `create_time`       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
|   `update_time`       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `index_user_suite_user_id` ON `cd_user_suite` (`user_id`); | ||||
| 
 | ||||
| 
 | ||||
| DROP TABLE IF EXISTS `cd_cert`; | ||||
| DROP TABLE IF EXISTS `cd_cert_apply_history`; | ||||
| DROP TABLE IF EXISTS `cd_cert_issuer`; | ||||
| DROP TABLE IF EXISTS `cd_task`; | ||||
| DROP TABLE IF EXISTS `cd_task_history`; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE `cd_cert_info` | ||||
| ( | ||||
|   `id`            bigint PRIMARY KEY AUTO_INCREMENT NOT NULL, | ||||
|   `user_id`       bigint, | ||||
|   `domain`        varchar(100), | ||||
|   `domains`       varchar(4096), | ||||
|   `domain_count`  bigint, | ||||
|   `pipeline_id`   bigint, | ||||
|   `apply_time`    bigint, | ||||
|   `from_type`     varchar(100), | ||||
|   `cert_provider` varchar(100), | ||||
|   `expires_time`  bigint, | ||||
|   `cert_info`     text, | ||||
|   `cert_file`     varchar(100), | ||||
|   `disabled`      boolean  NOT NULL DEFAULT false, | ||||
|   `create_time`   timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
|   `update_time`   timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `index_cert_info_user_id` ON `cd_cert_info` (`user_id`); | ||||
| CREATE INDEX `index_cert_info_domain` ON `cd_cert_info` (`domain`); | ||||
| CREATE INDEX `index_cert_info_domains` ON `cd_cert_info` (`domains`(200)); | ||||
| CREATE INDEX `index_cert_info_pipeline` ON `cd_cert_info` (`pipeline_id`); | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE `cd_site_info` | ||||
| ( | ||||
|   `id`                bigint PRIMARY KEY AUTO_INCREMENT NOT NULL, | ||||
|   `user_id`           bigint, | ||||
| 
 | ||||
|   `name`              varchar(100), | ||||
|   `domain`            varchar(100), | ||||
| 
 | ||||
|   `https_port`        bigint, | ||||
|   `cert_domains`      varchar(4096), | ||||
|   `cert_info`         varchar(4096), | ||||
|   `cert_provider`     varchar(100), | ||||
|   `cert_status`       varchar(100), | ||||
|   `cert_expires_time` bigint, | ||||
|   `last_check_time`   bigint, | ||||
|   `check_status`      varchar(100), | ||||
|   `error`             varchar(4096), | ||||
|   `pipeline_id`       bigint, | ||||
|   `cert_info_id`      bigint, | ||||
|   `disabled`          boolean  NOT NULL DEFAULT false, | ||||
| 
 | ||||
|   `create_time`       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
|   `update_time`       timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX `index_site_info_user_id` ON `cd_site_info` (`user_id`); | ||||
| CREATE INDEX `index_site_info_domain` ON `cd_site_info` (`domain`); | ||||
| CREATE INDEX `index_site_info_pipeline` ON `cd_site_info` (`pipeline_id`); | ||||
| 
 | ||||
| 
 | ||||
| ALTER TABLE pi_pipeline | ||||
|   ADD COLUMN `type` varchar(50); | ||||
| ALTER TABLE pi_pipeline | ||||
|   ADD COLUMN `from` varchar(50); | ||||
|  | @ -0,0 +1,137 @@ | |||
| CREATE TABLE "cd_product" | ||||
| ( | ||||
|   "id"              bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||||
|   "icon"            varchar(100), | ||||
|   "title"           varchar(100), | ||||
|   "type"            varchar(100), | ||||
|   "content"         varchar(4096), | ||||
|   "duration_prices" varchar(10240), | ||||
|   "duration"        bigint, | ||||
|   "price"           bigint, | ||||
|   "intro"           varchar(10240), | ||||
|   "order"           bigint, | ||||
|   "support_buy"     boolean, | ||||
|   "disabled"        boolean  NOT NULL DEFAULT (false), | ||||
|   "create_time"     timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||||
|   "update_time"     timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||||
| ); | ||||
| 
 | ||||
| CREATE TABLE "cd_trade" | ||||
| ( | ||||
|   "id"          bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||||
|   "trade_no"    varchar(100), | ||||
|   "user_id"     bigint, | ||||
|   "product_id"  bigint, | ||||
|   "title"       varchar(1024), | ||||
|   "desc"        varchar(2048), | ||||
|   "num"         bigint, | ||||
|   "duration"    bigint, | ||||
|   "price"       bigint, | ||||
|   "amount"      bigint, | ||||
|   "remark"      varchar(2048), | ||||
|   "status"      varchar(100), | ||||
|   "pay_type"    varchar(50), | ||||
|   "pay_time"    bigint, | ||||
|   "pay_no"      varchar(100), | ||||
|   "end_time"    bigint, | ||||
|   "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||||
|   "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX "index_trade_user_id" ON "cd_trade" ("user_id"); | ||||
| CREATE UNIQUE INDEX "index_trade_trade_no" ON "cd_trade" ("trade_no"); | ||||
| CREATE INDEX "index_trade_pay_no" ON "cd_trade" ("pay_type", "pay_no"); | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE "cd_user_suite" | ||||
| ( | ||||
|   "id"                bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||||
|   "user_id"           bigint, | ||||
|   "product_id"        bigint, | ||||
|   "trade_id"          bigint, | ||||
|   "icon"              varchar(100), | ||||
|   "title"             varchar(100), | ||||
|   "content"           text, | ||||
|   "duration"          bigint, | ||||
|   "product_type"      varchar(50), | ||||
|   "deploy_count_used" bigint, | ||||
|   "is_present"        boolean, | ||||
|   "is_bootstrap"      boolean, | ||||
|   "is_empty"          boolean, | ||||
|   "disabled"          boolean  NOT NULL DEFAULT (false), | ||||
|   "active_time"       bigint, | ||||
|   "expires_time"      bigint, | ||||
|   "create_time"       timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||||
|   "update_time"       timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX "index_user_suite_user_id" ON "cd_user_suite" ("user_id"); | ||||
| 
 | ||||
| 
 | ||||
| DROP TABLE IF EXISTS "cd_cert"; | ||||
| DROP TABLE IF EXISTS "cd_cert_apply_history"; | ||||
| DROP TABLE IF EXISTS "cd_cert_issuer"; | ||||
| DROP TABLE IF EXISTS "cd_task"; | ||||
| DROP TABLE IF EXISTS "cd_task_history"; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE "cd_cert_info" | ||||
| ( | ||||
|   "id"            bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||||
|   "user_id"       bigint, | ||||
|   "domain"        varchar(100), | ||||
|   "domains"       varchar(10240), | ||||
|   "domain_count"  bigint, | ||||
|   "pipeline_id"   bigint, | ||||
|   "apply_time"    bigint, | ||||
|   "from_type"     varchar(100), | ||||
|   "cert_provider" varchar(100), | ||||
|   "expires_time"  bigint, | ||||
|   "cert_info"     text, | ||||
|   "cert_file"     varchar(100), | ||||
|   "disabled"      boolean  NOT NULL DEFAULT (false), | ||||
|   "create_time"   timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||||
|   "update_time"   timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX "index_cert_info_user_id" ON "cd_cert_info" ("user_id"); | ||||
| CREATE INDEX "index_cert_info_domain" ON "cd_cert_info" ("domain"); | ||||
| CREATE INDEX "index_cert_info_domains" ON "cd_cert_info" ("domains"); | ||||
| CREATE INDEX "index_cert_info_pipeline" ON "cd_cert_info" ("pipeline_id"); | ||||
| 
 | ||||
| 
 | ||||
| CREATE TABLE "cd_site_info" | ||||
| ( | ||||
|   "id"                bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||||
|   "user_id"           bigint, | ||||
| 
 | ||||
|   "name"              varchar(100), | ||||
|   "domain"            varchar(100), | ||||
| 
 | ||||
|   "https_port"        bigint, | ||||
|   "cert_domains"      varchar(10240), | ||||
|   "cert_info"         varchar(10240), | ||||
|   "cert_provider"     varchar(100), | ||||
|   "cert_status"       varchar(100), | ||||
|   "cert_expires_time" bigint, | ||||
|   "last_check_time"   bigint, | ||||
|   "check_status"      varchar(100), | ||||
|   "error"             varchar(4096), | ||||
|   "pipeline_id"       bigint, | ||||
|   "cert_info_id"      bigint, | ||||
|   "disabled"          boolean  NOT NULL DEFAULT (false), | ||||
| 
 | ||||
|   "create_time"       timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), | ||||
|   "update_time"       timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) | ||||
| ); | ||||
| 
 | ||||
| CREATE INDEX "index_site_info_user_id" ON "cd_site_info" ("user_id"); | ||||
| CREATE INDEX "index_site_info_domain" ON "cd_site_info" ("domain"); | ||||
| CREATE INDEX "index_site_info_pipeline" ON "cd_site_info" ("pipeline_id"); | ||||
| 
 | ||||
| 
 | ||||
| ALTER TABLE pi_pipeline | ||||
|   ADD COLUMN "type" varchar(50); | ||||
| ALTER TABLE pi_pipeline | ||||
|   ADD COLUMN "from" varchar(50); | ||||
|  | @ -1,5 +1,15 @@ | |||
| import { Config, Controller, Get, Inject, Provide } from '@midwayjs/core'; | ||||
| import { BaseController, Constants, SysHeaderMenus, SysInstallInfo, SysPublicSettings, SysSettingsService, SysSiteEnv, SysSiteInfo } from '@certd/lib-server'; | ||||
| import { | ||||
|   BaseController, | ||||
|   Constants, | ||||
|   SysHeaderMenus, | ||||
|   SysInstallInfo, | ||||
|   SysPublicSettings, | ||||
|   SysSettingsService, | ||||
|   SysSiteEnv, | ||||
|   SysSiteInfo, | ||||
|   SysSuiteSetting, | ||||
| } from '@certd/lib-server'; | ||||
| import { AppKey, getPlusInfo, isComm } from '@certd/plus-core'; | ||||
| 
 | ||||
| /** | ||||
|  | @ -34,6 +44,16 @@ export class BasicSettingsController extends BaseController { | |||
|     return await this.sysSettingsService.getSetting(SysHeaderMenus); | ||||
|   } | ||||
| 
 | ||||
|   public async getSuiteSetting() { | ||||
|     if (!isComm()) { | ||||
|       return { enabled: false }; | ||||
|     } | ||||
|     const setting = await this.sysSettingsService.getSetting<SysSuiteSetting>(SysSuiteSetting); | ||||
|     return { | ||||
|       enabled: setting.enabled, | ||||
|     }; | ||||
|   } | ||||
| 
 | ||||
|   public async getSiteEnv() { | ||||
|     const env: SysSiteEnv = { | ||||
|       agent: this.agentConfig, | ||||
|  | @ -56,6 +76,7 @@ export class BasicSettingsController extends BaseController { | |||
|     const siteEnv = await this.getSiteEnv(); | ||||
|     const plusInfo = await this.plusInfo(); | ||||
|     const headerMenus = await this.getHeaderMenus(); | ||||
|     const suiteSetting = await this.getSuiteSetting(); | ||||
|     return this.ok({ | ||||
|       sysPublic, | ||||
|       installInfo, | ||||
|  | @ -63,6 +84,7 @@ export class BasicSettingsController extends BaseController { | |||
|       siteEnv, | ||||
|       plusInfo, | ||||
|       headerMenus, | ||||
|       suiteSetting, | ||||
|     }); | ||||
|   } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 xiaojunnuo
						xiaojunnuo