diff --git a/lock/db/app.db.lock b/lock/db/app.db.lock new file mode 100644 index 0000000..e9edbf5 --- /dev/null +++ b/lock/db/app.db.lock @@ -0,0 +1 @@ +time consuming:1172ms \ No newline at end of file diff --git a/lock/db/base.db.lock b/lock/db/base.db.lock new file mode 100644 index 0000000..4000013 --- /dev/null +++ b/lock/db/base.db.lock @@ -0,0 +1 @@ +time consuming:1035ms \ No newline at end of file diff --git a/lock/db/dict.db.lock b/lock/db/dict.db.lock new file mode 100644 index 0000000..232be0f --- /dev/null +++ b/lock/db/dict.db.lock @@ -0,0 +1 @@ +time consuming:3188ms \ No newline at end of file diff --git a/lock/db/task.db.lock b/lock/db/task.db.lock new file mode 100644 index 0000000..85af781 --- /dev/null +++ b/lock/db/task.db.lock @@ -0,0 +1 @@ +time consuming:156ms \ No newline at end of file diff --git a/lock/menu/app.menu.lock b/lock/menu/app.menu.lock new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/lock/menu/app.menu.lock @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/lock/menu/base.menu.lock b/lock/menu/base.menu.lock new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/lock/menu/base.menu.lock @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/lock/menu/cs.menu.lock b/lock/menu/cs.menu.lock new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/lock/menu/cs.menu.lock @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/lock/menu/fixtures.menu.lock b/lock/menu/fixtures.menu.lock new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/lock/menu/fixtures.menu.lock @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/src/config/config.default.ts b/src/config/config.default.ts index fdbfc31..ec5a572 100644 --- a/src/config/config.default.ts +++ b/src/config/config.default.ts @@ -54,8 +54,8 @@ export default { // }, cool: { redis: { - host: '127.0.0.1', - password: '', + host: '120.48.5.80', + password: 'redis_b3YetY', port: 6379, db: 10, }, diff --git a/src/config/config.local.ts b/src/config/config.local.ts index 7b6c0e2..a1f8163 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -9,11 +9,11 @@ export default { dataSource: { default: { type: 'mysql', - host: '127.0.0.1', + host: '120.48.5.80', port: 3306, username: 'root', - password: '123456', - database: 'mall', + password: 'mysql_PjAFkh', + database: 'automated_test', // 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失 synchronize: true, // 打印日志 diff --git a/src/config/config.prod.ts b/src/config/config.prod.ts index 8cf3e66..e99913f 100644 --- a/src/config/config.prod.ts +++ b/src/config/config.prod.ts @@ -5,9 +5,9 @@ import { createAdapter } from '@socket.io/redis-adapter'; import Redis from 'ioredis'; const redis = { - host: '127.0.0.1', + host: '120.48.5.80', port: 6379, - password: '', + password: 'redis_b3YetY', db: 0, }; const pubClient = new Redis(redis); diff --git a/src/modules/fixtures/config.ts b/src/modules/fixtures/config.ts new file mode 100644 index 0000000..930c56f --- /dev/null +++ b/src/modules/fixtures/config.ts @@ -0,0 +1,19 @@ +import { ModuleConfig } from '@cool-midway/core'; + +/** + * 模块配置 + */ +export default () => { + return { + // 模块名称 + name: '页面装修模块', + // 模块描述 + description: '装修管理', + // 中间件,只对本模块有效 + middlewares: [], + // 中间件,全局有效 + globalMiddlewares: [], + // 模块加载顺序,默认为0,值越大越优先加载 + order: 0, + } as ModuleConfig; +}; diff --git a/src/modules/fixtures/controller/admin/mould.ts b/src/modules/fixtures/controller/admin/mould.ts new file mode 100644 index 0000000..94e0b8a --- /dev/null +++ b/src/modules/fixtures/controller/admin/mould.ts @@ -0,0 +1,30 @@ +import { CoolController, BaseController } from '@cool-midway/core'; +import { Body, Inject, Post,Get } from '@midwayjs/core'; +import { FixturesMouldEntity } from '../../entity/mould'; +import { FixturesMouldService } from '../../service/mould'; + +/** + * 页面装修 + */ +@CoolController({ + api: ['add', 'delete', 'update', 'info', 'list', 'page'], + entity: FixturesMouldEntity, + service: FixturesMouldService, + pageQueryOp: { + keyWordLikeFields: ['name'] + } +}) +export class AdminFixturesMouldController extends BaseController { + @Inject() + fixturesMouldService: FixturesMouldService; + + @Post('/getFixturesPreviewCode', { summary: '保存配置' }) + async getFixturesPreviewCode(@Body() body) { + return this.ok(await this.fixturesMouldService.getFixturesPreviewCode(body)); + } + + @Get('/getPlatformPages', { summary: '获取平台页面' }) + async getPlatformPages() { + return this.ok(await this.fixturesMouldService.getPlatformPages()); + } +} diff --git a/src/modules/fixtures/controller/app/mould.ts b/src/modules/fixtures/controller/app/mould.ts new file mode 100644 index 0000000..02e4182 --- /dev/null +++ b/src/modules/fixtures/controller/app/mould.ts @@ -0,0 +1,30 @@ +import { CoolController, BaseController, CoolUrlTag, CoolTag, TagTypes } from '@cool-midway/core'; +import { Get, Inject, Query } from '@midwayjs/core'; +import { FixturesMouldEntity } from '../../entity/mould'; +import { FixturesMouldService } from '../../service/mould'; + +/** + * 装修页面 + */ +@CoolController({ + api: [], + entity: FixturesMouldEntity, +}) +@CoolUrlTag() +export class AppFixturesMouldController extends BaseController { + @Inject() + fixturesMouldService: FixturesMouldService; + + @CoolTag(TagTypes.IGNORE_TOKEN) + @Get('/getHomePage', { summary: '获取首页' }) + async getHomePage() { + return this.ok(await this.fixturesMouldService.getHomePage()); + } + + + @CoolTag(TagTypes.IGNORE_TOKEN) + @Get('/getPage', { summary: '获取指定页面' }) + async getPage(@Query('id') id: string) { + return this.ok(await this.fixturesMouldService.getPage(id)); + } +} diff --git a/src/modules/fixtures/entity/mould.ts b/src/modules/fixtures/entity/mould.ts new file mode 100644 index 0000000..d150cee --- /dev/null +++ b/src/modules/fixtures/entity/mould.ts @@ -0,0 +1,37 @@ +import { BaseEntity } from '@cool-midway/core'; +import { Column, Entity, Index } from 'typeorm'; + +/** + * 自定义页面 + */ +@Entity('fixtures_mould') +export class FixturesMouldEntity extends BaseEntity { + + @Column({ comment: '页面名称' }) + name: string; + + @Column({ comment: '页面背景色', default: '#f6f7f8' }) + background: string; + + @Column({ comment: '页面背景图', default: '', nullable: true }) + backgroundImage: string; + + @Index() + @Column({ comment: '是否首页 0-否 1-是', type: 'tinyint', default: 0 }) + isHome: number; + + @Column({ comment: '状态 0-关闭 1-正常', type: 'tinyint', default: 1 }) + status: number; + + @Column({ comment: '状态栏占位 0-隐藏 1-显示', type: 'tinyint', default: 1 }) + statusBar: number; + + @Column({ comment: '状态栏占位颜色', type: 'varchar', default: '#fff' }) + statusBarColor: string; + + @Column({ comment: '组件数据', type: 'json', nullable: true }) + data: string; + + @Column({ comment: '组件数据-未发布', type: 'json', nullable: true }) + form: string; +} diff --git a/src/modules/fixtures/menu.json b/src/modules/fixtures/menu.json new file mode 100644 index 0000000..aa595ed --- /dev/null +++ b/src/modules/fixtures/menu.json @@ -0,0 +1 @@ +[{"name":"页面装修","router":null,"perms":null,"type":0,"icon":"icon-design","orderNum":14,"viewPath":null,"keepAlive":true,"isShow":true,"childMenus":[{"name":"自定义页面","router":"/fixtures/mould","perms":null,"type":1,"icon":"icon-device","orderNum":2,"viewPath":"modules/fixtures/views/mould.vue","keepAlive":true,"isShow":true,"childMenus":[{"name":"权限","router":null,"perms":"fixtures:mould:delete,fixtures:mould:update,fixtures:mould:info,fixtures:mould:list,fixtures:mould:page,fixtures:mould:add","type":2,"icon":null,"orderNum":0,"viewPath":null,"keepAlive":true,"isShow":true,"childMenus":[]}]},{"name":"页面组装","router":"/fixtures/mould/edit","perms":null,"type":1,"icon":"icon-iot","orderNum":0,"viewPath":"modules/fixtures/views/edit.vue","keepAlive":true,"isShow":false,"childMenus":[]}]}] \ No newline at end of file diff --git a/src/modules/fixtures/service/mould.ts b/src/modules/fixtures/service/mould.ts new file mode 100644 index 0000000..793be81 --- /dev/null +++ b/src/modules/fixtures/service/mould.ts @@ -0,0 +1,125 @@ +import { Init, Inject, Provide } from '@midwayjs/decorator'; +import { BaseService, CoolCommException } from '@cool-midway/core'; +import { InjectEntityModel } from '@midwayjs/typeorm'; +import { Repository } from 'typeorm'; +import { FixturesMouldEntity } from '../entity/mould'; +import { PluginService } from '../../plugin/service/info'; + +/** + * 页面 + */ +@Provide() +export class FixturesMouldService extends BaseService { + @InjectEntityModel(FixturesMouldEntity) + fixturesMouldEntity: Repository; + @Inject() + pluginService: PluginService; + @Init() + async init() { + await super.init(); + this.setEntity(this.fixturesMouldEntity); + } + + /** + * 更新页面 + */ + async update(param: FixturesMouldEntity) { + if (param.isHome) { + await this.fixturesMouldEntity.update({ isHome: 1 }, { isHome: 0 }) + } + await this.fixturesMouldEntity.save(param) + } + + /** + * 获取首页 + */ + async getHomePage() { + const data = await this.fixturesMouldEntity.findOne({ where: { isHome: 1 } }) + if (!data || !data.status) throw new CoolCommException('该页面已丢失~'); + return data + } + + /** + * 获取指定页面 + * @param id + */ + async getPage(id: string) { + if (!Number(id)) throw new CoolCommException('该页面已丢失~'); + const data = await this.fixturesMouldEntity.findOne({ where: { id: Number(id) } }) + if (!data || !data.status) throw new CoolCommException('该页面已丢失~'); + + if (!data.data) throw new CoolCommException('该页面未发布~'); + + return data + } + + /** + * 获取页面预览小程序码 + * 需要调用 wx 插件 https://www.cool-admin.com/plugin/70 + *因为不注释掉,连 npm run dev 都过不了。。。 + */ + async getFixturesPreviewCode(body: any) { + throw new CoolCommException('请手动修改关闭代码注释 在 fixtures-service-mould-getFixturesPreviewCode') + // const { id, form } = body + // const info = await this.fixturesMouldEntity.findOne({ where: { id: id } }) + // if (!info) throw new CoolCommException('数据不存在~'); + // await this.fixturesMouldEntity.update({ id: info.id }, { form: form }) + // // 获取插件实例 + // const instance = await this.pluginService.getInstance('wx'); + // // 获得小程序实例 + // const MiniApp = await instance.MiniApp(); + // const miniToken = await MiniApp.getAccessToken().getToken(); + // let miniUrl = `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${miniToken}` + // // 获取 api 调用客户端 + // let client = MiniApp.getClient(); + // const data = { + // page: "uni_modules/cool-fixtures/pages/preview", + // scene: `id=${info.id}`, + // width: 200, + // check_path: false, + // } + // const result = await client.post(miniUrl, { data, responseType: 'arraybuffer' }); + // const buffer = Buffer.from(result.response.data, 'base64'); + // return 'data:image/png;base64,' + buffer.toString('base64'); + } + + /** + * 获取平台页面 + */ + async getPlatformPages() { + const data = [ + { + name: '基础页面', + children: [{ name: '平台首页', page: '/pages/index/home' }, + { name: '轻松赚钱', page: '/pages/index/introduce' }, + { name: '购物车', page: '/pages/index/shopping-cart' }, + { name: '商品分类', page: '/pages/index/category' }, + { name: '会员中心', page: '/pages/index/my' }, + { name: '订单列表', page: '/pages/order/list' }, + { name: '我的收益', page: '/pages/user/balance/purse' }, + { name: '在线客服', page: '/uni_modules/cool-cs/pages/chat' }, + { name: '附近终端店', page: '/pages/partnership/sample/vicinity' }, + ] + }, + { + name: '我的店铺', + children: [{ name: '店铺首页', page: '/pages/partnership/index' }, + { name: '店铺订单', page: '/pages/partnership/order' }, + { name: '店铺码', page: '/pages/partnership/code' }, + { name: '店铺代金券', page: '/pages/partnership/voucher/index' }, + { name: '店铺拉客工具', page: '/pages/partnership/activity/index' }, + ] + }, + { + name: '抽奖活动', + children: [{ name: '期数集奖', page: '/pages/activity/index' }, + { name: '九宫格抽奖', page: '/pages/partnership/activity/lottery/detail' }, + { name: '邀请赢红包', page: '/pages/partnership/activity/laxin/detail' }, + { name: '邀请赢代金券', page: '/pages/partnership/activity/lake/detail' }, + ] + } + ] + + return data + } +}