package com.td.Dawa.sys.sysGame.controller;

import com.td.Dawa.annotation.Decrypt;
import com.td.Dawa.annotation.Encrypt;
import com.td.Dawa.common.controller.CommonController;
import com.td.Dawa.common.pojo.PageInfo;
import com.td.Dawa.common.pojo.Result;

import com.td.Dawa.config.enums.GameEnum;
import com.td.Dawa.game.comusers.pojo.ComUsers;
import com.td.Dawa.game.comusers.vo.ComUsersVo;
import com.td.Dawa.game.excelcharacterattri.service.ExcelCharacterAttriService;
import com.td.Dawa.game.excelcharacterattri.vo.ExcelCharacterAttriVo;
import com.td.Dawa.game.excelcharactercreate.service.ExcelCharacterCreateService;
import com.td.Dawa.game.excelcharactercreate.vo.ExcelCharacterCreateVo;
import com.td.Dawa.game.excelcharacterlevel.service.ExcelCharacterLevelService;
import com.td.Dawa.game.excelcharacterlevel.vo.ExcelCharacterLevelVo;
import com.td.Dawa.game.exceldrop.service.ExcelDropService;
import com.td.Dawa.game.exceldrop.vo.ExcelDropVo;
import com.td.Dawa.game.excelparameter.service.ExcelParameterService;
import com.td.Dawa.game.excelparameter.vo.ExcelParameterVo;
import com.td.Dawa.game.excelprop.service.ExcelPropService;
import com.td.Dawa.game.excelprop.vo.ExcelPropVo;
import com.td.Dawa.game.excelresources.service.ExcelResourcesService;
import com.td.Dawa.game.excelresources.vo.ExcelResourcesVo;
import com.td.Dawa.game.excelscene.service.ExcelSceneService;
import com.td.Dawa.game.excelscene.vo.ExcelSceneVo;
import com.td.Dawa.game.excelworkpro.pojo.ExcelWorkPro;
import com.td.Dawa.game.excelworkpro.service.ExcelWorkProService;
import com.td.Dawa.game.excelworkpro.vo.ExcelWorkProVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@Slf4j
@RestController
@RequestMapping("/sys/sysExcel/")
public class sysExcelController extends CommonController<ComUsersVo, ComUsers, String> {

    @Autowired
    private ExcelWorkProService excelWorkProService;

    @Autowired
    private ExcelSceneService excelSceneService;

    @Autowired
    private ExcelResourcesService excelResourcesService;

    @Autowired
    private ExcelPropService excelPropService;

    @Autowired
    private ExcelParameterService excelParameterService;

    @Autowired
    private ExcelDropService excelDropService;

    @Autowired
    private ExcelCharacterLevelService excelCharacterLevelService;

    @Autowired
    private ExcelCharacterCreateService excelCharacterCreateService;

    @Autowired
    private ExcelCharacterAttriService excelCharacterAttriService;

    //参数表操作，修改数据需要刷新缓存
    @GetMapping("excelWorkPro")
    public ModelAndView excelWorkPro() {
        return new ModelAndView("sys/aComConfig/excelWorkPro");
    }

    @PostMapping("findAllExcelWorkPro")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelWorkProVo>> findAllExcelWorkPro(ExcelWorkProVo vo) {
        return excelWorkProService.page(vo);
    }

    @PostMapping("saveExcelWorkPro")
    @Decrypt
    @Encrypt
    public Result saveExcelWorkPro(ExcelWorkProVo vo) {
        Result result = excelWorkProService.save(vo);
        excelWorkProService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_WORK_PRO.getMessage());
        return result;
    }

    @PostMapping("deleteExcelWorkPro")
    @Decrypt
    @Encrypt
    public Result deleteExcelWorkPro(@RequestParam("id") Integer id) {
        //return excelWorkProService.delete(id);
        Result result = excelWorkProService.delete(id);
        excelWorkProService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_WORK_PRO.getMessage());
        return result;
    }


    //获取excel场景配置页面,修改缓存
    @GetMapping("excelScene")
    public ModelAndView excelScene() {
        return new ModelAndView("sys/aComConfig/excelScene");
    }

    @PostMapping("findAllExcelScene")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelSceneVo>> findAllExcelScene(ExcelSceneVo excelSceneVo) {
        return excelSceneService.page(excelSceneVo);
    }

    @PostMapping("saveExcelScene")
    @Decrypt
    @Encrypt
    public Result saveExcelScene(ExcelSceneVo excelSceneVo) {

        Result result = excelSceneService.save(excelSceneVo);
        excelSceneService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_SCENE.getMessage());
        return result;
    }

    @PostMapping("deleteExcelScene")
    @Decrypt
    @Encrypt
    public Result deleteExcelScene(@RequestParam("id") Integer id) {

        Result result = excelSceneService.delete(id);
        excelSceneService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_SCENE.getMessage());
        return result;
    }

    //资源操作
    @GetMapping("excelResources")
    public ModelAndView excelResources() {
        return new ModelAndView("sys/aComConfig/excelResources");
    }

    @PostMapping("findAllExcelResources")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelResourcesVo>> findAllExcelResources(ExcelResourcesVo vo) {
        return excelResourcesService.page(vo);
    }

    @PostMapping("saveExcelResources")
    @Decrypt
    @Encrypt
    public Result saveExcelResources(ExcelResourcesVo vo) {

        Result result = excelResourcesService.save(vo);
        excelResourcesService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_RESOURCES.getMessage());
        return result;

    }

    @PostMapping("deleteExcelResources")
    @Decrypt
    @Encrypt
    public Result deleteExcelResources(@RequestParam("id") Integer id) {
        Result result = excelResourcesService.delete(id);
        excelResourcesService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_RESOURCES.getMessage());
        return result;
    }
    //道具表操作
    @GetMapping("excelProp")
    public ModelAndView excelProp() {
        return new ModelAndView("sys/aComConfig/excelProp");
    }

    @PostMapping("findAllExcelProp")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelPropVo>> findAllExcelProp(ExcelPropVo vo) {
        return excelPropService.page(vo);
    }

    @PostMapping("saveExcelProp")
    @Decrypt
    @Encrypt
    public Result saveExcelProp(ExcelPropVo vo) {
        Result result = excelPropService.save(vo);
        excelPropService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_PROP.getMessage());
        return result;
    }

    @PostMapping("deleteExcelProp")
    @Decrypt
    @Encrypt
    public Result deleteExcelProp(@RequestParam("id") Integer id) {
        Result result = excelPropService.delete(id);
        excelPropService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_PROP.getMessage());
        return result;
    }
    //参数表操作
    @GetMapping("excelParameter")
    public ModelAndView excelParameter() {
        return new ModelAndView("sys/aComConfig/excelParameter");
    }

    @PostMapping("findAllExcelParameter")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelParameterVo>> findAllExcelParameter(ExcelParameterVo vo) {
        return excelParameterService.page(vo);
    }

    @PostMapping("saveExcelParameter")
    @Decrypt
    @Encrypt
    public Result saveExcelParameter(ExcelParameterVo vo) {
        Result result = excelParameterService.save(vo);
        excelParameterService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_PARAMETER.getMessage());
        return result;
    }

    @PostMapping("deleteExcelParameter")
    @Decrypt
    @Encrypt
    public Result deleteExcelParameter(@RequestParam("id") Integer id) {
        Result result = excelParameterService.delete(id);
        excelParameterService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_PARAMETER.getMessage());
        return result;
    }

    //掉落表操作
    @GetMapping("excelDrop")
    public ModelAndView excelDrop() {
        return new ModelAndView("sys/aComConfig/excelDrop");
    }

    @PostMapping("findAllExcelDrop")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelDropVo>> findAllExcelDrop(ExcelDropVo vo) {
        return excelDropService.page(vo);
    }

    @PostMapping("saveExcelDrop")
    @Decrypt
    @Encrypt
    public Result saveExcelDrop(ExcelDropVo vo) {
        return excelDropService.save(vo);
    }

    @PostMapping("deleteExcelDrop")
    @Decrypt
    @Encrypt
    public Result deleteExcelDrop(@RequestParam("id") Integer id) {
        return excelDropService.delete(id);
    }

    //人物等级表操作
    @GetMapping("excelCharacterLevel")
    public ModelAndView excelCharacterLevel() {
        return new ModelAndView("sys/aComConfig/excelCharacterLevel");
    }

    @PostMapping("findAllExcelCharacterLevel")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelCharacterLevelVo>> findAllExcelCharacterLevel(ExcelCharacterLevelVo vo) {
        return excelCharacterLevelService.page(vo);
    }

    @PostMapping("saveExcelCharacterLevel")
    @Decrypt
    @Encrypt
    public Result saveExcelCharacterLevel(ExcelCharacterLevelVo vo) {

        Result result = excelCharacterLevelService.save(vo);
        excelCharacterLevelService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_LEVEL.getMessage());
        return result;
    }

    @PostMapping("deleteExcelCharacterLevel")
    @Decrypt
    @Encrypt
    public Result deleteExcelCharacterLevel(@RequestParam("id") Integer id) {

        Result result = excelCharacterLevelService.delete(id);
        excelCharacterLevelService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_LEVEL.getMessage());
        return result;
    }
    //人物组件表操作
    @GetMapping("excelCharacterCreate")
    public ModelAndView excelCharacterCreate() {
        return new ModelAndView("sys/aComConfig/excelCharacterCreate");
    }

    @PostMapping("findAllExcelCharacterCreate")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelCharacterCreateVo>> findAllExcelCharacterCreate(ExcelCharacterCreateVo vo) {
        return excelCharacterCreateService.page(vo);
    }

    @PostMapping("saveExcelCharacterCreate")
    @Decrypt
    @Encrypt
    public Result saveExcelCharacterCreate(ExcelCharacterCreateVo vo) {

        Result result = excelCharacterCreateService.save(vo);
        excelCharacterCreateService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_CREATE.getMessage());
        return result;
    }

    @PostMapping("deleteExcelCharacterCreate")
    @Decrypt
    @Encrypt
    public Result deleteExcelCharacterCreate(@RequestParam("id") Integer id) {
        Result result = excelCharacterCreateService.delete(id);
        excelCharacterCreateService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_CREATE.getMessage());
        return result;
    }

    //人物属性表操作
    @GetMapping("excelCharacterAttri")
    public ModelAndView excelCharacterAttri() {
        return new ModelAndView("sys/aComConfig/excelCharacterAttri");
    }

    @PostMapping("findAllExcelCharacterAttri")
    @Decrypt
    @Encrypt
    public Result<PageInfo<ExcelCharacterAttriVo>> findAllExcelCharacterAttri(ExcelCharacterAttriVo vo) {
        return excelCharacterAttriService.page(vo);
    }

    @PostMapping("saveExcelCharacterAttri")
    @Decrypt
    @Encrypt
    public Result saveExcelCharacterAttri(ExcelCharacterAttriVo vo) {

        Result result = excelCharacterAttriService.save(vo);
        excelCharacterAttriService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_ATTRI.getMessage());
        return result;
    }


    @PostMapping("deleteExcelCharacterAttri")
    @Decrypt
    @Encrypt
    public Result deleteExcelCharacterAttri(@RequestParam("id") Integer id) {
        Result result = excelCharacterAttriService.delete(id);
        excelCharacterAttriService.updateListToCache(GameEnum.REDIS_KEY_EXCEL_CHARACTER_ATTRI.getMessage());
        return result;
    }
}
