package com.kmall.admin.controller;

import java.util.List;
import java.util.Map;

import com.kmall.admin.entity.ExportExceptionDataEntity;
import com.kmall.admin.service.ExportExceptionDataService;
import com.kmall.admin.utils.ParamUtils;
import com.kmall.common.constant.Dict;
import com.kmall.admin.fromcomm.entity.SysUserEntity;
import com.kmall.common.utils.PageUtils;
import com.kmall.common.utils.Query;
import com.kmall.common.utils.R;
import com.kmall.admin.utils.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 数据导入异常数据记录Controller
 *
 * @author huangyq
 * @email admin@qhdswl.com
 * @date 2018-12-07 09:41:15
 */
@Controller
@RequestMapping("exportexceptiondata")
public class ExportExceptionDataController {
    @Autowired
    private ExportExceptionDataService exportExceptionDataService;

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("exportexceptiondata:list")
    @ResponseBody
    public R list(@RequestParam Map<String, Object> params) {
        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
        //查询列表数据
        Query query = new Query(params);

        List<ExportExceptionDataEntity> exportExceptionDataList = exportExceptionDataService.queryList(query);
        int total = exportExceptionDataService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(exportExceptionDataList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }

    /**
     * 查看信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("exportexceptiondata:info")
    @ResponseBody
    public R info(@PathVariable("id") Integer id) {
        ExportExceptionDataEntity exportExceptionData = exportExceptionDataService.queryObject(id);

        return R.ok().put("exportExceptionData", exportExceptionData);
    }

    /**
     * 查看所有列表
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public R queryAll(@RequestParam Map<String, Object> params) {
        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
        List<ExportExceptionDataEntity> list = exportExceptionDataService.queryList(params);

        return R.ok().put("list", list);
    }
}
