/*
 * @Author: YKH
 * @Date: 2022-04-14 14:38:01
 * @LastEditTime: 2022-04-14 15:31:48
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\service\vx_api_type.ts
 */
import { Provide } from '@midwayjs/decorator';
import { BaseService } from 'midwayjs-cool-core';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';
import * as _ from 'lodash';
import { ShuyouVXApiTypeEntity } from '../entity/vx_api_type';

/**
 * 游戏目标
 */
@Provide()
export class ShuyouVXApiTypeService extends BaseService {

  @InjectEntityModel(ShuyouVXApiTypeEntity)
  ShuyouVXApiTypeEntity: Repository<ShuyouVXApiTypeEntity>;

  /**
   * 重载info接口
   */
  async info(id) {
    const exits = await this.ShuyouVXApiTypeEntity.findOne({ id });
    let info
    if (!_.isEmpty(exits)) {
      info = exits
      if (info.status == 1) {
        info.status = true
      } else {
        info.status = false
      }
      // console.log(info)
      return info;
    }
  }
  /**
   * 重写list查询
   */
  async list() {
    const sql = `
          SELECT
            *
          FROM
            vx_api_type
          WHERE 
            status = 1
          ORDER BY 
            orderUse asc
        `;
    return this.nativeQuery(sql);
  }


}
