hide_game_agent.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * @Author: YKH
  3. * @Date: 2021-12-08 10:26:27
  4. * @LastEditTime: 2022-04-21 17:05:47
  5. * @Description:
  6. * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\hide\service\hide_game_agent.ts
  7. */
  8. import { Provide } from '@midwayjs/decorator';
  9. import { BaseService } from 'midwayjs-cool-core';
  10. import { InjectEntityModel } from '@midwayjs/orm';
  11. import { Repository } from 'typeorm';
  12. import * as _ from 'lodash';
  13. import { HideGameAgentEntity } from '../entity/hide_game_agent';
  14. /**
  15. * 游戏目标
  16. */
  17. @Provide()
  18. export class HideGameAgentService extends BaseService {
  19. @InjectEntityModel(HideGameAgentEntity)
  20. HideGameAgentEntity: Repository<HideGameAgentEntity>;
  21. /**
  22. * 厂商对应的游戏数量+1
  23. * @param {*} game_agentId
  24. * @memberof HideGameAgentService
  25. */
  26. async recordGameNum(game_agentId: number) {
  27. if (game_agentId) {
  28. const gameAgentEntity = await this.HideGameAgentEntity.findOne(game_agentId);
  29. gameAgentEntity.game_count = gameAgentEntity.game_count + 1;
  30. await this.HideGameAgentEntity.save(gameAgentEntity);
  31. return 1000
  32. } else {
  33. return -1
  34. }
  35. }
  36. /**
  37. * 厂商对应的游戏数量-1
  38. * @param {*} game_agentId
  39. * @memberof HideGameAgentService
  40. */
  41. async reduceGameNum(game_agentId: number) {
  42. if (game_agentId) {
  43. const gameAgentEntity = await this.HideGameAgentEntity.findOne(game_agentId);
  44. gameAgentEntity.game_count = gameAgentEntity.game_count - 1;
  45. await this.HideGameAgentEntity.save(gameAgentEntity);
  46. return 1000
  47. } else {
  48. return -1
  49. }
  50. }
  51. /**
  52. *
  53. *减少游戏数量by name
  54. * @param {*} name
  55. * @return {*}
  56. * @memberof HideGameAgentService
  57. */
  58. async reduceGameNumByname(name: any) {
  59. if (name) {
  60. const gameAgentEntity = await this.HideGameAgentEntity.findOne({
  61. name: name
  62. });
  63. gameAgentEntity.game_count = gameAgentEntity.game_count - 1;
  64. await this.HideGameAgentEntity.save(gameAgentEntity);
  65. return 1000
  66. } else {
  67. return -1
  68. }
  69. }
  70. /**
  71. *
  72. *增加游戏数量by name
  73. * @param {*} name
  74. * @return {*}
  75. * @memberof HideGameAgentService
  76. */
  77. async addGameNumByname(name: any) {
  78. if (name) {
  79. const gameAgentEntity = await this.HideGameAgentEntity.findOne({
  80. name: name
  81. });
  82. gameAgentEntity.game_count = gameAgentEntity.game_count + 1;
  83. await this.HideGameAgentEntity.save(gameAgentEntity);
  84. return 1000
  85. } else {
  86. return -1
  87. }
  88. }
  89. // /**
  90. // * 重写分页查询
  91. // * @param query
  92. // */
  93. // async page(query) {
  94. // const { pc_name, is_rent,shop_name,is_abnormal } = query;
  95. // const sql = `
  96. // SELECT
  97. // *
  98. // FROM
  99. // hide_game_computer
  100. // WHERE 1 = 1
  101. // ${this.setSql(pc_name, 'and pc_name LIKE ?', [`%${pc_name}%`])}
  102. // ${this.setSql(is_rent, 'and is_rent = ?', [is_rent])}
  103. // ${this.setSql(shop_name, 'and shop_name LIKE ?', [`%${shop_name}%`])}
  104. // ${this.setSql(is_abnormal, 'and is_abnormal = ?', [is_abnormal])}
  105. // `;
  106. // return this.sqlRenderPage(sql, query);
  107. // }
  108. }