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

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

import com.kmall.admin.dto.CheckGoodsDto;
import com.kmall.admin.entity.mk.store.MkStoreTicketDiscountGoodsEntity;
import com.kmall.admin.service.mk.store.MkStoreTicketDiscountGoodsService;
import com.kmall.common.constant.Dict;
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.*;

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.*;

/**
 * 门店优惠券活动商品，参与优惠的商品Controller
 *
 * @author emato
 * @email admin@qhdswl.com
 * @date 2019-05-07 16:06:28
 */
@Controller
@RequestMapping("mkstoreticketdiscountgoods")
public class MkStoreTicketDiscountGoodsController {
    @Autowired
    private MkStoreTicketDiscountGoodsService mkStoreTicketDiscountGoodsService;

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

        List<MkStoreTicketDiscountGoodsEntity> mkStoreTicketDiscountGoodsList = mkStoreTicketDiscountGoodsService.queryList(query);
        int total = mkStoreTicketDiscountGoodsService.queryTotal(query);

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

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

    /**
     * 查看信息
     */
    @RequestMapping("/info/{discGoodId}")
    @RequiresPermissions("mkstoreticketdiscountgoods:info")
    @ResponseBody
    public R info(@PathVariable("discGoodId") Integer discGoodId) {
        MkStoreTicketDiscountGoodsEntity mkStoreTicketDiscountGoods = mkStoreTicketDiscountGoodsService.queryObject(discGoodId);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("mkstoreticketdiscountgoods:save")
    @ResponseBody
    public R save(@RequestBody MkStoreTicketDiscountGoodsEntity mkStoreTicketDiscountGoods) {
        mkStoreTicketDiscountGoodsService.save(mkStoreTicketDiscountGoods);

        return R.ok();
    }
    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("mkstoreticketdiscountgoods:update")
    @ResponseBody
    public R update(@RequestBody MkStoreTicketDiscountGoodsEntity mkStoreTicketDiscountGoods) {
        mkStoreTicketDiscountGoodsService.update(mkStoreTicketDiscountGoods);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("mkstoreticketdiscountgoods:delete")
    @ResponseBody
    public R delete(@RequestBody Integer[]discGoodIds) {
        mkStoreTicketDiscountGoodsService.deleteBatch(discGoodIds);

        return R.ok();
    }

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

        List<MkStoreTicketDiscountGoodsEntity> list = mkStoreTicketDiscountGoodsService.queryList(params);

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