refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范

这个提交包含在:
wikiboss
2026-09-20 17:05:22 +08:00
父节点 de3cf8b870
当前提交 9fa1d1fbd0
共有 1679 个文件被更改,包括 204798 次插入 和 16817 次删除

查看文件

@@ -0,0 +1,24 @@
import { ModuleConfig } from '@cool-midway/core';
/**
* 模块配置
*/
export default () => {
return {
// 模块名称
name: '文件空间',
// 模块描述
description: '上传和管理文件资源',
// 中间件,只对本模块有效
middlewares: [],
// 中间件,全局有效
globalMiddlewares: [],
// 模块加载顺序,默认为0,值越大越优先加载
order: 0,
// wps的配置
wps: {
// 这是个测试的appId,会有水印
appId: 'SX20230111NDUAGQ',
},
} as ModuleConfig;
};

查看文件

@@ -0,0 +1,18 @@
import { Provide } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { SpaceInfoEntity } from '../../entity/info';
import { SpaceInfoService } from '../../service/info';
/**
* 图片空间信息
*/
@Provide()
@CoolController({
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: SpaceInfoEntity,
service: SpaceInfoService,
pageQueryOp: {
fieldEq: ['type', 'classifyId'],
},
})
export class BaseAppSpaceInfoController extends BaseController {}

查看文件

@@ -0,0 +1,15 @@
import { Provide } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { SpaceTypeEntity } from '../../entity/type';
import { SpaceTypeService } from '../../service/type';
/**
* 空间分类
*/
@Provide()
@CoolController({
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: SpaceTypeEntity,
service: SpaceTypeService,
})
export class BaseAppSpaceTypeController extends BaseController {}

查看文件

@@ -0,0 +1 @@
编写接口

查看文件

@@ -0,0 +1,33 @@
import { BaseEntity } from '../../base/entity/base';
import { Column, Index, Entity } from 'typeorm';
/**
* 文件空间信息
*/
@Entity('space_info')
export class SpaceInfoEntity extends BaseEntity {
@Column({ comment: '地址' })
url: string;
@Column({ comment: '类型' })
type: string;
@Column({ comment: '分类ID', nullable: true })
classifyId: number;
@Index()
@Column({ comment: '文件id' })
fileId: string;
@Column({ comment: '文件名' })
name: string;
@Column({ comment: '文件大小' })
size: number;
@Column({ comment: '文档版本', default: 1 })
version: number;
@Column({ comment: '文件位置' })
key: string;
}

查看文件

@@ -0,0 +1,14 @@
import { BaseEntity } from '../../base/entity/base';
import { Column, Entity } from 'typeorm';
/**
* 图片空间信息分类
*/
@Entity('space_type')
export class SpaceTypeEntity extends BaseEntity {
@Column({ comment: '类别名称' })
name: string;
@Column({ comment: '父分类ID', nullable: true })
parentId: number;
}

查看文件

@@ -0,0 +1,30 @@
import { SpaceInfoEntity } from './../entity/info';
import { Inject, Provide } from '@midwayjs/core';
import { BaseService, MODETYPE } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { PluginService } from '../../plugin/service/info';
/**
* 文件信息
*/
@Provide()
export class SpaceInfoService extends BaseService {
@InjectEntityModel(SpaceInfoEntity)
spaceInfoEntity: Repository<SpaceInfoEntity>;
@Inject()
pluginService: PluginService;
/**
* 新增
*/
async add(param) {
const result = await this.pluginService.invoke('upload', 'getMode');
const config = await this.pluginService.getConfig('upload');
if (result.mode == MODETYPE.LOCAL) {
param.key = param.url.replace(config.domain, '');
}
return super.add(param);
}
}

查看文件

@@ -0,0 +1,28 @@
import { Provide } from '@midwayjs/core';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { In, Repository } from 'typeorm';
import { SpaceTypeEntity } from '../entity/type';
import { SpaceInfoEntity } from '../entity/info';
/**
* 文件分类
*/
@Provide()
export class SpaceTypeService extends BaseService {
@InjectEntityModel(SpaceTypeEntity)
spaceTypeEntity: Repository<SpaceTypeEntity>;
@InjectEntityModel(SpaceInfoEntity)
spaceInfoEntity: Repository<SpaceInfoEntity>;
/**
* 删除
* @param ids
*/
async delete(ids: any) {
await super.delete(ids);
// 删除该分类下的文件信息
await this.spaceInfoEntity.delete({ classifyId: In(ids) });
}
}