fix: 创建活动时

This commit is contained in:
liupo.wu 2022-06-11 11:04:41 +08:00 committed by khuntoriia
parent 906002f809
commit ac2aef980c
4 changed files with 14 additions and 12 deletions

View File

@ -35,7 +35,8 @@
"mysql2": "^2.3.3",
"reflect-metadata": "^0.1.13",
"sequelize": "^6.6.2",
"sequelize-typescript": "^2.1.0"
"sequelize-typescript": "^2.1.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@babel/core": "^7.15.0",

View File

@ -9,12 +9,13 @@ CREATE TABLE `magic_act_info` (
`act_create_time` varchar(128) NOT NULL COMMENT '活动创建时间',
`operator` varchar(512) DEFAULT NULL COMMENT '负责人',
`locker` varchar(128) DEFAULT NULL COMMENT '当前正在编辑的人',
`lock_time` datetime DEFAULT '0000-00-00 00:00:00' COMMENT '锁定时间',
`lock_time` datetime DEFAULT NULL COMMENT '锁定时间',
`act_status` int(11) DEFAULT NULL COMMENT '活动状态0-修改中1-部分已发布2-已发布',
`abtest_raw` mediumtext COMMENT 'serialize后的abtest',
PRIMARY KEY (`act_id`),
KEY `act_name` (`act_name`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = '魔方开源-活动信息表'
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = '魔方开源-活动信息表';
-- 页面配置表
CREATE TABLE `magic_ui_config` (
`id` int(8) unsigned NOT NULL AUTO_INCREMENT COMMENT '页面id',
@ -31,4 +32,4 @@ CREATE TABLE `magic_ui_config` (
`web_plugin` varchar(255) DEFAULT NULL COMMENT 'web插件',
`page_name` varchar(128) DEFAULT NULL COMMENT '页面名称(编辑器页面唯一标识)',
PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 5 DEFAULT CHARSET = utf8mb4 COMMENT = '魔方开源-uiconfig表'
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = '魔方开源-uiconfig表';

View File

@ -173,6 +173,7 @@ export default class ActService {
actModifyTime: getFormatTime(),
actCreateTime: getFormatTime(),
actStatus: ActStatus.MODIFYING,
actCryptoId: '', // 数据库不能为空,先做个占位符
...actInfo,
};
const act = await ActInfo.create<ActInfo>(newAct as ActInfo);
@ -187,7 +188,9 @@ export default class ActService {
);
// 添加默认活动页
const defaultPage = await this.pageService.create();
const defaultPage = await this.pageService.create({
actId: act.actId,
});
await act.$add<Page>('Pages', defaultPage);
return act.actId;

View File

@ -31,17 +31,14 @@ export default class PageService {
* @param {Page} page
* @returns {Page}
*/
create = (page?: Page) => {
const oldPage = page;
create = (page?: Partial<Page>) => {
const newPage = {
pageCreateTime: getFormatTime(),
pageModifyTime: getFormatTime(),
pagePublishStatus: PageStatus.MODIFYING,
distCode: oldPage?.distCode,
srcCode: oldPage?.srcCode,
pagePublishUiVersion: oldPage?.pagePublishUiVersion,
pageTitle: oldPage?.pageTitle || 'index',
pageName: oldPage?.pageName || 'index',
pageTitle: 'index',
pageName: 'index',
...page,
};
return Page.create(newPage as Page);
};