import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router } = app;

  const tokenParser = app.middleware.tokenParser();
  const checkMainten = app.middleware.checkMainten();
  router.get('/dev', controller.home.dev);
  router.get('/dev/smscode', controller.account.getSmsCode);
  router.get('/', controller.home.index);
  router.post('/user/checkreview', controller.game.checkReview);
  router.post('/user/checkr', controller.game.checkReview); // 增加一个接口，规避 iOS 敏感词
  router.post('/user/channellogin', controller.account.channelLogin);
  router.post('/user/devicelogin', controller.account.deviceLogin);
  router.post('/user/getsms', controller.account.getSms);
  router.post('/user/smslogin', controller.account.smsLogin);
  router.post('/user/setpassword', tokenParser, controller.account.setPassword);
  router.post('/user/pwlogin', controller.account.pwLogin);
  router.post('/user/checkrole', tokenParser, checkMainten, controller.account.checkRole);
  router.post('/user/createrole', tokenParser, checkMainten, controller.account.createRole);
  router.post('/user/bind', tokenParser, controller.account.bind);
  router.post('/user/authentication', tokenParser, controller.account.authentication);
  router.post('/user/checkversion', tokenParser, controller.game.checkVersion);
  router.post('/user/checkv', tokenParser, controller.game.checkVersion); // 增加一个接口，规避 iOS 敏感词
  router.post('/user/deleterole', controller.account.deleteRole);
  router.post('/game/getserverlist', tokenParser, controller.game.getServerList);
  router.post('/game/getnotice', tokenParser, controller.game.getnotice);
  router.post('/gate/queryenter', tokenParser, controller.game.queryEnter);
  router.post('/update/getversion', controller.update.getversion);
  router.post('/update/getupdateurl', controller.update.getUpdateUrl);
  router.post('/web/reloadresource', app.middleware.gmTokenParser(), controller.game.reloadResource);
  router.post('/web/upload', controller.game.upload);


  // sdk 回调
  router.post('/cb/pay37callback', controller.sdk.pay37Callback);
  // router.post('/cb/pay37ioscallback', controller.sdk.pay37IosCallback);
  router.get('/cb/treatusername', controller.sdk.treatRoleName);
  router.get('/cb/treatguildname', controller.sdk.treatGuildName);
  router.get('/cb/getguildbyuser', controller.sdk.getGuildByUser);
  router.get('/cb/getserverlist', controller.sdk.getServerList);
  router.post('/cb/getserverlist', controller.sdk.getServerList);
  router.post('/cb/refundioscallback', controller.sdk.refundIOSCallback);

  // 问卷星回调
  router.post('/cb/wjx', controller.sdk.wjxCallback)
};
