lrf 3 ヶ月 前
コミット
388e720b9e

+ 2 - 2
src/controller/common.controller.ts

@@ -15,7 +15,7 @@ export class CommonController {
    * @param page 分页设置
    * @returns RF
    */
-  @Get('/:table/list')
+  @Get('/list/:table')
   async list(
     @Param('table') table: string,
     @Query() query: object,
@@ -32,7 +32,7 @@ export class CommonController {
    * @param value 对应值
    * @returns RF
    */
-  @Get('/:table/:column/:value')
+  @Get('/detail/:table/:column/:value')
   async detail(@Param('table') table: string, @Param('column') column: string, @Param('value') value: string) {
     const query = { [column]: value }
     const model = this.service.getModel(table)

+ 2 - 2
src/entity/jc_comment.ts

@@ -1,8 +1,8 @@
 
 import { Column, Entity, PrimaryColumn } from 'typeorm';
 
-@Entity('jc_comment_ext', { comment: 'CMS评论扩展表' })
-export class JcCommentExt {
+@Entity('jc_comment', { comment: 'CMS评论表' })
+export class JcComment {
   @PrimaryColumn()
   comment_id: number;
   @Column({ comment: '评论用户ID' })

+ 1 - 1
src/entity/jc_content_ext.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, PrimaryColumn } from 'typeorm';
 
 @Entity('jc_content_ext', { comment: 'CMS内容扩展表' })
-export class JcContentTag {
+export class JcContentExt {
   @PrimaryColumn()
   content_id: number;
   @Column({ comment: '标题' })

+ 2 - 2
src/entity/jc_content_picture.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, PrimaryColumn } from 'typeorm';
 
-@Entity('jc_content_tag', { comment: 'CMS内容图片表' })
-export class JcContentTag {
+@Entity('jc_content_picture', { comment: 'CMS内容图片表' })
+export class JcContentPicture {
   @PrimaryColumn()
   content_id: number;
   @Column({ comment: '排列顺序' })

+ 2 - 2
src/entity/jc_content_topic.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, PrimaryColumn } from 'typeorm';
 
-@Entity('jc_content_type', { comment: 'CMS内容类型表' })
-export class JcContentType {
+@Entity('jc_content_topic', { comment: 'CMS专题内容关联表' })
+export class JcContentTopic {
   @PrimaryColumn()
   content_id: number;
   @Column({ comment: '' })

+ 1 - 1
src/entity/jc_contenttag.ts

@@ -1,7 +1,7 @@
 import { Column, Entity, PrimaryColumn } from 'typeorm';
 
 @Entity('jc_contenttag', { comment: 'CMS内容标签关联表' })
-export class jcContenttag {
+export class JcContenttag {
   @PrimaryColumn()
   content_id: number;
   @Column({ comment: '' })

+ 2 - 2
src/service/frame/common.service.ts

@@ -19,7 +19,7 @@ export class CommonService {
    * @returns total 总数
    */
   async search(model: Repository<ObjectLiteral>, query: object = {}, page: object = {}, others: object = {}) {
-    const data = await model.find({ ...query, ...page, ...others })
+    const data = await model.find({ where: query, ...page, ...others })
     const total = await model.count(query)
     return { data, total };
   }
@@ -41,7 +41,7 @@ export class CommonService {
    */
   getModel(tableName: string): Repository<ObjectLiteral> {
     const entitys = this.defaultDataSource.entityMetadatas;
-    const entity = entitys.find(f => replace(lowerCase(f.name), " ", '') === tableName)
+    const entity = entitys.find(f => replace(lowerCase(f.name), " ", '') === replace(lowerCase(tableName), " ", ''))
     if (!entity) throw new ServiceError(ErrorCode.ENTITY_NOT_FOUND)
     const entityClass = entity.target;
     const model = this.defaultDataSource.getRepository(entityClass)