package cn.pluss.platform.controller.channelCheck;


import cn.pluss.platform.api.PageInfo;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.controller.BaseNoModelController;
import cn.pluss.platform.entity.AppVersionInfo;
import cn.pluss.platform.entity.BestNewActivity;
import cn.pluss.platform.entity.MerchantChannelStatus;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
import cn.pluss.platform.util.PageUtils;
import cn.pluss.platform.vo.ChannelStatusVO;
import cn.pluss.platform.vo.merchantChannelVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lyf
 */
@Controller
@RequestMapping("/channel")
public class ChannelController extends BaseNoModelController {
    @Resource
    private MerchantChannelStatusService merchantChannelStatusService;
    @GetMapping("/merchantIndex")
    public String permissionIndex() {
        return "/channel/merchantIndex";
    }

    @GetMapping("/page")
    @ResponseBody
    public Result<List<merchantChannelVO>> page(Integer size, Integer page) {
        List<merchantChannelVO> pageData= merchantChannelStatusService.pageDate(size, page);
        return ResultGenerator.genSuccessResult(pageData);
    }

    @GetMapping("/update/{merchantCode}")
    @ResponseBody
    public Result<Object> update(@PathVariable(value = "merchantCode") String merchantCode){
        try {
            merchantChannelStatusService.updateValid(merchantCode);
            return ResultGenerator.genSuccessResult();
        }catch (Exception e){
            return ResultGenerator.genFailResult("更改失败");
        }
    }
}
