后台:问卷

This commit is contained in:
luying
2022-04-02 20:56:25 +08:00
parent 89744aeb13
commit 3b2670dd75
6 changed files with 113 additions and 10 deletions

View File

@@ -114,6 +114,27 @@ export default class GameController extends Controller {
return
}
public async getSurveylist() {
const { ctx } = this;
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
ctx.body = await ctx.service.game.getSurveylist(page, pageSize, sortField, sortOrder, form);
return
}
public async updateSurvey() {
const { ctx } = this;
const param = ctx.request.body;
ctx.body = await ctx.service.game.updateSurvey(param);
return
}
public async deleteSurvey() {
const { ctx } = this;
const param = ctx.request.body;
ctx.body = await ctx.service.game.deleteSurvey(param.code);
return
}
public async getAccuse() {
const { ctx } = this;
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;

View File

@@ -51,6 +51,9 @@ export default (app: Application) => {
router.post('/api/game/stopserverregister', tokenParser, controller.game.stopServerRegister);
router.post('/api/game/swicthserverstatus', tokenParser, controller.game.switchServerStatus);
router.post('/api/game/getorderlist', tokenParser, controller.game.getOrderlist);
router.post('/api/game/getsurveylist', controller.game.getSurveylist);
router.post('/api/game/updatesurvey', controller.game.updateSurvey);
router.post('/api/game/deletesurvey', controller.game.deleteSurvey)
router.post('/api/dic/getdicgoods', tokenParser, controller.game.getDicGoods);
router.post('/api/dic/getdichero', tokenParser, controller.game.getDicHero);

View File

@@ -15,10 +15,11 @@ import { ActivityGroupModel } from '@db/ActivityGroup';
import { nowSeconds } from '@pubUtils/timeUtil';
import { WhiteListModel } from '@db/RegionWhiteList';
import { RoleModel } from '@db/Role';
import { SearchMarqueeParam, SearchOrderParam } from '@domain/backEndField/search';
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
import { DicServerName } from '@pubUtils/dictionary/DicServerName';
import { CreateRegionParam } from '@domain/backEndField/params';
import { UserOrderModel } from '@db/UserOrder';
import { SurveyModel } from '@db/Survery';
/**
* Test Service
@@ -251,4 +252,34 @@ export default class Game extends Service {
list, total
});
}
public async getSurveylist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchSurveyParam) {
const { ctx } = this;
const list = await SurveyModel.findByCondition(page, pageSize, sortField, sortOrder, form);
const total = await SurveyModel.countByCondition( form )
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list: list.map(cur => {
return { ...cur, env: this.app.config.realEnv }
}), total
});
}
public async updateSurvey(param: any) {
const { ctx } = this;
try {
let reward = JSON.parse(param.goods);
let result = await SurveyModel.updateSurvey(param.code, {...param, reward});
if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return ctx.service.utils.resResult(STATUS.SUCCESS);
} catch(e) {
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
}
public async deleteSurvey(code: string) {
const { ctx } = this;
await SurveyModel.deleteSurvey(code);
return ctx.service.utils.resResult(STATUS.SUCCESS);
}
}