zs %!s(int64=2) %!d(string=hai) anos
pai
achega
39388a69f0

+ 89 - 0
src/controller/channel/channelVideo.controller.ts

@@ -0,0 +1,89 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ChannelVideoService } from '../../service/channel/channelVideo.service';
+import {
+  CDTO_channelVideo,
+  CVO_channelVideo,
+  FVO_channelVideo,
+  QDTO_channelVideo,
+  QVO_channelVideo,
+  UDTO_channelVideo,
+  UVAO_channelVideo,
+} from '../../interface/channel/channelVideo.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['科技频道-展会视频'])
+@Controller('/channelVideo')
+export class ChannelVideoController extends BaseController {
+  @Inject()
+  service: ChannelVideoService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_channelVideo })
+  async create(@Body() data: CDTO_channelVideo) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_channelVideo(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_channelVideo })
+  async query(
+    @Query() filter: QDTO_channelVideo,
+    @Query('skip') skip: number,
+    @Query('limit') limit: number
+  ) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_channelVideo(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_channelVideo })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_channelVideo(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_channelVideo })
+  async update(@Param('id') id: string, @Body() body: UDTO_channelVideo) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 12 - 12
src/controller/user/admin.controller.ts

@@ -36,8 +36,8 @@ import {
 import { Validate } from '@midwayjs/validate';
 import { JwtService } from '@midwayjs/jwt';
 import get = require('lodash/get');
-import lowerCase = require('lodash/lowerCase');
-import { RegisterCanNotIncludes } from '../../util/util';
+// import lowerCase = require('lodash/lowerCase');
+// import { RegisterCanNotIncludes } from '../../util/util';
 import { UserUtilService } from '../../service/util/user.util';
 import { UtilService } from '../../service/util/util';
 @ApiTags(['管理员表'])
@@ -92,15 +92,15 @@ export class AdminController extends BaseController {
   @ApiResponse({ type: CVO_admin })
   async create(@Body() data: CDTO_admin) {
     // 检查是否含有不允许字符
-    const haveInvalid = RegisterCanNotIncludes.find(f =>
-      lowerCase(data.account).includes(f)
-    );
-    if (haveInvalid)
-      throw new ServiceError(
-        `不允许包含特殊字符: ${RegisterCanNotIncludes.join('; ')}`
-      );
+    // const haveInvalid = RegisterCanNotIncludes.find(f =>
+    //   lowerCase(data.account).includes(f)
+    // );
+    // if (haveInvalid)
+    //   throw new ServiceError(
+    //     `不允许包含特殊字符: ${RegisterCanNotIncludes.join('; ')}`
+    //   );
     // 检查手机号和上级id
-    await this.userUtil.checkPhoneAndPid(data);
+    // await this.userUtil.checkPhoneAndPid(data);
     const dbData = await this.service.create(data);
     const result = new CVO_admin(dbData);
     return result;
@@ -113,7 +113,7 @@ export class AdminController extends BaseController {
     @Query('skip') skip: number,
     @Query('limit') limit: number
   ) {
-    filter = this.util.turnDateRangeQuery(this.util.turnFilter(filter));
+    // filter = this.util.turnDateRangeQuery(this.util.turnFilter(filter));
     const list = await this.service.query(filter, { skip, limit });
     const data = [];
     for (const i of list) {
@@ -137,7 +137,7 @@ export class AdminController extends BaseController {
   @ApiResponse({ type: UVAO_admin })
   async update(@Param('id') id: string, @Body() body: UDTO_admin) {
     // 检查手机号和上级id
-    await this.userUtil.checkUpdateCardAndPid(id, body);
+    // await this.userUtil.checkUpdateCardAndPid(id, body);
     const result = await this.service.updateOne(id, body);
     return result;
   }

+ 34 - 34
src/controller/user/expert.controller.ts

@@ -91,7 +91,7 @@ export class ExpertController extends BaseController {
   @ApiResponse({ type: CVO_expert })
   async create(@Body() data: CDTO_expert) {
     // 检查手机号
-    await this.userUtil.checkPhoneAndPid(data);
+    // await this.userUtil.checkPhoneAndPid(data);
     const dbData = await this.service.create(data);
     const result = new CVO_expert(dbData);
     return result;
@@ -104,38 +104,38 @@ export class ExpertController extends BaseController {
     @Query('skip') skip: number,
     @Query('limit') limit: number
   ) {
-    filter = this.util.dealQuery(filter);
-    const { code, status, company, name, phone } = filter;
-    let query: any = {};
-    if (code) query.code = code;
-    if (status) query.status = status;
-    if (name) query.name = name;
-    if (phone) query.phone = phone;
-    if (company) {
-      if (company === '中科系') {
-        query.company = {
-          $in: [
-            '中科院长春分院',
-            '中国科学院东北地理与农业生态研究所',
-            '中国科学院长春应用化学研究所',
-            '中科院长春光学精密机械与物理研究所',
-          ],
-        };
-      } else if (company === '其他') {
-        query.company = {
-          $nin: [
-            '中科院长春分院',
-            '中国科学院东北地理与农业生态研究所',
-            '中国科学院长春应用化学研究所',
-            '中科院长春光学精密机械与物理研究所',
-            '吉林大学',
-            '长春工业大学',
-          ],
-        };
-      } else query.company = company;
-    }
-    query = await this.service.dealQueryCondition(query);
-    const list = await this.service.query(query, { skip, limit });
+    // filter = this.util.dealQuery(filter);
+    // const { code, status, company, name, phone } = filter;
+    // let query: any = {};
+    // if (code) query.code = code;
+    // if (status) query.status = status;
+    // if (name) query.name = name;
+    // if (phone) query.phone = phone;
+    // if (company) {
+    //   if (company === '中科系') {
+    //     query.company = {
+    //       $in: [
+    //         '中科院长春分院',
+    //         '中国科学院东北地理与农业生态研究所',
+    //         '中国科学院长春应用化学研究所',
+    //         '中科院长春光学精密机械与物理研究所',
+    //       ],
+    //     };
+    //   } else if (company === '其他') {
+    //     query.company = {
+    //       $nin: [
+    //         '中科院长春分院',
+    //         '中国科学院东北地理与农业生态研究所',
+    //         '中国科学院长春应用化学研究所',
+    //         '中科院长春光学精密机械与物理研究所',
+    //         '吉林大学',
+    //         '长春工业大学',
+    //       ],
+    //     };
+    //   } else query.company = company;
+    // }
+    // query = await this.service.dealQueryCondition(query);
+    const list = await this.service.query(filter, { skip, limit });
     const data = [];
     for (const i of list) {
       const newData = new QVO_expert(i);
@@ -158,7 +158,7 @@ export class ExpertController extends BaseController {
   @ApiResponse({ type: UVAO_expert })
   async update(@Param('id') id: string, @Body() body: UDTO_expert) {
     // 检查手机号和上级id
-    await this.userUtil.checkUpdateCardAndPid(id, body);
+    // await this.userUtil.checkUpdateCardAndPid(id, body);
     const result = await this.service.updateOne(id, body);
     return result;
   }

+ 4 - 4
src/controller/user/personal.controller.ts

@@ -87,7 +87,7 @@ export class PersonalController extends BaseController {
   @ApiResponse({ type: CVO_personal })
   async create(@Body() data: CDTO_personal) {
     // 检查手机号
-    await this.userUtil.checkPhoneAndPid(data);
+    // await this.userUtil.checkPhoneAndPid(data);
     const dbData = await this.service.create(data);
     const result = new CVO_personal(dbData);
     return result;
@@ -100,8 +100,8 @@ export class PersonalController extends BaseController {
     @Query('skip') skip: number,
     @Query('limit') limit: number
   ) {
-    const query: any = await this.service.dealQueryCondition(filter);
-    const list = await this.service.query(query, { skip, limit });
+    // const query: any = await this.service.dealQueryCondition(filter);
+    const list = await this.service.query(filter, { skip, limit });
     const data = [];
     for (const i of list) {
       const newData = new QVO_personal(i);
@@ -124,7 +124,7 @@ export class PersonalController extends BaseController {
   @ApiResponse({ type: UVAO_personal })
   async update(@Param('id') id: string, @Body() body: UDTO_personal) {
     // 检查手机号和上级id
-    await this.userUtil.checkUpdateCardAndPid(id, body);
+    // await this.userUtil.checkUpdateCardAndPid(id, body);
     const result = await this.service.updateOne(id, body);
     return result;
   }

+ 27 - 0
src/entity/channel/channelVideo.entity.ts

@@ -0,0 +1,27 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'channelVideo' },
+})
+export class ChannelVideo extends BaseModel {
+  @prop({ required: false, index: true, zh: '展会id' })
+  channel_id: string;
+  @prop({ required: false, index: true, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: true, zh: '开始时间' })
+  start_dete: string;
+  @prop({ required: false, index: true, zh: '结束时间' })
+  end_date: string;
+  @prop({ required: false, index: false, zh: '视频文件' })
+  video_file: Array<any>;
+  @prop({ required: false, index: true, zh: '排序', default: '0' })
+  sort: number;
+  @prop({
+    required: false,
+    index: true,
+    zh: '是否使用',
+    remark: '字典:common_use',
+    default: '0',
+  })
+  is_use: string;
+}

+ 110 - 0
src/interface/channel/channelVideo.interface.ts

@@ -0,0 +1,110 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_channelVideo {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '展会id' })
+  'channel_id': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  'start_dete': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  'end_date': string = undefined;
+  @ApiProperty({ description: '视频文件' })
+  'video_file': Array<any> = undefined;
+  @ApiProperty({ description: '排序' })
+  'sort': number = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_channelVideo extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = [
+      'channel_id',
+      'title',
+      'start_dete',
+      'end_date',
+      'sort',
+      'is_use',
+    ];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '展会id' })
+  'channel_id': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  'start_dete': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  'end_date': string = undefined;
+  @ApiProperty({ description: '排序' })
+  'sort': number = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QVO_channelVideo extends FVO_channelVideo {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_channelVideo {
+  @ApiProperty({ description: '展会id' })
+  @Rule(RuleType['string']().empty(''))
+  'channel_id': string = undefined;
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  @Rule(RuleType['string']().empty(''))
+  'start_dete': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  @Rule(RuleType['string']().empty(''))
+  'end_date': string = undefined;
+  @ApiProperty({ description: '视频文件' })
+  @Rule(RuleType['array']().empty(''))
+  'video_file': Array<any> = undefined;
+  @ApiProperty({ description: '排序' })
+  @Rule(RuleType['number']().empty(''))
+  'sort': number = undefined;
+  @ApiProperty({ description: '是否使用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_channelVideo extends FVO_channelVideo {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_channelVideo extends CDTO_channelVideo {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_channelVideo extends FVO_channelVideo {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 11 - 0
src/service/channel/channelVideo.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { ChannelVideo } from '../../entity/channel/channelVideo.entity';
+type modelType = ReturnModelType<typeof ChannelVideo>;
+@Provide()
+export class ChannelVideoService extends BaseService<modelType> {
+  @InjectEntityModel(ChannelVideo)
+  model: modelType;
+}