95 lines
1.9 KiB
TypeScript
95 lines
1.9 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
|
import { RolesGuard } from '../../../auth/guards/RolesGuard';
|
|
import { H5Service } from '../../services/admin/H5Service';
|
|
|
|
@Controller('adminapi/channel/h5')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
export class H5Controller {
|
|
constructor(private readonly h5Service: H5Service) {}
|
|
|
|
/**
|
|
* H5渠道列表
|
|
*/
|
|
@Get('lists')
|
|
async lists(@Query() query: any) {
|
|
return this.h5Service.getPage(query);
|
|
}
|
|
|
|
/**
|
|
* H5渠道信息
|
|
*/
|
|
@Get('info/:channel_id')
|
|
async info(@Param('channel_id') channel_id: string) {
|
|
return this.h5Service.getInfo(parseInt(channel_id));
|
|
}
|
|
|
|
/**
|
|
* 添加H5渠道
|
|
*/
|
|
@Post('add')
|
|
async add(@Body() data: {
|
|
channel_name: string;
|
|
channel_desc?: string;
|
|
channel_config?: any;
|
|
status?: number;
|
|
sort?: number;
|
|
}) {
|
|
return this.h5Service.add(data);
|
|
}
|
|
|
|
/**
|
|
* 编辑H5渠道
|
|
*/
|
|
@Put('edit/:channel_id')
|
|
async edit(
|
|
@Param('channel_id') channel_id: string,
|
|
@Body() data: {
|
|
channel_name?: string;
|
|
channel_desc?: string;
|
|
channel_config?: any;
|
|
status?: number;
|
|
sort?: number;
|
|
},
|
|
) {
|
|
return this.h5Service.edit(parseInt(channel_id), data);
|
|
}
|
|
|
|
/**
|
|
* 删除H5渠道
|
|
*/
|
|
@Delete('delete/:channel_id')
|
|
async delete(@Param('channel_id') channel_id: string) {
|
|
return this.h5Service.delete(parseInt(channel_id));
|
|
}
|
|
|
|
/**
|
|
* 获取H5渠道配置
|
|
*/
|
|
@Get('config/:channel_id')
|
|
async getConfig(@Param('channel_id') channel_id: string) {
|
|
return this.h5Service.getConfig(parseInt(channel_id));
|
|
}
|
|
|
|
/**
|
|
* 设置H5渠道配置
|
|
*/
|
|
@Post('config/:channel_id')
|
|
async setConfig(
|
|
@Param('channel_id') channel_id: string,
|
|
@Body() data: { config: any },
|
|
) {
|
|
return this.h5Service.setConfig(parseInt(channel_id), data.config);
|
|
}
|
|
}
|