package com.kmall.admin.controller.mk.store;

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

import com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity;
import com.kmall.admin.service.mk.store.MkStoreCampMinusLevelService;
import com.kmall.common.utils.PageUtils;
import com.kmall.common.utils.Query;
import com.kmall.common.utils.R;
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.*;

/**
 * 门店满减活动层级表，活动减免类型为00：按满足最高层级减一次时增加的活动层级数据Controller
 *
 * @author emato
 * @email admin@qhdswl.com
 * @date 2019-05-29 14:43:29
 */
@Controller
@RequestMapping("mkstorecampminuslevel")
public class MkStoreCampMinusLevelController {
    @Autowired
    private MkStoreCampMinusLevelService mkStoreCampMinusLevelService;

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

        List<MkStoreCampMinusLevelEntity> mkStoreCampMinusLevelList = mkStoreCampMinusLevelService.queryList(query);
        int total = mkStoreCampMinusLevelService.queryTotal(query);

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

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

    /**
     * 查看信息
     */
    @RequestMapping("/info/{campMinusLevelId}")
    @RequiresPermissions("mkstorecampminuslevel:info")
    @ResponseBody
    public R info(@PathVariable("campMinusId") Integer campMinusLevelId) {
        MkStoreCampMinusLevelEntity mkStoreCampMinusLevel = mkStoreCampMinusLevelService.queryObject(campMinusLevelId);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("mkstorecampminuslevel:save")
    @ResponseBody
    public R save(@RequestBody MkStoreCampMinusLevelEntity mkStoreCampMinusLevel) {
        mkStoreCampMinusLevelService.save(mkStoreCampMinusLevel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("mkstorecampminuslevel:update")
    @ResponseBody
    public R update(@RequestBody MkStoreCampMinusLevelEntity mkStoreCampMinusLevel) {
        mkStoreCampMinusLevelService.update(mkStoreCampMinusLevel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("mkstorecampminuslevel:delete")
    @ResponseBody
    public R delete(@RequestBody Integer[] campMinusLevelIds) {
        mkStoreCampMinusLevelService.deleteBatch(campMinusLevelIds);

        return R.ok();
    }

    /**
     * 查看所有列表
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public R queryAll(@RequestParam Map<String, Object> params) {

        List<MkStoreCampMinusLevelEntity> list = mkStoreCampMinusLevelService.queryList(params);

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